public function load_file()
 {
     $tmpl = $_REQUEST['tmpl'];
     $directory = APP_ROOT_PATH . "app/Tpl/" . $tmpl . "/";
     $files = get_all_files($directory);
     $tmpl_files = array();
     foreach ($files as $item) {
         if (substr($item, -5) == ".html") {
             $item = explode($directory, $item);
             $item = $item[1];
             $tmpl_files[] = $item;
         }
     }
     $this->ajaxReturn($tmpl_files);
 }
示例#2
0
function get_all_files($dir, $subpath = '')
{
    global $includefiles;
    global $sourcepath;
    global $destpath;
    $d = dir($dir);
    while (false !== ($entry = $d->read())) {
        if (!($entry == '.') & !($entry == '..')) {
            if (is_dir($dir . '/' . $entry)) {
                get_all_files($dir . '/' . $entry, $subpath . $entry . '/');
            } else {
                $includefiles[] = array($sourcepath . $subpath . $entry, $destpath . $subpath . $entry);
            }
        }
    }
}
示例#3
0
function get_all_files($root, $dir, $max_depth = 3)
{
    $result = array();
    if ($handle = opendir($root . "/" . $dir)) {
        while (false !== ($entry = readdir($handle))) {
            if ($entry != "." && $entry != "..") {
                if (is_dir($root . "/" . $dir . "/" . $entry)) {
                    if ($max_depth > 1) {
                        $result = array_merge($result, get_all_files($root, $dir . "/" . $entry, $max_depth - 1));
                    }
                } else {
                    $result[] = $dir . "/" . $entry;
                }
            }
        }
        closedir($handle);
    }
    return $result;
}
function get_all_files($dir_path)
{
    static $all_file_path = array();
    if (!empty($dir_path)) {
        $tmp_dirs = scandir($dir_path);
        //print_r($tmp_dirs);
        foreach ($tmp_dirs as $tmp_dir) {
            if ($tmp_dir != '.' && $tmp_dir != '..') {
                $tmp_file_path = $dir_path . "/" . $tmp_dir;
                //echo $tmp_file_path."<br>";
                if (is_dir($tmp_file_path)) {
                    get_all_files($tmp_file_path);
                } else {
                    $all_file_path[] = $tmp_file_path;
                }
            }
        }
        return $all_file_path;
    }
}
示例#5
0
文件: common.php 项目: BruceJi/fanwe
function get_all_files($path)
{
    $list = array();
    $dir = @opendir($path);
    while (false !== ($file = @readdir($dir))) {
        if ($file != '.' && $file != '..') {
            if (is_dir($path . $file . "/")) {
                $list = array_merge($list, get_all_files($path . $file . "/"));
            } else {
                $list[] = $path . $file;
            }
        }
    }
    @closedir($dir);
    return $list;
}
 function decompress($type, $archive, $path)
 {
     $path = realpath($path) . DIRECTORY_SEPARATOR;
     $status = false;
     if (is_dir($path)) {
         chdir($path);
         if ($type == 'unzip') {
             if (class_exists('ZipArchive')) {
                 $zip = new ZipArchive();
                 $target = $path . basename($archive, ".zip");
                 if ($zip->open($archive)) {
                     if (!is_dir($target)) {
                         mkdir($target);
                     }
                     if ($zip->extractTo($target)) {
                         $status = true;
                     }
                     $zip->close();
                 }
             }
         } elseif ($type == 'untar') {
             $target = basename($archive, ".tar");
             if (!is_dir($target)) {
                 mkdir($target);
             }
             $before = count(get_all_files($target));
             execute("tar xf \"" . basename($archive) . "\" -C \"" . $target . "\"");
             $after = count(get_all_files($target));
             if ($before != $after) {
                 $status = true;
             }
         } elseif ($type == 'untargz') {
             $target = "";
             if (strpos(strtolower($archive), ".tar.gz") !== false) {
                 $target = basename($archive, ".tar.gz");
             } elseif (strpos(strtolower($archive), ".tgz") !== false) {
                 $target = basename($archive, ".tgz");
             }
             if (!is_dir($target)) {
                 mkdir($target);
             }
             $before = count(get_all_files($target));
             execute("tar xzf \"" . basename($archive) . "\" -C \"" . $target . "\"");
             $after = count(get_all_files($target));
             if ($before != $after) {
                 $status = true;
             }
         }
     }
     return $status;
 }
*/
include "test/framework/lib/header.php";
function eh($errno, $errstr)
{
    if ($errno == E_NOTICE) {
        return;
    }
    print "{$errno}, {$errstr}";
}
set_error_handler("eh", E_ALL);
$directory_name = "downloaded_php/downloads/";
$dirs = get_directories($directory_name);
foreach ($dirs as $dir) {
    $defines = "";
    $i = 0;
    $files = get_all_files($dir);
    foreach ($files as $file) {
        if ($file != NULL) {
            $defines = $defines . get_defines($file);
            echo "Analysing {$file}\n";
        }
    }
    foreach ($files as $file) {
        echo "Applying changes to {$file}\n";
        apply_changes($file, $defines);
    }
}
function get_directories($dirname)
{
    $result = array();
    foreach (new DirectoryIterator($dirname) as $fileInfo) {
示例#8
0
function decompress($type, $archive, $path)
{
    $path = realpath($path) . DIRECTORY_SEPARATOR;
    if (is_dir($path)) {
        chdir($path);
        if ($type == 'unzip') {
            if (class_exists('ZipArchive')) {
                $zip = new ZipArchive();
                $target = $path . basename($archive, '.zip');
                if ($zip->open($archive)) {
                    if (!is_dir($target)) {
                        mkdir($target);
                    }
                    if ($zip->extractTo($target)) {
                        return true;
                    }
                    $zip->close();
                }
            } else {
            }
        } elseif ($type == 'untar') {
            $target = basename($archive, '.tar');
            if (!is_dir($target)) {
                mkdir($target);
            }
            $before = count(get_all_files($target));
            execute('tar xf "' . basename($archive) . '" -C "' . $target . '"');
            $after = count(get_all_files($target));
            if ($before != $after) {
                return true;
            }
        } elseif ($type == 'untargz') {
            $target = '';
            if (strpos(strtolower($archive), '.tar.gz') !== false) {
                $target = basename($archive, '.tar.gz');
            } elseif (strpos(strtolower($archive), '.tgz') !== false) {
                $target = basename($archive, '.tgz');
            }
            if (!is_dir($target)) {
                mkdir($target);
            }
            $before = count(get_all_files($target));
            execute('tar xzf "' . basename($archive) . '" -C "' . $target . '"');
            $after = count(get_all_files($target));
            if ($before != $after) {
                return true;
            }
        }
    }
    return false;
}
function compile_wb($source_dir, $php_vers, $vers_plus)
{
    // set variables for makefile
    $obj_tmp_dir = PATH_BASE . 'obj';
    $dll_dir = PATH_BASE . "WinbinderComp\\binaries\\php-{$php_vers}xt";
    $inc_dir = PATH_INC;
    $ms_lib = PATH_LIB;
    $lib_dir = PATH_BASE . "WinbinderComp\\csource\\php-{$php_vers}";
    $phplib = $lib_dir . "\\php-" . $php_vers . "ts.lib";
    $cl = PATH_BIN . "cl.exe";
    $rc = PATH_BIN . "rc";
    $link = PATH_BIN . "link";
    $nmake = PATH_BIN . "nmake";
    $cl = "cl";
    $rc = "rc";
    $link = "link";
    $nmake = PATH_BIN . "nmake";
    // ------------------------------------------------------------------- Compile environment
    $P_path = getenv('PATH');
    if (strstr($P_path, PATH_BIN) === false) {
        $P_path = PATH_BIN . ";" . $P_path;
    }
    $P_path = putenv("PATH={$P_path}");
    $P_path = putenv("INCLUDE={$inc_dir}");
    $P_path = putenv("LIB={$ms_lib}");
    // ------------------------------------------------------------------- Makefile template
    $m_comp = <<<MCOMP


all: \$(DLLDIR)\\php_winbinder.dll

\$(OBJS): \$(SOURCES)
\t\$(cc) /nologo /MT /W3 /GX /O2 /YX /FD /c /QIfist \\
\t/D "NDEBUG" /D ZEND_DEBUG=0 /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D HAVE_WIN32STD=1 \\
\t/I "\$(LIBDIR)" /I "\$(INCDIR)\\" /I "\$(LIBDIR)\\main" /I "\$(LIBDIR)\\Zend" /I "\$(LIBDIR)\\win32" /I "\$(LIBDIR)\\TSRM" /I "\$(LIBDIR)xt\\standard" \\
\t/Fo"\$(OUTDIR)\\\\" /Fd"\$(OUTDIR)\\\\" \$(SOURCES)

\$(OUTDIR)\\php_winbinder.dll.res: \$(RCFILE)

\$(DLLDIR)\\php_winbinder.dll: \$(OBJS)
\t\$(rc) /r /fo \$(OUTDIR)\\php_winbinder.dll.res /i "\$(SRCDIR)\\" /d \$(FD) /d FILE_NAME="\\"php_winbinder.dll\\"" /d \$(PN) /d \$(PV) \$(RCFILE)

\t\$(link) /nologo /dll /machine:I386 -out:\$(DLLDIR)\\php_winbinder.dll \\
\t\$(OBJS) \$(LIBS) \$(OUTDIR)\\php_winbinder.dll.res

#clean temporary files:
\tdel /q \$(OUTDIR)\\ *.pch \$(DLLDIR)\\php_winbinder.exp \$(DLLDIR)\\php_winbinder.lib
MCOMP;
    if (!is_dir($obj_tmp_dir)) {
        if (!mkdir($obj_tmp_dir)) {
            // Stefano: now returns message to enable warning handling, instead of calling echo
            return 'Warning: could not create ' . $obj_tmp_dir;
        }
    } else {
        delete_files($obj_tmp_dir . '\\');
    }
    $libs = array("user32.lib", "gdi32.lib", "comdlg32.lib", "comctl32.lib", "shell32.lib", "ole32.lib ", "oleaut32.lib", "winmm.lib", "advapi32.lib", $phplib);
    $c_files = array();
    $h_files = array();
    $rc_files = array();
    $sub_dirs = array('.');
    while (($s_dir = array_shift($sub_dirs)) != null) {
        $content = get_all_files($source_dir, $s_dir);
        $sub_dirs = array_merge($sub_dirs, $content['dir']);
        $c_files = array_merge($c_files, $content['c']);
        $h_files = array_merge($h_files, $content['h']);
        $rc_files = array_merge($rc_files, $content['rc']);
    }
    // while
    if (count($c_files) == 0) {
        // Stefano: now returns message to enable error handling, instead of calling die
        return 'Fatal error: source to compile not found';
    }
    // assemble SOURCES OBJS
    $sources_str = "SOURCES = ";
    $objs_str = "OBJS = ";
    foreach ($c_files as $c_f) {
        $sources_str .= "\t\\\n\t" . $source_dir . $c_f;
        $objs_str .= "\t\\\n\t" . $obj_tmp_dir . "\\" . str_replace('.c', '.obj', basename($c_f));
    }
    // assemble LIBS
    $libs_str = "LIBS = ";
    foreach ($libs as $l) {
        $libs_str .= "\t\\\n\t" . $l;
    }
    // get rc file
    if (count($rc_files) == 1) {
        $rc_file = $source_dir . $rc_files[0];
        // should only one!
    } else {
        $rc_file = "";
    }
    // def
    $def_str = "OUTDIR = {$obj_tmp_dir} \n";
    $def_str .= "LIBDIR = {$lib_dir} \n";
    $def_str .= "DLLDIR = {$dll_dir} \n";
    $def_str .= "SRCDIR = {$source_dir} \n";
    $def_str .= "INCDIR = {$inc_dir} \n";
    $def_str .= "MSLIB = {$ms_lib} \n";
    $def_str .= "RCFILE = {$rc_file} \n";
    $def_str .= "cc = {$cl} \n";
    $def_str .= "rc = {$rc} \n";
    $def_str .= "link = {$link} \n";
    $sources_str .= "\n\n";
    $objs_str .= "\n\n";
    $def_str .= "\n\n";
    // stitch together makefile
    $make_str = $def_str . $sources_str . $objs_str . $libs_str . $m_comp;
    $res = file_put_contents("makefile", $make_str);
    // nmake run
    $cmd = PATH_BIN . 'nmake';
    $par = ' -f makefile FD="FILE_DESCRIPTION=\\"\\\\\\"Windows Binding for PHP ' . $vers_plus . '\\\\\\"\\"" PN="PRODUCT_NAME=\\"\\\\\\"PHP ' . $vers_plus . ' php_winbinder.dll\\\\\\"\\"" PV="P_VERSION=\\"\\\\\\"' . $vers_plus . '\\\\\\"\\""';
    $par = ' -f ' . PATH_BASE . 'makefile FD="FILE_DESCRIPTION=\\"\\\\\\"Windows Binding for PHP ' . $vers_plus . '\\\\\\"\\"" PN="PRODUCT_NAME=\\"\\\\\\"PHP ' . $vers_plus . ' php_winbinder.dll\\\\\\"\\"" PV="P_VERSION=\\"\\\\\\"' . $vers_plus . '\\\\\\"\\""';
    // needed for PHPedit + debugger and php-4.3.10
    if (!empty($_ENV['HTTP_COOKIE']) and strstr($_ENV['HTTP_COOKIE'], 'DBGSESSID') != false or PHP_VERSION == '4.3.10') {
        $dspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
        $pro = proc_open($cmd . $par, $dspec, $pipes);
        if (is_resource($pro)) {
            $result = "";
            while (!feof($pipes[1])) {
                $result .= fgets($pipes[1], 1024);
            }
            while (!feof($pipes[2])) {
                $result .= fread($pipes[2], 8024);
            }
            fclose($pipes[0]);
            fclose($pipes[1]);
            fclose($pipes[2]);
        }
        proc_close($pro);
    } else {
        $WshShell = new COM('WScript.Shell');
        $WshShell->run('cmd /K ' . $cmd . ' ' . $par . ' > ' . PATH_BASE . 'log.txt & exit', 0, true);
        $result = file_get_contents(PATH_BASE . 'log.txt');
        unlink('log.txt');
    }
    return $result;
}
示例#10
0
function scantemplate($path)
{
    if (!($html = new DOMDocument())) {
        return '服务器不支持 DOM,无法检查模板文件。';
    }
    $list = get_all_files($path);
    $result = '';
    //print_r($list);
    foreach ($list as $file) {
        //echo $file.'<br />';
        $suggestion1 = '该文件有通过脚本调用外链地址的代码, 请自行检查!';
        $suggestion2 = '该文件有通过框架调用外链地址的代码, 请自行检查!';
        $html = new DOMDocument();
        @$html->loadHTMLFile($file);
        $scripts = $html->getElementsByTagName('script');
        foreach ($scripts as $script) {
            if (($src = $script->getAttribute('src')) && substr($src, 0, 7) == 'http://') {
                if (!scanurl($src)) {
                    $result .= get_all_errors($file, $suggestion1, $src);
                }
            }
            if ($data = $script->nodeValue) {
                preg_match_all('/(http:\\/\\/)([^\\/\'"]+)/i', $data, $urls);
                if ($urls && is_array($urls)) {
                    foreach ($urls[0] as $url) {
                        if (!scanurl($url)) {
                            //return $suggestion1;
                            $result .= get_all_errors($file, $suggestion1, $src);
                        }
                    }
                }
            }
        }
        $iframes = $html->getElementsByTagName('iframe');
        foreach ($iframes as $iframe) {
            if (($src = $iframe->getAttribute('src')) && substr($src, 0, 7) == 'http://') {
                if (!scanurl($src)) {
                    //return $suggestion2;
                    $result .= get_all_errors($file, $suggestion2, $src);
                }
            }
        }
        unset($html);
        //return $file;
    }
    return $result;
}
示例#11
0
文件: base.php 项目: lionsoft/b374k
        $res = "error";
    }
    output($res);
} elseif (isset($p['findType'])) {
    $findType = trim($p['findType']);
    $findPath = trim($p['findPath']);
    $findName = trim($p['findName']);
    $findNameRegex = trim($p['findNameRegex']);
    $findNameInsensitive = trim($p['findNameInsensitive']);
    $findContent = trim($p['findContent']);
    $findContentRegex = trim($p['findContentRegex']);
    $findContentInsensitive = trim($p['findContentInsensitive']);
    $findReadable = trim($p['findReadable']);
    $findWritable = trim($p['findWritable']);
    $findExecutable = trim($p['findExecutable']);
    $candidate = get_all_files($findPath);
    if ($findType == 'file') {
        $candidate = array_filter($candidate, "is_file");
    } elseif ($findType == 'folder') {
        $candidate = array_filter($candidate, "is_dir");
    } else {
        $res = "error";
    }
    foreach ($candidate as $k) {
        if ($findType == "file" || $findType == "folder") {
            if (!empty($findName)) {
                if ($findNameRegex == "true") {
                    $case = $findNameInsensitive == "true" ? "i" : "";
                    if (!preg_match("/" . $findName . "/" . $case, basename($k))) {
                        $candidate = array_diff($candidate, array($k));
                    }
 function testGetAllFiles()
 {
     $files = get_all_files(__DIR__ . "/../resources", "1");
     $this->assertEquals(array('1/1.coffee', '1/2.coffee', '1/3.js'), $files);
 }
示例#13
0
    echo "graph_vlabel Files Count / {$graph_period}\n";
    echo "graph_category Drupal\n";
    echo "graph_scale no\n";
    echo "graph_info Displays the online files uploaded to your Drupal site\n";
    echo "files_total.label total files\n";
    echo "files_total.type GAUGE\n";
    echo "files_total.min 0\n";
    exit(0);
}
// Connect to database
$dbh = new mysqli($host, $user, $pass, $db, $port);
if (mysqli_connect_errno()) {
    echo "Connecction failed: " . mysqli_connect_error() . PHP_EOL;
    exit(1);
}
// Print out the actual values
$total_files = (int) get_all_files($dbh);
echo "files_total.value {$total_files}\n";
$dbh->close();
/**
 * Get count for all online users
 * @return integer $count total online users
 */
function get_all_files(&$dbh = NULL)
{
    $table_prefix = getenv('table_prefix');
    $sql = "SELECT COUNT(fid) AS count FROM {$table_prefix}files";
    $result = $dbh->query($sql);
    $row = $result->fetch_assoc();
    return (int) $row['count'];
}