function list_file($cur) { global $PHP_SELF, $order, $asc, $order0; if ($dir = opendir($cur)) { /* tableaux */ $tab_dir = array(); $tab_file = array(); /* extraction */ while ($file = readdir($dir)) { if (is_dir($cur . "/" . $file)) { if (!in_array($file, array(".", ".."))) { $tab_dir[] = addScheme($file, $cur, 'dir'); } } else { $tab_file[] = addScheme($file, $cur, 'file'); } } /* tri */ // usort($tab_dir,"cmp_".$order); // usort($tab_file,"cmp_".$order); /* affichage */ //********************************************************************************************************* echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">"; echo "<tr style=\"font-size:8pt;font-family:arial;\">\n <th>" . ($order == 'name' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Nom</th><td> </td>\n <th>" . ($order == 'size' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Taille</th><td> </td>\n\t<th>" . ($order == 'date' ? $asc == 'a' ? '/\\ ' : '\\/ ' : '') . "Derniere modification</th><td> </td>\n\t</tr>"; //********************************************************************************************************* foreach ($tab_file as $elem) { if ($_SESSION['privilege'] == 1) { $cheminWeb = "#"; } else { $cheminWeb = "pages/force-download.php?file=" . INI_Conf_Moteur($_SESSION['opensim_select'], "address") . $elem['name']; } if (assocExt($elem['ext']) != 'inconnu') { echo "<tr><td>"; echo '<FORM METHOD=POST ACTION=""><INPUT TYPE="submit" VALUE="Telecharger" NAME="cmd" ' . $btnN3 . '><INPUT TYPE="submit" VALUE="Supprimer" NAME="cmd" ' . $btnN3 . '><INPUT TYPE="hidden" VALUE="' . $_SESSION['opensim_select'] . '" NAME="name_sim"><INPUT TYPE="hidden" VALUE="' . $elem['name'] . '" NAME="name_file"> ' . $elem['name'] . ' </FORM>'; echo "</td><td> </td>\n\t\t <td align=\"right\">" . formatSize($elem['size']) . "</td><td> </td>\n\t\t <td>" . date("d/m/Y H:i:s", $elem['date']) . "</td><td> </td></tr>"; } } echo "</table>"; closedir($dir); //********************************************************************************************************* } }
function list_dir($base, $cur, $level = 0) { global $PHP_SELF, $order, $asc; if ($dir = opendir($base)) { $tab = array(); while ($entry = readdir($dir)) { if (is_dir($base . "/" . $entry) && !in_array($entry, array(".", ".."))) { $tab[] = addScheme($entry, $base, 'dir'); } } /* tri */ usort($tab, "cmp_name"); foreach ($tab as $elem) { $entry = $elem['name']; /* chemin relatif a la racine */ $file = $base . "/" . $entry; /* marge gauche */ for ($i = 1; $i <= 4 * $level; $i++) { echo " "; } /* l'entree est-elle le dossier courant */ if ($file == $cur) { echo "<p><i class='glyphicon glyphicon-star'></i> {$entry}</p>\n"; } else { echo "<p><i class='glyphicon glyphicon-star'></i>"; echo " <a href=\"{$PHP_SELF}?dir=" . rawurlencode($file) . "&order={$order}&asc={$asc}\">{$entry}</a></p>\n"; } /* l'entree est-elle dans la branche dont le dossier courant est la feuille */ if (ereg($file . "/", $cur . "/")) { list_dir($file, $cur, $level + 1); } } closedir($dir); } }