| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 | 
							- <?php
 
- header('Content-Type: text/html; charset=utf-8');date_default_timezone_set("PRC");define('DEVER_TIME', $_SERVER['REQUEST_TIME']);define('DEVER_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
 
- Dever::run();
 
- class Dever
 
- {
 
-     public static $data = array();
 
-     public static $app = array();
 
-     public static $commit = true;
 
-     public static function run()
 
-     {
 
-         spl_autoload_register(array('Dever', 'autoload'));
 
-         $route = Dever\Route::get();
 
-         Dever\Debug::init();
 
-         Dever\Project::register();
 
-         if (isset(self::config('setting')['cache'])) {
 
-             $index = DEVER_APP_NAME . DIRECTORY_SEPARATOR . $route['l'];
 
-             if (isset(self::config('setting')['cache'][$index])) {
 
-                 $expire = self::config('setting')['cache'][$index];
 
-                 if (isset($route['shell'])) {
 
-                     unset($route['shell']);
 
-                 }
 
-                 $key = md5(DEVER_APP_NAME . http_build_query($route));
 
-                 if ($result = self::cache($key)) {
 
-                     return Dever\Output::success($result);
 
-                 }
 
-             }
 
-         }
 
-         self::$app[] = DEVER_APP_NAME;
 
-         if ($route['l'] && strpos($route['l'], '.')) {
 
-             list($class, $method) = explode('.', $route['l']);
 
-             $result = Dever\Output::success(self::load($class, DEVER_APP_NAME, 'api')->loadDevelop($method, Dever\Route::input(), true));
 
-         } else {
 
-             $result = Dever\Output::success('ok');
 
-         }
 
-         if (isset($expire)) {
 
-             self::cache($key, $result, $expire);
 
-         }
 
-     }
 
-     public static function autoload($class)
 
-     {
 
-         if (strpos($class, 'Dever') === 0) {
 
-             include DEVER_PATH . 'src/' . str_replace('\\', '/', $class) . '.php';
 
-         } else {
 
-             Dever\Library::autoload($class);
 
-         }
 
-     }
 
-     public static function call($class, $param = array(), $path = '')
 
-     {
 
-         if (strpos($class, '.')) {
 
-             list($class, $method) = explode('.', $class);
 
-             $call = 'load';
 
-             if (!$path) $path = 'lib';
 
-         } elseif (strpos($class, '-')) {
 
-             list($class, $method) = explode('-', $class);
 
-             $call = 'db';
 
-             if (!$path) $path = 'default';
 
-         }
 
-         return self::$call($class, '', $path)->$method(...$param);
 
-     }
 
-     public static function load($class, $app = '', $path = 'lib')
 
-     {
 
-         if (strpos($class, '/') && !$app) {
 
-             list($app, $class) = explode('/', $class);
 
-         }
 
-         if ($app) {
 
-             array_unshift(self::$app, $app);
 
-         } else {
 
-             $app = self::$app[0];
 
-         }
 
-         $index = $app . $path . $class;
 
-         if (empty(self::$data[$index])) {
 
-             self::$data[$index] = new Dever\Import($class, $app, $path);
 
-         }
 
-         return self::$data[$index];
 
-     }
 
-     public static function db($table, $app = '', $store = 'default', $partition = false, $path = 'table')
 
-     {
 
-         if (strpos($table, '/') && !$app) {
 
-             list($app, $table) = explode('/', $table);
 
-         }
 
-         if ($app) {
 
-             array_unshift(self::$app, $app);
 
-         } else {
 
-             $app = self::$app[0];
 
-         }
 
-         $index = $app . $path . $table;
 
-         if (empty(self::$data[$index])) {
 
-             self::$data[$index] = new Dever\Model($table, $app, $store, $partition, $path);
 
-         }
 
-         return self::$data[$index];
 
-     }
 
-     public static function reset()
 
-     {
 
-         if (count(self::$app) > 1) {
 
-             array_shift(self::$app);
 
-         }
 
-     }
 
-     public static function config()
 
-     {
 
-         return Dever\Config::get(...func_get_args());
 
-     }
 
-     public static function apply()
 
-     {
 
-         return Dever\Library::apply(...func_get_args());
 
-     }
 
-     public static function success()
 
-     {
 
-         return Dever\Output::success(...func_get_args());
 
-     }
 
-     public static function error()
 
-     {
 
-         return Dever\Output::error(...func_get_args());
 
-     }
 
-     public static function out()
 
-     {
 
-         return Dever\Output::out(...func_get_args());
 
-     }
 
-     public static function input()
 
-     {
 
-         return Dever\Route::input(...func_get_args());
 
-     }
 
-     public static function url()
 
-     {
 
-         return Dever\Route::url(...func_get_args());
 
-     }
 
-     public static function host()
 
-     {
 
-         return Dever\Route::host(...func_get_args());
 
-     }
 
-     public static function project()
 
-     {
 
-         return Dever\Project::load(...func_get_args());
 
-     }
 
-     public static function log()
 
-     {
 
-         return Dever\Log::add(...func_get_args());
 
-     }
 
-     public static function debug()
 
-     {
 
-         return Dever\Debug::add(...func_get_args());
 
-     }
 
-     public static function session()
 
-     {
 
-         return Dever\Session::oper(...func_get_args());
 
-     }
 
-     public static function view()
 
-     {
 
-         return Dever\View::show(...func_get_args());
 
-     }
 
-     public static function file()
 
-     {
 
-         return Dever\File::get(...func_get_args());
 
-     }
 
-     public static function data()
 
-     {
 
-         return Dever\File::data();
 
-     }
 
-     public static function page()
 
-     {
 
-         return Dever\Paginator::get(...func_get_args());
 
-     }
 
-     public static function rule()
 
-     {
 
-         return Dever\Helper\Rule::get(...func_get_args());
 
-     }
 
-     public static function curl()
 
-     {
 
-         $curl = new Dever\Helper\Curl();
 
-         return $curl->load(...func_get_args());
 
-     }
 
-     public static function cache($key, $value = false)
 
-     {
 
-         if (isset(self::config('setting')['redis'])) {
 
-             if ($value) {
 
-                 if ($value == 'delete') {
 
-                     return \Dever\Helper\Redis::delete($key);
 
-                 }
 
-                 return \Dever\Helper\Redis::set($key, self::json_encode($value));
 
-             } else {
 
-                 return self::json_decode(\Dever\Helper\Redis::get($key));
 
-             }
 
-         }
 
-         return false;
 
-     }
 
-     public static function shell($value)
 
-     {
 
-         return Dever::check(Dever\Route::input('shell'), $value);
 
-     }
 
-     public static function store($store = 'default', $partition = false)
 
-     {
 
-         $setting = Dever\Config::get('setting')['database'][$store];
 
-         $class = 'Dever\\Store\\' . $setting['type'];
 
-         return $class::getInstance($store, $setting, $partition);
 
-     }
 
-     public static function in_array($array, $value, $key = 'id', $show = 'name')
 
-     {
 
-         $column = array_column($array, $key);
 
-         if ($column) {
 
-             $index = array_search($value, $column);
 
-             if ($index >= 0) {
 
-                 return $array[$index][$show];
 
-             }
 
-         }
 
-         return false;
 
-     }
 
-     public static function isset($input, $value = false)
 
-     {
 
-         if (isset($input[$value])) {
 
-             if (is_string($input[$value]) && !strlen($input[$value])) {
 
-                 return false;
 
-             }
 
-             return $input[$value];
 
-         }
 
-         return false;
 
-     }
 
-     public static function check($var, $find)
 
-     {
 
-         if (is_array($var)) {
 
-             $var = implode(',', $var);
 
-         }
 
-         $var = ',' . $var . ',';
 
-         $find = ',' . $find . ',';
 
-         return strpos($var, $find) !== false;
 
-     }
 
-     public static function json_encode($value)
 
-     {
 
-         $value = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK | JSON_PRESERVE_ZERO_FRACTION);
 
-         if (strpos($value, '<')) {
 
-             $value = Dever\Helper\Secure::xss($value);
 
-         }
 
-         return $value;
 
-     }
 
-     public static function json_decode($value)
 
-     {
 
-         return json_decode($value, true);
 
-     }
 
-     public static function array_order($array, $key, $sort)
 
-     {
 
-         $reorder = array_column($array, $key);
 
-         array_multisort($reorder, $sort, $array);
 
-         return $array;
 
-     }
 
-     public static function number($number, $num = 2, $type = 1)
 
-     {
 
-         if ($type == 2) {
 
-             return number_format($number, $num);
 
-         }
 
-         if ($type == 3) {
 
-             return round($number, $num);
 
-         }
 
-         return sprintf("%.".$num."f", $number);
 
-     }
 
-     public static function uuid()
 
-     {
 
-         mt_srand((double)microtime() * 10000);
 
-         $charid = strtoupper(self::id());
 
-         $hyphen = chr(45);
 
-         return chr(123).substr($charid, 0, 8).$hyphen.substr($charid, 8, 4).$hyphen.substr($charid,12, 4).$hyphen.substr($charid,16, 4).$hyphen.substr($charid,20,12).chr(125);
 
-     }
 
-     public static function id()
 
-     {
 
-         $charid = strtoupper(md5(uniqid(mt_rand(), true)));
 
-         return substr($charid, 0, 8) . substr($charid, 8, 4) . substr($charid, 12, 4) . substr($charid, 16, 4) . substr($charid, 20, 12);
 
-     }
 
-     public static function is_file($file)
 
-     {
 
-         if (strtolower(substr($file, 0, 4)) == 'http') {
 
-             $header = get_headers($file, true);
 
-             return isset($header[0]) && (strpos($header[0], '200') || strpos($header[0], '304'));
 
-         } else {
 
-             return is_file($file);
 
-         }
 
-     }
 
-     public static function subdir($dir)
 
-     {
 
-         return array_filter(scandir($dir), function($file) use ($dir) {
 
-             return is_dir($dir . '/' . $file) && $file !== '.' && $file !== '..';
 
-         });
 
-     }
 
- }
 
 
  |