From 8b39a207dbe0875093314791653f2b1347d20df8 Mon Sep 17 00:00:00 2001 From: Knah Tsaeb Date: Fri, 29 Aug 2014 16:56:52 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20possibilit=C3=A9=20de=20sauve?= =?UTF-8?q?r=20des=20fichiers=20seul.=20Ajout=20d'une=20favicon=20en=20fon?= =?UTF-8?q?ction=20du=20type=20de=20fichier.=20Ajout=20d'une=20favicon=20p?= =?UTF-8?q?ar=20d=C3=A9faut=20si=20aucune=20favicon=20est=20trouv=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.php | 44 ++++++++++++++++++++------- config_page.php | 1 + design/icons/AUTHORS | 5 ++++ design/icons/bmp.png | 1 + design/icons/doc.png | 1 + design/icons/exe.png | Bin 0 -> 748 bytes design/icons/gif.png | 1 + design/icons/html.png | Bin 0 -> 770 bytes design/icons/jpg.png | 1 + design/icons/msi.png | 1 + design/icons/odp.png | Bin 0 -> 630 bytes design/icons/ods.png | Bin 0 -> 495 bytes design/icons/odt.png | Bin 0 -> 535 bytes design/icons/pdf.png | Bin 0 -> 799 bytes design/icons/png.png | Bin 0 -> 671 bytes design/icons/rar.png | 1 + design/icons/rtf.png | Bin 0 -> 463 bytes design/icons/tiff.png | 1 + design/icons/xls.png | 1 + design/icons/zip.png | Bin 0 -> 551 bytes index.php | 67 ++++++++++++++++++++++++++++++++++-------- 21 files changed, 102 insertions(+), 23 deletions(-) create mode 100644 design/icons/AUTHORS create mode 120000 design/icons/bmp.png create mode 120000 design/icons/doc.png create mode 100644 design/icons/exe.png create mode 120000 design/icons/gif.png create mode 100644 design/icons/html.png create mode 120000 design/icons/jpg.png create mode 120000 design/icons/msi.png create mode 100644 design/icons/odp.png create mode 100644 design/icons/ods.png create mode 100644 design/icons/odt.png create mode 100644 design/icons/pdf.png create mode 100644 design/icons/png.png create mode 120000 design/icons/rar.png create mode 100644 design/icons/rtf.png create mode 120000 design/icons/tiff.png create mode 120000 design/icons/xls.png create mode 100644 design/icons/zip.png diff --git a/config.php b/config.php index 5f3a281..73b077b 100644 --- a/config.php +++ b/config.php @@ -1,12 +1,36 @@ - 'png', + 'image/jpg' => 'jpg', + 'image/jpeg' => 'jpg', + 'image/jpe' => 'jpg', + 'image/gif' => 'gif', + 'image/bmp' => 'bmp', + 'image/tiff' => 'tiff' +); +$GLOBAL['document'] = array( + 'application/vnd.oasis.opendocument.text' => 'odt', + 'application/vnd.oasis.opendocument.spreadsheet' => 'ods', + 'application/pdf' => 'pdf', + 'application/msword' => 'doc', + 'application/rtf' => 'rtf', + 'application/vnd.ms-excel' => 'xls', + 'application/vnd.ms-powerpoint' => 'ppt' +); +$GLOBAL['archive'] = array( + 'application/zip' => 'zip', + 'application/x-rar-compressed' => 'rar', + 'application/x-msdownload' => 'exe', + 'application/x-msdownload' => 'msi' +); ?> \ No newline at end of file diff --git a/config_page.php b/config_page.php index 0d31f8d..9fc115d 100644 --- a/config_page.php +++ b/config_page.php @@ -134,6 +134,7 @@ if(file_exists('user_config.php')){ } unset($GLOBAL['private_data_folder']); unset($GLOBAL['public_data_folder']); +unset($GLOBAL['image'],$GLOBAL['document'],$GLOBAL['archive']); $GLOBAL['default_data_folder']=basename($GLOBAL['default_data_folder']); $message=''; diff --git a/design/icons/AUTHORS b/design/icons/AUTHORS new file mode 100644 index 0000000..bb7475c --- /dev/null +++ b/design/icons/AUTHORS @@ -0,0 +1,5 @@ +Faenza is designed and developed by Matthieu James . + +Faenza icons are all licensed under the GPL. + +Thanks to Holger Seelig and clemyeats for their help for having some text preview inside icons in Nautilus. diff --git a/design/icons/bmp.png b/design/icons/bmp.png new file mode 120000 index 0000000..6776957 --- /dev/null +++ b/design/icons/bmp.png @@ -0,0 +1 @@ +png.png \ No newline at end of file diff --git a/design/icons/doc.png b/design/icons/doc.png new file mode 120000 index 0000000..4e8d7a3 --- /dev/null +++ b/design/icons/doc.png @@ -0,0 +1 @@ +odt.png \ No newline at end of file diff --git a/design/icons/exe.png b/design/icons/exe.png new file mode 100644 index 0000000000000000000000000000000000000000..169b32d39a42394970982aa820f811c12469ca75 GIT binary patch literal 748 zcmVvgj+QM18E#IU9kQ4}py zu&}WZF@>FlHVUQ`1Q8L^+u2#!*aj>lg%+{U>ndU6V|}1mQS;dB!?|;3EF>G3M9>4% z%$fh2`49hy>FMd?TI&g8%wGPZ9LEWylvl;n)KpL?6pHzL9>;P1No zRMGc+lv1lFtmWs24+u{Z>mOJb;`=`3a=9p@C?blYcH`rX>nuOGODx{ROL?SEj*-1` z8zDMhx1y6;Ypk`aH$S>hc1uXtU>uPZc!P$?nQMGosL_``z^iv}Sg0*??c6Q2*2pjn z+kocFfMnNq5~Cj8E*B>&a7T~QTD(uqlnG`gd0P?e9~#42OBjYYQ50dV#ac__$wQLE z1H=!Xz%BG3(k}Dq&8Vn`zhN`IzDswv<Ek=j-VXggbVFgfcgM4r3z3lGkB^~Q!zWI)kT#i%2LwIg% zEnxap71h$zTOkYepKR*xBA;lISiZw98-d%vtv#h-E}}ET0G)ux&p#8^6$^_^J|#So zF^7#i-s6T9gjqu9ub8<-^qwPa%N>Blr4}bf@)QbLp3NNwuf~FP}&exS~%Z+U~3_|mOyPgy_%Un0bv*-rR+$W=L+iEClL9|fWW2) z+F@G}Yprpll;t1@P)fD)@aHnA0ZgjDV^1kX5Cljm%QBTpjnB@`PLxWeoqzp)>r^}* epUq@4gw0t`#U1?IUf8q|FA_- zEaiDlQ4|0u@bK}!Jl`3z@#=u{Gd0fS8F@A3i%a=2B+qktz21@yArL|U;N|X!pMQHs zty<=j_9d4IXAzVr#)5SNN2qFs461Dz2&FGNy4EMW}6ucvy;>( z5;nH?F($%exV!u(&IeQ#?>)vjhpO`9!@rSe?7`Lf8B!aQSc9mdz+|;VeImugmY;s@ zqpCRPFd>X-8?T0(o2m2VXQydoDK<7Fv7zw7V0Va!awe}(E+wpQ9iXa&5U@uh#Kv%S zeui>tF(x855jHkF-FQvmgw3~aP*w6;nPIH&M>qnUovyLH_m)R%TkH*sW4E(Xf{Di4 z@uG|hPwQ0WBw!*js0eE>_W0$=KRnyo#|Po^g(lx$yGWywA_9}ulq8N$0;cOJJGug;Fo{Xeny9&4@bbvm8-#l=OEB*DfJH?Fk*_lZ;$0OuUt zZWn89&t_S6yWj8M>2|x9KJ1alQ7V=CjYi}4J5=3(H%{8rYXATM07*qoM6N<$g05?9 AwEzGB literal 0 HcmV?d00001 diff --git a/design/icons/jpg.png b/design/icons/jpg.png new file mode 120000 index 0000000..6776957 --- /dev/null +++ b/design/icons/jpg.png @@ -0,0 +1 @@ +png.png \ No newline at end of file diff --git a/design/icons/msi.png b/design/icons/msi.png new file mode 120000 index 0000000..7524067 --- /dev/null +++ b/design/icons/msi.png @@ -0,0 +1 @@ +exe.png \ No newline at end of file diff --git a/design/icons/odp.png b/design/icons/odp.png new file mode 100644 index 0000000000000000000000000000000000000000..76a1e840b8efc2b6a23c91a1e2de1edb2e2967c7 GIT binary patch literal 630 zcmV-+0*U>JP)jK~y-6jgviSQ&AMhfA8joG$>@Sk7^LABp`lKG$=(KGIr>e z&0X9CQAZI6!OcbJCS4p{Iyi{n;3Bq4#jjSdMr#w%)L5iqReH~P*CBn6_eil`IB-Az z=XXACuz35z`JeBfUR&=j6#>>y-yw=3wi?EmSJv8#!OP31ehqFj#ht@djLD&m3B33J zd@Lfg+ig0X&TG52yjVOqvLEx|5k!h}4iVXspjFH?z z!Z4)U?IsVyFr-?o;=M;zu_6&Tmt2SiMn^}Jy-KB$@g9dLB3Ka*k?#{|Hk*m(G(}7R z;GDy%dQjizp;D=2Jg4U|fvRFuHUu^-CfLjhUv3h(ZnEx$pb@0%9v>1Zx%mg=o=xFP zLqua|D15p{{@V;c4%~vkA|m|+v51*}h@HAlu(W{g8o_p-5Uj3}TWMpz&!!2oIfx0& z%w4>gUaWg-NI1;z-HmjjdIGAOS0R!dI151j#@XK4&>q&$O(b_k1S1+j+BQVw_&8on z#^l&|CaDR56Hne`3G~oOXej3KeF7Eq#28wuL#l~H1iO8({O9@C<$)tREP0cvLST?u z9cuMVkKjGdIp*f(u+}cvaNp6ZAK%PgdGYr10KnShRt9xU@r?lxmPV6^i72T!&!V^do^@xWl=Zd+t5wz1;oF`9(K)z5AZ@ zivVy|e}dK;S-}`{IpWQerq9A_#(a{x$9wk9O+l z{W#F1Aoc~qFa%>PmBg|v_`ZM0l>o+551JGJKnMZHaWW;eS}iE0z?CFODdWcf`ORiC zuKB)?YPA|;$8kUu&2c3Ft*}I}=))>3gaB895(M*G(=ZXuBxps61_0Q$9oI&q5h|5R zj6KhrNzekI4JAY#ELq-)|*zi+m6v_1bBa_z|1dhCL-i{j-n{e zMN$3^-?jH~UCd#bq4f@k=v9L_j*(^AfgodWdv9PLsmu&!#&9?U04Sv}o6Y=2r4+i| zE|?j{7zjfIGEbddz+f=&vm{AsbXSpxAczdAXXXN?)2Sy{Et~-WXsscPC9hu%Ns^>S zuHHL?#|j44a_u2AV>BAo=t`-TDntZfjDe{LxPX4Y?`NG(r$$~1pqjzD7oS_+pn3+* zU_2iCnUoR$P?ja6l)lPSz?!en>-AQM%T@jb(E19_KuYP!aU3HI!_^9!2th+UYv9Ps zbRt3^Tif%S>?cTTSj#@(rE9TRAWc&UA+E&Rz4*(;ul(e4bg>BlUv>0fKU1^WoJ3Ld Z=>bTwJbCQ{8OZd# literal 0 HcmV?d00001 diff --git a/design/icons/pdf.png b/design/icons/pdf.png new file mode 100644 index 0000000000000000000000000000000000000000..7408d8d65d6c4be3394ce605d719ddade3b6691f GIT binary patch literal 799 zcmV+)1K|9LP)WBQ+$<6&=z0Siw>IL9MuT#>jMln6f{7xe^bhjy-?Se8j1%l2dwrZ#-+t;7--7{p z`xbXs5A}MTYPAZ`)}VahTVBUCGKYuAd~uZQ)mxK{ZzHpUPU zl>O)cPOFAQEsW#h?g_EhVvHeP`43rJQ0@0=_@sZ6OrGbVn#aFHPMpA4LvsHPtEaw# z%h#~oJ+QCZH7MfKhUQ52C*r?J+) z2dv-1x_6%WhRTEcxZS%jDuWmh1C_fI#I-8vbebed+5n~0%VM!e9LE~~vRUZdiL9=| z?r;MTul!H_;zhL96pKZaQZH2y1m{bo(vA7~`Hw$TxUMaku~8aMisZvrnVKRihTQOQ dsjI8&{5#5Ng9j%04W0l1002ovPDHLkV1ll-ZH52< literal 0 HcmV?d00001 diff --git a/design/icons/png.png b/design/icons/png.png new file mode 100644 index 0000000000000000000000000000000000000000..add1c5915f43ce85974c751787073adbd23028b5 GIT binary patch literal 671 zcmV;Q0$}}#P)Y9xF&lZFV~m-_0C}F%ZnrlQ=N#|$ z4|)FjEwNT1YK2TaGImHAkV!x$5oJIuh!+6fyn2Cij>I`fcQ9c2eiND31T9Q23*yj_ zT7@bjVPv5Uh!vDqh`?EY%)D|W)>>4pM&nKcRn-InPCLSUfQd&8=xL-pFG(vIS*?ar zf>cv%VXquil;-K%v!E3hV?(S(aDrH&W&`fFCqzwcX^||`i1t?zy!R+o;pY(6 z@2zmsA9FXEr=DoeCy|v@b9_8tX}L;NDXWi`h-m`S#e0u(&Ov|}BNOXTQCO|d@#~_b z7)uvk~J_NpOJ=opb!u}#5=%1WYNfUw(n6Y6pDDj0wp$Il!m45~mom>Gn9$o{gQ_G((KTx_t^Z`>$ zaHae2keq#R4QS+bPQQJfX^AWOBK_{a7B-(W`TqXpOn~8V$mji!Buc6F-rnBY`uaLr z>l=x!wX|9-lv3?vVPRqG=;&y>)oQKH;vmbicD-KT`U{mXE~Mg5YP+YL!FW8b-ND~^m|(lzR@|=FD?t#{)+z*yF^CAW*{lNU_xmN+-(+hoo`}Rz6rr^y z%d)4A)|x1a5Rq6~t=2M0lGW*SdV6XCKhtbBlXknk{07ed_tgh+a3uf$002ovPDHLk FV1o4Y#MS@+ literal 0 HcmV?d00001 diff --git a/design/icons/tiff.png b/design/icons/tiff.png new file mode 120000 index 0000000..6776957 --- /dev/null +++ b/design/icons/tiff.png @@ -0,0 +1 @@ +png.png \ No newline at end of file diff --git a/design/icons/xls.png b/design/icons/xls.png new file mode 120000 index 0000000..dc9cad1 --- /dev/null +++ b/design/icons/xls.png @@ -0,0 +1 @@ +ods.png \ No newline at end of file diff --git a/design/icons/zip.png b/design/icons/zip.png new file mode 100644 index 0000000000000000000000000000000000000000..99ae6fc6677bb9c0b47e740778a315a56b1fc3c5 GIT binary patch literal 551 zcmV+?0@(eDP)hnm57*rzi*-_GEo$ne!p+>JU83z z)&xNisx(cXT-QZweNTXTy$(R9)4AP=2(IgLI2@joh)|a0-C+RBvH+OR=Y(MhfH8)$ zED;ebtu+p&-3toAAqW=5E1e`$0~~Ap9a_X zzK`d5x4tY(ilRV?2vt=*G`Qxi!CMP;Jv@qtFdB_++ef1jBEogCs;Uaxw#l;WF5q&x zuvjc^e<31VE*EUueg(vFjN>@;dcFTXeKUADolc*I!y&e9ziYTC3W6X&YyDE2&1T<@ p$K!LFrk_7z&}cM%b-UdkzX4XSEHy8yRp'); - }else{ + $urlInfo =pathinfo($GLOBAL['url']); + $title = $urlInfo['filename']; + $finfo = new finfo(FILEINFO_MIME_TYPE); + $mineType = $finfo->buffer($GLOBAL['main_page_data']); + if(array_key_exists($mineType, $GLOBAL['image'])){ + $ext = $GLOBAL['image'][$mineType]; + file_put_contents($GLOBAL['target_folder'].'/'.$title.'.'.$ext, $GLOBAL['main_page_data']); + file_put_contents($GLOBAL['target_folder'].'/index.php',''.$title.'Save image from '.$GLOBAL['url'].''); + } elseif(array_key_exists($mineType, $GLOBAL['document'])){ + $ext = $GLOBAL['document'][$mineType]; + $title=basename($_GET['q']); + file_put_contents($GLOBAL['target_folder'].'/'.$title,$GLOBAL['main_page_data']); + file_put_contents($GLOBAL['target_folder'].'/index.php',''); + } elseif(array_key_exists($mineType, $GLOBAL['archive'])){ + $ext = $GLOBAL['archive'][$mineType]; + $title=basename($_GET['q']); + file_put_contents($GLOBAL['target_folder'].'/'.$title,$GLOBAL['main_page_data']); + file_put_contents($GLOBAL['target_folder'].'/index.php',''); + }else{ $liste_css = array(); @@ -374,12 +386,14 @@ if (!$GLOBAL['public']){ // private $n++; $count = count($liste_css); } + $mineType = ''; } - // enregistre un fichier d’informations concernant la page (date, url, titre) + // enregistre un fichier d’informations concernant la page (date, url, titre, extension du fichier) $info = ''; $info .= 'URL="'.$GLOBAL['url'].'"'."\n"; $info .= 'TITLE="'.$title.'"'."\n"; $info .= 'DATE="'.time().'"'."\n"; + $info .= 'TYPE="'.$ext.'"'."\n"; file_put_contents($GLOBAL['target_folder'].'/'.'index.ini', $info); /*$GLOBAL['done']['d'] = 'ajout'; $GLOBAL['done']['lien'] = $GLOBAL['target_folder'].'/'; */ @@ -795,6 +809,36 @@ function rand_new_name($name) { return 'f_'.str_shuffle('abcd').mt_rand(100, 999).'--'.preg_replace('#[^\w.]#', '_', substr($name, 15)).'.'.pathinfo($name, PATHINFO_EXTENSION); } +function returnLocalFavicon($path,$fileType){ + $favicon = glob($path.'*favicon.*'); + if(empty($favicon)){ + if(file_exists('design/icons/'.$fileType.'.png')){ + return 'design/icons/'.$fileType.'.png'; + } else { + return 'design/icons/html.png'; + } + } else { + return $favicon[0]; + } +} + +/** + * Améliore la sortie print + * + * @author Tatane http://www.tatane.info/index.php/print_rn + * @author http://www.blog.cactuscrew.com/77-print_rn.html + * @param $data (array) tableau à examiner + * @param $name (string) nom a affiché + * @return false affiche les clef valeur du tableau $data + */ +function n_print($data, $name = '') { + $aBackTrace = debug_backtrace(); + echo '

', $name, '

'; + echo '
'; + echo '', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], ''; + echo '
',           htmlentities(print_r($data, 1)), '
'; + echo '

'; +} if ($GLOBAL['done']['d'] !== FALSE) { switch($GLOBAL['done']['d']) { @@ -890,9 +934,7 @@ if ($GLOBAL['done']['d'] !== FALSE) { if (is_dir($GLOBAL['public_data_folder'].'/'.$liste_pages[$i]) and ($liste_pages[$i] != '.') and ($liste_pages[$i] != '..')) { // each folder should contain such a file "index.ini". $ini_file = $GLOBAL['public_data_folder'].'/'.$liste_pages[$i].'/index.ini'; - $favicon = glob($GLOBAL['public_data_folder'].'/'.$liste_pages[$i].'/*favicon.*'); - $favicon = (isset($favicon[0])) ? $favicon[0] : ''; if ( is_file($ini_file) and is_readable($ini_file) ) { $infos = parse_ini_file($ini_file); } else { @@ -903,7 +945,7 @@ if ($GLOBAL['done']['d'] !== FALSE) { } else { $titre = 'titre'; $url = '#'; $date = 'date inconnue'; } - + $favicon = returnLocalFavicon($GLOBAL['public_data_folder'].'/'.$liste_pages[$i].'/',$infos['TYPE']); $tags=$taglinks=''; if (isset($GLOBAL['tag_array']['public'][$liste_pages[$i]])){$tags=$GLOBAL['tag_array']['public'][$liste_pages[$i]];$taglinks=tag2links($GLOBAL['tag_array']['public'][$liste_pages[$i]]);} echo "\t".'
  • '; @@ -940,8 +982,6 @@ if ($GLOBAL['done']['d'] !== FALSE) { if (is_dir($GLOBAL['private_data_folder'].'/'.$liste_pages[$i]) and ($liste_pages[$i] != '.') and ($liste_pages[$i] != '..')) { // each folder should contain such a file "index.ini". $ini_file = $GLOBAL['private_data_folder'].'/'.$liste_pages[$i].'/index.ini'; - $favicon=glob($GLOBAL['private_data_folder'].'/'.$liste_pages[$i].'/*favicon.*'); - $favicon = (isset($favicon[0])) ? $favicon[0] : ''; if ( is_file($ini_file) and is_readable($ini_file) ) { $infos = parse_ini_file($ini_file); } else { @@ -952,6 +992,7 @@ if ($GLOBAL['done']['d'] !== FALSE) { } else { $titre = 'titre'; $url = '#'; $date = 'date inconnue'; } + $favicon = returnLocalFavicon($GLOBAL['public_data_folder'].'/'.$liste_pages[$i].'/',$infos['TYPE']); $tags=$taglinks=''; if (isset($GLOBAL['tag_array']['private'][$liste_pages[$i]])){$tags=$GLOBAL['tag_array']['private'][$liste_pages[$i]];$taglinks=tag2links($GLOBAL['tag_array']['private'][$liste_pages[$i]]);}