public function beforeAction($action) { if (Yii::app()->user->isGuest) { $controller = Yii::app()->controller->getId(); if ($controller != "default" || $action->getId() != 'login' && $action->getId() != 'index' && $action->getId() != 'captcha') { $this->redirect('/console/default/login'); } } else { $userModel = CatalogUsers::fetch(Yii::app()->user->id); if (!$userModel || !$userModel->type_id) { Yii::app()->user->logout(); $this->redirect('/console/default/login'); } if ($userModel->type_id->id == 1) { $this->redirect('/'); } } /* if ($this->getBackendUser()->getState('expires') > 0 && $this->getBackendUser()->getState('expires') < time()) { $this->getBackendUser()->logout(false); $this->redirect('/console'); } else { $this->checkAccess(); }*/ return parent::beforeAction($action); }
/** * Run before each action. * * @param CAction $action Passed action from Yii. * * @return boolean */ public function beforeAction($action) { if ($action->Id == "checkout" && _xls_get_conf('ENABLE_SSL') == 1) { if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') { $this->redirect(Yii::app()->createAbsoluteUrl('cart/' . $action->Id, array(), 'https')); Yii::app()->end(); } } // For passing a cart when not logged in under Common SSL if ($action->Id == "checkout" && Yii::app()->isCommonSSL && Yii::app()->user->isGuest) { $c = Yii::app()->getRequest()->getQuery('c'); if (isset($c)) { $item = explode(",", _xls_decrypt($c)); Yii::app()->shoppingcart->assign($item[0]); } } if (Yii::app()->shoppingcart->wasCartModified && Yii::app()->request->isAjaxRequest === false) { // Web Store has removed cart items or modified requested quantities // to reflect recent updates to inventory. // Since these changes may have invalidated the end user's originally selected shipping // option, clear cache of shipping info. When the user returns to checkout they will be // forced to recalculate shipping and choose from valid options Yii::app()->shoppingcart->clearCachedShipping(); // Redirect the user to the index page and display the relevant message. $this->redirect(Yii::app()->createUrl('cart/index')); } return parent::beforeAction($action); }
public function beforeAction($action) { if ($this->forceAjax) { $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; } return parent::beforeAction($action); }
protected function beforeAction($action) { //increase the max execution time @ini_set('max_execution_time', -1); //initial needed session variables $migrated_data = array('website_ids' => array(), 'store_group_ids' => array(), 'store_ids' => array(), 'category_ids' => array(), 'product_type_ids' => array(), 'product_ids' => array(), 'customer_group_ids' => array(), 'customer_ids' => array(), 'sales_object_ids' => array(), 'sales_order_ids' => array(), 'sales_quote_ids' => array(), 'sales_invoice_ids' => array(), 'sales_shipment_ids' => array(), 'sales_credit_ids' => array(), 'object_ids' => array(), 'review_ids' => array(), 'rating_ids' => array(), 'other_object_ids' => array()); $migratedObj = (object) $migrated_data; //update migrated data $steps = MigrateSteps::model()->findAll("status = " . MigrateSteps::STATUS_DONE); if ($steps) { foreach ($steps as $step) { $migrated_data = json_decode($step->migrated_data); if ($migrated_data) { $attributes = get_object_vars($migrated_data); if ($attributes) { foreach ($attributes as $attr => $value) { $migratedObj->{$attr} = $value; } } } } } $attributes = get_object_vars($migratedObj); if ($attributes) { foreach ($attributes as $attr => $value) { Yii::app()->session['migrated_' . $attr] = $value; } } //end initial needed session variables return parent::beforeAction($action); }
protected function beforeAction($action) { $reca = parent::beforeAction($action); return $reca; //check whether authenticated if (Yii::app()->request->isPostRequest) { //decode json try { $this->postData = json_decode(file_get_contents("php://input")); } catch (Exception $e) { throw new CHttpException(400, 'Bad request, invalid input format!'); } //validate schema $validator = new JsonSchema\Validator(); $validator->check($this->postData, ApiSchema::Schema(Yii::app()->controller->action->id)); if (!$validator->isValid()) { $ret = ''; foreach ($validator->getErrors() as $error) { $ret .= '"' . $error['property'] . '" ' . $error['message'] . '<br />'; } throw new CHttpException(401, 'Input data is invalid!'); } //validate token if ($this->validateToken($this->postData->token)) { throw new CHttpException(402, 'Token is invalid!'); } } return $reca; }
/** * A method that will be triggered before calling action method. * Any changes here will reflect then on Controller::triggerComponents() method * */ public function beforeAction() { parent::beforeAction(); $action = $this->request->param('action'); $actions = ['getUsers', 'updateUserInfo', 'deleteUser']; // define the action methods that needs to be triggered only through POST & Ajax request. $this->Security->requireAjax($actions); $this->Security->requirePost($actions); // You need to explicitly define the form fields that you expect to be returned in POST request, // if form field wasn't defined, this will detected as form tampering attempt. switch ($action) { case "getUsers": $this->Security->config("form", ['fields' => ['name', 'email', 'role', 'page']]); break; case "updateUserInfo": $this->Security->config("form", ['fields' => ['user_id', 'name', 'password', 'role']]); break; case "deleteUser": $this->Security->config("form", ['fields' => ['user_id']]); break; case "updateBackup": case "restoreBackup": $this->Security->config("validateCsrfToken", true); break; } }
protected function beforeAction($action) { if ($_SERVER['SERVER_NAME'] == "127.0.0.1" || $_SERVER['SERVER_NAME'] == "localhost") { Yii::app()->assetManager->forceCopy = true; } return parent::beforeAction($action); }
public function beforeAction($action) { if (Yii::app()->user->isGuest && $action->id != 'login') { $this->redirect(array('/users/userAdmin/login', 'redirect' => base64_encode($_SERVER['REQUEST_URI']))); } return parent::beforeAction($action); }
public function beforeAction($action) { if (isset(Yii::app()->session['type'])) { Yii::app()->singly->setAccessToken(Yii::app()->session['token']); } return parent::beforeAction($action); }
public function beforeAction() { //是否已经登录 if (HSession::isLogin()) { $access_token_deadline = HSession::get('access_token_deadline', 0); if ($access_token_deadline > time()) { return parent::beforeAction(); } } //获取code $code = $this->getParams('code', false); if ($code) { $user_data = WeiXin::model()->getUserWebAccessToken($code); $user_data['access_token_deadline'] = $user_data['expires_in'] + time(); $user_info = WeiXin::model()->getSnsUserInfo($user_data['access_token'], $user_data['openid']); $user_data['nickname'] = isset($user_info['nickname']) ? $user_info['nickname'] : ''; $user_data['sex'] = isset($user_info['sex']) ? $user_info['sex'] : ''; $user_data['city'] = isset($user_info['city']) ? $user_info['city'] : ''; $user_data['unionid'] = isset($user_info['unionid']) ? $user_info['unionid'] : ''; HSession::login($user_data); return parent::beforeAction(); } //跳转到微信auth2验证接口 $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $auth2url = WeiXin::model()->getAuth2Url($url); $this->redirect($auth2url); }
public function beforeAction() { parent::beforeAction(); $this->vars['globalPage'] = "newsfeed"; $action = $this->request->param('action'); $actions = ['getAll', 'create', 'getUpdateForm', 'update', 'getById', 'delete']; $this->Security->requireAjax($actions); $this->Security->requirePost($actions); switch ($action) { case "getAll": $this->Security->config("form", ['fields' => ['page_number']]); break; case "create": $this->Security->config("form", ['fields' => ['content']]); break; case "getUpdateForm": $this->Security->config("form", ['fields' => ['newsfeed_id']]); break; case "update": $this->Security->config("form", ['fields' => ['newsfeed_id', 'content']]); break; case "getById": case "delete": $this->Security->config("form", ['fields' => ['newsfeed_id']]); break; } }
public function beforeAction($action) { if (Yii::app()->user->isGuest) { $this->redirect('/wechat/help/nologin'); } return parent::beforeAction($action); }
public function beforeAction($action) { if (!$this->isSecureRequest()) { echo ':)'; Yii::app()->end(); } return parent::beforeAction($action); }
/** * We want to ensure Wish lists are enabled before a user can view, * search and-or create lists. So, we display an exception to prevent * running any of these processes. * * @param CAction $action * @return bool * @throws CHttpException */ public function beforeAction($action) { if (_xls_get_conf('ENABLE_WISH_LIST', 0) == 0) { _xls_404('Wish lists are not enabled on this store.'); return false; } return parent::beforeAction($action); }
/** * Establecer como fondo de la pagina "bg-estadio-dentro" * * > Llamada a la funcion ```beforeAction``` * * @param object $action * @return true */ public function beforeAction($action) { if (!parent::beforeAction($action)) { return false; } Yii::app()->setParams(array('bgclass' => 'bg-estadio-dentro')); return true; }
public function beforeAction($action) { //js Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . "/js/main.js", CClientScript::POS_END); //css Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . "/css/main.css"); return parent::beforeAction($action); }
protected function beforeAction($action) { // проверка на то, что сайт уже установлен... if (file_exists($this->alreadyInstalledFlag) && !in_array($this->{$_freeActions}, $this->action->id)) { throw new CHttpException(404, Yii::t('install', 'Страница не найдена!')); } return parent::beforeAction($action); }
protected function beforeAction($action) { Yii::import('application.statistics.*'); if (parent::beforeAction($action)) { $this->breadcrumbs = array('Results' => array('/results/index'), ucfirst($this->action->id)); return true; } }
public function beforeAction($action) { Yii::app()->bootstrap->init(); if (Yii::app()->user->isGuest && $action->id != 'login') { $this->redirect(array('/admin/login')); } return parent::beforeAction($action); }
public function beforeAction($action) { if (!Yii::app()->user->isGuest && $action->id == 'login') { $this->redirect(array('loggedin')); return false; } return parent::beforeAction($action); }
public function beforeAction($action) { if (MenuLoader::isGuest()) { $this->redirect(array('site/login')); Yii::app()->end(); } return parent::beforeAction($action); }
public function beforeAction($action) { parent::beforeAction($action); if ($this->module !== null) { $this->breadcrumbs[$this->module->Id] = array('/' . $this->module->Id); } return true; }
protected function beforeAction($action) { parent::beforeAction($action); $accessRules = $this->mobcentAccessRules(); $checkLogin = isset($accessRules[$action->id]) ? $accessRules[$action->id] : true; $this->checkUserAccess($checkLogin); return true; }
protected function beforeAction($action) { if (parent::beforeAction($action)) { $deployKey = Yii::app()->getParams()->itemAt('deployKey'); return $deployKey !== null && $deployKey === Yii::app()->request->getParam('key'); } return false; }
public function beforeAction($action) { if ($this->module->conversationMode) { $this->redirect(array('thread/index')); } $this->_userId = Yii::app()->getModule('pm')->getUserId(); $this->breadcrumbs = array(PmModule::t('Personal messages') => array('/pm')); return parent::beforeAction($action); }
protected function beforeAction($action) { $this->image_folder = TelemedellinForm::getImageRoute(); Yii::app()->session->remove('dir'); if (!isset(Yii::app()->session['dir'])) { Yii::app()->session['dir'] = $this->image_folder; } return parent::beforeAction($action); }
/** * For this controller, we only want to run these functions if LSKEY isn't set (meaning we're partially through an install) * Otherwise, we give an exception to prevent running any of these processes. * @param CAction $action * @return bool * @throws CHttpException */ public function beforeAction($action) { defined('DEFAULT_THEME') or define('DEFAULT_THEME', 'brooklyn2014'); if (strlen(Yii::app()->params['LSKEY']) > 0 && $action->id != "install" && $action->id != "upgrade" && $action->id != "migratephotos") { _xls_404(); return false; } return parent::beforeAction($action); }
/** * (non-PHPdoc) * @see CController::beforeAction() */ protected function beforeAction($action) { $allowActions = array('login', 'logout', 'chgpassword'); $actionName = $action->getId(); if (in_array($actionName, $allowActions)) { return parent::beforeAction($action); } return UserModel::instance()->isLoginSuper(); }
public function beforeAction() { if (Yii::app()->user->isGuest) { //Yii::app()->session->cookieMode = 'only';// cookieMode' => 'only', Yii::app()->user->saveGuestLikes(); Yii::app()->user->restoreGuestLikes(); } return parent::beforeAction(); }
public function beforeAction() { parent::beforeAction(); $actions = ['download', 'users']; $this->Security->requireGet($actions); // if you want to add csrf_token in the URL of file download // So, it will be something like this: http://localhost/miniPHP/downloads/download/f850749b62bf3badfb6c0?csrf_token=21eb0f2c6b4fddce8a7f3 // $this->Security->config("validateCsrfToken", true); }