oor jouw Thoma
By: U mama | Date: Nov 27 2006 21:41 | Format: PHP | Expires: never | Size: 3.59 KB | Hits: 1454
- <? rn$_GET[newdir] = htmlspecialchars($_GET[newdir], ENT_QUOTES); rn//Bestanden die niet weergegeven worden rn $exclude = Array(".","..",".php",".htm",".html",".css",".sql",".inc"); rnrn //Het complete path van het script rn $standpath = substr($_SERVER["SCRIPT_FILENAME"],0,strrpos($_SERVER["SCRIPT_FILENAME"],"/")); rnrn //Check naar welke directory er gegaan moet worden rn If ($_GET[newdir]) { rn (file_exists($standpath . "/" . $_GET[newdir])) ? $standpath = $standpath . "/" . $_GET[newdir] : header("Location: ?show=files"); rn } rn rn //Lees elke file en directory uit de geopende directory en zet deze beide een aparte array rn $wdir = opendir($standpath); rn while (false !== ($filename = readdir($wdir))) { rn If (!in_array(substr($filename,strrpos($filename,".")),$exclude)) { rn (is_dir($standpath . "/" . $filename)) ? $all_dirs[] = $filename : $all_files[] = $filename; rn } rn } rnrn //Sorteer beide array's rn If ($all_dirs) sort($all_dirs); rn If ($all_files) sort($all_files); rnrn //Voeg de beide array's samen rn $totaldir = array_merge_recursive($all_dirs,$all_files); rnrn //Loop alle files en directory's afzonderlijk na rn $counter = 0; rn While ($totaldir[$counter]) { rnrn //Check of het een directory of een file is rn If (is_dir($standpath . "/" . $totaldir[$counter])) { rn $ftype = "Directory"; rn $link = $_SERVER['PHP_SELF'] . "?show=files&newdir=" . $_GET[newdir] . "/" . $totaldir[$counter]; rn $fsize = ""; rn } Else { rnrn //Bereken bestandsgroote in Bytes, KiloBytes, MegaBytes of GigaBytes rn $fsize = filesize($standpath . "/" . $totaldir[$counter]); rn If ($fsize < 1024) $fsize .= " B"; rn ElseIf ($fsize < 1048576) $fsize = round($fsize / 1024,2) . " KB"; rn ElseIf ($fsize < 1073741824) $fsize = round($fsize / 1024 / 1024,2) . " MB"; rn ElseIf ($fsize < 1099511627776) $fsize = round($fsize / 1024 / 1024 / 1024,2) . " GB"; rnrn //Maak een HTML link rn $ftype = "File"; rn ($_GET[newdir]) ? $link = substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],"/")) . $_GET[newdir] . "/" . $totaldir[$counter] : $link = $totaldir[$counter]; rn } rn ($_GET[newdir]) ? $location = $_GET[newdir] : $location = "/"; rn rn //Maak de HTML source rn $files .= " rn <tr> rn <td class=\"type\">" . $ftype . "</td> rn <td class=\"link\"><a href=\"" . $link . "\">" . $totaldir[$counter] . "</a></td> rn <td class=\"path\">" . $location . "</td> rn <td class=\"size\">" . $fsize . "</td> rn <td class=\"modified\">" . date("d-m-Y H:i", filemtime($standpath . "/" . $totaldir[$counter])) . "</td> rn </tr>"; rn $counter++; rn } rn?> rnrnrnrnrnrnrnrnrn<? rn //Een 'Parent Directory' link maken rn If ($_GET[newdir]) { ?> rn <tr> rn <td colspan="5"><a href="<? echo $_SERVER['PHP_SELF'] . "?show=files&newdir=" . substr($_GET[newdir],0,strrpos($_GET[newdir],"/")); ?>">Parent Directory</a></td> rn </tr> rn<? rn } rn echo $files; rn?>
Latest pastes
3 hours ago
1 days ago
1 days ago
2 days ago
2 days ago