Esempio n. 1
0
 public function run()
 {
     try {
         return parent::run();
     } catch (Exception $exc) {
         Yii::error(print_r('RUN LOG:' . $exc, true));
         \app\helpers\Flash::setUndisplayError($exc->getMessage());
         header("location:/site/oooops");
     }
 }
Esempio n. 2
0
 public function runTest()
 {
     if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
         die('You are not allowed to access this file.');
     }
     if (!is_array($this->appConfig)) {
         say("You must load your configure file in" . PATH_WEBROOT . 'index-test.php');
         exit;
     }
     $application = new yii\web\Application($this->appConfig);
     $application->run();
 }
Esempio n. 3
0
<?php

defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
defined('REALM') or define('REALM', 'TmCt');
error_reporting(E_ALL & ~E_NOTICE);
require __DIR__ . '/../../vendor/autoload.php';
require __DIR__ . '/../../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../../common/config/aliases.php';
$config = yii\helpers\ArrayHelper::merge(require Yii::getAlias('@common') . '/config/main.php', require Yii::getAlias('@common') . '/config/main-local.php', require Yii::getAlias('@api') . '/config/main.php', require Yii::getAlias('@api') . '/config/main-local.php');
/*
echo '<pre>';
print_r($config);
echo '</pre>';
///*/
$application = new yii\web\Application($config);
$application->run();
Esempio n. 4
0
<?php

// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/vendor/yiisoft/yii2/Yii.php';
$config = (require __DIR__ . '/config/web.php');
$app = new yii\web\Application($config);
$app->run();
Esempio n. 5
0
 public static function run($config1, $config2)
 {
     //截取路径第一部分
     $paths = explode('/', $_SERVER['REQUEST_URI']);
     $first = '';
     if (!empty($paths[0])) {
         $first = $paths[0];
     } elseif (!empty($paths[1])) {
         $first = $paths[1];
     }
     if (in_array($first, $config1['params']['urlPrefix'])) {
         $app = new yii\web\Application($config2);
         restore_error_handler();
         restore_exception_handler();
         static::createWebApplication($config1)->run();
     } else {
         static::createWebApplication($config1);
         if (!empty($config1['import'])) {
             Yii::app()->setImport($config1['import']);
         }
         restore_error_handler();
         restore_exception_handler();
         $app = new yii\web\Application($config2);
         $app->run();
     }
 }
Esempio n. 6
0
    Yii::$app->language = Yii::$app->request->cookies['language'];
}
if (!Yii::$app->user->isGuest) {
    if (!isset($_COOKIE['lastVisit']) || time() - $_COOKIE['lastVisit'] >= 60) {
        \app\models\User::updateLastVisit();
        setcookie("lastVisit", time(), time() - 3600);
        setcookie("lastVisit", time());
    }
}
if (!isset($_COOKIE['width'])) {
    if (isset($_GET['width'])) {
        setcookie("width", $_GET['width']);
        $language = ['uk' => 'uk-UA', 'ru' => 'ru-RU', 'en' => 'en-GB', 'fr' => 'fr-FR', 'de' => 'de-DE', 'es' => 'es-ES', 'zh' => 'zh-CN'];
        setcookie("language", $language[$_GET['language']], time() + 3600 * 24 * 365);
        if (@$_SERVER['HTTP_REFERER'] != null) {
            header("Location: " . $_SERVER['HTTP_REFERER']);
        }
    } else {
        echo "<script language='javascript'>\n";
        echo " var lang = window.navigator.userLanguage || window.navigator.language;";
        echo " location.href=\"{$_SERVER['SCRIPT_NAME']}?{$_SERVER['QUERY_STRING']}" . "width=\" + window.innerWidth + \"&language=\" + lang;\n";
        echo "</script>\n";
        die;
    }
} else {
    Yii::$app->params['width'] = $_COOKIE['width'];
    if (!isset($_COOKIE['first_time'])) {
        setcookie('first_time', 1, time() + 3600 * 24 * 365);
    }
    $app_m->run();
}