function loadDir($dirName) { if ($handle = openDir($dirName)) { echo "<tr class='trTitle'><td>类型</td><td>文件名</td><td>大小</td><td>最后修改时间</td><td>操作</td></tr>"; while (false !== ($files = readDir($handle))) { if ($files != "." && $files != "..") { $urlStrs = $dirName . "/" . $files; if (!is_dir($dirName . "/" . $files)) { $types = "文件"; $cons = "<a href=\"loaddir.php?action=edit&urlstr={$urlStrs}\">编辑</a>"; $className = "file"; $fileSize = getSize($dirName . "/" . $files); $fileaTime = date("Y-m-d H:i:s", getEditTime($dirName . "/" . $files)); $arrayfile[] = "<tr class='{$className}'><td>{$types}</td><td>{$files}</td><td>" . $fileSize . " bytes</td><td>{$fileaTime}</td><td>{$cons}</td></tr>"; } //echo "<tr class='$className'><td>$types</td><td>$files</td><td>".$fileSize." bytes</td><td>$fileaTime</td><td>$cons</td></tr>"; } } //$arraydirLen=count($arraydir); //for($i=0;$i<$arraydirLen;$i++) echo $arraydir[$i]; $arrayfileLen = count($arrayfile); for ($i = 0; $i < $arrayfileLen; $i++) { echo $arrayfile[$i]; } //echo $arraydir; closeDir($handle); } }
public function loadAll() { $pluginpath = Settings::getInstance()->get("root") . "system/plugins"; $oDir = openDir($pluginpath); while ($item = readDir($oDir)) { $this->AddInfo($item); } closeDir($oDir); }
/** * This function returns a list of teaser - images contained in the $teaser - directory */ function get_teaser_array($teaser_directory) { $teaser_array = array(); $directory = openDir($teaser_directory); while ($file = readDir($directory)) { if ($file != "." && $file != "..") { array_push($teaser_array, $teaser_directory . $file); } } closeDir($directory); return $teaser_array; }
function getFiles() { //get list of all files for use in other routines global $dirPtr, $theFiles; chdir("."); $dirPtr = openDir("."); $currentFile = readDir($dirPtr); while ($currentFile !== false) { $theFiles[] = $currentFile; $currentFile = readDir($dirPtr); } // end while }
private function get_filelist() { $filelist = array(); $contentfolderpath = 'content/'; $contentfolder = openDir($contentfolderpath); while ($file = readDir($contentfolder)) { if ($file != "." && $file != ".." && !is_dir($contentfolderpath . "/" . $file)) { $pathparts = pathinfo($file); $filelist[$pathparts['filename']] = $file; } } closeDir($contentfolder); return $filelist; }
/** * * @param string $dir * @return array */ public static function getFolders($dir) { $res = array(); $oDir = openDir($dir); while ($item = readDir($oDir)) { if (is_dir($dir . "/" . $item)) { if ($item != "." && $item != "..") { $res[] = $item; } } } closeDir($oDir); return $res; }
/** * Copies all files from one directory to another directory. * @param string $sourceDirectory The source directory. * @param string $targetDirectory The target directory. */ public function copyFiles($sourceDirectory, $targetDirectory) { $dir = openDir($sourceDirectory); @mkDir($targetDirectory); while (false !== ($file = readDir($dir))) { if ($file == '.' || $file == '..') { continue; } if (is_dir($sourceDirectory . '/' . $file)) { $this->copyFiles($sourceDirectory . '/' . $file, $targetDirectory . '/' . $file); } else { copy($sourceDirectory . '/' . $file, $targetDirectory . '/' . $file); } } closeDir($dir); }
function getModulesList() { $dir = openDir(DIR_MODULES); $lst = array(); while ($file = readDir($dir)) { if (Is_Dir(DIR_MODULES . "{$file}") && $file != "." && $file != "..") { $rec = array(); $rec['FILENAME'] = $file; $lst[] = $rec; } } $this->modules = $lst; return $lst; }
function getModulesList() { $dir = openDir(DIR_MODULES); $lst = array(); while ($file = readDir($dir)) { if (Is_Dir(DIR_MODULES . "{$file}") && $file != "." && $file != "..") { $rec = array(); $rec['FILENAME'] = $file; $lst[] = $rec; } } function cmp_modules($a, $b) { return strcmp($a["FILENAME"], $b["FILENAME"]); } usort($lst, 'cmp_modules'); $this->modules = $lst; return $lst; }
$zeit = 0; //Arrays für ansprechende Zeitausgabe $monate = array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"); $tage = array("Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"); //Nun die Routine, um Dateien aus einem Verzeichnis auszulesen: //Erstes Verzeichnis wird geöffnet: $topdir = openDir("../graph"); //Jede Datei in erstem Verzeichnis ausgelesen: while ($topfile = readDir($topdir)) { //Überprüfung, ob die Datei kein versteckter Ordner ist, wenn nicht wird ein Titel geschrieben if (substr($topfile, 0, 1) != ".") { echo "<div class=\"titel\"><h1>{$topfile}</h1></div>"; echo "<div class=\"liste\">"; //Gefundenes Kategorienverzeichnis wird geöffnet und nun nach Bildern durchsucht. JS-Links werden generiert. $categorydir = openDir("../graph/{$topfile}"); while ($file = readDir($categorydir)) { if (substr($file, 0, 1) != ".") { echo "<a href='javascript:anzeigen(\"../graph/{$topfile}/{$file}\")' id=\"{$zaehler}\">{$file}</a><br>\n"; $zaehler = $zaehler + 1; //Datei mit der Höchsten änderungszeit wird gesucht if (filemtime("../graph/{$topfile}/{$file}") > $zeit) { $zeit = fileatime("../graph/{$topfile}/{$file}"); } } } //Zeiten werden formatiert $zeit_monat = $monate[date("n", $zeit) - 1]; $zeit_tag = $tage[date("N", $zeit) - 1]; $zeit_datum = date("d.", $zeit); $zeit_uhrzeit = date("H:i:s", $zeit); echo "<h6>Dieser Ordner wurde am {$zeit_tag}, den {$zeit_datum} {$zeit_monat} um {$zeit_uhrzeit} zuletzt geändert.</h6>";
/** * Title * * Description * * @access public */ function getCover($path) { $common_covers=array('cover.jpg'); foreach($common_covers as $file) { if (file_exists($path.$file)) { return $file; } } //search for images @$d=openDir($path); if ($d) { $files=array(); $biggest_size=0; $biggest_file=''; while ($file=readDir($d)) { if (preg_match('/\.jpg$/is', $file) || preg_match('/\.jpeg$/is', $file) || preg_match('/\.gif$/is', $file) || preg_match('/\.png$/is', $file) ) { $file_size=filesize($path.$file); if ($file_size>$biggest_size) { $biggest_size=$file_size; $biggest_file=$file; } //$files=array('FILENAME'=>$file); } } closeDir($d); if ($biggest_file) { return $biggest_file; } } }
<head> <title>imageIndex</title> </head> <body> <?php // image index // generates an index file containing all images in a particular directory //point to whatever directory you wish to index. //index will be written to this directory as imageIndex.html $dirName = "c:/csci/mm"; $dp = opendir($dirName); chdir($dirName); //add all files in directory to $theFiles array while ($currentFile !== false) { $currentFile = readDir($dp); $theFiles[] = $currentFile; } // end while //extract gif and jpg images $imageFiles = preg_grep("/jpg\$|gif\$/", $theFiles); $output = ""; foreach ($imageFiles as $currentFile) { $output .= <<<HERE <a href = {$currentFile}> <img src = "{$currentFile}" height = 50 width = 50> </a> HERE;
function getNotYetInstalledPlugins() { $col = array(); $paths = array($this->_getCustomPluginsRoot(), $this->_getOfficialPluginsRoot()); $exclude = array('.', '..', 'CVS', '.svn'); foreach ($paths as $path) { $dir = openDir($path); while ($file = readDir($dir)) { if (!in_array($file, $exclude) && is_dir($path . '/' . $file)) { if (!$this->isPluginInstalled($file) && !in_array($file, $col)) { $col[] = $file; } } } closeDir($dir); } return $col; }
/** * retourne un tableau des repertoire disponible * @access public * @param array $tInclusion * @param array $tExclusion * @return array d'objet _file */ public function getListDir($bWithHidden = false) { $this->verif(); $open = openDir($this->_sAdresse); $tFile = array(); while (false !== ($sFile = readDir($open))) { $bIsDir = is_dir($this->_sAdresse . '/' . $sFile); if ($bWithHidden == false and $sFile[0] == '.') { continue; } elseif ($bIsDir == true) { $oElement = new _dir($this->_sAdresse . '/' . $sFile); $tFile[] = $oElement; } } return $tFile; }
/** * Function that will doest the sum of files in the directory * * @param string sFolder, required. the path to check * @param bool bSubfolders, optional, default value TRUE; do you wants the list of the subfolders too? * @private * @type int **/ function _SIZE_get($sFolder, $bSubfolders) { $sum = -1; $dir = openDir(realpath($sFolder)); while ($oObj = readDir($dir)) { if (is_file(realpath($sFolder) . $this->cSep . $oObj)) { $sum += filesize(realpath($sFolder) . $this->cSep . $oObj); } if ($bSubfolders && is_dir(realpath($sFolder) . $this->cSep . $oObj) && $oObj != '.' && $oObj != '..') { $sum += $this->_SIZE_get(realpath($sFolder) . $this->cSep . $oObj, TRUE); } } //while closeDir($dir); return $sum; }
<?php $verzeichnis = openDir("./"); // Verzeichnis lesen while ($file = readDir($verzeichnis)) { // Höhere Verzeichnisse nicht anzeigen! $file_extension = substr($file, strlen($file) - 4); if ($file != "." && $file != ".." && ($file_extension == ".html" || $file_extension == ".HTML")) { // Link erstellen echo "<a href=\"{$file}\">{$file}</a><br>\n"; } if (is_dir($file)) { // Link zu HQ und HD Bildern erstellen echo "<a href=\"{$file}\"/hq/list_images.php>HQ {$file}</a><br>\n"; echo "<a href=\"{$file}\"/fullhd/list_images.php>HD {$file}</a><br>\n"; } } // Verzeichnis schließen closeDir($verzeichnis);
/** * カテゴリを全て取得する * @return array 全てのカテゴリのカテゴリ名とファイルサイズ */ private function _getCategories() { $h = openDir(Todo::DATA_DIR); if (!$h) { exit('data directory is not found.'); } $cats = array(); $limit = date('YmdHis', strToTime(Todo::BACKUP_TIME)); while (false !== ($file = readDir($h))) { if (is_dir($file)) { continue; } $arr = explode('.', $file); $path = Todo::DATA_DIR . '/' . $file; if (count($arr) == 3) { //バックアップの場合 if ($arr[2] < $limit) { //期限切れは削除 unlink($path); } } else { //最新版の場合 $cat = mb_convert_encoding($arr[0], Todo::ENCODING, Todo::FILE_NAME_ENCODING); $cats[$cat] = fileSize($path); } } closeDir($h); ksort($cats); return $cats; }
<br /> <?php echo make_navi_red("Galerie", $team); ?> <br /><br /> <a class="button" href="add_pic.php" title="Neues Bild">Neues Bild</a> <br /> <br /> <?php $c1 = 0; $verzeichnis = 'bilder/teams/Galerie/1516/' . $team . '/'; $handle = openDir($verzeichnis); $html = '<table><tr>'; while ($datei = readDir($handle)) { if ($datei != "." && $datei != ".." && !is_dir($datei)) { if (strstr($datei, ".jpeg") || strstr($datei, ".png") || strstr($datei, ".jpg") || strstr($datei, ".JPEG") || strstr($datei, ".PNG") || strstr($datei, ".JPG")) { $verzeichnis_datei = $verzeichnis . $datei; $info = getImageSize($verzeichnis_datei); if ($info[0] >= $info[1]) { $quot = $info[0] / 200; $info[0] = 200; $info[1] /= $quot; } else { $quot = $info[1] / 200; $info[1] = 200; $info[0] /= $quot; } $c1++; $html .= "<td class=\"galerie_table\"><a href=\"erase_pic.php?pic={$verzeichnis_datei}\"><img src=\"bilder/teams/Thumbnails/1516/" . $team . "/TN" . $datei . "\"></a></td>";
function files($parameters="") { global $REQUEST_URI; global $out; global $mode; $dir=str_replace('\\\'', "'", $_SERVER['REQUEST_URI']); $dir=preg_replace("/^\/.*?\//", "./", $dir); $dir=preg_replace("/\?.*?$/", "", $dir); $dir=urldecode($dir); //echo utf2win($dir); //exit; $paths=split("/", $dir); $old=""; $history=array(); foreach($paths as $v) { if ($v=="") continue; if ($v==".") continue; $rec=array(); $rec['TITLE']=$v; $rec['PATH']=$old."$v/"; $old.="$v/"; $history[]=$rec; } $out['HISTORY']=$history; $out['CURRENT_DIR_TITLE']=($dir); $out['CURRENT_DIR']=urlencode($dir); $act_dir=INIT_DIR."$dir"; if (@$mode=="descr") { global $file; global $new_descr; global $REMOTE_ADDR; global $can_edit; if (strpos($can_edit, $REMOTE_ADDR)>0) setDescription($act_dir, $file, $new_descr); $mode=""; header("Location:?\n\n"); exit; } $descriptions=getDescriptions($act_dir); $d=openDir($act_dir); $dirs=array(); while ($file=readDir($d)) { if (($file==".") || ($file=="..")) { continue; } if (Is_Dir($act_dir.$file)) { $rec=array(); $rec['TITLE']=$file; $rec['TITLE_SHORT']=$rec['TITLE']; if (strlen($rec['TITLE_SHORT'])>30) { $rec['TITLE_SHORT']=substr($rec['TITLE_SHORT'], 0, 30).'...'; } if (IsSet($descriptions[$file])) { $rec['DESCR']=$descriptions[$file]; } $rec['PATH']=urlencode("$file").'/'; $rec['REAL_PATH']=$dir.$file; $dirs[]=$rec; } } closeDir($d); $dirs=mysort_array($dirs, "TITLE"); if (count($dirs)>0) $out['DIRS']=$dirs; $d=openDir($act_dir); $files=array(); while ($file=readDir($d)) { if (($file==".") || ($file=="..") || ($file=="Descript.ion")) { continue; } if (Is_File($act_dir.$file)) { $rec=array(); $rec['TITLE']=$file; if (IsSet($descriptions[$file])) { $rec['DESCR']=$descriptions[$file]; } if (strlen($rec['TITLE'])>30) { $rec['TITLE_SHORT']=substr($rec['TITLE'], 0, 30)."..."; } else { $rec['TITLE_SHORT']=$rec['TITLE']; } $rec['PATH']="$file"; $size=filesize($act_dir.$file); $total_size+=$size; if ($size>1024) { if ($size>1024*1024) { $size=(((int)(($size/1024/1024)*10))/10)." Mb"; } else { $size=(int)($size/1024)." Kb"; } } else { $size.=" b"; } $rec['SIZE']=$size; $files[]=$rec; } } closeDir($d); $files=mysort_array($files, "TITLE"); if (count($files)>0) $out['FILES']=$files; $out['TOTAL_FILES']=count($files); $out['TOTAL_DIRS']=count($dirs); if ($total_size>1024) { if ($total_size>1024*1024) { $total_size=(((int)(($total_size/1024/1024)*10))/10)." Mb"; } else { $total_size=(int)($total_size/1024)." Kb"; } } else { $total_size.=" b"; } $out['TOTAL_SIZE']=$total_size; }