コード例 #1
0
ファイル: ai-bolit-wl.php プロジェクト: AlexeyManikin/aibolit
function scan_directory_recursively($directory, $filter = FALSE)
{
    global $extensions_list;
    echo "Scan: " . $directory . "\n";
    $handle = @opendir($directory);
    if ($handle === false) {
        return;
    }
    while (false !== ($file = readdir($handle))) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        $path = $directory . '/' . $file;
        $type = filetype($path);
        if ($type == 'dir') {
            scan_directory_recursively($path);
        }
        if ($type == 'file') {
            $extension = pathinfo($path, PATHINFO_EXTENSION);
            if (!in_array($extension, $extensions_list)) {
                continue;
            }
            if (filesize($path) > MAX_SIZE_TO_SCAN) {
                continue;
            }
            $hash = _hash_($path);
            $ok = insert_into_whitelist(pack("H*", $hash));
            if (LOG) {
                _log_(($ok ? "new" : "dup") . " {$hash}|{$path}");
            }
        }
    }
    closedir($handle);
}
コード例 #2
0
function scan_directory_recursively($directory, $filter = FALSE)
{
    // if the path has a slash at the end we remove it here
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    // if the path is not valid or is not a directory ...
    if (!file_exists($directory) || !is_dir($directory)) {
        // ... we return false and exit the function
        return FALSE;
        // ... else if the path is readable
    } elseif (is_readable($directory)) {
        // we open the directory
        $directory_tree = array();
        //ip108
        $directory_list = opendir($directory);
        // and scan through the items inside
        while (FALSE !== ($file = readdir($directory_list))) {
            // if the filepointer is not the current directory
            // or the parent directory
            if ($file != '.' && $file != '..') {
                // we build the new path to scan
                $path = $directory . '/' . $file;
                // if the path is readable
                if (is_readable($path)) {
                    // we split the new path by directories
                    $subdirectories = explode('/', $path);
                    // if the new path is a directory
                    if (is_dir($path)) {
                        // add the directory details to the file list
                        $directory_tree[] = array('path' => $path, 'name' => end($subdirectories), 'kind' => 'directory', 'content' => scan_directory_recursively($path, $filter));
                        // if the new path is a file
                    } elseif (is_file($path)) {
                        // get the file extension by taking everything after the last dot
                        $extension = end(explode('.', end($subdirectories)));
                        // if there is no filter set or the filter is set and matches
                        if ($filter === FALSE || $filter == $extension) {
                            // add the file details to the file list
                            $directory_tree[] = array('path' => $path, 'name' => end($subdirectories), 'extension' => $extension, 'size' => filesize($path), 'kind' => 'file');
                        }
                    }
                }
            }
        }
        // close the directory
        closedir($directory_list);
        // return file list
        return $directory_tree;
        // if the path is not readable ...
    } else {
        // ... we return false
        return FALSE;
    }
}
コード例 #3
0
ファイル: function.recurse.php プロジェクト: uptonic/Moopix
function scan_directory_recursively($directory, $filter = FALSE)
{
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory)) {
        return FALSE;
    } elseif (is_readable($directory)) {
        $directory_list = opendir($directory);
        while ($file = readdir($directory_list)) {
            if ($file != '.' && $file != '..' && $file != '.DS_Store' && $file != '.svn') {
                $path = $directory . '/' . $file;
                if (is_readable($path)) {
                    $subdirectories = explode('/', $path);
                    if (is_dir($path)) {
                        $directory_tree[] = array('path' => $path, 'name' => end($subdirectories), 'modified' => filemtime($path), 'kind' => 'directory', 'content' => scan_directory_recursively($path, $filter));
                    } elseif (is_file($path)) {
                        $extension = end(explode('.', end($subdirectories)));
                        if ($filter === FALSE || $filter == $extension) {
                            // Get metadata and image dimensions
                            $size = getimagesize($path, $info);
                            // Get containing directory of file
                            $directory_array = explode('/', $path);
                            $parent_folder = min($directory_array);
                            // Reset title, caption, tags
                            $title = $caption = $taglist = $tags = '';
                            $directory_tree[] = array('path' => dirname($path), 'group' => $parent_folder, 'file' => end($subdirectories), 'extension' => $extension, 'size' => filesize($path), 'width' => $size[0], 'height' => $size[1], 'modified' => filemtime($path), 'title' => $title, 'caption' => $caption, 'tags' => $tags, 'kind' => 'file');
                        }
                    }
                }
            }
        }
        closedir($directory_list);
        return $directory_tree;
    } else {
        return FALSE;
    }
}
コード例 #4
0
ファイル: index.php プロジェクト: shwing/waterforcambodia
     * remove Javascript temp files
     *
     * @author Technoguru Aka. Johnathan Pulos
     */
    $directoryResults = scan_directory_recursively($settings['global']['js_compress_directory']);
    foreach ($directoryResults as $jsFile) {
        if ($jsFile['extension'] == 'js') {
            unlink($jsFile['path']);
        }
    }
    /**
     * Remove all temp files
     *
     * @author Technoguru Aka. Johnathan Pulos
     */
    $directoryResults = scan_directory_recursively('tmp');
    foreach ($directoryResults as $tempFile) {
        if ($tempFile['extension'] == 'cache') {
            unlink($tempFile['path']);
        }
    }
    echo 'All cache has been cleared';
    exit;
}
/* 404 page */
$page_url = isset($_GET['url']) && !array_key_exists($page_url, $settings) ? '404' : $page_url;
/**
 * Set path for the page design and code files.
 * 
 * All file will exist based on the url.  For example,  if the page requested is /meetings/rooms.html then
 * -  the page code can be found in $pages_code_directory/meetings/rooms.php
コード例 #5
0
function scan_directory_recursively($directory, $filter = FALSE)
{
    global $global_list, $global_ignore_dir, $global_ignore_file;
    for ($i = 0; $i < count($global_ignore_dir); $i++) {
        if (stripos($directory, $global_ignore_dir[$i]) !== false) {
            return;
        }
    }
    // if the path has a slash at the end we remove it here
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    // if the path is not valid or is not a directory ...
    if (!file_exists($directory) || !is_dir($directory)) {
        // ... we return false and exit the function
        return FALSE;
        // ... else if the path is readable
    } elseif (is_readable($directory)) {
        // initialize directory tree variable
        $directory_tree = array();
        // we open the directory
        $directory_list = opendir($directory);
        // and scan through the items inside
        while (FALSE !== ($file = readdir($directory_list))) {
            $ignore_file = false;
            for ($i = 0; $i < count($global_ignore_file); $i++) {
                if (stripos($file, $global_ignore_file[$i]) !== false) {
                    $ignore_file = true;
                    break;
                }
            }
            if ($ignore_file) {
                continue;
            }
            // if the filepointer is not the current directory
            // or the parent directory
            if ($file != '.' && $file != '..') {
                // we build the new path to scan
                $path = $directory . '/' . $file;
                print $path . ' // mem=' . memory_get_usage() . "\n";
                // if the path is readable
                if (is_readable($path)) {
                    // we split the new path by directories
                    $subdirectories = explode('/', $path);
                    $inf = null;
                    $stat = stat($path);
                    // if the new path is a directory
                    if (is_dir($path)) {
                        // add the directory details to the file list
                        $inf = array('knd' => 0, 'c' => $stat[10], 'm' => $stat[9], 'ino' => $stat['ino'], 'uid' => $stat['uid'], 'gid' => $stat['gid'], 'perm' => fileperms($path), 'sub' => scan_directory_recursively($path, $filter));
                        //$directory_tree[] = $inf;
                        // if the new path is a file
                    } else {
                        // get the file extension by taking everything after the last dot
                        $path_info = pathinfo($path);
                        $extension = $path_info['extension'];
                        // if there is no filter set or the filter is set and matches
                        if ($filter === FALSE || $filter == $extension) {
                            // add the file details to the file list
                            $crc = 0;
                            if ($stat[7] < 5 * 1024 * 1024) {
                                $content = implode('', file($path));
                                $crc = realCRC($content);
                                unset($content);
                            }
                            $adv_crc = $crc + realCRC(basename($path));
                            $inf = array('crc' => $crc, 'acrc' => $adv_crc, 'ext' => $extension, 'sze' => $stat[7], 'c' => $stat[10], 'm' => $stat[9], 'ino' => $stat['ino'], 'uid' => $stat['uid'], 'gid' => $stat['gid'], 'perm' => fileperms($path), 'knd' => 1);
                            //$directory_tree[] = $inf;
                        }
                    }
                    if ($inf != null) {
                        $sum_crc = '';
                        foreach ($inf as $field) {
                            $sum_crc .= $field;
                        }
                        $inf['chk'] = realCRC($sum_crc);
                        if (isset($inf['sub'])) {
                            $inf['chd'] = count($inf['sub']);
                            unset($inf['sub']);
                        }
                        $global_list[$path] = $inf;
                        unset($inf);
                    }
                }
            }
        }
        // close the directory
        closedir($directory_list);
        // return file list
        return $directory_tree;
        // if the path is not readable ...
    } else {
        // ... we return false
        return FALSE;
    }
}
コード例 #6
0
ファイル: images.php プロジェクト: uptonic/Moopix
/*
#####################################################
Builds XML file for a gallery based on the filesystem

FileName:   images.php
Author:     Uptonic
Version:    2011.05.16
#####################################################
*/
// Include class file
require_once dirname(__FILE__) . '/scripts/protos.utils.php';
require_once dirname(__FILE__) . '/scripts/function.recurse.php';
require_once dirname(__FILE__) . '/scripts/config.php';
// Get file structure
$albums = scan_directory_recursively('albums');
// Let's build some XML
$doc = new DOMDocument("1.0", "UTF-8");
$doc->formatOutput = TRUE;
// Create root node for the gallery
$r = $doc->createElement("gallery");
$doc->appendChild($r);
// Cycle through albums
foreach ($albums as $album) {
    // Ignore albums that don't contain content
    if ($album['content'] != NULL) {
        // New album tag
        $a = $doc->createElement('album');
        $a->setAttribute('name', $album['name']);
        $a->setAttribute('modified', $album['modified']);
        // Expecting subfolders like "prototypes" and "wireframes"
コード例 #7
0
ファイル: updater.model.php プロジェクト: ntemple/com_updater
 function getManifests($path)
 {
     global $sd_files;
     $sd_files = array();
     scan_directory_recursively($path, 'xml', 2);
     foreach ($sd_files as $file) {
         $path = $file['file'];
         if (basename($path) == 'config.xml') {
             continue;
         }
         // Ignore config files
         try {
             $contents = file_get_contents($path);
             $xml = new SimpleXMLElement($contents);
             $name = strtolower($xml->getName());
             if ($name == 'install' || $name == 'mosinstall') {
                 $xml = simplexml2array($xml);
                 $jid = self::getJidFromXML($xml, "{$path}:{$name}");
                 $version = $xml['version'];
                 $this->versions[$jid] = $version;
             }
         } catch (Exception $e) {
             // can't read it, do nothing
         }
     }
 }
コード例 #8
0
 * @package         phpinfo
 * @author          Ruud Eisinga - www.dev4me.nl
 * @link			http://www.dev4me.nl/
 * @license         http://www.gnu.org/licenses/gpl.html
 * @platform        WebsiteBaker 2.8.x
 * @version         0.4.1
 * @lastmodified    August 23, 2016
 *
 */
// Must include code to stop this file being access directly
if (defined('WB_PATH') == false) {
    die("Cannot access this file directly");
}
clearstatcache();
$path = isset($_GET['path']) ? $admin->add_slashes($_GET['path']) : '/';
$r = scan_directory_recursively(WB_PATH . $path);
?>
<table cellpadding="3" border="0">
	<tbody>
	<tr class="h">
		<td><h1 class="p">WebsiteBaker - Permission checking</h1></td>
	</tr>
	</tbody>
</table>
<br/>

<table cellpadding="3" border="0">
	<tbody>
	<tr class="h">
		<td>Tree: 
<?php 
コード例 #9
0
/**
*	Purpose: Used to recurse through the images dir/sub-dir structure and build a 
*	list that can be used to hand back a JS array to TinyMCE's image list parameter
*
*	Note: Based on lixlpixel recursive PHP function (http://lixlpixel.org/recursive_function/php/recursive_directory_scan/)
**/
function scan_directory_recursively($directory, $filter = FALSE)
{
    $imagesArray = array();
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory)) {
        return FALSE;
    } else {
        if (is_readable($directory)) {
            $directory_list = opendir($directory);
            while ($file = readdir($directory_list)) {
                if ($file != '.' && $file != '..') {
                    $path = $directory . '/' . $file;
                    if (is_readable($path)) {
                        $subdirectories = explode('/', $path);
                        if (is_dir($path)) {
                            $directory_tree[] = array('path' => $path, 'name' => end($subdirectories), 'kind' => 'directory', 'content' => scan_directory_recursively($path, $filter));
                        } else {
                            if (is_file($path)) {
                                $imagesArray[] = $path;
                                $extension = end(explode('.', end($subdirectories)));
                                if ($filter === FALSE || $filter == $extension) {
                                    $directory_tree[] = array('path' => $path, 'name' => end($subdirectories), 'extension' => $extension, 'size' => filesize($path), 'kind' => 'file');
                                }
                            }
                        }
                    }
                }
            }
            closedir($directory_list);
        } else {
            return FALSE;
        }
    }
    return $imagesArray;
}