Example #1
0
 /**
  * 移动临时文件
  *
  * @param {array} $file
  * @param {string} $target
  * @return {string}
  */
 public static function move($file, $target)
 {
     $timestamp = microtime(true);
     $source = is_array($file) ? $file['tmp_name'] : $file;
     move_uploaded_file($source, $target);
     DEBUG::put('Move ' . $source . ' to ' . $target . ' spent: ' . round((microtime(true) - $timestamp) * 1000, 3) . 'ms', 'Upload');
     return $target;
 }
Example #2
0
 /**
  * 载入模板
  * 如果指定了参数$layout,则会嵌套一个layout模板
  *
  * @param string $name   模板名
  * @param array $locals  变量
  * @return string
  */
 public static function getTemplate($name, $locals = array())
 {
     if (!pathinfo($name, PATHINFO_EXTENSION)) {
         $name = $name . '.html';
     }
     $filename = APP_TEMPLATE_ROOT . $name;
     $timestamp = microtime(true);
     ob_start();
     extract($locals, EXTR_SKIP);
     include $filename;
     $html = ob_get_clean();
     DEBUG::put('Render ' . $filename . ' spent: ' . round((microtime(true) - $timestamp) * 1000, 3) . 'ms', 'Template');
     return $html;
 }
Example #3
0
 /**
  * 关闭SQL连接
  */
 public static function close()
 {
     DEBUG::put('Close connection.', 'MySQL');
     return @mysqli_close(SQL::$connection);
 }
Example #4
0
 /**
  * 注册中间件
  *
  * @param string $path        路径
  * @param callback $function  要执行的函数
  * @param bool $is_preg       路径是否为正则表达式,默认为false
  */
 public static function register($path, $function, $is_preg = false)
 {
     ROUTER::$_list[] = array($path, $function, $is_preg);
     DEBUG::put("Use: {$path} => {$function}", 'Router');
 }