Example #1
0
 private function _init_config()
 {
     $config = jconf::get();
     define('CHARSET', $config['charset']);
     @header('Content-Type: text/html; charset=' . CHARSET);
     @header('P3P: CP="CAO PSA OUR"');
     if ($config['install_lock_time'] < 1) {
         if (!is_file(ROOT_PATH . 'data/install.lock') && is_file(ROOT_PATH . 'install.php')) {
             die("<meta http-equiv='refresh' content=\"1; URL='./install.php'\">\r\n\t\t\t\t\t<a href='./install.php'>Please click here for the installation of the system ... </a>");
         }
     }
     if (!isset($config['charset'])) {
         exit('config get invalid');
     }
     require ROOT_PATH . 'setting/constants.php';
     $config['sys_version'] = sys_version();
     $config['sys_published'] = SYS_PUBLISHED;
     if (!$config['wap_url']) {
         $config['wap_url'] = $config['site_url'] . "/wap";
     }
     if (!$config['mobile_url']) {
         $config['mobile_url'] = $config['site_url'] . "/mobile";
     }
     if ($config['extra_domains']) {
         $http_host = getenv('HTTP_HOST') ? getenv('HTTP_HOST') : $_SERVER['HTTP_HOST'];
         if ($config['site_domain'] != $http_host && in_array($http_host, $config['extra_domains'])) {
             $site_url = rtrim(jhtmlspecialchars('http' . (443 == $_SERVER['SERVER_PORT'] ? 's' : '') . ':/' . '/' . $http_host . preg_replace("/\\/+/", '/', str_replace("\\", '/', dirname($_SERVER['PHP_SELF'])) . "/")), '/');
             if (true === IN_JISHIGOU_WAP || true === IN_JISHIGOU_MOBILE) {
                 $site_url = str_replace(array('/wap', '/mobile'), '', $site_url);
             }
             $config['wap_url'] = str_replace($config['site_url'], $site_url, $config['wap_url']);
             $config['mobile_url'] = str_replace($config['site_url'], $site_url, $config['mobile_url']);
             $config['site_url'] = $site_url;
             $config['site_domain'] = $http_host;
         }
     }
     if (!$config['topic_cut_length']) {
         $config['topic_cut_length'] = 140;
         if (!isset($config['topic_input_length'])) {
             $config['topic_input_length'] = 140;
         }
     }
     $config['topic_input_length'] = (int) $config['topic_input_length'];
     Obj::register('config', $config);
     $load_configs = array('robot' => 'robot_enable', 'ad' => 'ad_enable', 'credits' => 'extcredits_enable');
     foreach ($load_configs as $k => $v) {
         if ($config[$v]) {
             $config[$k] = jconf::get($k);
         }
     }
     $load_configs = array('modules', 'table', 'changeword');
     foreach ($load_configs as $k) {
         $config[$k] = jconf::get($k);
     }
     $config['changeword']['n_weibo'] || ($config['changeword']['n_weibo'] = '微博');
     $config['changeword']['p_weibo'] || ($config['changeword']['p_weibo'] = '微博');
     $config['changeword']['weiqun'] || ($config['changeword']['weiqun'] = '微群');
     $config['changeword']['dig'] || ($config['changeword']['dig'] = '赞');
     $config['changeword']['username'] || ($config['changeword']['username'] = '******');
     $config['changeword']['account'] || ($config['changeword']['account'] = '帐号昵称');
     $config['seccode_comment'] || ($config['seccode_comment'] = 0);
     $config['seccode_forward'] || ($config['seccode_forward'] = 0);
     $config['in_publish_notice_js'] = $this->_php_js_arr($config['in_publish_notice'], 0);
     $config['in_publish_notice_str'] = $this->_php_js_arr($config['in_publish_notice'], 1);
     $config['on_publish_notice_str'] = $this->_php_js_arr($config['on_publish_notice'], 1);
     $this->var['charset'] = strtolower($config['charset']);
     $this->var['db_charset'] = $config['db_charset'] = str_replace('-', '', $this->var['charset']);
     $this->var['site_name'] = $config['site_name'];
     $this->var['site_url'] = $config['site_url'];
     $this->var['wap_url'] = $config['wap_url'];
     $this->var['mobile_url'] = $config['mobile_url'];
     $this->var['config'] =& $config;
 }
Example #2
0
 function MasterObject(&$config)
 {
     require_once ROOT_PATH . 'mobile/include/func/mobile.func.php';
     $config['client_type'] = '';
     $user_agent = $_SERVER['HTTP_USER_AGENT'];
     if (empty($user_agent)) {
         exit('Access Denied');
     }
     $pc_browser = false;
     if (preg_match("/android/i", $user_agent)) {
         $config['client_type'] = "android";
     } else {
         if (preg_match("/iphone/i", $user_agent)) {
             $config['client_type'] = "iphone";
         } else {
             $pc_browser = true;
         }
     }
     $config['is_mobile_client'] = false;
     if (isset($_GET['JSG_SESSION']) && isset($_GET['iv']) && isset($_GET['app_key']) && isset($_GET['app_secret']) && isset($_GET['bt'])) {
         $config['is_mobile_client'] = true;
         define("IS_MOBILE_CLIENT", true);
     }
     define("CLIENT_TYPE", $config['client_type']);
     $config['sys_version'] = sys_version();
     $config['sys_published'] = SYS_PUBLISHED;
     if (!$config['mobile_url']) {
         $config['mobile_url'] = $config['site_url'] . "/mobile";
     }
     if (!$config['topic_length']) {
         $config['topic_length'] = 140;
     }
     $this->Config = $config;
     $this->Config = array_merge($this->Config, Mobile::config());
     define("CHARSET", $this->Config['charset']);
     Obj::register('config', $this->Config);
     $this->Get =& $_GET;
     $this->Post =& $_POST;
     $this->Module = trim($this->Post['mod'] ? $this->Post['mod'] : $this->Get['mod']);
     $this->Code = trim($this->Post['code'] ? $this->Post['code'] : $this->Get['code']);
     $this->DatabaseHandler =& Obj::registry('DatabaseHandler');
     $uid = 0;
     $password = '';
     $authcode = '';
     $implicit_pass = true;
     if (!empty($this->Get['JSG_SESSION']) && $config['is_mobile_client']) {
         $authcode = $this->Get['JSG_SESSION'];
         $authcode = rawurldecode($authcode);
         $implicit_pass = false;
     } else {
         $authcode = jsg_getcookie('auth');
     }
     if (!empty($authcode)) {
         list($password, $uid) = explode("\t", authcode($authcode, 'DECODE'));
     }
     $this->MemberHandler = jclass('member');
     $MemberFields = $this->MemberHandler->FetchMember($uid, $password);
     if ($this->MemberHandler->HasPermission($this->Module, $this->Code) == false) {
         Mobile::show_message(411);
         exit;
     }
     if (!in_array($this->Module, array('member', 'login', 'wechat'))) {
         $visit_rets = $this->MemberHandler->visit();
         if ($visit_rets['error']) {
             Mobile::show_message(411);
             exit;
         }
     }
     $this->Title = $this->MemberHandler->CurrentAction['name'];
     Obj::register("MemberHandler", $this->MemberHandler);
     $rets = jsg_member_login_extract();
     if ($rets) {
         if (MEMBER_ID < 1) {
             $func = $rets['login_direct'];
         } else {
             $func = $rets['logout_direct'];
         }
         if ($func && function_exists($func)) {
             $ret = $func();
         }
     }
     if (MEMBER_ID > 0) {
         jsg_member_login_set_status($MemberFields);
     }
     if ($this->Config['extcredits_enable']) {
         if (MEMBER_ID > 0 && jsg_getcookie('login_credits') + 3600 < time()) {
             update_credits_by_action('login', MEMBER_ID);
             jsg_setcookie('login_credits', time(), 3600);
         }
     }
 }