• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP opendir函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中opendir函数的典型用法代码示例。如果您正苦于以下问题:PHP opendir函数的具体用法?PHP opendir怎么用?PHP opendir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了opendir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: onls

 function onls()
 {
     $logdir = UC_ROOT . 'data/logs/';
     $dir = opendir($logdir);
     $logs = $loglist = array();
     while ($entry = readdir($dir)) {
         if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
             $logs = array_merge($logs, file($logdir . $entry));
         }
     }
     closedir($dir);
     $logs = array_reverse($logs);
     foreach ($logs as $k => $v) {
         if (count($v = explode("\t", $v)) > 1) {
             $v[3] = $this->date($v[3]);
             $v[4] = $this->lang[$v[4]];
             $loglist[$k] = $v;
         }
     }
     $page = max(1, intval($_GET['page']));
     $start = ($page - 1) * UC_PPP;
     $num = count($loglist);
     $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
     $loglist = array_slice($loglist, $start, UC_PPP);
     $this->view->assign('loglist', $loglist);
     $this->view->assign('multipage', $multipage);
     $this->view->display('admin_log');
 }
开发者ID:tang86,项目名称:discuz-utf8,代码行数:28,代码来源:log.php


示例2: listCommands

 private static function listCommands()
 {
     $commands = array();
     $dir = __DIR__;
     if ($handle = opendir($dir)) {
         while (false !== ($entry = readdir($handle))) {
             if ($entry != "." && $entry != ".." && $entry != "base.php") {
                 $s1 = explode("cli_", $entry);
                 $s2 = explode(".php", $s1[1]);
                 if (sizeof($s2) == 2) {
                     require_once "{$dir}/{$entry}";
                     $command = $s2[0];
                     $className = "cli_{$command}";
                     $class = new $className();
                     if (is_a($class, "cliCommand")) {
                         $commands[] = $command;
                     }
                 }
             }
         }
         closedir($handle);
     }
     sort($commands);
     return implode(" ", $commands);
 }
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:25,代码来源:cli_help.php


示例3: quoteFromDir

 function quoteFromDir($dir)
 {
     $amount = 0;
     $index = 0;
     if ($handle = opendir($dir)) {
         while (false !== ($file = readdir($handle))) {
             if (strpos($file, ".dat") != false) {
                 $len = strlen($file);
                 if (substr($file, $len - 4) == ".dat") {
                     $number = $this->getNumberOfQuotes($dir . "/" . $file);
                     $amount += $number;
                     $quotes[$index] = $amount;
                     $files[$index] = $file;
                     $index++;
                 }
             }
         }
         srand((double) microtime() * 1000000);
         $index = rand(0, $amount);
         $i = 0;
         while ($quotes[$i] < $index) {
             $i++;
         }
         return $this->getRandomQuote($dir . "/" . $files[$i]);
     }
     return -1;
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:27,代码来源:fortune.php


示例4: collect

 /**
  *
  * @static
  * @return array
  */
 public static function collect()
 {
     if (null === self::$_collection) {
         $themes = Axis_Collect_Theme::collect();
         $layouts = array();
         $designPath = Axis::config('system/path') . '/app/design/front';
         foreach ($themes as $theme) {
             $path = $designPath . '/' . $theme . '/layouts';
             if (!file_exists($path)) {
                 continue;
             }
             $dir = opendir($path);
             while ($file = readdir($dir)) {
                 if (is_dir($path . '/' . $file) || substr($file, 0, 7) != 'layout_') {
                     continue;
                 }
                 $layout = substr($file, 0, -6);
                 if (isset($layouts[$layout])) {
                     $layouts[$layout]['themes'][] = $theme;
                     continue;
                 }
                 $layouts[$layout] = array('name' => $layout, 'themes' => array($theme));
             }
         }
         $collection = array();
         foreach ($layouts as $key => $layout) {
             $collection[$key] = $layout['name'] . ' (' . implode(', ', $layout['themes']) . ')';
         }
         self::$_collection = $collection;
     }
     return self::$_collection;
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:37,代码来源:Layout.php


示例5: chmod_R

 /**
  * Chmod recursive
  *
  * @see http://www.php.net/manual/fr/function.chmod.php#105570
  */
 private function chmod_R($path, $filemode, $dirmode)
 {
     if (is_dir($path)) {
         if (!chmod($path, $dirmode)) {
             $dirmode_str = decoct($dirmode);
             print "Failed applying filemode '{$dirmode_str}' on directory '{$path}'\n";
             print "  `-> the directory '{$path}' will be skipped from recursive chmod\n";
             return;
         }
         $dh = opendir($path);
         while (($file = readdir($dh)) !== false) {
             if ($file != '.' && $file != '..') {
                 // skip self and parent pointing directories
                 $fullpath = $path . '/' . $file;
                 $this->chmod_R($fullpath, $filemode, $dirmode);
             }
         }
         closedir($dh);
     } else {
         if (is_link($path)) {
             print "link '{$path}' is skipped\n";
             return;
         }
         if (!chmod($path, $filemode)) {
             $filemode_str = decoct($filemode);
             print "Failed applying filemode '{$filemode_str}' on file '{$path}'\n";
             return;
         }
     }
 }
开发者ID:noreiller,项目名称:PlopCMS-sandbox,代码行数:35,代码来源:sfAssetFolder.php


示例6: chmod_r

function chmod_r($path, $filemode)
{
    if (!is_dir($path)) {
        return chmod($path, $filemode);
    }
    $dh = opendir($path);
    while (($file = readdir($dh)) !== false) {
        if ($file != '.' && $file != '..') {
            $fullpath = $path . '/' . $file;
            if (is_link($fullpath)) {
                return FALSE;
            } elseif (!is_dir($fullpath)) {
                if (!chmod($fullpath, $filemode)) {
                    return FALSE;
                } elseif (!chmod_r($fullpath, $filemode)) {
                    return FALSE;
                }
            }
        }
    }
    closedir($dh);
    if (chmod($path, $filemode)) {
        return TRUE;
    } else {
        return FALSE;
    }
}
开发者ID:nong053,项目名称:condo,代码行数:27,代码来源:picture_process.php


示例7: findDirs

/**
 * Returns an array of found directories
 *
 * This function checks every found directory if they match either $uid or $gid, if they do
 * the found directory is valid. It uses recursive function calls to find subdirectories. Due
 * to the recursive behauviour this function may consume much memory.
 *
 * @param  string   path       The path to start searching in
 * @param  integer  uid        The uid which must match the found directories
 * @param  integer  gid        The gid which must match the found direcotries
 * @param  array    _fileList  recursive transport array !for internal use only!
 * @return array    Array of found valid pathes
 *
 * @author Martin Burchert  <[email protected]>
 * @author Manuel Bernhardt <[email protected]>
 */
function findDirs($path, $uid, $gid)
{
    $list = array($path);
    $_fileList = array();
    while (sizeof($list) > 0) {
        $path = array_pop($list);
        $path = makeCorrectDir($path);
        $dh = opendir($path);
        if ($dh === false) {
            standard_error('cannotreaddir', $path);
            return null;
        } else {
            while (false !== ($file = @readdir($dh))) {
                if ($file == '.' && (fileowner($path . '/' . $file) == $uid || filegroup($path . '/' . $file) == $gid)) {
                    $_fileList[] = makeCorrectDir($path);
                }
                if (is_dir($path . '/' . $file) && $file != '..' && $file != '.') {
                    array_push($list, $path . '/' . $file);
                }
            }
            @closedir($dh);
        }
    }
    return $_fileList;
}
开发者ID:HobbyNToys,项目名称:SysCP,代码行数:41,代码来源:function.findDirs.php


示例8: actionGetfilelist

 public function actionGetfilelist($template)
 {
     $fileutil = new FileUtil();
     $dir = null;
     $loc = $_REQUEST['loc'];
     if ($loc == null) {
         $dir = 'themes/' . $template . '/views';
     } else {
         $dir = $loc;
     }
     $handler = opendir($dir);
     $files = array();
     while (($filename = readdir($handler)) !== false) {
         //务必使用!==,防止目录下出现类似文件名“0”等情况
         $extend = pathinfo($filename);
         $extend = strtolower($extend["extension"]);
         if ($filename != "." && $filename != ".." && $extend !== "db") {
             if (is_dir($dir . '/' . $filename)) {
                 $files[] = array(name => $filename, loc => $dir . '/' . $filename, isParent => true);
             } else {
                 $files[] = array(name => $filename, loc => $dir . '/' . $filename, isParent => false);
             }
         }
     }
     closedir($handler);
     echo json_encode($files);
 }
开发者ID:Toney,项目名称:xmcms,代码行数:27,代码来源:TemplateController.php


示例9: add_demo_templates

function add_demo_templates()
{
    $dir = dirname(__FILE__) . '/templates';
    if ($handle = opendir($dir)) {
        while (false !== ($entry = readdir($handle))) {
            if ($entry != "." && $entry != ".." && $entry != ".DS_Store") {
                $template_name = str_replace('.php', '', $entry);
                $template_name = str_replace('-', ' ', $template_name);
                $template_name = ucwords($template_name);
                $template = file_get_contents($dir . '/' . $entry);
                $template_arr = array("name" => stripslashes($template_name), "template" => stripslashes($template));
                $option_name = 'wpb_js_templates';
                $saved_templates = get_option($option_name);
                $template_id = sanitize_title($template_name) . "_" . rand();
                if ($saved_templates == false) {
                    $deprecated = '';
                    $autoload = 'no';
                    //
                    $new_template = array();
                    $new_template[$template_id] = $template_arr;
                    //
                    add_option($option_name, $new_template, $deprecated, $autoload);
                } else {
                    $saved_templates[$template_id] = $template_arr;
                    update_option($option_name, $saved_templates);
                }
            }
        }
        closedir($handle);
    }
    return true;
}
开发者ID:Beutiste,项目名称:wordpress,代码行数:32,代码来源:import.php


示例10: sup_repertoire

function sup_repertoire($chemin)
{
    // vérifie si le nom du repertoire contient "/" à la fin
    if ($chemin[strlen($chemin) - 1] != '/') {
        $chemin .= '/';
        // rajoute '/'
    }
    if (is_dir($chemin)) {
        $sq = opendir($chemin);
        // lecture
        while ($f = readdir($sq)) {
            if ($f != '.' && $f != '..') {
                $fichier = $chemin . $f;
                // chemin fichier
                if (is_dir($fichier)) {
                    sup_repertoire($fichier);
                    // rapel la fonction de manière récursive
                } else {
                    unlink($fichier);
                    // sup le fichier
                }
            }
        }
        closedir($sq);
        rmdir($chemin);
        // sup le répertoire
    } else {
        unlink($chemin);
        // sup le fichier
    }
}
开发者ID:BackupTheBerlios,项目名称:sitebe-svn,代码行数:31,代码来源:responsable_module.php


示例11: buildSecFile

/**
 * Build a secured file with token name
 *
 * @param string $reqkey The reference key
 *
 * @return string The secure key
 */
function buildSecFile($reqkey)
{
    $CI =& get_instance();
    $skey = mt_rand();
    $dir = $CI->config->item('token_dir');
    $file = $skey . '.tok';
    //make the file with the reqkey value in it
    file_put_contents($dir . '/' . $file, $reqkey);
    //do some cleanup - find ones older then the threshold and remove
    $rm = $CI->config->item('token_rm');
    //this is in minutes
    if (is_dir($dir)) {
        if (($h = opendir($dir)) !== false) {
            while (($file = readdir($h)) !== false) {
                if (!in_array($file, array('.', '..'))) {
                    $p = $dir . '/' . $file;
                    if (filemtime($p) < time() - $rm * 60) {
                        unlink($p);
                    }
                }
            }
        }
    }
    return $skey;
}
开发者ID:Bittarman,项目名称:joind.in,代码行数:32,代码来源:reqkey_helper.php


示例12: list_files

/**
 * Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep.
 * The depth of the recursiveness can be controlled by the $levels param.
 *
 * @since 2.6.0
 *
 * @param string $folder Full path to folder
 * @param int $levels (optional) Levels of folders to follow, Default: 100 (PHP Loop limit).
 * @return bool|array False on failure, Else array of files
 */
function list_files($folder = '', $levels = 100)
{
    if (empty($folder)) {
        return false;
    }
    if (!$levels) {
        return false;
    }
    $files = array();
    if ($dir = @opendir($folder)) {
        while (($file = readdir($dir)) !== false) {
            if (in_array($file, array('.', '..'))) {
                continue;
            }
            if (is_dir($folder . '/' . $file)) {
                $files2 = list_files($folder . '/' . $file, $levels - 1);
                if ($files2) {
                    $files = array_merge($files, $files2);
                } else {
                    $files[] = $folder . '/' . $file . '/';
                }
            } else {
                $files[] = $folder . '/' . $file;
            }
        }
    }
    @closedir($dir);
    return $files;
}
开发者ID:Nancers,项目名称:Snancy-Website-Files,代码行数:39,代码来源:file.php


示例13: copyr

 public static function copyr($source, $dest)
 {
     // recursive function to copy
     // all subdirectories and contents:
     if (is_dir($source)) {
         $dir_handle = opendir($source);
         $sourcefolder = basename($source);
         if (!is_dir($dest . "/" . $sourcefolder)) {
             mkdir($dest . "/" . $sourcefolder);
         }
         while ($file = readdir($dir_handle)) {
             if ($file != "." && $file != "..") {
                 if (is_dir($source . "/" . $file)) {
                     self::copyr($source . "/" . $file, $dest . "/" . $sourcefolder);
                 } else {
                     copy($source . "/" . $file, $dest . "/" . $file);
                 }
             }
         }
         closedir($dir_handle);
     } else {
         // can also handle simple copy commands
         copy($source, $dest);
     }
 }
开发者ID:ASDAFF,项目名称:RosYama.2,代码行数:25,代码来源:Y.php


示例14: GetFoldersAndFiles

function GetFoldersAndFiles($resourceType, $currentFolder)
{
    // Map the virtual path to the local server path.
    $sServerDir = ServerMapFolder($resourceType, $currentFolder);
    // Initialize the output buffers for "Folders" and "Files".
    $sFolders = '<Folders>';
    $sFiles = '<Files>';
    $oCurrentFolder = opendir($sServerDir);
    while ($sFile = readdir($oCurrentFolder)) {
        if ($sFile != '.' && $sFile != '..') {
            if (is_dir($sServerDir . $sFile)) {
                $sFolders .= '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />';
            } else {
                $iFileSize = filesize($sServerDir . $sFile);
                if ($iFileSize > 0) {
                    $iFileSize = round($iFileSize / 1024);
                    if ($iFileSize < 1) {
                        $iFileSize = 1;
                    }
                }
                $sFiles .= '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" />';
            }
        }
    }
    echo $sFolders;
    // Close the "Folders" node.
    echo '</Folders>';
    echo $sFiles;
    // Close the "Files" node.
    echo '</Files>';
}
开发者ID:jankichaudhari,项目名称:yii-site,代码行数:31,代码来源:commands.php


示例15: dokusAnzeigen

function dokusAnzeigen($eintragid)
{
    $ordnerid = $eintragid;
    $directory = "attachments/{$eintragid}/dokus/";
    if (is_dir($directory) == true) {
        $handle = opendir($directory);
        while (false !== ($file = readdir($handle))) {
            $endung = substr($file, -3);
            $endung = strtolower($endung);
            if ($endung == "doc" || $endung == "txt" || $endung == "css" || $endung == "htm" || $endung == "tml" || $endung == "php" || $endung == "xls" || $endung == "zip" || $endung == "pdf") {
                $gezeigtesDok = "{$directory}{$file}";
                $dateityp = "dokus";
                echo "<a href='{$gezeigtesDok}' target='_blank'><br><nobr><img src='picts/miniicon_" . $endung . ".gif' border='0' > {$file}</nobr></a>&nbsp;";
                if (isset($_SESSION["username"])) {
                    echo "<a href='#' onClick='loeschpop(\"{$file}\",\"{$ordnerid}\",\"{$dateityp}\");'>&nbsp;<img src='picts/delete.gif' border='0' alt='loescht Dokument'></a>";
                }
            }
            //end if
        }
        //end while
        closedir($handle);
    } else {
        echo "";
    }
    //end if
}
开发者ID:haraldmueller,项目名称:lcmeilen.ch,代码行数:26,代码来源:inc.functions.php


示例16: transfer_templates

function transfer_templates($dir, $root_dir, $level = 0)
{
	if (!$dh = @opendir($dir))
		die("ERROR! Unable to open directory " . $dir . ".\n");
	while ($file = readdir($dh)) {
		if ($file == "." || $file == "..")
			continue;

		$full_path = $dir . "/" . $file;
		$filetype = filetype($full_path);
		if ($filetype == "dir") {
			transfer_templates($full_path, $root_dir, $level + 1);
			continue;
		}

		if ($filetype != "file") // ignore special files and links
			continue;
		$ending = substr($file, strlen($file) - 4);
		if ($ending != ".tpl") // ignore files that are not templates (end in .tpl)
			continue;

		$rel_path = substr($full_path, strlen($root_dir) + 1);
		$sql = "INSERT IGNORE INTO Templates (Name, Level) values('"
		     . $rel_path . "', " . $level . ")";
		if (!mysql_query($sql))
			die("Unable to insert template " . $rel_path . ".\n");
	}
}
开发者ID:nistormihai,项目名称:Newscoop,代码行数:28,代码来源:transfer_templates.php


示例17: getDirectory

function getDirectory($path = '.', $level = 0)
{
    $ignore = array('cgi-bin', '.', '..');
    // Directories to ignore when listing output. Many hosts
    // will deny PHP access to the cgi-bin.
    $dh = @opendir($path);
    // Open the directory to the handle $dh
    while (false !== ($file = readdir($dh))) {
        // Loop through the directory
        if (!in_array($file, $ignore)) {
            // Check that this file is not to be ignored
            str_repeat(' ', $level * 4);
            // Just to add spacing to the list, to better
            // show the directory tree.
            if (is_dir("{$path}/{$file}")) {
                // Its a directory, so we need to keep reading down...
                echo "{$path}/{$file};";
                getDirectory("{$path}/{$file}", $level + 1);
                // Re-call this same function but on a new directory.
                // this is what makes function recursive.
            } else {
                echo "{$path}/{$file};";
                // Just print out the filename
            }
        }
    }
    closedir($dh);
    // Close the directory handle
}
开发者ID:rogermelich,项目名称:consultesLdap,代码行数:29,代码来源:uploadPhotos.php


示例18: convert_dir_list

function convert_dir_list($topdir)
{
    global $config;
    if (!is_dir($topdir)) {
        return;
    }
    $imspector_config = $config['installedpackages']['imspector']['config'][0];
    $limit = preg_match("/\\d+/", $imspector_config['reportlimit']) ? $imspector_config['reportlimit'] : "50";
    $count = 0;
    if ($dh = opendir($topdir)) {
        while (($file = readdir($dh)) !== false) {
            if (!preg_match('/^\\./', $file) == 0) {
                continue;
            }
            if (is_dir("{$topdir}/{$file}")) {
                $list .= convert_dir_list("{$topdir}/{$file}");
            } else {
                $list .= "{$topdir}/{$file}\n";
            }
            $count++;
            if ($count >= $limit) {
                closedir($dh);
                return $list;
            }
        }
        closedir($dh);
    }
    return $list;
}
开发者ID:LFCavalcanti,项目名称:pfsense-packages,代码行数:29,代码来源:services_imspector_logs2.php


示例19: recursive_compile_all

/**
* Compiles all source templates below the source scheme directory
* including subdirectories
* 
* @param string $ root directory name
* @param string $ path relative to root
* @return void 
* @access protected 
*/
function recursive_compile_all($root, $path)
{
	if ($dh = opendir($root . $path))
	{
		while (($file = readdir($dh)) !== false)
		{
			if (substr($file, 0, 1) == '.')
			{
				continue;
			} 
			if (is_dir($root . $path . $file))
			{
				recursive_compile_all($root, $path . $file . '/');
				continue;
			} 
			if (substr($file, -5, 5) == '.html')
			{
				compile_template_file($path . $file);
			} 
			else if (substr($file, -5, 5) == '.vars')
			{
				compile_var_file($path . $file);
			} 
		} 
		closedir($dh);
	} 
} 
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:36,代码来源:compiler_support.inc.php


示例20: setPermissions

 /**
  * Chmods files and directories recursively to given permissions.
  *
  * @param   string  $path        Root path to begin changing mode [without trailing slash].
  * @param   string  $filemode    Octal representation of the value to change file mode to [null = no change].
  * @param   string  $foldermode  Octal representation of the value to change folder mode to [null = no change].
  *
  * @return  boolean  True if successful [one fail means the whole operation failed].
  *
  * @since   11.1
  */
 public static function setPermissions($path, $filemode = '0644', $foldermode = '0755')
 {
     // Initialise return value
     $ret = true;
     if (is_dir($path)) {
         $dh = opendir($path);
         while ($file = readdir($dh)) {
             if ($file != '.' && $file != '..') {
                 $fullpath = $path . '/' . $file;
                 if (is_dir($fullpath)) {
                     if (!JPath::setPermissions($fullpath, $filemode, $foldermode)) {
                         $ret = false;
                     }
                 } else {
                     if (isset($filemode)) {
                         if (!@chmod($fullpath, octdec($filemode))) {
                             $ret = false;
                         }
                     }
                 }
             }
         }
         closedir($dh);
         if (isset($foldermode)) {
             if (!@chmod($path, octdec($foldermode))) {
                 $ret = false;
             }
         }
     } else {
         if (isset($filemode)) {
             $ret = @chmod($path, octdec($filemode));
         }
     }
     return $ret;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:46,代码来源:path.php



注:本文中的opendir函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP openfile函数代码示例发布时间:2022-05-15
下一篇:
PHP opendb_logger函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap