/** * 执行App控制器 */ public static function execApp() { //防止CSRF if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' && stripos($_SERVER['HTTP_REFERER'], SITE_URL) !== 0 && $_SERVER['HTTP_USER_AGENT'] !== 'Shockwave Flash' && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'adobe flash player') === false && MODULE_NAME != 'Weixin') { exit('illegal request.'); } // 微信自动登陆和绑定 $openid = session('wx_open_id'); $mid = $_SESSION['mid'] ?: $_SESSION['uid']; // var_dump($openid);exit; if ($openid) { $login = Ts\Models\Login::byType('weixin')->byVendorId($openid)->orderBy('login_id', 'desc')->first(); if (!$login && $mid) { $login = new Ts\Model\Login(); $login->uid = $mid; $login->type_uid = $openid; $login->type = 'weixin'; $login->is_sync = 0; $login->save(); // var_dump(123); } // var_dump($openid, $login, $_SESSION);exit; if (!$mid && $login) { $_SESSION['mid'] = $login->uid; } } // 微信 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false && isset($_REQUEST['w_sign']) && !$openid) { U('h5/sign/weixin', '', true); /* # 跳转移动版首页,以后有时间,可以做兼容跳转 */ } elseif ($_SESSION['wap_to_normal'] != 1 and cookie('wap_to_normal') != 1 and $_REQUEST['wap_to_normal'] != 1 and !isiPad() and json_decode(json_encode(model('Xdata')->get('admin_Mobile:setting')), false)->switch and in_array(APP_NAME, array('public', 'channel', 'weiba', 'square', 'people')) and MODULE_NAME != 'Widget' and !in_array(strtolower(MODULE_NAME), array('message', 'register', 'feed')) and strtolower(ACTION_NAME) != 'message' and isMobile()) { if (\Medz\Component\Filesystem\Filesystem::exists(TS_APPLICATION . '/h5') === true) { Jumper::start(); } } $GLOBALS['time_run_detail']['addons_end'] = microtime(true); //创建Action控制器实例 $className = MODULE_NAME . 'Action'; // tsload(APP_ACTION_PATH.'/'.$className.'.class.php'); $action = ACTION_NAME; // action名称 $appTimer = sprintf('%s/%s/app/%s/timer', TS_ROOT, TS_STORAGE, strtolower(APP_NAME)); if (!file_exists($appTimer) || time() - file_get_contents($appTimer) > 604800 || defined('TS_APP_DEV') && TS_APP_DEV == true) { \Ts\Helper\AppInstall::getInstance(APP_NAME)->moveResources(); \Medz\Component\Filesystem\Filesystem::mkdir(dirname($appTimer), 0777); file_put_contents($appTimer, time()); } $app = new \Ts\Helper\Controller(); $app->setApp(APP_NAME)->setController(MODULE_NAME)->setAction(ACTION_NAME)->run(); //执行计划任务 model('Schedule')->run(); $GLOBALS['time_run_detail']['action_run'] = microtime(true); return; }