// ['en','es','zh-CN','zh-TW']; $sys_surport_language = $this->sys_surport_default_lan ; foreach($sys_surport_language as $key => $value){ $sys_surport_language[$key] = strtolower($value); } $lan ='en'; $browser_lan_order = strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']); $browser_lan_order = explode(',',$browser_lan_order); $all_order_lan = []; foreach($browser_lan_order as $key => $value){ $lan_tmp = explode(';',$value); $lan_one = strtolower($lan_tmp[0]); if( $lan_one == 'zh-hk'){ $lan_one = 'zh-tw'; }
foreach($sys_surport_language as $key => $value){ $sys_surport_language[$key] = strtolower($value); } $lan ='en'; $browser_lan_order = strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']); $browser_lan_order = explode(',',$browser_lan_order); $all_order_lan = []; foreach($browser_lan_order as $key => $value){ $lan_tmp = explode(';',$value); $lan_one = strtolower($lan_tmp[0]);
$url = Yii::$app->request->getUrl(); if (isset($_GET['user']) && $_GET['user'] == 'Guest' && isset($_GET['company'])) { $_SESSION['guest_company'] = $_GET['company']; } if( empty($session["user_name"]) ){ //未登录,需要先登录805071 $this->setLanguage_login(); /*guset 免登录 bhz 2023.9.13*/ if (isset($_GET['user']) && $_GET['user'] == 'Guest') { $data = []; $data['username'] = 'Guest'; $data['company'] = $_GET['company']; $data['pwd'] = 123456;
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
* @param array $config name-value pairs that will be used to initialize the object properties. */ public function __construct($id, $module, $config = []) { $this->id = $id; $this->module = $module; parent::__construct($config); } /** * Declares external actions for the controller. * This method is meant to be overwritten to declare external actions for the controller. * It should return an array, with array keys being action IDs, and array values the corresponding
$dependencies = $this->resolveDependencies($dependencies, $reflection); if (!$reflection->isInstantiable()) { throw new NotInstantiableException($reflection->name); } if (empty($config)) { return $reflection->newInstanceArgs($dependencies); } if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten) $dependencies[count($dependencies) - 1] = $config; return $reflection->newInstanceArgs($dependencies);
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
* @throws InvalidConfigException if the configuration is invalid. * @see \yii\di\Container */ public static function createObject($type, array $params = []) { if (is_string($type)) { return static::$container->get($type, $params); } elseif (is_array($type) && isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } elseif (is_callable($type, true)) { return static::$container->invoke($type, $params);
$className = ltrim($this->controllerNamespace . '\\' . str_replace('/', '\\', $prefix) . $className, '\\'); if (strpos($className, '-') !== false || !class_exists($className)) { return null; } if (is_subclass_of($className, 'yii\base\Controller')) { $controller = Yii::createObject($className, [$id, $this]); return get_class($controller) === $className ? $controller : null; } elseif (YII_DEBUG) { throw new InvalidConfigException("Controller class must extend from \\yii\\base\\Controller."); } return null; }
if (($pos = strrpos($route, '/')) !== false) { $id .= '/' . substr($route, 0, $pos); $route = substr($route, $pos + 1); } $controller = $this->createControllerByID($id); if ($controller === null && $route !== '') { $controller = $this->createControllerByID($id . '/' . $route); $route = ''; } return $controller === null ? false : [$controller, $route];
* @param array $params the parameters to be passed to the action * @return mixed the result of the action. * @throws InvalidRouteException if the requested route cannot be resolved into an action successfully. */ public function runAction($route, $params = []) { $parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params);
$params = $this->catchAll; unset($params[0]); } try { Yii::trace("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } else { $response = $this->getResponse(); if ($result !== null) { $response->data = $result;
try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
$config = yii\helpers\ArrayHelper::merge( require(__DIR__ . '/../../common/config/main.php'), require(__DIR__ . '/../../common/config/main-local.php'), require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main-local.php') ); (new yii\web\Application($config))->run(); ?>
$_GET = [ 'r' => 'site/login', ]; $_SESSION = [ '__flash' => [], 'upload_max_filesize' => 20971520, 'max_file_uploads' => 20, ];