Esempio n. 1
0
 public function getRoot()
 {
     if (!isset($this->root)) {
         exec('git rev-parse --show-cdup', $output);
         $this->root = real_path($output[0]);
     }
     return $this->root;
 }
Esempio n. 2
0
 protected function onExecute($argv = null)
 {
     $start = microtime();
     $root = $this->git->getRoot();
     $dir = $this->getExportDir($this->version);
     $files = $this->git->getChangeFiles($this->version);
     $total = 0;
     foreach ($files as $file) {
         $path = real_path("{$root}/{$file}");
         if ($path && $this->copy($path, "{$dir}/{$file}")) {
             $this->console->println("exporting file {$file} ...");
             $total++;
         }
     }
     $usedTime = round(diff_milli($start), 4);
     $this->console->println("There are {$total} files export to \"{$dir}\", used {$usedTime} ms!");
 }
Esempio n. 3
0
 public final function __construct(Argv $argv = null)
 {
     // 绑定当前的默认的上下文环境实例
     if (!isset(self::$context)) {
         self::$context = $this;
     }
     $this->app = App::getApp();
     if (!$this->app->isInit()) {
         $this->app->init();
     }
     $this->app->getLoader()->loadHelper('string');
     $this->writer = new Writer();
     $this->cwd = real_path(getcwd());
     // 将错误和异常处理,从App中接管过来。
     register_shutdown_function(function () {
         $this->onExiting();
     });
     set_error_handler([$this, 'errorHandle']);
     set_exception_handler([$this, 'exceptionHandle']);
     if (isset($argv)) {
         $this->setArgv($argv);
     }
 }
Esempio n. 4
0
 protected function parseFunctions(SourceScanner $scanner)
 {
     if (preg_match_all($this->regexFunction, $this->content, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             $fn = trim($match[1]);
             if (!$this->autoImport && !function_exists($fn)) {
                 require $this->path;
             }
             if (function_exists($fn)) {
                 $ref = new \ReflectionFunction($fn);
                 if (real_path($ref->getFileName()) === $this->path) {
                     $parser = FuncParser::autoParse($ref, $scanner);
                     $scanner->addFunction($parser);
                 } else {
                     $scanner->addMissItem(DocMen::FUNC, $fn, $this->path);
                 }
             } else {
                 $scanner->addMissItem(DocMen::FUNC, $fn, $this->path);
             }
         }
     }
     return $this;
 }
Esempio n. 5
0
 /**
  * real_path的文件版,判定标准是路径为文件。
  *
  * @param string $path 路径名
  * @return string|false 路径是一个文件,则返回全路径,不存在则返回false
  */
 function real_file(string $path)
 {
     global $KE;
     $realPath = $KE['paths'][$path] ?? real_path($path);
     if ($realPath === false) {
         return false;
     }
     if (!isset($KE['stats'][$realPath][1])) {
         $KE['stats'][$realPath][1] = $realPath === false ? false : is_file($realPath);
     }
     return $KE['stats'][$realPath][1] ? $realPath : false;
 }
Esempio n. 6
0
 public static function verifyValue($type, $value = null, array $column = [])
 {
     if ($type === KE_STR) {
         return (string) $value;
     } elseif ($type === KE_BOOL || $type === 'bool' || $type === 'single') {
         if ($value === 'false' || $value === '0' || $value === 0 || $value === 0.0) {
             return false;
         }
         if (strtolower($value) === 'off') {
             return false;
         }
         if ($type === 'single' && $value === '') {
             return !$column['default'];
         }
         return (bool) $value;
     } elseif ($type === KE_INT || $type === 'int') {
         return (int) $value;
     } elseif ($type === KE_FLOAT) {
         return (double) $value;
     } elseif ($type === 'array') {
         if (is_string($value)) {
             if (strpos($value, ',') > 0) {
                 $result = [];
                 foreach (explode(',', $value) as $item) {
                     $result[] = trim($item);
                 }
                 return $result;
             }
         }
         return (array) $value;
     } elseif ($type === 'dir') {
         if (empty($value)) {
             return false;
         }
         return real_dir($value);
     } elseif ($type === 'file') {
         if (empty($value)) {
             return false;
         }
         return real_file($value);
     } elseif ($type === 'realpath') {
         if (empty($value)) {
             return KE_SCRIPT_DIR;
         }
         return real_path($value);
     } elseif ($type === 'json') {
         $decode = json_decode($value, true);
         return $decode;
     } elseif ($type === 'dirs' || $type === 'files') {
         if (empty($value)) {
             return [];
         }
         $value = static::verifyValue('array', $value, $column);
         if ($type === 'dirs') {
             foreach ($value as $index => $item) {
                 $value[$index] = static::verifyValue('dir', $item, $column);
             }
         } elseif ($type === 'files') {
             foreach ($value as $index => $item) {
                 $value[$index] = static::verifyValue('file', $item, $column);
             }
         }
         return $value;
     } else {
         if ($value === 'false') {
             return false;
         }
         if ($value === 'true') {
             return true;
         }
         if ($value === 'null') {
             return null;
         }
         if (is_float($value)) {
             return (double) $value;
         }
         if (is_int($value)) {
             return (int) $value;
         }
         return $value;
     }
 }
Esempio n. 7
0
 static function includeFile($params = null)
 {
     if (!isset($_GET['ctype']) || $_GET['ctype'] != 'gedcom') {
         return '';
     }
     if ($params === null) {
         $params = array();
     }
     if (isset($params[0]) && $params[0] != '') {
         $fn = $params[0];
     } else {
         return '';
     }
     if (!file_exists($fn) || stristr($fn, 'config.php')) {
         return '';
     }
     ob_start();
     include filename_decode(real_path($fn));
     return trim(ob_get_clean());
 }
Esempio n. 8
0
<?php

$type = isset($_GET['type']) ? $_GET['type'] : 'js';
if ($type == 'css') {
    header('Content-type: text/css');
} else {
    header('Content-type: application/x-javascript');
}
$path = urldecode($_GET['module']) . '/' . $type . '/';
function real_path()
{
    global $path;
    $base_dir = realpath('../src');
    return $base_dir . '/' . $path;
}
$path = real_path();
$filelist = scandir($path);
$lineNumber = 1;
foreach ($filelist as $file) {
    if (preg_match('/' . $type . '$/', $file) && ($fh = fopen($path . $file, 'r'))) {
        echo '/*========FILE=: ' . $file . " ----line: " . $lineNumber . "----===============*/\n";
        while (!feof($fh)) {
            $line = fgets($fh);
            $lineNumber += 1;
            echo $line;
        }
        fclose($fh);
    }
}
Esempio n. 9
0
 public function getFile($name)
 {
     if (!isset($this->files[$name])) {
         return false;
     }
     $data = $this->files[$name];
     $dir = $this->dirs[$data['dir']] ?? '';
     $path = $dir . '/' . $data['path'];
     $path = real_path($path);
     //
     $data['source'] = '';
     if ($path !== false && is_file($path)) {
         $data['source'] = file_get_contents($path);
     }
     return $data;
 }