Esempio n. 1
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. 2
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. 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
<?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');
$service = new \yii\di\ServiceLocator();
$service->set('cache', 'yii\\caching\\FileCache');
//(new yii\web\Application($config))->set('locator', $service);
//(new yii\web\Application($config))->run();
$application = new yii\web\Application($config);
$application->set('locator', $service);
$application->run();
Esempio n. 6
0
 /**
  * @param yii\web\Application $app
  */
 public function bootstrap($app)
 {
     $app->getUrlManager()->addRules([["class" => "yii\\web\\UrlRule", "pattern" => "{$this->id}/?", "route" => "{$this->id}/articles/index"], ["class" => "yii\\web\\UrlRule", "pattern" => "{$this->id}/<controller:[\\w\\-]+>/<action:[\\w\\-]+>", "route" => "{$this->id}/<controller>/<action>"], ["class" => "yii\\web\\UrlRule", "pattern" => "{$this->id}/categories/<id:\\w+>", "route" => "{$this->id}/categories/view"], ["class" => "yii\\web\\UrlRule", "pattern" => "{$this->id}/articles/<id:\\w+>", "route" => "{$this->id}/articles/view"]]);
 }
Esempio n. 7
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. 8
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');
require __DIR__ . '/../config/bootstrap.php';
$application = new yii\web\Application($config);
$application->set('locator', $locator);
$application->run();
Esempio n. 9
0
        echo '<h1>В настоящее время проект fotonastiya.com находится на стадии разработки. Если у Вас возникли вопросы - пишите на почту I@korzun.com.ua</h1>';
        echo '</form>';
        echo '</body>';
        echo '</html>';
        die;
    }

}*/
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/yii/vendor/autoload.php';
require __DIR__ . '/yii/vendor/yiisoft/yii2/Yii.php';
$config = (require __DIR__ . '/yii/config/web.php');
header('Content-Type: text/html; charset=UTF-8', true);
// кодировка в UTF-8
$app_m = new yii\web\Application($config);
if (Yii::$app->request->cookies->has('language')) {
    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);
Esempio n. 10
0
 function __construct($appConfig)
 {
     parent::__construct($appConfig);
 }