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 load() { $this->headline = $GLOBALS['language']->getString("FILES"); if (!isset($_GET['dir']) || substr($_GET['dir'], 0, 1) == '.') { $_GET['dir'] = ""; } $uploadpath = Settings::getInstance()->get("root") . "content/uploads/"; $this->template = new Template(); $this->template->load("plugin_filelistwidget_filelist"); $this->template->show_if("FILES_EXIST", false); $this->template->show_if("NOFILES", false); $this->template->assign_var("DIR", htmlentities($_GET['dir'])); $actions = ActionList::get("plugin_filelistwidget"); $dir = $_GET['dir']; if (file_exists($uploadpath . $dir)) { $this->delete($uploadpath); $this->rename($dir, $uploadpath); $verzeichnis = openDir($uploadpath . $dir); $pre = ""; $path = ""; foreach (explode("/", $dir) as $cDir) { $index = $this->template->add_loop_item("PATH"); $path .= "/" . $cDir; if ($path == "/") { $this->template->assign_loop_var("PATH", $index, "URL", "/admin/index.php?page=files"); $this->template->assign_loop_var("PATH", $index, "LABEL", "/"); $path = ""; } else { $this->template->assign_loop_var("PATH", $index, "URL", "/admin/index.php?page=files&dir=" . $path); $this->template->assign_loop_var("PATH", $index, "LABEL", $cDir); } } if (trim($_GET['dir']) != "" & trim($_GET['dir']) != "/") { $this->template->assign_var("DELETEFOLDERLINK", "<a href=\"/admin/index.php?page=files&rmdir=" . $_GET['dir'] . "\">Ordner löschen</a>"); } else { $this->template->assign_var("DELETEFOLDERLINK", ""); } $files = FileServer::getFiles($uploadpath . $dir); } if (isset($files) && sizeOf($files) > 0) { $this->template->show_if("FILES_EXIST", true); $this->template->show_if("NOFILES", false); foreach ($files as $file) { $index = $this->template->add_loop_item("FILES"); $this->template->assign_loop_var("FILES", $index, "IMAGE", $this->getImageCode($uploadpath, $dir, $file)); $this->template->assign_loop_var("FILES", $index, "FILELINK", "<a href=\"../content/uploads" . $dir . "/" . $file . "\">" . $file . "</a>"); $params = array(); $params['dir'] = $_GET['dir']; $params['file'] = $file; $this->template->assign_loop_var("FILES", $index, "ACTIONS", $actions->getCode($params)); } } else { $this->template->show_if("FILES_EXIST", false); $this->template->show_if("NOFILES", true); } $this->template->assign_var("MESSAGE", ""); $this->content = $this->template->getCode(); }
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); }
/** * @param string $configDir */ public function __construct($configDir) { $yml = new Parser(); $configFilesPath = []; if (is_dir($configDir)) { $dirHandler = openDir($configDir); while ($data = readdir($dirHandler)) { $configFilesPath[] = $data; } $configFilesPath = array_diff($configFilesPath, ['.', '..']); closedir(); } $config = []; foreach ($configFilesPath as $configFilePath) { $config[$configFilePath] = $yml->parse(file_get_contents($configDir . '/' . $configFilePath)); } $this->config = $config; }
/** * Метод рекурсивно собирает все классы в директории. * * @param string $dirAbsPath - путь к директории * @param array $classes - карта [PsUtil] => [C:/www/postupayu.ru/www/kitcore/utils/PsUtil.php] * @param bool $skipDirClasses - пропускать ли классы в корневой директории. * Флаг позволит не подключать классы, лежащие в корне kitcore, * так как их мы подключим сами (Globals, Defines, PsCoreIncluder) */ public static function loadClassPath($dirAbsPath, array &$classes, $skipDirClasses) { if (!is_dir($dirAbsPath)) { return; //--- } $dir = openDir($dirAbsPath); while ($file = readdir($dir)) { if (!is_valid_file_name($file)) { continue; } $isphp = ends_with($file, '.php'); if ($isphp && $skipDirClasses) { continue; } $path = next_level_dir($dirAbsPath, $file); if ($isphp) { $classes[cut_string_end($file, '.php')] = $path; } else { self::loadClassPath($path, $classes, false); } } closedir($dir); }
$zaehler = 0; $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);
/** * 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; } } }
public static function poidsDossier($dossier) { $dir = openDir($dossier); $poids = 0; while ($f = readdir($dir)) { if ($f != '.' && $f != '..') { if (is_dir($dossier . $f)) { $poids += poidsDossier($dossier . $f . '/'); } else { $poids += filesize($dossier . $f); } } } return $poids; }
/** * Получает названия папок, вложенных в переданную директорию * * @param array $allowed - список допустимых названий подпапок */ public final function getSubDirNames($dirs = null, $allowed = null, $denied = null) { $result = array(); $allowed = $allowed === null ? null : to_array($allowed); if (is_array($allowed) && empty($allowed)) { return $result; } $denied = $denied === null ? null : to_array($denied); $absDirPath = $this->absDirPath($dirs); if (is_dir($absDirPath)) { $dir = openDir($absDirPath); if ($dir) { $absDirPath = ensure_dir_endswith_dir_separator($absDirPath); while ($file = readdir($dir)) { if (!is_valid_file_name($file)) { continue; } if (is_array($allowed) && !in_array($file, $allowed)) { continue; } if (is_array($denied) && in_array($file, $denied)) { continue; } if (is_dir($absDirPath . $file)) { $result[] = $file; } } closedir($dir); } } return $result; }
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; }
<?php $htmlDir = "../htmlObjectHarness"; $svgViewer = "../SvgViewer.swf"; $fhDir = openDir($htmlDir); while ($file = readdir($fhDir)) { $file = $htmlDir . "/" . $file; if (preg_match('/\\.htm[l]*$/si', $file)) { $fh = fopen($file, "r"); $content = fread($fh, filesize($file)); fclose($fh); if (preg_match('/<object.*?\\/>/si', $content, $match)) { if (stripos($match[0], 'classid="') === false) { if (!preg_match('/data="([^"]+)" width="([^"]+)" height="([^"]+)"/si', $match[0], $matches)) { print "Error updateing file: {$file}\n"; break; } $svg = $matches[1]; $width = $matches[2]; $height = $matches[3]; $newTag = ' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="" id="mySVGViewerObj" width=' . $width . ' height=' . $height . '> <param name=movie value="' . $svgViewer . '"> <param name="FlashVars" value="sourceType=url_svg&svgURL=' . $svg . '"> <param name="wmode" value="transparent"> <embed play=false name="mySVGViewerObj" src="' . $svgViewer . '" quality=high wmode="transparent" width=' . $width . ' height=' . $height . ' type="application/x-shockwave-flash" FlashVars="sourceType=url_svg&svgURL=' . $svg . '"> </embed >
/** * Seeks out plugins in the filesystem and puts them in a nice array * These plugins are not necessarily installed * * @access public * @since 2/23/06 */ function _registerPlugins($directory) { $_SESSION['registeredPlugins'] = array(); // open the plugin directory if ($directory != 'plugins-dist' && $directory != 'plugins-local') { throw new InvalidArgumentException("'{$directory}' should be 'plugins-dist' or 'plugins-local'"); } $plugPath = MYDIR . "/" . $directory . "/"; $pDirHandle = openDir($plugPath); // directories that should be there and are not plugins $ignore = array(".", "..", "CVS"); // first grab a domain folder and then look inside it while ($domainDir = readdir($pDirHandle)) { $domainPath = $plugPath . "/" . $domainDir; if (is_dir($domainPath) && !in_array($domainDir, $ignore) && preg_match("/^[a-zA-Z0-9_]+\$/", $domainDir)) { $domain = $domainDir; $dDirHandle = openDir($domainPath); // now take an authority folder and open it while ($authDir = readdir($dDirHandle)) { $authPath = $domainPath . "/" . $authDir; if (is_dir($authPath) && !in_array($authDir, $ignore) && preg_match("/^[a-zA-Z0-9\\._]+\$/", $authDir)) { $authority = $authDir; $aDirHandle = openDir($authPath); // finally find all the keyword folders (each is a plugin) while ($keyDir = readdir($aDirHandle)) { $keyPath = $authPath . "/" . $keyDir; if (is_dir($keyPath) && !in_array($keyDir, $ignore) && preg_match("/^[a-zA-Z0-9_]+\$/", $keyDir)) { $keyword = $keyDir; $type = new Type($domain, $authority, $keyword); $indexString = $type->asString(); // unique types are placed in the array if (!isset($_SESSION['registeredPlugins'][$indexString])) { $_SESSION['registeredPlugins'][$indexString] = $type; } } } } } } } }
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; }
/** * 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; }
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; }
<?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; }
" method="post" > <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; }
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; }
/** * 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; }