コード例 #1
1
 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);
 }
コード例 #2
0
ファイル: filesys.inc.php プロジェクト: naffis/rejectmail-php
function deleteDir($dir) {
	$dir = (substr($dir,0,-1)!='/')?$dir.'/':$dir;

	if (OS == 'unix') {

	} else {
		if (file_exists($dir)) {
			if ($handle = @opendir($dir)) {
				while (false !== ($file = readdir($handle))) {
					if ($file != '.' && $file != '..') {
						if (is_dir($dir.$file)) {
							deleteDir($dir.$file.'/');
							@rmdir($dir.$file);
						}
						if (is_file($dir.$file)) {
							deleteFile($dir.$file);
						}
					}
				}
				closedir($handle);
			}
			rmdir($dir);
		}
	}
}
コード例 #3
0
ファイル: helpers.php プロジェクト: GabeGibitz/DIY
function getElementsData() {
	$elements_dirname = ADMIN_BASE_PATH.'/components/elements';
	if ($elements_dir = opendir($elements_dirname)) {
		$tmpArray = array();
		while (false !== ($dir = readdir($elements_dir))) {
			if (substr($dir,0,1) != "." && is_dir($elements_dirname . '/' . $dir)) {
				$tmpKey = strtolower($dir);
				if (@file_exists($elements_dirname . '/' . $dir . '/metadata.json')) {
					$tmpValue = json_decode(@file_get_contents($elements_dirname . '/' . $dir . '/metadata.json'));
					if ($tmpValue) {
						$tmpArray["$tmpKey"] = $tmpValue;
					}
				}
			}
		}
		closedir($elements_dir);
		if (count($tmpArray)) {
			return $tmpArray;
		} else {
			return false;
		}
	} else {
		echo 'not dir';
		return false;
	}
}
コード例 #4
0
ファイル: install.php プロジェクト: pavpanchekha/tullok
function chmod_R($path, $filemode)
{
    if (!is_dir($path)) {
        return chmod($path, $filemode);
    }
    $dh = opendir($path);
    while ($file = readdir($dh)) {
        if ($file != '.' && $file != '..') {
            $fullpath = $path . '/' . $file;
            if (!is_dir($fullpath)) {
                if (!chmod($fullpath, $filemode)) {
                    return FALSE;
                }
            } else {
                if (!chmod_R($fullpath, $filemode)) {
                    return FALSE;
                }
            }
        }
    }
    closedir($dh);
    if (chmod($path, $filemode)) {
        return true;
    } else {
        return false;
    }
}
コード例 #5
0
 /**
  * Returns all certificates trusted by the user
  *
  * @return \OCP\ICertificate[]
  */
 public function listCertificates()
 {
     if (!$this->config->getSystemValue('installed', false)) {
         return array();
     }
     $path = $this->getPathToCertificates() . 'uploads/';
     if (!$this->view->is_dir($path)) {
         return array();
     }
     $result = array();
     $handle = $this->view->opendir($path);
     if (!is_resource($handle)) {
         return array();
     }
     while (false !== ($file = readdir($handle))) {
         if ($file != '.' && $file != '..') {
             try {
                 $result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
             } catch (\Exception $e) {
             }
         }
     }
     closedir($handle);
     return $result;
 }
コード例 #6
0
/**
 * Gets all available MIME-types
 *
 * @return  array    array[mimetype], array[transformation]
 *
 * @access  public
 *
 * @author  Garvin Hicking <*****@*****.**>
 */
function PMA_getAvailableMIMEtypes()
{
    $handle = opendir('./libraries/transformations');
    $stack = array();
    $filestack = array();
    while (($file = readdir($handle)) != false) {
        $filestack[$file] = $file;
    }
    closedir($handle);
    if (is_array($filestack)) {
        @ksort($filestack);
        foreach ($filestack as $key => $file) {
            if (preg_match('|^.*__.*\\.inc\\.php$|', trim($file))) {
                // File contains transformation functions.
                $base = explode('__', str_replace('.inc.php', '', $file));
                $mimetype = str_replace('_', '/', $base[0]);
                $stack['mimetype'][$mimetype] = $mimetype;
                $stack['transformation'][] = $mimetype . ': ' . $base[1];
                $stack['transformation_file'][] = $file;
            } elseif (preg_match('|^.*\\.inc\\.php$|', trim($file))) {
                // File is a plain mimetype, no functions.
                $base = str_replace('.inc.php', '', $file);
                if ($base != 'global') {
                    $mimetype = str_replace('_', '/', $base);
                    $stack['mimetype'][$mimetype] = $mimetype;
                    $stack['empty_mimetype'][$mimetype] = $mimetype;
                }
            }
        }
    }
    return $stack;
}
コード例 #7
0
/**
* 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);
	} 
} 
コード例 #8
0
 /**
  * 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;
         }
     }
 }
コード例 #9
0
ファイル: search.php プロジェクト: Harvie/dokuwiki
/**
 * recurse direcory
 *
 * This function recurses into a given base directory
 * and calls the supplied function for each file and directory
 *
 * @param   array ref $data The results of the search are stored here
 * @param   string    $base Where to start the search
 * @param   callback  $func Callback (function name or arayy with object,method)
 * @param   string    $dir  Current directory beyond $base
 * @param   int       $lvl  Recursion Level
 * @author  Andreas Gohr <*****@*****.**>
 */
function search(&$data, $base, $func, $opts, $dir = '', $lvl = 1)
{
    $dirs = array();
    $files = array();
    //read in directories and files
    $dh = @opendir($base . '/' . $dir);
    if (!$dh) {
        return;
    }
    while (($file = readdir($dh)) !== false) {
        if (preg_match('/^[\\._]/', $file)) {
            continue;
        }
        //skip hidden files and upper dirs
        if (is_dir($base . '/' . $dir . '/' . $file)) {
            $dirs[] = $dir . '/' . $file;
            continue;
        }
        $files[] = $dir . '/' . $file;
    }
    closedir($dh);
    sort($files);
    sort($dirs);
    //give directories to userfunction then recurse
    foreach ($dirs as $dir) {
        if (call_user_func_array($func, array(&$data, $base, $dir, 'd', $lvl, $opts))) {
            search($data, $base, $func, $opts, $dir, $lvl + 1);
        }
    }
    //now handle the files
    foreach ($files as $file) {
        call_user_func_array($func, array(&$data, $base, $file, 'f', $lvl, $opts));
    }
}
コード例 #10
0
function listDir($dir){
   if(is_dir($dir)){
     if ($dh = opendir($dir)) {
        while (($file= readdir($dh)) !== false){
		
       if((is_dir($dir."/".$file)) && $file!="." && $file!="..")
       {
	    if(is_writable($dir."/".$file)&&is_readable($dir."/".$file))
		{
		echo "<b><font color='red'>文件名:</font></b>".$dir.$file."<font color='red'> 可写</font><font color='Blue'> 可读</font>"."<br><hr>";
		}else{
		if(is_writable($dir."/".$file))
		{
              echo "<b><font color='red'>文件名:</font></b>".$dir.$file."<font color='red'> 可写</font>"."<br><hr>";
		}else
		{
	      echo "<b><font color='red'>文件名:</font></b>".$dir.$file."<font color='red'> 可读</font><font color='Blue'> 不可写</font>"."<br><hr>";
		}
		}
		
		listDir($dir."/".$file."/");
       }
     
       }
        }
closedir($dh);

     }
 
   }
コード例 #11
0
ファイル: Archive.php プロジェクト: Toushi/flow
 /**
  * Adds files or directories, recursively, to an archive.
  *
  * @param   string   file or directory to add
  * @param   string   name to use for the given file or directory
  * @param   bool     add files recursively, used with directories
  * @return  object
  */
 public function add($path, $name = NULL, $recursive = NULL)
 {
     // Normalize to forward slashes
     $path = str_replace('\\', '/', $path);
     // Set the name
     empty($name) and $name = $path;
     if (is_dir($path)) {
         // Force directories to end with a slash
         $path = rtrim($path, '/') . '/';
         $name = rtrim($name, '/') . '/';
         // Add the directory to the paths
         $this->paths[] = array($path, $name);
         if ($recursive === TRUE) {
             $dir = opendir($path);
             while (($file = readdir($dir)) !== FALSE) {
                 // Do not add hidden files or directories
                 if (substr($file, 0, 1) === '.') {
                     continue;
                 }
                 // Add directory contents
                 $this->add($path . $file, $name . $file, TRUE);
             }
             closedir($dir);
         }
     } else {
         $this->paths[] = array($path, $name);
     }
     return $this;
 }
コード例 #12
0
function getDirContent($sub) 
{
	global $allowed_types;
	global $a_img;
	global $a_path;
	global $imgdir, $smarty;
	$allimg = array();
	$tmp = $imgdir;
	if ($sub <> "") $tmp.= '/' . $sub;
	if (!@($dimg = opendir($tmp))) {
		$msg = tra("Invalid directory name");
		$smarty->assign('msg', $msg);
		$smarty->display("error.tpl");
		die;
	}
	while ((false !== ($imgf = readdir($dimg)))) {
		if ($imgf != "." && $imgf != ".." && substr($imgf, 0, 1) != ".") {
			$allimg[] = $imgf;
		}
	}
	sort($allimg);
	foreach ($allimg as $imgfile) {
		if (is_dir($tmp . "/" . $imgfile)) {
			if ((substr($sub, -1) <> "/") && (substr($sub, -1) <> "\\")) {
				$sub.= '/';
			}
			getDirContent($sub . $imgfile);
		} elseif (in_array(strtolower(substr($imgfile, -(strlen($imgfile) - strrpos($imgfile, ".")))), $allowed_types)) {
			$a_img[] = $imgfile;
			$a_path[] = $sub;
		}
	}
	closedir($dimg);
}
コード例 #13
0
ファイル: Functions.php プロジェクト: vojtajina/sitellite
function chmod_recursive($path, $mode)
{
    umask(00);
    if (!is_dir($path)) {
        return chmod($path, $mode);
    }
    $dh = opendir($path);
    while ($file = readdir($dh)) {
        if ($file != '.' && $file != '..') {
            $fullpath = $path . '/' . $file;
            if (!is_dir($fullpath)) {
                if (!chmod($fullpath, $mode)) {
                    return false;
                } else {
                    if (!chmod_recursive($fullpath, $mode)) {
                        return false;
                    }
                }
            }
        }
    }
    closedir($dh);
    if (chmod($path, $mode)) {
        return true;
    }
    return false;
}
コード例 #14
0
ファイル: der-to-pem.php プロジェクト: bizonix/phpMyCA
/**
 * Return array of filenames to convert
 * @param string $dirName
 * @return mixed
 */
function getFileList($dirName = null)
{
    if (!is_string($dirName)) {
        return false;
    }
    if (!is_dir($dirName)) {
        return false;
    }
    if (!is_readable($dirName)) {
        return false;
    }
    clearstatcache();
    $ret_ar = array();
    if (!($dh = opendir($dirName))) {
        return false;
    }
    while (false !== ($file = readdir($dh))) {
        if ($file == '..' or $file == '.') {
            continue;
        }
        $cur_file = $dirName . '/' . $file;
        if (is_dir($cur_file)) {
            $tmp_ar = getFileList($cur_file);
            if (is_array($tmp_ar)) {
                $ret_ar = array_merge($ret_ar, $tmp_ar);
            }
        }
        $ret_ar[] = $cur_file;
    }
    closedir($dh);
    natcasesort($ret_ar);
    return $ret_ar;
}
コード例 #15
0
 function clear_tmpfiles($cachetime = 1800)
 {
     global $GB_TMP;
     $delfiles = 0;
     $filelist = '';
     if (is_dir("{$this->include_path}/{$GB_TMP}")) {
         chdir("{$this->include_path}/{$GB_TMP}");
         $hnd = opendir(".");
         while ($file = readdir($hnd)) {
             if (is_file($file)) {
                 $filelist[] = $file;
             }
         }
         closedir($hnd);
     }
     if (is_array($filelist)) {
         while (list($key, $file) = each($filelist)) {
             $tmpfile = explode(".", $file);
             $tmpfile[0] = ereg_replace("img-", "", $tmpfile[0]);
             if ($tmpfile[0] < time() - $cachetime) {
                 if (unlink($file)) {
                     $delfiles++;
                 }
             }
         }
     }
     return $delfiles;
 }
コード例 #16
0
ファイル: search.php プロジェクト: yczhangsjtu/html
function exploreDir($dirname, $keyword)
{
    $allowedExt = ".php.pdf.chm";
    $dh = opendir($dirname);
    while ($file = readdir($dh)) {
        if (is_dir("{$dirname}/{$file}")) {
            if ($file != '.' and $file != '..') {
                exploreDir("{$dirname}/{$file}", $keyword);
            }
        } else {
            if ($file == 'index.php') {
                $file = basename($dirname);
                if (ereg($keyword, $file)) {
                    echo '<a href="', $dirname, '">', $file, '</a><br>';
                }
            } else {
                if (ereg($keyword, $file)) {
                    $ext = pathinfo($file, PATHINFO_EXTENSION);
                    $ext = ".{$ext}";
                    if (ereg($ext, $allowedExt)) {
                        echo '<a href="', $dirname, '/', $file, '">', basename($file, $ext), '</a><br>';
                    }
                }
            }
        }
    }
    closedir($dh);
}
コード例 #17
0
ファイル: delpath.php プロジェクト: ailingsen/pigcms
 function wm_chief_delpath($del_path)
 {
     if (!file_exists($del_path)) {
         echo "Directory not found.";
         return false;
     }
     $hand = @opendir($del_path);
     $i = 0;
     while ($file = @readdir($hand)) {
         $i++;
         if ($file != "." && $file != "..") {
             //目录
             if (is_dir($del_path . "/" . $file)) {
                 $del_s_path = $del_path . "/" . $file;
                 $this->wm_chief_delpath($del_s_path);
             } else {
                 $del_file = $del_path . "/" . $file;
                 $this->wm_chief_file($del_file);
             }
         }
     }
     @closedir($hand);
     $this->wm_chief_path($del_path);
     return true;
 }
コード例 #18
0
/**
 * Get an array that represents directory tree
 * 
 * from http://php.net/manual/en/function.scandir.php
 * @param string $directory     Directory path
 * @param bool $recursive         Include sub directories
 * @param bool $listDirs         Include directories on listing
 * @param bool $listFiles         Include files on listing
 * @param regex $exclude         Exclude paths that matches this regex
 */
function directoryToArray($directory, $recursive = true, $listDirs = false, $listFiles = true, $exclude = '')
{
    $arrayItems = array();
    $skipByExclude = false;
    $handle = opendir($directory);
    if ($handle) {
        while (false !== ($file = readdir($handle))) {
            preg_match("/(^(([\\.]){1,2})\$|(\\.(svn|git|md))|(Thumbs\\.db|\\.DS_STORE))\$/iu", $file, $skip);
            if ($exclude) {
                preg_match($exclude, $file, $skipByExclude);
            }
            if (!$skip && !$skipByExclude) {
                if (is_dir($directory . DIRECTORY_SEPARATOR . $file)) {
                    if ($recursive) {
                        $arrayItems = array_merge($arrayItems, directoryToArray($directory . DIRECTORY_SEPARATOR . $file, $recursive, $listDirs, $listFiles, $exclude));
                    }
                    if ($listDirs) {
                        $file = $directory . DIRECTORY_SEPARATOR . $file;
                        $arrayItems[] = $file;
                    }
                } else {
                    if ($listFiles) {
                        $file = $directory . DIRECTORY_SEPARATOR . $file;
                        $arrayItems[] = $file;
                    }
                }
            }
        }
        closedir($handle);
    }
    return $arrayItems;
}
コード例 #19
0
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
}
コード例 #20
0
ファイル: administration.php プロジェクト: phprocks/cadastro
function getDirectorySize($path)
{
    $totalsize = 0;
    $totalcount = 0;
    $dircount = 0;
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            $nextpath = $path . '/' . $file;
            if ($file != '.' && $file != '..' && !is_link($nextpath)) {
                if (is_dir($nextpath)) {
                    $dircount++;
                    $result = getDirectorySize($nextpath);
                    $totalsize += $result['size'];
                    $totalcount += $result['count'];
                    $dircount += $result['dircount'];
                } elseif (is_file($nextpath)) {
                    $totalsize += filesize($nextpath);
                    $totalcount++;
                }
            }
        }
    }
    closedir($handle);
    $total['size'] = $totalsize;
    $total['count'] = $totalcount;
    $total['dircount'] = $dircount;
    return $total;
}
コード例 #21
0
ファイル: TemplateController.php プロジェクト: Toney/xmcms
 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);
 }
コード例 #22
0
ファイル: picture_process.php プロジェクト: nong053/condo
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;
    }
}
コード例 #23
0
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;
}
コード例 #24
0
ファイル: import.php プロジェクト: Beutiste/wordpress
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;
}
コード例 #25
0
ファイル: path.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * 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;
 }
コード例 #26
0
ファイル: Y.php プロジェクト: ASDAFF/RosYama.2
 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);
     }
 }
コード例 #27
0
/**
 * 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  <*****@*****.**>
 * @author Manuel Bernhardt <*****@*****.**>
 */
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;
}
コード例 #28
0
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
    }
}
コード例 #29
0
ファイル: copyDir.php プロジェクト: skyler2tao/languageStudy
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-7-11
 * Time: 上午10:40
 */
function copyDir($dirSrc, $dirTo)
{
    if (is_file($dirTo)) {
        //如果目标不是一个目录则退出
        echo "目标不是目录不能创建!!";
        return;
    }
    if (!file_exists($dirTo)) {
        //如果目标不存在,则创建目录
        mkdir($dirTo);
    }
    if ($dir_handle = @opendir($dirSrc)) {
        //打开目录并判断是否成功
        while ($filename = readdir($dir_handle)) {
            //循环遍历目录
            if ($filename != "." && $filename != "..") {
                //排除两个特殊目录
                $subSrcFile = $dirSrc . "/" . $filename;
                $subToFile = $dirTo . "/" . $filename;
                if (is_dir($subSrcFile)) {
                    //如果是子目录,则递归
                    copyDir($subSrcFile, $subToFile);
                }
                if (is_file($subSrcFile)) {
                    //如果是文件,则使用copy直接拷贝
                    copy($subSrcFile, $subToFile);
                }
            }
        }
        closedir($dir_handle);
        //最后记得一定要关闭目录句柄
    }
}
コード例 #30
-15
ファイル: log.php プロジェクト: tang86/discuz-utf8
 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');
 }