Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente | |||
| info:myphp:dir-mod-meta [2018/07/18 09:45] – ↷ Page déplacée de info:git:homepage:myphp:dir-mod-meta à info:myphp:dir-mod-meta radeff | info:myphp:dir-mod-meta [2026/03/05 09:25] (Version actuelle) – radeff | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | dir-mod-meta.php | + | ====== PHP parser un répertoire (dir-mod) ====== |
| + | |||
| + | ===== Version 1 ===== | ||
| + | |||
| + | < | ||
| + | <? | ||
| + | #written radeff, 02.2002, you can use that code freely | ||
| + | #erase next line if you dont want ordered bullets | ||
| + | #CALL THAT FILE index.php OR welcome.php OR WHATEVER php file | ||
| + | # YOUR WEB SERVER UNDERSTAND AS A REPERTORY | ||
| + | #set the number of columns you like | ||
| + | $nbcol=4; | ||
| + | $letexte= "< | ||
| + | #path (MODIFY) | ||
| + | $path=" | ||
| + | $fd=dir($path); | ||
| + | #create array | ||
| + | while($v = $fd->read()) { | ||
| + | $arr[]=$v; | ||
| + | } | ||
| + | $fd-> | ||
| + | #sort array, reverse sort would be function arsort() | ||
| + | sort($arr); | ||
| + | #make a loop with filename | ||
| + | $t=0; | ||
| + | foreach ($arr as $elem) | ||
| + | #count item/ | ||
| + | |||
| + | $fichier=" | ||
| + | # exclusion of the " | ||
| + | if ($fichier!=" | ||
| + | $text=$fichier; | ||
| + | #another way to to exclude eg extensions html or doc or file(s), eg index.php you can do it here also* | ||
| + | $text=eregi_replace(" | ||
| + | $text=eregi_replace(" | ||
| + | $text=eregi_replace(" | ||
| + | $text=eregi_replace(" | ||
| + | $text=eregi_replace(" | ||
| + | #execute only if $text is not empty | ||
| + | if ($text!="" | ||
| + | #if directory add / and a special CSS class | ||
| + | if(is_dir($fichier)) { | ||
| + | $text.="/"; | ||
| + | | ||
| + | $laclasse=" | ||
| + | } else { | ||
| + | $laclasse=""; | ||
| + | | ||
| + | } | ||
| + | #uncomment if you like ordered bullets with # items | ||
| + | |||
| + | $t++; | ||
| + | $test=($t/ | ||
| + | # | ||
| + | if($test==" | ||
| + | #break | ||
| + | $ligF="</ | ||
| + | } else { | ||
| + | $ligD=""; | ||
| + | $ligF=""; | ||
| + | } | ||
| + | |||
| + | $letexte.= | ||
| + | if( $repertoire!=1 && file_exists($fichier ." | ||
| + | $letexte.= " [<a href='" | ||
| + | } | ||
| + | $letexte.= " | ||
| + | } | ||
| + | |||
| + | |||
| + | } | ||
| + | } | ||
| + | |||
| + | $letexte.= | ||
| + | echo $letexte; | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | ===== Version 2 ===== | ||
| + | |||
| < | < | ||
| <? | <? | ||