* @see open() * @see isActive */ public function regenerateID($deleteOldSession = false) { if ($this->getIsActive()) { // add @ to inhibit possible warning due to race condition // https://github.com/yiisoft/yii2/pull/1812 if (YII_DEBUG && !headers_sent()) { session_regenerate_id($deleteOldSession); } else { @session_regenerate_id($deleteOldSession); } } } /** * Gets the name of the current session. * This is a wrapper for [PHP session_name()](http://php.net/manual/en/function.session-name.php).
public function regenerateID($deleteOldSession = false) { if ($this->getIsActive()) { // add @ to inhibit possible warning due to race condition // https://github.com/yiisoft/yii2/pull/1812 if (YII_DEBUG && !headers_sent()) { session_regenerate_id($deleteOldSession); } else { @session_regenerate_id($deleteOldSession); } } }
// if no session is started, there is nothing to regenerate if (empty($oldID)) { return; } parent::regenerateID(false); $newID = session_id(); // if session id regeneration failed, no need to create/update it. if (empty($newID)) { Yii::warning('Failed to generate new session ID', __METHOD__); return; }
if ($this->enableAutoLogin) { $this->removeIdentityCookie(); } $session = Yii::$app->getSession(); if (!YII_ENV_TEST) { $session->regenerateID(true); } $session->remove($this->idParam); $session->remove($this->authTimeoutParam); if ($identity) { $session->set($this->idParam, $identity->getId());
{ $data = $this->getIdentityAndDurationFromCookie(); if (isset($data['identity'], $data['duration'])) { $identity = $data['identity']; $duration = $data['duration']; if ($this->beforeLogin($identity, true, $duration)) { $this->switchIdentity($identity, $this->autoRenewCookie ? $duration : 0); $id = $identity->getId(); $ip = Yii::$app->getRequest()->getUserIP(); Yii::info("User '$id' logged in from $ip via cookie.", __METHOD__); $this->afterLogin($identity, true, $duration); } }
$session->set($this->authTimeoutParam, time() + $this->authTimeout); } } if ($this->enableAutoLogin) { if ($this->getIsGuest()) { $this->loginByCookie(); } elseif ($this->autoRenewCookie) { $this->renewIdentityCookie(); } } }
*/ public function getIdentity($autoRenew = true) { if ($this->_identity === false) { if ($this->enableSession && $autoRenew) { $this->_identity = null; $this->renewAuthStatus(); } else { return null; } } return $this->_identity;
* Returns a value indicating whether the user is a guest (not authenticated). * @return bool whether the current user is a guest. * @see getIdentity() */ public function getIsGuest() { return $this->getIdentity() === null; } /** * Returns a value that uniquely represents the user. * @return string|int the unique identifier for the user. If `null`, it means the user is a guest. * @see getIdentity()
*/ public function __get($name) { $getter = 'get' . $name; if (method_exists($this, $getter)) { // read property, e.g. getName() return $this->$getter(); } // behavior property $this->ensureBehaviors(); foreach ($this->_behaviors as $behavior) { if ($behavior->canGetProperty($name)) {
<?php /* @var $panel yii\debug\panels\UserPanel */ ?> <div class="yii-debug-toolbar__block"> <a href="<?= $panel->getUrl() ?>"> <?php if (Yii::$app->user->isGuest): ?> <span class="yii-debug-toolbar__label">Guest</span> <?php else: ?> User <span class="yii-debug-toolbar__label yii-debug-toolbar__label_info"><?= Yii::$app->user->id ?></span> <?php endif; ?> </a> </div>
{ $_obInitialLevel_ = ob_get_level(); ob_start(); ob_implicit_flush(false); extract($_params_, EXTR_OVERWRITE); try { require($_file_); return ob_get_clean(); } catch (\Exception $e) { while (ob_get_level() > $_obInitialLevel_) { if (!@ob_end_clean()) { ob_clean(); }
$this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /* @var $renderer ViewRenderer */ $renderer = $this->renderers[$ext]; $output = $renderer->render($this, $viewFile, $params); } else { $output = $this->renderPhpFile($viewFile, $params); } $this->afterRender($viewFile, $params, $output); } array_pop($this->_viewFiles); $this->context = $oldContext;
* @throws InvalidCallException if the view cannot be resolved. * @see renderFile() */ public function render($view, $params = [], $context = null) { $viewFile = $this->findViewFile($view, $context); return $this->renderFile($viewFile, $params, $context); } /** * Finds the view file based on the given view name. * @param string $view the view name or the [path alias](guide:concept-aliases) of the view file. Please refer to [[render()]] * on how to specify this parameter.
/** * @inheritdoc */ public function getSummary() { return Yii::$app->view->render('panels/user/summary', ['panel' => $this]); } /** * @inheritdoc */ public function getDetail()
<div class="yii-debug-toolbar__block yii-debug-toolbar__title"> <a href="#"> <img width="30" height="30" alt="" src="<?= \yii\debug\Module::getYiiLogo() ?>"> </a> </div> <?php foreach ($panels as $panel): ?> <?= $panel->getSummary() ?> <?php endforeach; ?> </div> </div> <div class="container"> <div class="row">
{ $_obInitialLevel_ = ob_get_level(); ob_start(); ob_implicit_flush(false); extract($_params_, EXTR_OVERWRITE); try { require($_file_); return ob_get_clean(); } catch (\Exception $e) { while (ob_get_level() > $_obInitialLevel_) { if (!@ob_end_clean()) { ob_clean(); }
$this->renderers[$ext] = Yii::createObject($this->renderers[$ext]); } /* @var $renderer ViewRenderer */ $renderer = $this->renderers[$ext]; $output = $renderer->render($this, $viewFile, $params); } else { $output = $this->renderPhpFile($viewFile, $params); } $this->afterRender($viewFile, $params, $output); } array_pop($this->_viewFiles); $this->context = $oldContext;
* @throws InvalidCallException if the view cannot be resolved. * @see renderFile() */ public function render($view, $params = [], $context = null) { $viewFile = $this->findViewFile($view, $context); return $this->renderFile($viewFile, $params, $context); } /** * Finds the view file based on the given view name. * @param string $view the view name or the [path alias](guide:concept-aliases) of the view file. Please refer to [[render()]] * on how to specify this parameter.
* These parameters will not be available in the layout. * @return string the rendering result. * @throws InvalidParamException if the view file or the layout file does not exist. */ public function render($view, $params = []) { $content = $this->getView()->render($view, $params, $this); return $this->renderContent($content); } /** * Renders a static string by applying a layout. * @param string $content the static string being rendered
$this->loadData($tag); return $this->render('index', [ 'panels' => $this->module->panels, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'manifest' => $this->getManifest(), ]); } public function actionView($tag = null, $panel = null) { if ($tag === null) {
$args = $this->controller->bindActionParams($this, $params); Yii::trace('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$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); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$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();
header("Access-Control-Allow-Credentials: true"); header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); header("Access-Control-Allow-Headers: XMLHttpRequest,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Cookie,Origin,X-CSRF-Token"); header("Access-Control-Max-Age: 1728000"); (new yii\web\Application($config))->run();