示例#1
0
function parseDir($dir = '/logs')
{
    global $functions, $templates, $layers;
    $tableRows = '';
    $fileList = preg_split('/\\n/', trim($functions->getOtherFile($dir)));
    ++$layers;
    foreach ($fileList as $fileName) {
        if ($fileName == '') {
            break;
        }
        if (preg_match('/(.*)\\.[a-z0-9]{3,}/i', $fileName)) {
            $tableRows = '<tr>' . '<td>' . $fileName . '</td>' . '<td style="width:90px;"><button class="btn btn-default btn-sm" onclick="openPopup(\'pops/log-viewer.php?file=' . $dir . '/' . $fileName . '\', \'PhantomBot WebPanel Log Viewer\')">View Log</button></td>' . '</tr>' . $tableRows;
        } else {
            $tableRows .= '<tr><td colspan="2">' . parseDir($dir . '/' . $fileName) . '</td></tr>';
        }
    }
    if ($dir == '/logs') {
        if ($layers > 1) {
            return '<table class="table table-condensed">' . $tableRows . '</table>';
        } else {
            return '<table class="table table-striped">' . $tableRows . '</table>';
        }
    } else {
        return $templates->dataTable($dir, [], $tableRows, true, '', [], true);
    }
}
 function __construct()
 {
     $rand = rand(0, 1);
     if ($rand == 0) {
         $this->font = __ROOT__ . parseDir(Config::config('core_dir'), 'libs', 'font') . 'elephant.ttf';
     } else {
         $this->font = __ROOT__ . parseDir(Config::config('core_dir'), 'libs', 'font') . 'Vineta.ttf';
     }
 }
示例#3
0
function get_local($key)
{
    global $g_conf;
    $date_tm = parseDir($key);
    $file_dir = $g_conf['data_dir'] . '/' . $date_tm;
    $file_name = $file_dir . '/' . $key;
    if (!is_file($file_name)) {
        return false;
    }
    return file_get_contents($file_name);
}
示例#4
0
 private function get_path($templateName, $type = 'template', $key = false)
 {
     switch ($type) {
         case 'template':
             return __ROOT__ . parseDir(Config::config('app_dir'), Config::template('view_dir'), Config::template('view_name')) . $templateName . Config::template('view_suffix');
         case 'cache':
             return __ROOT__ . parseDir(Config::config('app_dir'), Config::template('cache_dir'), Config::template('view_cache_dir'), Config::template('view_name')) . '/' . $templateName . $key;
         case 'view_c':
             return __ROOT__ . parseDir(Config::config('app_dir'), Config::template('view_c_dir'), Config::template('view_name')) . $templateName . '.php';
     }
 }
示例#5
0
function parseDir($dir, $parent)
{
    $path = $parent . ($dir['name'] != '/' ? $dir['name'] . '/' : '');
    foreach ($dir->file as $file) {
        if (in_array($file['role'], array('test', 'php'))) {
            showSource($path, $file['name']);
        }
    }
    foreach ($dir->dir as $child) {
        parseDir($child, $path);
    }
    return;
}
/**
 * Parses a directory for files, recursively
 * @param $path string The folder to start processing
 */
function parseDir($path)
{
    foreach (glob($path) as $filename) {
        if (strpos($filename, ".coffee")) {
            parseFile($filename);
        } else {
            if (strpos($filename, ".css")) {
                parseFile($filename);
            } else {
                if (strpos($filename, ".") == "") {
                    parseDir($filename . "/*");
                }
            }
        }
    }
}
示例#7
0
 public function getViewList($type, $filter = '')
 {
     $dirArr = array();
     $dir = Config::cms('cms_path') . parseDir(Config::template('view_dir'), Config::template('view_name'), $type);
     //var_dump($dir);exit;
     if (file_exists($dir)) {
         //echo $dir;exit;
         if ($filter == '') {
             $filter = '*';
         }
         if ($filter != '*') {
             $filter = $filter . '*';
         }
         $d = glob($dir . $filter);
         $filter = substr($filter, 0, strlen($filter) - 1);
         foreach ($d as $value) {
             if (preg_match('/' . srtToRE($dir) . srtToRE($filter) . '(.*)' . srtToRE(Config::template('view_suffix')) . '$/', $value)) {
                 $dirArr[] = preg_replace('/' . srtToRE($dir) . srtToRE($filter) . '(.*)' . srtToRE(Config::template('view_suffix')) . '$/', $type . '/' . $filter . "\$1", $value);
             }
         }
     }
     return $dirArr;
 }
示例#8
0
 /**
  * 清空指定文件夹的缓存
  */
 public function _flush($space)
 {
     $dir = __ROOT__ . parseDir(Config::config('app_dir'), Config::cache('cache_dir'), $space);
     if (!file_exists($dir)) {
         return true;
     }
     $dh = opendir($dir);
     while ($file = readdir($dh)) {
         if ($file != "." && $file != "..") {
             $fullpath = $dir . "/" . $file;
             if (!is_dir($fullpath)) {
                 unlink($fullpath);
             } else {
                 $this->flush($space . '/' . $file);
             }
         }
     }
     closedir($dh);
     //删除当前文件夹:
     if (rmdir($dir)) {
         return true;
     } else {
         return false;
     }
 }
示例#9
0
<?php

/**
 * 项目基本配置
 * 创建项目需要首先配置此文件
 * 所有文件夹配置需要以'/'开头
 */
return array('view_dir' => 'view', 'default_view_name' => 'default', 'view_name' => 'default', 'view_c_dir' => Config::config('app_dir') . '/view_c', 'view_cache_dir' => Config::config('app_dir') . '/view', 'view_suffix' => '.php', 'view_cache' => 1, 'leftDelim' => '<\\{', 'rightDelim' => '\\}>', 'view_cache_time' => 0, 'public_path' => '/' . parseDir(Config::config('app_dir'), '/public/'), 'css_path' => '/' . parseDir(Config::config('app_dir'), '/public/css/'), 'js_path' => '/' . parseDir(Config::config('app_dir'), '/public/js/'), 'img_path' => '/' . parseDir(Config::config('app_dir'), '/public/images/'));
示例#10
0
 public function _delete_timeout($space, $lifetime)
 {
     $dir = __ROOT__ . parseDir(Config::config('app_dir'), Config::cache('cache_dir'), $space);
     if (!file_exists($dir)) {
         return true;
     }
     foreach (glob($dir . '*') as $v) {
         $time = $lifetime + filemtime($v);
         if ($time < time()) {
             @unlink($v);
         }
     }
     return true;
 }
示例#11
0
<?php

/**
 * CMS 另加的配置,后台不使用,只负责修改,供前台使用
 * PGF      15-08-25 14:23
 * 定义为$var,视图中可以使用
 * 在视图中需要的变量在这里添加
 */
return array('cms_path' => __ROOT__ . 'gouwanmei/', 'cms_app_name' => 'gouwanmei', 'view_cache_time' => '-1', 'view_cache' => '1', 'view_dir' => 'view', 'default_view_name' => 'default', 'view_name' => 'default', 'tpl_leftDelim' => '\\{', 'tpl_rightDelim' => '\\}', 'html_cache_time' => 3600 * 24, 'css_path' => '/' . parseDir(Config::config('app_dir'), '/public/css/'), 'js_path' => '/' . parseDir(Config::config('app_dir'), '/public/js/'), 'img_path' => '/' . parseDir(Config::config('app_dir'), '/public/img/'), 'upload_path' => 'upload/', 'upload_url' => '/upload/', 'debug' => false);