Précédent   Forum des professionnels en informatique > PHP > Langage > Sessions
Sessions Forum d'entraide sur les sessions avec PHP. Avant de poster -> FAQ sessions, Cours sessions et Sources sécurité
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 16/10/2006, 12h36   #1
Membre régulier
 
Avatar de hugo69
 
Inscription : avril 2005
Messages : 498
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 498
Points : 91
Points : 91
Par défaut [Sécurité] Accès Repertoire Securisé

Bonjour,

J'ai mis en place le systeme .htacess et .htpasswd sur un repertoire.

J'ai un script qui ouvre une session et une fois la personne loguée, la session autorise le visionnage des pages sécurisée.

Ces pages sécurisée sont en fait une liste de liens vers les fichiers placés dans le répertoire protégé.

Je voudrais que le visiteur, n'ai pas à retaper ses identifiants quand il décide d'ouvrir les fichiers dans le répertoire protégé.

Y a t-il un moyen de transmettre automatiquement les identifiants?

Merci
hugo69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 14h14   #2
Membre chevronné
 
Avatar de kankrelune
 
Inscription : décembre 2005
Messages : 766
Détails du profil
Informations forums :
Inscription : décembre 2005
Messages : 766
Points : 745
Points : 745
Non... ton système d'authentification et l'authentification http sont deux procédés d'authentification différent... il est donc logique de devoir passer par les deux... après tu peux virer l'authentification http protéger le répertoire contenant tes pages par un htaccess contenant "deny from all" et afficher tes pages via une page tierce qui n'affichera les documents que si l'utilisateur est authentifié... .. .

@ tchaOo°
kankrelune est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 14h27   #3
Membre régulier
 
Avatar de hugo69
 
Inscription : avril 2005
Messages : 498
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 498
Points : 91
Points : 91
Citation:
via une page tierce qui n'affichera les documents que si l'utilisateur est authentifié
Ca me va bien comme solution, mais je bloque sur cette partie.

Si je met un readfile(), je vais voir mon fichier (disons pour exemple du pdf), en caractères binaires sur IE.

Si je met un file_get_contents(), j'ai ca comme erreur:

Code :
1
2
3
Warning: file_get_contents(): HTTP request failed! HTTP/1.1 404 Not Found in /home/clients/xxxxxxxxxx.com/http/fr/page/xxx/read.php on line 27
 
Warning: file_get_contents(http://wwww.xxxxxxxxxx.com/fr/page/xxx/articles/20061016test.pdf): failed to open stream: Success in /home/clients/xxxxxxxx.com/http/fr/page/xxx/read.php on line 27
pourquoi il me met 4w après file_get_contents????j'ai rien de tel dans mon code
Pourrais tu me mettre sur la fonction qui va appeler mon fichier, le top étant d'ouvrir par defaut le fichier, si cest du pdf, ca me louvre sous IE, du xls, pareil....

Sinon eventuellement forcer le telechargement par un ouvrir ou enregistrer
hugo69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 14h38   #4
Membre chevronné
 
Avatar de kankrelune
 
Inscription : décembre 2005
Messages : 766
Détails du profil
Informations forums :
Inscription : décembre 2005
Messages : 766
Points : 745
Points : 745
utilise un chemin physique pour ton file_get_contents() en voyant le message d'erreur cela devrait donner quelque chose du genre...

Code php :
1
2
 
echo file_get_contents(dirname(__FILE__).DIRECTORY_SEPARATOR.'articles'.DIRECTORY_SEPARATOR.'20061016test.pdf');

après pour ton histoire d'ouverture tu la gère en envoyant le bon header... quand au téléchargement le navigateur te proposera de le télécharger si le myme type est pas reconnu ou si le plugin de lecture n'est pas installé... .. .

@ tchaOo°
kankrelune est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 14h53   #5
Membre régulier
 
Avatar de hugo69
 
Inscription : avril 2005
Messages : 498
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 498
Points : 91
Points : 91
jai pas compris grand chose la.

J'ai reperer le fameux lien: http://php.developpez.com/faq/?page=..._forcedownload

mais je ne men sors pas.

Je t'explique.

Quand je suis sur ma page securisée qui affiche mes liens, jenvoi un href vers un fichier php avec la variable get "doc=<?= $nomfichier ?>"

et la sur ma page php (read.php) censée appeler le fichier, j'ai ce code:

Code :
1
2
3
4
5
6
7
8
<?php
$document = "http://xxxxxx.com/fr/page/telechargement/articles/".$_GET['doc'];
 
$mon_fichier = file_get_contents($document);
 
echo $mon_fichier;
 
?>
A ce moment jai ma page d'erreur vu ci dessus.
Que le ficghier souvre directement, sous IE ou passe par une fenetre ouvrir/enregistrer n'a pas trop d'importance pour moi*.

si je met ton code, jai du binaire dans mon IE genre:

Code X :
%PDF-1.4 %Çì¢ 5 0 obj <> stream ¬§rÎ:4²êõ–W¬ ]¨*•tÞ!êqij˜v‚ZuFpûå²)S:•;Øë:‚(#é‚rŠŠ0¯ KB^Èd¬‘Ї¬h›œfÚºžÓ¯£ÅãnøÛi WrôÖßåøj‹$’'£\-¾¿óÎÍÙâ´Üã—¹†©´Í¶’õ0X U3 Ú™TàÔ û¿*qí(ÙŠ ï\×2¶JM¦–IÍKl˜ eá*qE",eÙ‰3ãB>=Ðí0óÕ2Óî²kqõ[j~R[(ÒŠŸs Åö¾=¨Þj¤Ú§ì˜?Ïe¡'dÒKJ× ƒä<±\ãxÆhûcu•d_Ùúœ%ˆdë¸Ø>¾ã³DTsþ“.®”éÜOj®Ñå>MæRz #üD+ì^Å$S†ÒÉ)ìg<Z3ážÏ—49PoîÉa¨§4]Ÿ;iýž*]6ê±Ñ[¦µüýô»°{úéÌjÁÐLÐSsµ#Ü6¨gçÍRœÝªuïIa]k3ÜŒ,wúx×Tö~ ëüòc I,6õf_“õfãÝ4Ù¶± ¿ú†Í.éŸà4©Ôì4ŽÝJó¥}cD*sVö%À— 4‡È“Ó±·c…Fµˆ· †£³5e@kÈ>ÐOòι=+Eô‘ö&ã|Öƒö ¤Ü›ôÖ^•ÀÛ7AF:æ¯Ðç™=ö^=—ü2þ>¾t„)ÊÙeäóï¼l²ÂÛ6‹^ûŠضëwâ’Ÿ‚(@=-:øû³)!Êžp®ŽÕ>æ!^âéž&GÖçÖr½¼'.çp¬¬1¬s£Ê™–ê§œôožûó _ÍàGÌÕDñ‹z\ÕÉ:1¥Ù¨.ž3¾Â žÍº•´g«ÓU È E‘§ÕR16ŽÿmA¥ŠÐ St¡±Ó¿M*±®Ü?ÂÁK!(X¶"•OYòÅ*œùx)Œç³„åvIlq:e˜`iE~ÙÝ‘yÁ;*Ú õ¢4š‹]HðÒÒåJúû8«Èhþ¼ºÕ^ “8¹L¸EKv–.ó¾*—™ý¿÷{ªå#¡ëúúF7UÁHè^€Þ¿otQÆ—ò*4fúÚ“ƒµh:N[%9Ù…oc³$ªl—¾Ëw£å0>Ùm!  ÔM*¢7¶ûR¯€÷üÍFÌð} ç ËW7îf\äÛ5Rç¤áÎh×nÈЙÎ!ýÄÕlæ£wñCI ÅXÁ¡†žÄŒ½ej›ä°£üò7)}èÎí²ðÙ "lÔÍepòµšPÕ‰Ò–ÌJóNd/}Ú 5É'¼n!h .;DדæWŸ¥Ö“kiÊâíf²r=RÆ9í芖 öÃç$dñ:õg=\|¤V.ï€a&¾]Åm{ókâ_*(h#%í‰5µ¿oè1°ÐEÌ»¨õc¹ð÷‹3â±½/“nj YY;"&Óiü…9 ï]¾»éïjÙð"±ÚKãÐñNž`Âq£Ö„t ´6ÛXÃÏ _j]Oè“„ÇW^×®ØÄQÆ&‚#£ÄýýôÈ:ýcg›X|ëÏ1ÕZ‰,ÅÛ: @F[Ib’mâ±\QïLŽÄ5„ <ûHcyhÑÚø<º †îð®þ:ØÔ³í)¡·ÍK1n8F>i/ºb†dJÓœ¤M&ûq¡ÚÚ‡Š²ÓÐêãNÕÊè¥cŠ÷¦…ø×"³MiŸŽcGI e©~  ¥bÅ_k/„G[t6±wøt"Ü(éNïRÑÐQ_ܰŸp|ÑW)Ú&3WÚOÞ-¯‹¤;C›}–f{èÔº)ˆ¦Íeô>Ïdil£çãü¯3@ $DÁ×SÚ+T\š'RZn€aø€>ûJYÆMÂg‰Æ•üž ÷ìæ =êöÞרG•áóMGL›½™…¿ê+[$®$åÊQ³ï3#ƒ(ZfÚ]y_d¯«¡½=ôKó “žöºäºðÓî2U]H?²%GÅ팗b–PQçéhˆd¤]7ßWx͇}ÎÅ‘“ÜßâY¾Ø,ü®ÐÒÚA…9ŽÕ™dÃþ9½šó$¾d)Ê]!ü1‚*õú´:M›‰+Å òú•BÒA7!Õÿ™Â:éž·Ii.騉ˆ1}ÉRJ–D>âcãò'ØÖ;Ðj‡Ú‹bë«…"4`½ÅÓxÃ, D!¨"hª“qËÒ¸‰ÚR±¡ÍÚäõ~DSv¹_oü$¤ÂhÃŒ‰þy [?ª®§ùœeVzdøÃùuAûư~Úrç½MŽÐc-µQÑ£g m+Ñ.œàßÛ·kÉ`lC‰z¬(q-ݨ¬õdÒak9•bãVƒ×‹µw+n«7œüù)ò\†ä¨§Q‚(׿FbF‡‰ò.^#æ!úûß[üÀÆ0“Žb.¦XXZµ®@ÍæWHW91ݦ 2‚ŠŠõd~•dcž–aH Èžt/Þ¿°9gÇZo:˘֊wÒ#ÏÈÈd{5Ÿn#¾wi‹M”Áã(ê~m8d2øæz~@=±½žzÚ—§¶Ûþ³‹sÙå ÷ãùÜQ9Mð8¥âJd‰)}ºÑ±ÏËÜú%à"ƒ <èÿµ’:`<Í´[%æ+.C°O05ÃÁÉ…Î Rp×Z_R-©bXâuh_m“Sܬl«à3–ö©?«ÏÖF5Êô:Œ Ÿ9Ô~qÅ´#þÖ;ÚgéXûn¦Qä@Nc2OÞ1åî1Y7`5›‰ß²~ìØuaËD¹ïs“eÿÆ0ýœKI ¡ý¨‚é×4ÓSrè–Í]±¢d‚Ê]—¨vXfæ¶…oAÈAŽêãu_ ¨8cïÈJqaмÞdQWÉ%e„ÐéiÃü=±êõìÄkÎhiuúÇuÈ©ù=ÎN0ÿmÄÒT<"fQeÃØûêï{êéojendstream endobj 6 0 obj 2281 endobj 4 0 obj <> /Contents 5 0 R >> endobj 3 0 obj << /Type /Pages /Kids [ 4 0 R ] /Count 1 /Rotate 0>> endobj 1 0 obj <> endobj 9 0 obj [/Indexed /DeviceRGB 255 (\361\367z\225\024\267\275\217}\234D\253i\204\277\277\305<\220t}\025\031.\360r\355\372\b\317O\236\334\334\235\270\246a\315\373`*\200\340\233\n\257U\367\321uPf\241\357T\313\307\222\325\276\273\023\241\347\236\035i\201\006\027f\273\360\356\231\327Ks/o\250\314Z\001nY\177\300\222\310{\036X\255-\207\311\007\006\034\035\374x\266\335\237\005\342G\245G\276\213.\002\324\274\367\356'\021\024\n\025J\266j\314\303\304\206\)\031Yy\316%\235e\006\005\270b\3008\212\)n\333z\255*yb\311B\311_\004\364\3263\021\335\)\026\231\201\246\(\343\234g\351e\022\301X\030Vxm-\333y{\037z\322\201~\264d\366]\340\024\217z\317\322\017\301@\036h_\270\005\236\236\n\306\273\201\242\346a\342\031\303\000\227\305/\317\353D\324\354\376Jj\322\276S\f?\342\027,A\257l\357+\242\237\363\302E~\305\234\230Z\304`\300\235\372\264v\254\271u\254L\203\277e\362\220\013\235u\375B\323r\202\222\337\204z\206\326\2430\314\016Sn\(\305\264\365\263\236\315f\025\3677m\332\310cB\013c\212Ho\231\302\016y\376iYM_\353\002\247\337\355\2276M\016CY\344H=\(\225\320\265\250\361\2026\013\213\223\273\t\353\302\337\007h\353Lf\\\245j\245\347\361\373\242\263e\250\r\224\357\000.\343\362\256F5Yz\244.\241\366:\360[\364\031\351'\216\234*1\362S\031\313B5\313qa;f\336\036\277=\036K\177\347\024\000u\372\031:\261A\031+\212^Ch\240\211\253{4\245\277\356\306\007\252~\222\025\311\343\207p\320\2314\220\377E%\262\035\025f\221\304\323\306\3263\230\271\267\362\346\271\tR\364;\267q\326|6\304\260\231\374=\262\357\375pe\236\3216\260\2242R\362\241/[\237.\272\035F\036\224$\275\3448 \326\355\240W\305nw\b\000mW\204\220A;\217\242\253\300g\361\202\361*\002\354\341\236\354\373\360\221-\017\177}>2pX\372k{\2738\\n\362Y\016=a\310sZ\037\231\3575\205\240\246\305 \236\037\362\3712q\313A\217\247\251W!\000\327\202\313\271\341\024\324\356\202\325-\304\242\006KW\277\034\r\236\275o_\tF@\226svjdr\247\262\273\373\026\220x%\022dji\034\307\317\360
hugo69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 15h15   #6
Membre chevronné
 
Avatar de kankrelune
 
Inscription : décembre 2005
Messages : 766
Détails du profil
Informations forums :
Inscription : décembre 2005
Messages : 766
Points : 745
Points : 745
La réponse se trouve dans mon précédant post... .. .

@ tchaOo°
kankrelune est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 15h30   #7
Membre régulier
 
Avatar de hugo69
 
Inscription : avril 2005
Messages : 498
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 498
Points : 91
Points : 91
mais jai mis ton code, et jai du binaire qui me sors.

Jai essayer de mettre des headers mais n'y comprenant pas grand chose, le seul resultat que j'ai est qu'il me propose d'ouvrir ou enregistrer le fichier read (sans extension)

il me propose donc bien : "read" qui est en fait à la base mon fichier php qui detient le code d'ouverture du fichier.


Voic le code utiliser, qui vient en gros de toi:

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
$file = "http://xxxxxxxxx.com/fr/page/telechargement/articles/".$_GET['doc'];
 
function getMime($file)
{
	if(false === ($pos = strrpos($file,'.')))
		return  'application/octet-stream';
 
	$mimes = array(
				'hqx'		=> 'application/mac-binhex40',
				'doc'		=> 'application/msword',
				'dot'		=> 'application/msword',
				'bin'		=> 'application/octet-stream',
				'lha'		=> 'application/octet-stream',
				'lzh'		=> 'application/octet-stream',
				'exe'		=> 'application/octet-stream',
				'class'		=> 'application/octet-stream',
				'so'		=> 'application/octet-stream',
				'dll'		=> 'application/octet-stream',
				'pdf'		=> 'application/pdf',
				'ai'		=> 'application/postscript',
				'eps'		=> 'application/postscript',
				'ps'		=> 'application/postscript',
				'smi'		=> 'application/smil',
				'smil'		=> 'application/smil',
				'wbxml'		=> 'application/vnd.wap.wbxml',
				'wmlc'		=> 'application/vnd.wap.wmlc',
				'wmlsc'		=> 'application/vnd.wap.wmlscriptc',
				'xla'		=> 'application/vnd.ms-excel',
				'xls'		=> 'application/vnd.ms-excel',
				'xlt'		=> 'application/vnd.ms-excel',
				'ppt'		=> 'application/vnd.ms-powerpoint',
				'csh'		=> 'application/x-csh',
				'dcr'		=> 'application/x-director',
				'dir'		=> 'application/x-director',
				'dxr'		=> 'application/x-director',
				'spl'		=> 'application/x-futuresplash',
				'gtar'		=> 'application/x-gtar',
				'php'		=> 'application/x-httpd-php',
				'php3'		=> 'application/x-httpd-php',
				'php5'		=> 'application/x-httpd-php',
				'phtml'		=> 'application/x-httpd-php',
				'js'		=> 'application/x-javascript',
				'sh'		=> 'application/x-sh',
				'swf'		=> 'application/x-shockwave-flash',
				'sit'		=> 'application/x-stuffit',
				'tar'		=> 'application/x-tar',
				'tcl'		=> 'application/x-tcl',
				'xhtml'		=> 'application/xhtml+xml',
				'xht'		=> 'application/xhtml+xml',
				'xhtml'		=> 'application/xml',
				'ent'		=> 'application/xml-external-parsed-entity',
				'dtd'		=> 'application/xml-dtd',
				'mod'		=> 'application/xml-dtd',
				'gz'		=> 'application/x-gzip',
				'zip'		=> 'application/zip',
				'au'		=> 'audio/basic',
				'snd'		=> 'audio/basic',
				'mid'		=> 'audio/midi',
				'midi'		=> 'audio/midi',
				'kar'		=> 'audio/midi',
				'mp1'		=> 'audio/mpeg',
				'mp2'		=> 'audio/mpeg',
				'mp3'		=> 'audio/mpeg',
				'aif'		=> 'audio/x-aiff',
				'aiff'		=> 'audio/x-aiff',
				'm3u'		=> 'audio/x-mpegurl',
				'ram'		=> 'audio/x-pn-realaudio',
				'rm'		=> 'audio/x-pn-realaudio',
				'rpm'		=> 'audio/x-pn-realaudio-plugin',
				'ra'		=> 'audio/x-realaudio',
				'wav'		=> 'audio/x-wav',
				'bmp'		=> 'image/bmp',
				'gif'		=> 'image/gif',
				'jpeg'		=> 'image/jpeg',
				'jpg'		=> 'image/jpeg',
				'jpe'		=> 'image/jpeg',
				'png'		=> 'image/png',
				'tiff'		=> 'image/tiff',
				'tif'		=> 'image/tif',
				'wbmp'		=> 'image/vnd.wap.wbmp',
				'pnm'		=> 'image/x-portable-anymap',
				'pbm'		=> 'image/x-portable-bitmap',
				'pgm'		=> 'image/x-portable-graymap',
				'ppm'		=> 'image/x-portable-pixmap',
				'xbm'		=> 'image/x-xbitmap',
				'xpm'		=> 'image/x-xpixmap',
				'ics'		=> 'text/calendar',
				'ifb'		=> 'text/calendar',
				'css'		=> 'text/css',
				'html'		=> 'text/html',
				'htm'		=> 'text/html',
				'asc'		=> 'text/plain',
				'txt'		=> 'text/plain',
				'rtf'		=> 'text/rtf',
				'sgml'		=> 'text/x-sgml',
				'sgm'		=> 'text/x-sgml',
				'tsv'		=> 'text/tab-seperated-values',
				'wml'		=> 'text/vnd.wap.wml',
				'wmls'		=> 'text/vnd.wap.wmlscript',
				'xsl'		=> 'text/xml',
				'mpeg'		=> 'video/mpeg',
				'mpg'		=> 'video/mpeg',
				'mpe'		=> 'video/mpeg',
				'qt'		=> 'video/quicktime',
				'mov'		=> 'video/quicktime',
				'avi'		=> 'video/x-msvideo',
			);
 
	$ext = strtolower(substr($file,$pos+1));
 
	return (isset($mimes[$ext]) ? $mimes[$ext] : 'application/octet-stream');
}
 
//
// Constantes de configuration
//
define('CFG_SYSTEM_FILENAME', 'read.php');
define('CFG_SEND_FILENAME', $file);
 
if(!is_file(CFG_SYSTEM_FILENAME))
   die('file '.CFG_SYSTEM_FILENAME.' not found !!! .. .');
 
 
@error_reporting(0);
@ini_set('zlib.output_compression', 0);
 
header('Pragma: public');
header('Last-Modified: '.gmdate("D, d M Y H:i:s").' GMT');
header('Cache-Control: must-revalidate, pre-check=0, post-check=0, max-age=0');
header('Date: '.gmdate("D, d M Y H:i:s", time()).' GMT');
header('Expires: '.gmdate("D, d M Y H:i:s", time()+1).' GMT');
header('Last-Modified: '.gmdate("D, d M Y H:i:s", time()).' GMT');
header('Content-Tranfer-Encoding: none');
header('Content-Length: '.filesize(CFG_SYSTEM_FILENAME));
header('Content-MD5: '.base64_encode(md5_file(CFG_SYSTEM_FILENAME)));
header('Content-Type: '.getMime(CFG_SYSTEM_FILENAME).'; name="'.CFG_SEND_FILENAME.'"');
header('Content-Disposition: attachement; filename="'.CFG_SEND_FILENAME.'"');
 
 
 
 
 
 
?>
hugo69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 16h52   #8
Membre régulier
 
Avatar de hugo69
 
Inscription : avril 2005
Messages : 498
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 498
Points : 91
Points : 91
j'ai finalement trouvé ca qui fonctionne:

Code :
1
2
3
4
5
6
7
8
9
10
$file = $_GET['doc'];
 
        header("Content-disposition: attachment; filename=$file");
        header("Content-Type: application/force-download");
        header("Content-Transfer-Encoding: binary"); 
        header("Content-Length: ".filesize("./articles/".$file));
        header("Pragma: no-cache");
 
        header("Expires: 0");
        readfile("./articles/".$file);
mon seul problème est que j'aimerai que la fenetre vierge qui s'ouvre se ferme automatiquement.

Merci pour votre aide.
hugo69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 17h00   #9
Membre chevronné
 
Avatar de kankrelune
 
Inscription : décembre 2005
Messages : 766
Détails du profil
Informations forums :
Inscription : décembre 2005
Messages : 766
Points : 745
Points : 745
C'est normal... le code que tu prend est fait pour forcer le téléchargement... donc forcement il te propose de télécharger le fichier dont le nom final est spécifié dans...

define('CFG_SYSTEM_FILENAME', ...

Toi ce que tu veux c'est lire un fichier et si ce dernier ne peut être lu par le navigateur proposer le téléchargement...

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
 
<?php
 
if(!isset($_GET['doc']))
	exit('Please select a file... .. .');
 
function getMime($file)
{
	$file = str_replace("\0",'',$file);
 
	if(false === ($pos = strrpos($file,'.')))
		return  'application/octet-stream';
 
	$mimes = array(
				'hqx'		=> 'application/mac-binhex40',
				'doc'		=> 'application/msword',
				'dot'		=> 'application/msword',
				'bin'		=> 'application/octet-stream',
				'lha'		=> 'application/octet-stream',
				'lzh'		=> 'application/octet-stream',
				'exe'		=> 'application/octet-stream',
				'class'		=> 'application/octet-stream',
				'so'		=> 'application/octet-stream',
				'dll'		=> 'application/octet-stream',
				'pdf'		=> 'application/pdf',
				'ai'		=> 'application/postscript',
				'eps'		=> 'application/postscript',
				'ps'		=> 'application/postscript',
				'smi'		=> 'application/smil',
				'smil'		=> 'application/smil',
				'wbxml'		=> 'application/vnd.wap.wbxml',
				'wmlc'		=> 'application/vnd.wap.wmlc',
				'wmlsc'		=> 'application/vnd.wap.wmlscriptc',
				'xla'		=> 'application/vnd.ms-excel',
				'xls'		=> 'application/vnd.ms-excel',
				'xlt'		=> 'application/vnd.ms-excel',
				'ppt'		=> 'application/vnd.ms-powerpoint',
				'csh'		=> 'application/x-csh',
				'dcr'		=> 'application/x-director',
				'dir'		=> 'application/x-director',
				'dxr'		=> 'application/x-director',
				'spl'		=> 'application/x-futuresplash',
				'gtar'		=> 'application/x-gtar',
				'php'		=> 'application/x-httpd-php',
				'php3'		=> 'application/x-httpd-php',
				'php5'		=> 'application/x-httpd-php',
				'phtml'		=> 'application/x-httpd-php',
				'js'		=> 'application/x-javascript',
				'sh'		=> 'application/x-sh',
				'swf'		=> 'application/x-shockwave-flash',
				'sit'		=> 'application/x-stuffit',
				'tar'		=> 'application/x-tar',
				'tcl'		=> 'application/x-tcl',
				'xhtml'		=> 'application/xhtml+xml',
				'xht'		=> 'application/xhtml+xml',
				'xhtml'		=> 'application/xml',
				'ent'		=> 'application/xml-external-parsed-entity',
				'dtd'		=> 'application/xml-dtd',
				'mod'		=> 'application/xml-dtd',
				'gz'		=> 'application/x-gzip',
				'zip'		=> 'application/zip',
				'au'		=> 'audio/basic',
				'snd'		=> 'audio/basic',
				'mid'		=> 'audio/midi',
				'midi'		=> 'audio/midi',
				'kar'		=> 'audio/midi',
				'mp1'		=> 'audio/mpeg',
				'mp2'		=> 'audio/mpeg',
				'mp3'		=> 'audio/mpeg',
				'aif'		=> 'audio/x-aiff',
				'aiff'		=> 'audio/x-aiff',
				'm3u'		=> 'audio/x-mpegurl',
				'ram'		=> 'audio/x-pn-realaudio',
				'rm'		=> 'audio/x-pn-realaudio',
				'rpm'		=> 'audio/x-pn-realaudio-plugin',
				'ra'		=> 'audio/x-realaudio',
				'wav'		=> 'audio/x-wav',
				'bmp'		=> 'image/bmp',
				'gif'		=> 'image/gif',
				'jpeg'		=> 'image/jpeg',
				'jpg'		=> 'image/jpeg',
				'jpe'		=> 'image/jpeg',
				'png'		=> 'image/png',
				'tiff'		=> 'image/tiff',
				'tif'		=> 'image/tif',
				'wbmp'		=> 'image/vnd.wap.wbmp',
				'pnm'		=> 'image/x-portable-anymap',
				'pbm'		=> 'image/x-portable-bitmap',
				'pgm'		=> 'image/x-portable-graymap',
				'ppm'		=> 'image/x-portable-pixmap',
				'xbm'		=> 'image/x-xbitmap',
				'xpm'		=> 'image/x-xpixmap',
				'ics'		=> 'text/calendar',
				'ifb'		=> 'text/calendar',
				'css'		=> 'text/css',
				'html'		=> 'text/html',
				'htm'		=> 'text/html',
				'asc'		=> 'text/plain',
				'txt'		=> 'text/plain',
				'rtf'		=> 'text/rtf',
				'sgml'		=> 'text/x-sgml',
				'sgm'		=> 'text/x-sgml',
				'tsv'		=> 'text/tab-seperated-values',
				'wml'		=> 'text/vnd.wap.wml',
				'wmls'		=> 'text/vnd.wap.wmlscript',
				'xsl'		=> 'text/xml',
				'mpeg'		=> 'video/mpeg',
				'mpg'		=> 'video/mpeg',
				'mpe'		=> 'video/mpeg',
				'qt'		=> 'video/quicktime',
				'mov'		=> 'video/quicktime',
				'avi'		=> 'video/x-msvideo',
			);
 
	$ext = strtolower(substr($file,$pos+1));
 
	return (isset($mimes[$ext]) ? $mimes[$ext] : 'application/octet-stream');
}
 
define('CFG_FILES_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR.'articles'.DIRECTORY_SEPARATOR);
$file = str_replace(array('../','..\\','./','.\\'),'',$_GET['doc']);
 
if(!is_file(CFG_FILES_PATH.$file))
   exit('Requested file "'.$file.'" not found !!! .. .');
 
 
@error_reporting(0);
 
header('Pragma: public');
header('Last-Modified: '.gmdate("D, d M Y H:i:s").' GMT');
header('Cache-Control: must-revalidate, pre-check=0, post-check=0, max-age=0');
header('Date: '.gmdate("D, d M Y H:i:s", time()).' GMT');
header('Expires: '.gmdate("D, d M Y H:i:s", time()+1).' GMT');
header('Last-Modified: '.gmdate("D, d M Y H:i:s", time()).' GMT');
header('Content-Type: '.getMime($file).'; name="'.$file.'"');
echo file_get_contents(CFG_FILES_PATH.$file);
exit();
 
?>
J'ais pas testé mais ça devrait être bon... .. .

@ tchaOo°
kankrelune est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 17h16   #10
Membre régulier
 
Avatar de hugo69
 
Inscription : avril 2005
Messages : 498
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 498
Points : 91
Points : 91
oui ca marche très bien.

Merci bcp pour ton aide.

Je laisse bien le resolu sur le post.

LA seule chose que je ne comprend pas est pourquoi pour les pdf il mouvre un IE vierge puis acrobat reader, alors que pour excel et word, il me l'ouvre bien dans la fenetre du navigateur????

La ligne :
Code :
'pdf'		=> 'application/pdf',
est bien presente

je precise egalement que pour les word et excel, il me demande si je veux ouvrir ou enregistrer le fichier avant de louvrir dans IE, alors qu'il ouvre directement le pdf sans me demander mon avis et ce, dans acrobat, pas dans IE.

Comme cest le pdf qui va etre le plus utilisé, cest emmerdant.
hugo69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 17h18   #11
Membre chevronné
 
Avatar de kankrelune
 
Inscription : décembre 2005
Messages : 766
Détails du profil
Informations forums :
Inscription : décembre 2005
Messages : 766
Points : 745
Points : 745
Ca doit venir de ton lien... par hasard tu n'aurais pas un target="_blank" ou un target="_new" qui se balade... .. ?

@ tchaOo°
kankrelune est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/10/2006, 17h22   #12
Membre régulier
 
Avatar de hugo69
 
Inscription : avril 2005
Messages : 498
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 498
Points : 91
Points : 91
si bien sur, dans la page qui appelle le telechargement.
mais je nai pas envie que xls souvre dans la fenetre du site par exemple, je prefere quelle souvre dans une autre fenetre, et dans le cas du pdf justement, je me retrouve avec mon site en page blanche
hugo69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 17h28.


 
 
 
 
Partenaires

Hébergement Web