Ejemplo n.º 1
0
function load_recursive_include_path($sPathDir, $arNotToCountOn = array(), $sDS = "/")
{
    //bug($arNotToCountOn);die;
    $arDirPaths = dir_tree($sPathDir, $arNotToCountOn, $sDS);
    $sDirPaths = implode(PATH_SEPARATOR, $arDirPaths);
    if (!empty($sDirPaths)) {
        $sDirPaths = get_include_path() . PATH_SEPARATOR . $sDirPaths;
        set_include_path($sDirPaths);
    }
}
Ejemplo n.º 2
0
function ShowVertify()
{
    global $CONF, $LNG;
    $EXT = explode("|", HTTP::_GP("ext", ""));
    $action = HTTP::_GP("action", "");
    $file = HTTP::_GP("file", "");
    $template = new template();
    switch ($action) {
        case 'check':
            $REV = explode(".", Config::get("VERSION"));
            $REV = $REV[2];
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_AUTOREFERER, true);
            curl_setopt($ch, CURLOPT_URL, 'http://2moons.googlecode.com/svn-history/r' . $REV . '/trunk/' . $file);
            curl_setopt($ch, CURLOPT_HEADER, false);
            curl_setopt($ch, CURLOPT_USERAGENT, "2Moons Update API");
            curl_setopt($ch, CURLOPT_CRLF, true);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $FILE = curl_exec($ch);
            $SVNHASH = crc32(preg_replace(array("/(\r\n)|(\r)/", '/(\\/\\*[\\d\\D]*?\\*\\/)/', '/\\$I' . 'd[^\\$]+\\$/'), array("\n", '', ''), $FILE));
            if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 404) {
                echo 4;
                exit;
            }
            if (curl_errno($ch)) {
                echo 3;
                exit;
            }
            curl_close($ch);
            $FILE2 = file_get_contents(ROOT_PATH . $file);
            $LOCALHASH = crc32(preg_replace(array("/(\r\n)|(\r)/", '/(\\/\\*[\\d\\D]*?\\*\\/)/', '/\\$I' . 'd[^\\$]+\\$/'), array("\n", '', ''), $FILE2));
            if ($SVNHASH == $LOCALHASH) {
                echo 1;
                exit;
            } else {
                echo 2;
                exit;
            }
            exit;
            break;
        case 'vertify':
            $template->loadscript('vertify.js');
            $template->show("VertifyPageResult.tpl");
            exit;
            break;
        case 'getFileList':
            echo json_encode(array_merge(dir_tree('./', $EXT, false), dir_tree('chat/', $EXT), dir_tree('includes/', $EXT), dir_tree('includes/', $EXT), dir_tree('language/', $EXT), dir_tree('scripts/', $EXT), dir_tree('styles/', $EXT)));
            exit;
            break;
    }
    $template->show("VertifyPage.tpl");
}
Ejemplo n.º 3
0
function dir_tree($dir, $root = null)
{
    foreach ($dir as $name => $sub) {
        $name = $root . $name;
        if (!file_exists($name)) {
            mkdir($name);
        }
        if (is_array($sub)) {
            dir_tree($sub, $name . '/');
        }
    }
    return true;
}
Ejemplo n.º 4
0
function dir_tree($directory, $level)
{
    //$num = "1";
    //echo ("<b>Soubory v $directory :</b><br /><br />\n<ul>");
    $dirfp = opendir($directory);
    $leveli = $level;
    while ($leveli) {
        echo "-";
        $leveli--;
    }
    echo "[DIR] {$directory}\n";
    while (false !== ($file = readdir($dirfp))) {
        if ($file != "." && $file != "..") {
            if (is_dir($directory . $file)) {
                echo "\n";
                $leveli = $level;
                while ($leveli < 0) {
                    echo "-";
                    $leveli--;
                }
                //echo "-[DIR] $file\n";
                dir_tree("{$directory}{$file}\\", $level + 2);
                echo "\n";
            } else {
                $leveli = $level;
                while ($leveli + 1) {
                    echo "-";
                    $leveli--;
                }
                echo "{$file} - ({$directory}{$file})\n";
                //$num = ($num + 1);
            }
        }
    }
    closedir($dirfp);
}
Ejemplo n.º 5
0
                 $dbexists = true;
             } else {
                 $extension_not_allowed = true;
             }
         }
     }
 }
 //- Scan a directory for databases
 if ($directory !== false) {
     if ($directory[strlen($directory) - 1] == DIRECTORY_SEPARATOR) {
         //if user has a trailing slash in the directory, remove it
         $directory = substr($directory, 0, strlen($directory) - 1);
     }
     if (is_dir($directory)) {
         if ($subdirectories === true) {
             $arr = dir_tree($directory);
         } else {
             $arr = scandir($directory);
         }
         $databases = array();
         $j = 0;
         for ($i = 0; $i < sizeof($arr); $i++) {
             if ($subdirectories === false) {
                 $arr[$i] = $directory . DIRECTORY_SEPARATOR . $arr[$i];
             }
             if (@(!is_file($arr[$i]))) {
                 continue;
             }
             $con = file_get_contents($arr[$i], NULL, NULL, 0, 60);
             if (strpos($con, "** This file contains an SQLite 2.1 database **", 0) !== false || strpos($con, "SQLite format 3", 0) !== false) {
                 $databases[$j]['path'] = $arr[$i];
Ejemplo n.º 6
0
/**
 * Returns directory tree starting at given directory.
 *
 * @param string starting directory
 * @param integer maximum depth of the tree
 * @param integer depth counter, for internal use
 * @return array directory tree
 */
function dir_tree($path, $hidden = false, $maxdepth = -1, $d = 0)
{
    if (substr($path, strlen($path) - 1) != '/') {
        $path .= '/';
    }
    $hiddens = @file_get_contents($path . '.hidden');
    if ($hiddens) {
        $hiddens = explode(",", trim($hiddens));
    }
    if (is_array($hidden)) {
        if (!is_array($hiddens)) {
            $hiddens = array();
        }
        $hiddens = array_merge($hiddens, $hidden);
        $show_hidden = false;
    } elseif ($hidden) {
        $show_hidden = true;
    } else {
        $show_hidden = false;
    }
    $dirlist = array();
    $dirlist[] = $path;
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            if ($file == '.' || $file == '..' || !$show_hidden && preg_match('/^\\./', $file) || $hiddens && in_array($file, $hiddens)) {
                continue;
            }
            $file = $path . $file;
            if (is_dir($file) && $d >= 0 && ($d < $maxdepth || $maxdepth < 0)) {
                $result = dir_tree($file . '/', $hidden, $maxdepth, $d + 1);
                $dirlist = array_merge($dirlist, $result);
            }
        }
        closedir($handle);
    }
    if ($d == 0) {
        natcasesort($dirlist);
    }
    return $dirlist;
}
Ejemplo n.º 7
0
 /**
  * combo store数据
  *
  * @author          mrmsl <*****@*****.**>
  * @date            2013-06-27 17:45:25
  *
  * @return void 无返回值
  */
 public function comboAction()
 {
     $dir_arr = dir_tree(LOG_PATH);
     foreach ($dir_arr as $k => $item) {
         $dir_arr[$k] = array('filename' => str_replace(LOG_PATH, '', $item['dir']));
     }
     array_unshift($dir_arr, array('filename' => DS));
     $this->_ajaxReturn(true, '', $dir_arr);
 }
Ejemplo n.º 8
0
/**
 * 目录列表
 *
 * @param string $dir       路径
 * @param bool   $recursive 递归。默认true
 * @param int    $parent_id 父id。默认0
 * @param array  $dirs      传入的目录。默认array()
 *
 * @param array 目录列表
 */
function dir_tree($dir, $recursive = true, $parent_id = 0, $dirs = array())
{
    global $id;
    $parent_id == 0 && ($id = 0);
    $list = glob($dir . '*');
    foreach ($list as $v) {
        if (is_dir($v) && $recursive) {
            $id++;
            $dirs[$id] = array('id' => $id, 'parentid' => $parent_id, 'name' => basename($v), 'dir' => $v . '/');
            $dirs = dir_tree($v . '/', $recursive, $id, $dirs);
        }
    }
    return $dirs;
}
Ejemplo n.º 9
0
 function dir_tree($df, $level = 0)
 {
     global $tcolors, $self;
     $df = str_replace("//", "/", $df);
     $dirs = array();
     $files = array();
     if ($dir = opendir($df)) {
         while (($file = readdir($dir)) !== false) {
             if ($file == "." || $file == "..") {
                 continue;
             }
             if (is_dir("{$df}/{$file}")) {
                 $dirs[] = $file;
             } else {
                 $files[] = $file;
             }
         }
     }
     closedir($dir);
     sort($dirs);
     sort($files);
     $i = min($level, count($tcolors) - 1);
     $c = $tcolors[$i][0] . $tcolors[$i][0] . $tcolors[$i][1] . $tcolors[$i][1] . $tcolors[$i][2] . $tcolors[$i][2];
     echo "\r\n\r\n\r\n\n   <table width=100% border=0 cellspacing=2 cellpadding=1><tr><td bgcolor=#000000>\n   <table width=100% border=0 cellspacing=0 cellpadding=1 bgcolor=#{$c}>\n   <tr><td colspan=3 class=dir>" . "<a href={$self}?c=l&d=" . urlencode($df) . " class=dir><img src={$self}?name=dir&c=img&1 border=0>" . $df . "</a></td></tr>";
     if (count($dirs) || count($files)) {
         echo "<tr><td width=15>&nbsp;</td><td class=all width=97%>";
         for ($i = 0; $i < count($files); $i++) {
             echo $files[$i] . " ";
         }
         for ($i = 0; $i < count($dirs); $i++) {
             dir_tree($df . "/" . $dirs[$i], $level + 1);
         }
         echo "</td><td width=10>&nbsp;</td></tr>";
     }
     echo '</table></td></tr></table>';
 }
Ejemplo n.º 10
0
 /**
  * Creates list of modules currently available to install along with list of available versions.
  *
  * @return array array built as follows: array('Box'=>array(0,1)...)
  */
 public static final function list_modules()
 {
     $dirs = dir_tree('modules', array('theme', 'lang', 'help'));
     $ret = array();
     foreach ($dirs as $d) {
         $module = str_replace('/', '_', substr($d, 8, -1));
         $file = self::get_module_file_name($module);
         if (!file_exists($d . $file . 'Install.php')) {
             continue;
         }
         self::include_install($module);
         $version_f = array(self::$modules_install[$module], 'version');
         if (is_callable($version_f)) {
             $version_ret = call_user_func($version_f);
         } else {
             $version_ret = 0;
         }
         $version_arr = array();
         if (is_array($version_ret)) {
             $version_arr = $version_ret;
             $version = count($version_ret);
         } else {
             $version = intval($version_ret);
             for ($i = 0; $i <= $version; $i++) {
                 $version_arr[] = $i;
             }
         }
         $ret[$module] = $version_arr;
     }
     return $ret;
 }
Ejemplo n.º 11
0
function dir_tree($dir, $parentid = 0, $dirs = array())
{
    if ($parentid == 0) {
        $id = 0;
    }
    $list = glob($dir . '*');
    foreach ($list as $v) {
        if (is_dir($v)) {
            $id++;
            $dirs[$id] = array('id' => $id, 'parentid' => $parentid, 'name' => basename($v), 'dir' => $v . '/');
            $dirs = dir_tree($v . '/', $id, $dirs);
        }
    }
    return $dirs;
}
if ($numeric_alt_suffixes > 0) {
    // add numeric suffixes to alt suffix list if we've been told to do that.
    $newsuffixarray = array();
    foreach ($staticsync_alt_suffix_array as $thesuffix) {
        array_push($newsuffixarray, $thesuffix);
        for ($i = 1; $i < $numeric_alt_suffixes; $i++) {
            array_push($newsuffixarray, $thesuffix . $i);
        }
    }
    $staticsync_alt_suffix_array = $newsuffixarray;
}
echo date('Y-m-d H:i:s    ');
echo "Looking for orphaned alternate files\n";
echo date('Y-m-d H:i:s    ');
echo "syncdir is {$syncdir}\n";
$files = dir_tree($syncdir);
//print_r($staticsync_alt_suffix_array);
foreach ($files as $thefile) {
    if (is_dir($thefile) || preg_match("/^\\..*/", basename($thefile))) {
        continue;
    }
    // ignore directories and hidden files
    //echo "$thefile\n";
    foreach ($staticsync_alt_suffix_array as $suffix) {
        if (preg_match("/^" . preg_quote($syncdir, "/") . "\\/(.*)\\/([^\\/]+)({$suffix})\\.([^.]+)\$/", $thefile, $matches)) {
            echo date('Y-m-d H:i:s    ');
            echo "Processing {$thefile}\n";
            //print_r($matches);
            $filename_field = 51;
            $searchpath = addslashes(str_replace('/', '~', $matches[1]));
            $filename = $matches['2'];
Ejemplo n.º 13
0
function init_tables()
{
    create_tables();
    dir_tree();
}