Author: Seven Du (lovevipdsw@outlook.com)
Beispiel #1
0
 /**
  * 执行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;
 }
Beispiel #2
0
    tsdefine('THEME_NAME', 'stv1');
}
//默认静态文件、模版文件目录
tsdefine('THEME_PATH', ADDON_PATH . '/theme/' . THEME_NAME);
tsdefine('THEME_URL', ADDON_URL . '/theme/' . THEME_NAME);
tsdefine('THEME_PUBLIC_PATH', THEME_PATH . '/_static');
tsdefine('THEME_PUBLIC_URL', THEME_URL . '/_static');
tsdefine('APP_PUBLIC_PATH', APP_PATH . '/_static');
// tsdefine('APP_PUBLIC_URL', APP_URL.'/_static');
tsdefine('APP_TPL_PATH', APP_PATH . '/Tpl/default');
tsdefine('APP_TPL_URL', APP_URL . '/Tpl/default');
tsdefine('CANVAS_PATH', SITE_PATH . '/config/canvas/');
/* 临时兼容代码,新方法开发中 */
$timer = sprintf('%s%s/app/timer', TS_ROOT, TS_STORAGE);
if (!file_exists($timer) || time() - file_get_contents($timer) > 604800) {
    \Ts\Helper\AppInstall::moveAllApplicationResources();
    // 移动应用所有的资源
    \Medz\Component\Filesystem\Filesystem::mkdir(dirname($timer), 0777);
    file_put_contents($timer, time());
}
define('APP_PUBLIC_URL', sprintf('%s%s/app/%s', SITE_URL, TS_STORAGE, strtolower(APP_NAME)));
//设置语言包
setLang();
/*
 * 新应用入口文件
 */
if (file_exists(sprintf('%s/bootstrap.php', APP_PATH))) {
    Ts::import(APP_PATH, 'bootstrap', '.php');
    /*
     * 兼容旧的应用
     */