Example #1
0
 static function boot()
 {
     $pathinfo = request::getPathInfo();
     // 生成part
     if (isset($pathinfo[1])) {
         if ($p = strpos($pathinfo, '/', 2)) {
             $part = substr($pathinfo, 0, $p);
         } else {
             $part = $pathinfo;
         }
     } else {
         $part = '/';
     }
     if ($part == '/openapi') {
         return kernel::single('base_rpc_service')->process($pathinfo);
     } elseif ($part == '/app-doc') {
         //cachemgr::init();
         return kernel::single('base_misc_doc')->display($pathinfo);
     }
     // 确认是否安装流程. 如果是安装流程则开启debug. 如果不是则检查是否安装, 如果未安装则跳到安装流程
     // 目前其他的url, 都应移到routes中进行
     //
     if ($part == '/setup') {
         config::set('app.debug', true);
     } else {
         static::checkInstalled();
     }
     cacheobject::init();
     static::registRouteMiddleware();
     $response = route::dispatch(request::instance());
     // 临时处理方式
     kernel::single('base_session')->close();
     $response->send();
     exit;
 }
Example #2
0
 public function index()
 {
     header('Location:index.php?app=b2c&ctl=admin_setting&act=index');
     die;
     $dashboard_from = $this->_request->get_post('f');
     $dashboard_to = $this->_request->get_post('t');
     $default_enter = true;
     if (!$dashboard_to) {
         $dashboard_to = strtotime(date('Y-m-d'));
     } else {
         $default_enter = false;
     }
     if (!$dashboard_from) {
         $dashboard_from = strtotime('-1 week', $dashboard_to);
     } else {
         $default_enter = false;
     }
     //权限带入
     $user = vmc::singleton('desktop_user');
     $is_super = $user->is_super();
     $group = $user->group();
     $group = (array) $group;
     //统一时间格式
     if (strpos($dashboard_from, ':')) {
         $dashboard_from = strtotime($dashboard_from);
         $dashboard_to = strtotime($dashboard_to);
     }
     if ($dashboard_from > $dashboard_to) {
         $tmp_t = $dashboard_to;
         $dashboard_to = $dashboard_from;
         $dashboard_from = $tmp_t;
     }
     //桌面挂件排序,用户自定义
     if ($default_enter && cacheobject::get('desktop.dashboard.widgets' . $dashboard_to, $cache_data) && isset($cache_data['data'])) {
         $this->pagedata['cached_time'] = $cache_data['cached_time'];
         $widgets = $cache_data['data'];
     } else {
         foreach (vmc::servicelist('desktop.widgets') as $key => $obj) {
             if ($is_super || in_array(get_class($obj), $group)) {
                 $item = array('title' => $obj->get_title(), 'layout' => $obj->get_layout(), 'html' => $obj->get_html($dashboard_from, $dashboard_to), 'order' => $obj->get_order());
                 if (method_exists($obj, 'get_classname')) {
                     $item['classname'] = $obj->get_classname();
                 }
                 $widgets[$item['layout']][] = $item;
             }
         }
         if ($default_enter) {
             $cache_data = array('cached_time' => time(), 'data' => $widgets);
             cacheobject::set('desktop.dashboard.widgets' . $dashboard_to, $cache_data, time() + 86400);
             //缓存24小时
         }
     }
     $this->pagedata['widgets'] = $widgets;
     $this->pagedata['dashboard_from'] = $dashboard_from;
     $this->pagedata['dashboard_to'] = $dashboard_to;
     //快捷
     $this->pagedata['tody'] = date('Y-m-d H:i', strtotime(date('Y-m-d')));
     $this->pagedata['from_arr'] = array('w' => date('Y-m-d H:i', strtotime('-1 week', strtotime($this->pagedata['tody']))), 'm' => date('Y-m-d H:i', strtotime('-1 month', strtotime($this->pagedata['tody']))), 'q' => date('Y-m-d H:i', strtotime('-3 month', strtotime($this->pagedata['tody']))));
     $this->display('dashboard.html');
 }
Example #3
0
 function __construct()
 {
     set_time_limit(0);
     cachemgr::init(false);
     cacheobject::init(false);
     kernel::$console_output = true;
     set_error_handler(array(&$this, 'error_handle'));
     if (file_exists(ROOT_DIR . '/config/config.php')) {
         require ROOT_DIR . '/config/config.php';
         $this->status['config'] = ROOT_DIR . '/config/config.php';
     } else {
         $this->status['config'] = 'false';
     }
     include APP_DIR . '/base/defined.php';
     //为shell设置BASE_URL
     if (!defined('BASE_URL')) {
         if ($shell_base_url = app::get('base')->getConf('shell_base_url')) {
             define('BASE_URL', $shell_base_url);
         } else {
             trigger_error('please login backend first!', E_USER_NOTICE);
         }
     }
     date_default_timezone_set(defined('DEFAULT_TIMEZONE') ? 'Etc/GMT' . (DEFAULT_TIMEZONE >= 0 ? DEFAULT_TIMEZONE * -1 : '+' . DEFAULT_TIMEZONE * -1) : 'UTC');
     $this->buildin_commander = new base_shell_buildin($this);
 }
Example #4
0
 /**
  * Determine if the view at the given path is expired.
  *
  * @param  string  $path
  * @return bool
  */
 public function isExpired($object)
 {
     if (cacheobject::get($this->getCompiledCacheKey($object), $cache) === false) {
         return true;
     }
     $lastModified = $object->lastModified();
     return $lastModified >= $cache['lastModified'];
 }
Example #5
0
 public static function instance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = kernel::single(self::$_instance_name);
     }
     //使用实例时再构造实例
     return self::$_instance;
 }
Example #6
0
 function __construct()
 {
     if (!kernel::is_online()) {
         die('error');
     }
     cacheobject::init();
     self::$is_start = true;
 }
Example #7
0
 private function _set_session($value, $ttl)
 {
     if (WITHOUT_CACHE === true) {
         return base_kvstore::instance('sessions')->store($this->_get_cache_key(), $value, $ttl);
     } else {
         return cacheobject::set($this->_get_cache_key(), $value, $ttl + time());
     }
 }
Example #8
0
 private function _set_session($value, $ttl)
 {
     if (!config::get('cache.enabled', true)) {
         return base_kvstore::instance('sessions')->store($this->_get_cache_key(), $value, $ttl);
     } else {
         return cacheobject::set($this->_get_cache_key(), $value, $ttl + time());
     }
 }
Example #9
0
 public function __construct()
 {
     if (config::get('cache.enabled', true) && cacheobject::get('areaKvdata', $areaKvdataCache)) {
         $this->areaKvdata = $areaKvdataCache['area'];
         $this->areaIdPath = $areaKvdataCache['areaIdPath'];
     } else {
         $this->areaKvdata = $this->__preKeyValue();
     }
 }
Example #10
0
 public function getCacheInfo()
 {
     $driver = config::get('cache.default', 'base_cache_secache');
     $aTmp = explode("_", $driver);
     $msg = false;
     cacheobject::status($msg);
     $aResult = array("name" => $aTmp[count($aTmp) - 1], "status" => $msg);
     return $aResult;
 }
Example #11
0
 public function __construct()
 {
     set_time_limit(0);
     cachemgr::init(false);
     cacheobject::init(false);
     vmc::$console_output = true;
     set_error_handler(array(&$this, 'error_handle'));
     $this->buildin_commander = new base_shell_buildin($this);
 }
Example #12
0
 function __construct()
 {
     if (!kernel::is_online()) {
         die('error');
     } else {
         require ROOT_DIR . '/config/config.php';
         @(include APP_DIR . '/base/defined.php');
     }
     cachemgr::init();
     cacheobject::init();
 }
Example #13
0
 function __construct()
 {
     if (!kernel::is_online()) {
         die('error');
     } else {
         @(include APP_DIR . '/base/defined.php');
     }
     cachemgr::init();
     cacheobject::init();
     self::$is_start = true;
 }
Example #14
0
 function __construct()
 {
     if (!kernel::is_online()) {
         die('error');
     } else {
         @(include APP_DIR . '/base/defined.php');
     }
     cachemgr::init();
     cacheobject::init();
     self::$is_start = true;
     //@file_put_contents(ROOT_DIR.'/api_post_log.txt', json_encode($_POST));
 }
Example #15
0
 static function verify($key, $value)
 {
     $sess_id = kernel::single('base_session')->sess_id();
     $key = $key . $sess_id;
     if (defined('WITHOUT_CACHE') && !constant('WITHOUT_CACHE')) {
         cacheobject::get($key, $vcode);
     } else {
         base_kvstore::instance('vcode')->fetch($key, $vcode);
     }
     if ($vcode == $value) {
         return true;
     }
     return false;
 }
Example #16
0
 static function verify($key, $value)
 {
     $value = strtolower($value);
     $sess_id = kernel::single('base_session')->sess_id();
     $vcodekey = $key . $sess_id;
     if (config::get('cache.enabled', true)) {
         cacheobject::get($vcodekey, $vcode);
         //使用后则是过期
         cacheobject::set($vcodekey, $vcode, time() - 1);
     } else {
         base_kvstore::instance('vcode')->fetch($vcodekey, $vcode);
         //使用后则是过期
         base_kvstore::instance('vcode')->store($vcodekey, $vcode, 1);
     }
     if ($vcode == strval($value)) {
         return true;
     }
     return false;
 }
Example #17
0
 public function get_access_token($bind_id = false, $app_define = false)
 {
     if ($app_define) {
         $app_id = $app_define['app_id'];
         $app_secret = $app_define['app_secret'];
     } else {
         $bind = app::get('wechat')->model('bind')->dump($bind_id);
         $app_id = $bind['appid'];
         $app_secret = $bind['appsecret'];
     }
     $http_client = vmc::singleton('base_httpclient');
     if (!cacheobject::get('wechat_access_token_' . $app_id, $access_token) || !$access_token) {
         $access_token_action = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$app_id}&secret={$app_secret}";
         $respnese = $http_client->get($access_token_action);
         $respnese = json_decode($respnese, 1);
         $access_token = $respnese['access_token'];
         if ($access_token) {
             cacheobject::set('wechat_access_token_' . $app_id, $access_token, time() + $respnese['expires_in']);
         }
     }
     return $access_token;
 }
Example #18
0
File: vcode.php Project: noikiy/snk
 public function delete_vcode($account, $type, $vcodeData)
 {
     $vcode = $this->randomkeys(6);
     $vcodeData['vcode'] = $vcode;
     $key = $this->get_vcode_key($account, $type);
     if (WITHOUT_CACHE === true) {
         base_kvstore::instance('vcode/account')->store($key, $vcodeData, $this->ttl);
     } else {
         cacheobject::set($key, $vcodeData, $this->ttl + time());
     }
     return $vcodeData;
 }
Example #19
0
 public function maintenance_theme_files($platform, $theme_dir = '')
 {
     if (!$theme_dir) {
         return;
     }
     set_time_limit(0);
     cacheobject::init(false);
     header('Content-type: text/html;charset=utf-8');
     ignore_user_abort(false);
     ob_implicit_flush(1);
     ini_set('implicit_flush', true);
     kernel::$console_output = true;
     while (ob_get_level()) {
         ob_end_flush();
     }
     echo str_repeat("", 1024);
     echo '<pre>';
     echo '>update themes' . "\n";
     if ($theme_dir == THEME_DIR) {
         $dir = new DirectoryIterator($theme_dir);
         foreach ($dir as $file) {
             $filename = $file->getFilename();
             if ($filename[0] == '.') {
                 continue;
             } else {
                 $this->update_theme_widgets($platform, $filename);
             }
         }
     } else {
         $this->update_theme_widgets($platform, $theme_dir);
     }
     echo 'ok.</pre>';
 }
Example #20
0
 function command_cacheclean()
 {
     logger::info('Cache Clear...');
     if (cacheobject::clean($msg)) {
         logger::info($msg ? $msg : '...Clear Success');
     } else {
         logger::info($msg ? $msg : '...Clear Failure');
     }
     cacheobject::init(false);
 }
Example #21
0
 public function clean()
 {
     $this->begin('');
     $this->end(cacheobject::clean($msg), $msg);
 }
Example #22
0
 /**
  * 不破坏缓存情况下的商品统计
  */
 public function counter($args = array())
 {
     $args = array_merge((array) $args, $this->req_params);
     $mdl_goods = app::get('b2c')->model('goods');
     $gid = $args['goods_id'];
     if (!$gid) {
         return false;
     }
     $db = vmc::database();
     $kv = base_kvstore::instance('b2c_counter');
     foreach ($args as $key => $value) {
         $value = intval($value);
         $update_sql = false;
         if ($value < 1) {
             $value = 1;
         }
         switch ($key) {
             case 'view_count':
                 $this->history($gid);
                 //UV型统计 24小时同一IP记录一次
                 $c_key = 'view_count_uv_' . $gid . '_' . base_request::get_remote_addr();
                 cacheobject::get($c_key, $time);
                 $kv->fetch('view_w_count_time', $vw_last_update);
                 if (!$time || strtotime('+1 day', $time) < time()) {
                     //获得周标记
                     if ($vw_last_update > strtotime('-1 week')) {
                         $update_sql = "UPDATE vmc_b2c_goods SET view_count=view_count+{$value},view_w_count=view_w_count+{$value} WHERE goods_id={$gid}";
                     } else {
                         $update_sql = "UPDATE vmc_b2c_goods SET view_count=view_count+{$value},view_w_count={$value} WHERE goods_id={$gid}";
                         $kv->store('view_w_count_time', time());
                     }
                     cacheobject::set($c_key, time(), 86400 + time());
                 }
                 break;
             case 'buy_count':
                 //验证
                 if (md5($gid . 'buy_count' . $value * 1024) != $args['buy_count_sign']) {
                     break;
                 }
                 //获得周标记
                 $kv->fetch('buy_w_count_time', $bw_last_update);
                 if ($bw_last_update > strtotime('-1 week')) {
                     $update_sql = "UPDATE vmc_b2c_goods SET buy_count=buy_count+{$value},buy_w_count=buy_w_count+{$value} WHERE goods_id={$gid}";
                 } else {
                     $update_sql = "UPDATE vmc_b2c_goods SET buy_count=buy_count+{$value},buy_w_count={$value} WHERE goods_id={$gid}";
                     $kv->store('buy_w_count_time', time());
                 }
                 break;
             case 'comment_count':
                 if (md5($gid . 'comment_count' . $value * 1024) == $args['comment_count_sign']) {
                     $update_sql = "UPDATE vmc_b2c_goods SET comment_count=comment_count+{$value} WHERE goods_id={$gid}";
                 }
                 break;
         }
         if ($update_sql) {
             logger::info($update_sql);
             $db->exec($update_sql, true);
         }
     }
 }
Example #23
0
<?php

ob_implicit_flush(1);
require __DIR__ . '/../../bootstrap/start.php';
kernel::$console_output = true;
cacheobject::init(false);
// 时区设置
//$timezone = config::get('app.timezone', 8);
//date_default_timezone_set('Etc/GMT'.($timezone>=0?($timezone*-1):'+'.($timezone*-1)));
if (!defined('BASE_URL')) {
    if ($shell_base_url = app::get('base')->getConf('shell_base_url')) {
        define('BASE_URL', $shell_base_url);
    } else {
        echo 'Please install ecstore first, and login to the backend ';
    }
}
Example #24
0
 /**
  * 获得子类.
  */
 public function children($parent_id)
 {
     $cache_expired = $this->touch_cache();
     if (cacheobject::get('b2c-gcat-tree-cache-' . $parent_id, $children) && $children && $cache_expired > 0) {
         return $children;
     } else {
         $children = $this->getList('*', array('parent_id' => $parent_id), 0, -1, ' p_order ASC');
         $children = utils::array_change_key($children, 'cat_id');
         cacheobject::set('b2c-gcat-tree-cache-' . $parent_id, $children, time() + 60 * 60 * 24 * 30);
         return $children;
     }
 }
Example #25
0
 public function touch_theme_tmpl($theme)
 {
     $db = app::get('site')->database();
     $qb = $db->createQueryBuilder();
     $rows = $qb->select('*')->from('site_themes_tmpl')->where('theme=' . $qb->createPositionalParameter($theme))->execute()->fetchAll();
     if ($rows) {
         array_push($rows, array('tmpl_path' => 'block/header.html'), array('tmpl_path' => 'block/footer.html'));
         foreach ($rows as $row) {
             $this->touch_tmpl_file($theme . '/' . $row['tmpl_path']);
         }
         kernel::single('site_theme_base')->set_theme_cache_version($theme);
     }
     $cache_keys = $db->executeQuery('SELECT `prefix`, `key` FROM base_kvstore WHERE `prefix` IN ("cache/template", "cache/theme")')->fetchAll();
     foreach ($cache_keys as $value) {
         base_kvstore::instance($value['prefix'])->get_controller()->delete($value['key']);
     }
     app::get('base')->database()->executeUpdate('DELETE FROM base_kvstore WHERE `prefix` IN ("cache/template", "cache/theme")');
     //todo cacheobject touch tmpl时清缓存
     cacheobject::init(true);
     cacheobject::clean($msg);
     cacheobject::init(false);
     return true;
 }
Example #26
0
 static function boot()
 {
     set_error_handler(array('kernel', 'exception_error_handler'));
     try {
         if (!self::register_autoload()) {
             require dirname(__FILE__) . '/autoload.php';
         }
         require ROOT_DIR . '/config/mapper.php';
         if (self::is_online()) {
             require ROOT_DIR . '/config/config.php';
         }
         @(include APP_DIR . '/base/defined.php');
         date_default_timezone_set(defined('DEFAULT_TIMEZONE') ? 'Etc/GMT' . (DEFAULT_TIMEZONE >= 0 ? DEFAULT_TIMEZONE * -1 : '+' . DEFAULT_TIMEZONE * -1) : 'UTC');
         self::$url_app_map = $urlmap;
         foreach (self::$url_app_map as $flag => $value) {
             self::$app_url_map[$value['app']] = $flag;
         }
         if (get_magic_quotes_gpc()) {
             self::strip_magic_quotes($_GET);
             self::strip_magic_quotes($_POST);
         }
         $pathinfo = self::request()->get_path_info();
         $jump = false;
         if (isset($pathinfo[1])) {
             if ($p = strpos($pathinfo, '/', 2)) {
                 $part = substr($pathinfo, 0, $p);
             } else {
                 $part = $pathinfo;
                 $jump = true;
             }
         } else {
             $part = '/';
         }
         if ($part == '/api') {
             return kernel::single('base_rpc_service')->process($pathinfo);
         } elseif ($part == '/openapi') {
             return kernel::single('base_rpc_service')->process($pathinfo);
         } elseif ($part == '/app-doc') {
             //cachemgr::init();
             return kernel::single('base_misc_doc')->display($pathinfo);
         }
         if (isset(self::$url_app_map[$part])) {
             if ($jump) {
                 $request_uri = self::request()->get_request_uri();
                 $urlinfo = parse_url($request_uri);
                 $query = $urlinfo['query'] ? '?' . $urlinfo['query'] : '';
                 header('Location: ' . $urlinfo['path'] . '/' . $query);
                 exit;
             } else {
                 $app = self::$url_app_map[$part]['app'];
                 $prefix_len = strlen($part) + 1;
                 kernel::set_lang(self::$url_app_map[$part]['lang']);
             }
         } else {
             $app = self::$url_app_map['/']['app'];
             $prefix_len = 1;
             kernel::set_lang(self::$url_app_map['/']['lang']);
         }
         if (!$app) {
             readfile(ROOT_DIR . '/app/base/readme.html');
             exit;
         }
         if (!self::is_online()) {
             if (file_exists(APP_DIR . '/setup/app.xml')) {
                 if ($app != 'setup') {
                     //todo:进入安装check
                     setcookie('LOCAL_SETUP_URL', app::get('setup')->base_url(1), 0, '/');
                     header('Location: ' . kernel::base_url() . '/app/setup/check.php');
                     exit;
                 }
             } else {
                 echo '<h1>System is Offline, install please.</h1>';
                 exit;
             }
         }
         // 检查是否手机端
         if (base_mobiledetect::is_mobile()) {
             base_mobiledetect::select_terminator($part, $_GET['ignore_ua_check'], self::$url_app_map);
         }
         if (isset($pathinfo[$prefix_len])) {
             $path = substr($pathinfo, $prefix_len);
         } else {
             $path = '';
         }
         //init cachemgr
         if ($app == 'setup') {
             cachemgr::init(false);
         } else {
             cachemgr::init();
             cacheobject::init();
         }
         //get app router
         self::$__router = app::get($app)->router();
         self::$__router->dispatch($path);
     } catch (Exception $e) {
         base_errorpage::exception_handler($e);
     }
 }
Example #27
0
File: ui.php Project: 453111208/bbc
 function getVer($flag = true, $ver = null)
 {
     return $flag ? '?' . substr(cacheobject::ask_cache_check_version(), 0, 6) : ($ver ? '?' . $ver : '');
 }
Example #28
0
 public static function get_key($key)
 {
     $kvprefix = config::get('cache.prefix', '');
     $key_array['key'] = $key;
     $key_array['kv_prefix'] = $kvprefix;
     $key_array['prefix'] = 'cacheobject';
     $key_array['version'] = cacheobject::get_cache_check_version();
     return md5(serialize($key_array));
 }
Example #29
0
 public function send_email($type, $email, $content)
 {
     if (!($tmpl = $this->sendtypeToTmpl($type))) {
         return false;
     }
     $vcodeData = $this->checkVcode($email, $type);
     $vcode = $this->randomkeys(6);
     $vcodeData['account'] = $email;
     $vcodeData['vcode'] = $vcode;
     $vcodeData['count'] = 1;
     $vcodeData['createtime'] = date('Ymd');
     $vcodeData['lastmodify'] = time();
     $data['shopname'] = app::get('sysconf')->getConf('site.name');
     $data['vcode'] = $content . "&vcode=" . $vcode;
     $key = $this->getVcodeKey($email, $type);
     $result = messenger::sendEmail($email, $tmpl, $data);
     if ($result['rsp'] == "fail") {
         throw new \LogicException(app::get('system')->_('邮件发送失败,请检查邮箱格式是否正确!'));
     }
     if (defined('WITHOUT_CACHE') && !constant('WITHOUT_CACHE')) {
         cacheobject::set($key, $vcodeData, 3600 * 24);
     } else {
         base_kvstore::instance('vcode/account')->store($key, $vcodeData, 3600 * 24);
     }
     return true;
 }
Example #30
0
 private function get_access_token($action_url)
 {
     if (!cacheobject::get('b2c_sms_platform_access_token_' . md5($action_url), $access_token) || !$access_token) {
         $res = $this->net->post($action_url);
         $res = json_decode($res, 1);
         $access_token = $res['access_token'];
         if ($access_token) {
             cacheobject::set('b2c_sms_platform_access_token_' . md5($action_url), $access_token, time() + $res['expires_in']);
         }
     }
     return $access_token;
 }