本文整理汇总了PHP中recur_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP recur_dir函数的具体用法?PHP recur_dir怎么用?PHP recur_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了recur_dir函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recur_dir
function recur_dir($path, $alt_path)
{
print "===\n $path" . "\n\n";
$dhandle = opendir($path);
while($file = readdir($dhandle))
if(!($file === '.svn' || $file === '.' || $file === '..'))
{
// if the current file is not a directory
if(!is_dir($path . $file))
{
// find file name without extension and display
$split = preg_split("/\.[A-Za-z0-9]+$/", $file);
// encode
$of_name = $path . $file;
$nf_name = $alt_path . $split[0] . ".ogg";
$of_name = preg_replace("/\"/", "\\\"", $of_name);
$nf_name = preg_replace("/\:/", "", $nf_name);
$nf_name = preg_replace("/\"/", "", $nf_name);
if(!file_exists($nf_name))
{
// if already in ogg format, move
if(preg_match("/.+\.ogg/", $file))
{
print "Moving " . $split[0] . ".ogg\n";
shell_exec("cp \"$of_name\" \"$nf_name\" 2> /dev/null");
print ("cp \"$of_name\" \"$nf_name\" 2> /dev/null");
}
// else reencode
else
{
print "Encoding " . $split[0] . ".ogg\n";
shell_exec("ffmpeg -i \"$of_name\" -acodec vorbis -aq 50 \"$nf_name\" 2> /dev/null");
}
}
else
{
print "Skipping " . $split[0] . ".ogg\n";
}
}
// else recur into the directory
else
{
$current = $alt_path . $file . '/';
// create the directory if it does not exist
if(!file_exists($current))
mkdir($current);
recur_dir($path . $file . "/", $current);
}
}
}
示例2: recur_dir
function recur_dir($dir)
{
clearstatcache();
$htmldirlist = '';
$htmlfilelist = '';
$dirlist = opendir($dir);
while ($file = readdir($dirlist)) {
if ($file != '.' && $file != '..') {
$newpath = $dir . '/' . $file;
$level = explode('/', $newpath);
if (is_dir($newpath)) {
/*$mod_array[] = array(
'level'=>count($level)-1,
'path'=>$newpath,
'name'=>end($level),
'type'=>'dir',
'mod_time'=>filemtime($newpath),
'size'=>'');
$mod_array[] = recur_dir($newpath);
*/
$dirname = end($level);
$htmldirlist .= space(count($level)) . "<TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap><A onClick=\"Toggle(this, '" . $newpath . "');\"><IMG SRC=\"images/plus.gif\"> <IMG SRC=\"images/folder.gif\" border='0'> {$dirname} </a><DIV style='display:none'>\n";
//$htmldirlist .= space(count($level))." <TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap><A onClick=\"Toggle(this)\"><IMG SRC=\"images/plus.gif\"> <IMG SRC=\"images/gear.png\"> Tools </A><DIV style='display:none'>\n";
//$htmldirlist .= space(count($level))." <TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap align='bottom'><IMG SRC=\"images/file.png\"><a href='foldernew.php?folder=".urlencode($newpath)."' title=''>New Folder </a><DIV style='display:none'>\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."'
//$htmldirlist .= space(count($level))." </DIV></TD></TR></TABLE>\n";
//$htmldirlist .= space(count($level))." <TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap align='bottom'><IMG SRC=\"images/file.png\"><a href='filenew.php?folder=".urlencode($newpath)."' title=''>New File </a><DIV style='display:none'>\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."'
//$htmldirlist .= space(count($level))." </DIV></TD></TR></TABLE>\n";
//$htmldirlist .= space(count($level))." </DIV></TD></TR></TABLE>\n";
//$htmldirlist .= space(count($level))." <TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap align='bottom'><IMG SRC=\"images/gear.png\"><a href='fileoptions.php?folder=".urlencode($newpath)."' title=''>Options </a><DIV style='display:none'>\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."'
//$htmldirlist .= space(count($level))." </DIV></TD></TR></TABLE>\n";
$htmldirlist .= recur_dir($newpath);
$htmldirlist .= space(count($level)) . "</DIV></TD></TR></TABLE>\n";
} else {
/*$mod_array[] = array(
'level'=>count($level)-1,
'path'=>$newpath,
'name'=>end($level),
'type'=>'file',
'mod_time'=>filemtime($newpath),
'size'=>filesize($newpath));
*/
$filename = end($level);
$filesize = round(filesize($newpath) / 1024, 2);
$newpath = str_replace($filename, "", $newpath);
$htmlfilelist .= space(count($level)) . "<TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap align='bottom'><a href='javascript:void(0);' onclick=\"parent.document.getElementById('filename').value='" . $filename . "'; parent.document.getElementById('folder').value='" . $newpath . "';\" title='{$filesize} KB'><IMG SRC=\"images/file.png\" border='none'>{$filename}</a><DIV style='display:none'>\n";
$htmlfilelist .= space(count($level)) . "</DIV></TD></TR></TABLE>\n";
}
}
}
closedir($dirlist);
return $htmldirlist . "\n" . $htmlfilelist;
}
示例3: recur_dir
function recur_dir($dir)
{
clearstatcache();
$htmldirlist = '';
$htmlfilelist = '';
$dirlist = opendir($dir);
$dir_array = array();
if ($dirlist !== false) {
while (false !== ($file = readdir($dirlist))) {
if ($file != "." and $file != "..") {
$newpath = $dir . '/' . $file;
$level = explode('/', $newpath);
if (substr(strtolower($newpath), -4) == ".svn" || substr(strtolower($newpath), -4) == ".git" || substr(strtolower($newpath), -3) == ".db" || substr(strtolower($newpath), -4) == ".jpg" || substr(strtolower($newpath), -4) == ".gif" || substr(strtolower($newpath), -4) == ".png" || substr(strtolower($newpath), -4) == ".ico" || substr(strtolower($newpath), -4) == ".ttf") {
//ignore certain files (and folders)
} else {
$dir_array[] = $newpath;
}
if ($x > 1000) {
break;
}
$x++;
}
}
}
asort($dir_array);
foreach ($dir_array as $newpath) {
$level = explode('/', $newpath);
if (is_dir($newpath)) {
$dirname = end($level);
$htmldirlist .= "<div style='white-space: nowrap; padding-left: 16px;'>\n";
$htmldirlist .= "<a onclick='Toggle(this);' style='display: block; cursor: pointer;'><img src='resources/images/icon_folder.png' border='0' align='absmiddle' style='margin: 1px 2px 3px 0px;'>" . $dirname . "</a>";
$htmldirlist .= "<div style='display: none;'>" . recur_dir($newpath) . "</div>\n";
$htmldirlist .= "</div>\n";
} else {
$filename = end($level);
$filesize = round(filesize($newpath) / 1024, 2);
$newpath = str_replace('//', '/', $newpath);
$newpath = str_replace("\\", "/", $newpath);
$htmlfilelist .= "<div style='white-space: nowrap; padding-left: 16px;'>\n";
$htmlfilelist .= "<a href='javascript:void(0);' onclick=\"parent.document.getElementById('filepath').value='" . $newpath . "'; parent.document.getElementById('current_file').value = '" . $newpath . "'; makeRequest('fileread.php','file=" . urlencode($newpath) . "');\" title='" . $newpath . " " . $filesize . " KB'>";
$htmlfilelist .= "<img src='resources/images/icon_file.png' border='0' align='absmiddle' style='margin: 1px 2px 3px -1px;'>" . $filename . "</a>\n";
$htmlfilelist .= "</div>\n";
}
}
closedir($dirlist);
return $htmldirlist . "\n" . $htmlfilelist;
}
示例4: recur_dir
function recur_dir($dir)
{
clearstatcache();
$htmldirlist = '';
$htmlfilelist = '';
$dirlist = opendir($dir);
$dir_array = array();
while (false !== ($file = readdir($dirlist))) {
if ($file != "." and $file != "..") {
$newpath = $dir . '/' . $file;
$level = explode('/', $newpath);
if (substr($newpath, -4) == ".svn" || substr($newpath, -4) == ".git") {
//ignore .svn and .git dir and subdir
} elseif (substr($newpath, -3) == ".db") {
//ignore .db files
} else {
$dir_array[] = $newpath;
}
if ($x > 1000) {
break;
}
$x++;
}
}
asort($dir_array);
foreach ($dir_array as $newpath) {
$level = explode('/', $newpath);
if (is_dir($newpath)) {
$dirname = end($level);
$newpath = str_replace('//', '/', $newpath);
$htmldirlist .= "\n\t\t\t\t\t<table border=0 cellpadding='0' cellspacing='0'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td nowrap style='padding-left: 16px;'>\n\t\t\t\t\t\t\t\t<a onclick=\"Toggle(this, '" . $newpath . "');\" style='cursor: pointer;'><img src='resources/images/icon_folder.png' border='0' align='absmiddle' style='margin: 1px 2px 3px 0px;'>" . $dirname . "</a><div style='display:none'>" . recur_dir($newpath) . "</div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n";
} else {
$filename = end($level);
$filesize = round(filesize($newpath) / 1024, 2);
$newpath = str_replace('//', '/', $newpath);
$newpath = str_replace("\\", "/", $newpath);
$newpath = str_replace($filename, '', $newpath);
$htmlfilelist .= "\n\t\t\t\t\t<table border=0 cellpadding='0' cellspacing='0'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td nowrap align='bottom' style='padding-left: 16px;'>\n\t\t\t\t\t\t\t\t<a href='javascript:void(0);' onclick=\"parent.document.getElementById('filename').value='" . $filename . "'; parent.document.getElementById('folder').value='" . $newpath . "';\" title='" . $newpath . " " . $filesize . " KB'><img src='resources/images/icon_file.png' border='0' align='absmiddle' style='margin: 1px 2px 3px -1px;'>" . $filename . "</a>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n";
}
}
closedir($dirlist);
return $htmldirlist . "\n" . $htmlfilelist;
}
示例5: recur_dir
function recur_dir($dir, $clevel = 0)
{
$dirlist = opendir($dir);
$std = count(explode('/', $dir));
$i = 0;
$mod_array = array();
while ($file = readdir($dirlist)) {
$i++;
if ($file != '.' && $file != '..') {
$newpath = $dir . '/' . $file;
$level = explode('/', $newpath);
if (is_dir($newpath)) {
$mod_array[-100000 + $i] = array('path' => $newpath, 'name' => end($level), 'dir' => true, 'level' => $clevel, 'mod_time' => filemtime($newpath), 'content' => recur_dir($newpath, $clevel + 1));
} else {
$mod_array[$i] = array('path' => $newpath, 'name' => end($level), 'dir' => false, 'level' => $clevel, 'mod_time' => filemtime($newpath), 'size' => filesize($newpath));
}
}
}
closedir($dirlist);
ksort($mod_array);
return $mod_array;
}
示例6: foot
?>
</table>
<?php
echo foot();
} elseif ($job == 'templates_browse') {
echo head();
$id = $gpc->get('id', int);
$sub = rawurldecode($gpc->get('dir', none));
$path = 'templates/' . $id . iif(!empty($sub), "/{$sub}");
$result = $db->query('SELECT template FROM ' . $db->pre . 'designs WHERE id = "' . $config['templatedir'] . '" LIMIT 1');
$design = $db->fetch_assoc($result);
if ($id != $design['template']) {
$opath = 'templates/' . $design['template'] . iif(!empty($sub), "/{$sub}");
$dirs = recur_dir($opath);
} else {
$dirs = recur_dir($path);
}
?>
<table class="border" border="0" cellspacing="0" cellpadding="4" align="center">
<tr>
<td class="obox" colspan="2">Templates</td>
</tr>
<tr>
<td class="ubox" width="50%">File</td>
<td class="ubox" width="50%">Action</td>
</tr>
<?php
foreach ($dirs as $dir) {
if ($dir['dir']) {
if (isset($dir['content']) && is_array($dir['content']) && count($dir['content']) > 0) {
$empty = false;
示例7: recur_dir
function recur_dir($dir)
{
clearstatcache();
$htmldirlist = '';
$htmlfilelist = '';
$dirlist = opendir($dir);
$dir_array = array();
while (false !== ($file = readdir($dirlist))) {
if ($file != "." and $file != "..") {
$newpath = $dir . '/' . $file;
$level = explode('/', $newpath);
if (substr($newpath, -4) == ".svn") {
//ignore .svn dir and subdir
} elseif (substr($newpath, -3) == ".db") {
//ignore .db files
} else {
$dir_array[] = $newpath;
}
if ($x > 1000) {
break;
}
$x++;
}
}
asort($dir_array);
foreach ($dir_array as $newpath) {
$level = explode('/', $newpath);
if (is_dir($newpath)) {
/*$mod_array[] = array(
'level'=>count($level)-1,
'path'=>$newpath,
'name'=>end($level),
'type'=>'dir',
'mod_time'=>filemtime($newpath),
'size'=>'');
$mod_array[] = recur_dir($newpath);
*/
$dirname = end($level);
$htmldirlist .= space(count($level)) . "<TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap><a onClick=\"Toggle(this)\"><IMG SRC=\"images/plus.gif\"> <IMG SRC=\"images/folder.gif\" border='0'> {$dirname} </a><DIV style='display:none'>\n";
//$htmldirlist .= space(count($level))." <TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap><A onClick=\"Toggle(this)\"><IMG SRC=\"images/plus.gif\"> <IMG SRC=\"images/gear.png\"> Tools </A><DIV style='display:none'>\n";
//$htmldirlist .= space(count($level))." <TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap align='bottom'><IMG SRC=\"images/file.png\"><a href='foldernew.php?folder=".urlencode($newpath)."' title=''>New Folder </a><DIV style='display:none'>\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."'
//$htmldirlist .= space(count($level))." </DIV></TD></TR></TABLE>\n";
//$htmldirlist .= space(count($level))." <TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap align='bottom'><IMG SRC=\"images/file.png\"><a href='filenew.php?folder=".urlencode($newpath)."' title=''>New File </a><DIV style='display:none'>\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."'
//$htmldirlist .= space(count($level))." </DIV></TD></TR></TABLE>\n";
//$htmldirlist .= space(count($level))." </DIV></TD></TR></TABLE>\n";
//$htmldirlist .= space(count($level))." <TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap align='bottom'><IMG SRC=\"images/gear.png\"><a href='fileoptions.php?folder=".urlencode($newpath)."' title=''>Options </a><DIV style='display:none'>\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."'
//$htmldirlist .= space(count($level))." </DIV></TD></TR></TABLE>\n";
$htmldirlist .= recur_dir($newpath);
$htmldirlist .= space(count($level)) . "</DIV></TD></TR></TABLE>\n";
} else {
/*$mod_array[] = array(
'level'=>count($level)-1,
'path'=>$newpath,
'name'=>end($level),
'type'=>'file',
'mod_time'=>filemtime($newpath),
'size'=>filesize($newpath));
*/
$filename = end($level);
$filesize = round(filesize($newpath) / 1024, 2);
$htmlfilelist .= space(count($level)) . "<TABLE BORDER=0 cellpadding='0' cellspacing='0'><TR><TD nowrap WIDTH=12></TD><TD nowrap align='bottom'><a href='javascript:void(0);' onclick=\"parent.document.title='" . $newpath . "';parent.document.getElementById('file').value='" . urlencode($newpath) . "'; parent.window.frames['frame_'+'edit1'].editArea.previous= new Array(); parent.window.frames['frame_'+'edit1'].editArea.switchClassSticky(document.getElementById('undo'), 'editAreaButtonDisabled', true); makeRequest('fileread.php','file=" . urlencode($newpath) . "'); window.setTimeout('parent.my_setSelectionRange(\\'edit1\\')','100');\" title='{$filesize} KB'><IMG SRC=\"images/file.png\" border='none'> {$filename} </a><DIV style='display:none'>\n";
$htmlfilelist .= space(count($level)) . "</DIV></TD></TR></TABLE>\n";
}
}
//end foreache
closedir($dirlist);
return $htmldirlist . "\n" . $htmlfilelist;
}
示例8: recur_dir
function recur_dir($dir)
{
global $svn_array;
global $dir_count;
global $file_count;
global $svn_path;
global $row_count;
$htmldirlist = '';
$htmlfilelist = '';
$dirlist = opendir($dir);
while ($file = readdir($dirlist)) {
if ($file != '.' && $file != '..') {
$newpath = $dir . '/' . $file;
$level = explode('/', $newpath);
if (substr($newpath, -4) == ".svn") {
//ignore .svn dir and subdir
} elseif (substr($newpath, -3) == ".db") {
//ignore .db files
} elseif (end($level) == "config.php") {
//ignore config.php
} elseif (substr(end($level), 0, 12) == "php_service_") {
//ignore files that are prefixed with 'php_service_'
} else {
if (is_dir($newpath)) {
//directories
if (strlen($newpath) > 0) {
$relative_path = substr($newpath, strlen($svn_path), strlen($newpath));
//remove the svn_path
//echo $relative_path."<br />\n";
$svn_array[$row_count]['type'] = 'directory';
$svn_array[$row_count]['path'] = $relative_path;
$svn_array[$row_count]['last_mod'] = '';
$svn_array[$row_count]['md5'] = '';
$svn_array[$row_count]['size'] = '';
$row_count++;
$dir_count++;
}
$dirname = end($level);
recur_dir($newpath);
} else {
//files
if (strlen($newpath) > 0) {
$relative_path = substr($newpath, strlen($svn_path), strlen($newpath));
//remove the svn_path
//echo $relative_path."<br />\n";
$svn_array[$row_count]['type'] = 'file';
$svn_array[$row_count]['path'] = $relative_path;
$svn_array[$row_count]['last_mod'] = gmdate("D, d M Y H:i:s T", filemtime($newpath));
$svn_array[$row_count]['md5'] = md5_file($newpath);
$svn_array[$row_count]['size'] = filesize($newpath);
//round(filesize($newpath)/1024, 2);
//echo $newpath."<br />\n";
$row_count++;
$file_count++;
}
}
}
}
}
closedir($dirlist);
}
示例9: recur_dir
function recur_dir($path, $wpath, $dir)
{
global $gallery_id;
$db = new nggdb_extended();
$images = array();
$children = array();
$gal_created = 0;
// Read directory config file
$config = null;
if(file_exists($path . '/galleryconf'))
$config = config_parser($path . '/galleryconf');
// Sort files by filename
$files = array();
$dhandle = opendir($path);
while($file = readdir($dhandle))
array_push($files, $file);
natsort($files);
// Loop over files, generate thumbs and add to gallery
foreach($files as $file)
{
if(!($file === '.svn' || $file === '.' || $file === '..'))
{
// decend into directory
if(is_dir($path .'/'. $file) && $file != 'thumbs')
{
print "\nEntering: $file\n";
$child = recur_dir($path .'/'. $file, $wpath .'/'. $file, $file);
array_push($children, $child);
print "\nLeaving: $file\n";
}
// prosess images
else if(preg_match("/(.JPG|.PNG|.GIF)/i", $file))
{
if($gal_created == 0)
{
// Create gallery
$db->add_gallery_gid($gallery_id, $dir, "wp-content/$wpath", '', 0, $previewpic = 0);
if($config != null)
{
$body = $config['body'];
if(strtolower($config['head']['position']) == 'after')
$post = "[nggallery id=$gallery_id]\n<div style='clear: both;'></div>$body";
else
$post = "$body\n[nggallery id=$gallery_id]";
}
else
$post = "[nggallery id=$gallery_id]";
// Create gallary post
wp_insert_post(array(
'post_title' => $dir,
'post_name' => $slug,
'comment_status' => 'gallery_page',
'post_type' => 'page',
'post_content' => $post,
'post_status' => 'publish',
'post_author' => 1));
$gal_created = 1;
}
// create thumbs
if(!file_exists("$path/thumbs"))
mkdir("$path/thumbs");
exec("convert -resize 180x180 \"$path/$file\" \"{$path}/thumbs/thumbs_$file\"");
// insert into db
print "Added file: $file\n";
$id = $db->insert_image($gallery_id, $file, $file, "", 0);
array_push($images, $id);
}
}
}
$return = array(
'Name' => $dir,
'Path' => $path,
'ID' => $gallery_id,
'Img' => $images,
'Children' => $children);
if($gal_created == 1)
$gallery_id ++;
// Generate index gallary
if($config != null && strtolower($config['head']['mode']) == 'index')
{
print "\n\n-- making index --\n";
//.........这里部分代码省略.........