Пример #1
0
 function beforeFilter()
 {
     $this->BlowFish = new BlowfishPasswordHasher();
     if ($this->request->prefix == "admin") {
         //Security::setHash('md5');
         AuthComponent::$sessionKey = 'Auth.Admin';
         $this->Auth->loginAction = array('controller' => 'users', 'action' => 'admin_login');
         $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'admin_dashboard');
         $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'admin_login');
         $this->Auth->authenticate = array('Form' => array('userModel' => 'User', 'passwordHasher' => 'Blowfish', 'fields' => array('username' => 'email', 'password' => 'password'), 'scope' => array('User.role' => 'Admin')));
         if (!$this->Auth->loggedIn()) {
             $this->Auth->authError = false;
         }
         $this->Auth->allow('admin_login');
         $this->layout = 'admin_default';
     }
     if ($this->request->prefix == "") {
         //Security::setHash('md5');
         AuthComponent::$sessionKey = 'Auth.User';
         $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
         $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'dashboard');
         $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
         $this->Auth->authenticate = array('Form' => array('userModel' => 'User', 'passwordHasher' => 'Blowfish', 'fields' => array('username' => 'email', 'password' => 'password'), 'scope' => array('User.role' => 'User')));
         if (!$this->Auth->loggedIn()) {
             $this->Auth->authError = false;
         }
         $this->Auth->allow('login');
         $this->layout = 'default';
     }
 }
 public function beforeFilter()
 {
     AuthComponent::$sessionKey = 'Auth.admins';
     parent::beforeFilter();
     $view_flg = array('0' => '非表示', '1' => '表示');
     $this->set('view_flg', $view_flg);
 }
Пример #3
0
 public function beforeFilter()
 {
     if (!$this->ControleDeAcesso->validaAcessoAcao()) {
         //$this->Session->setFlash('<strong>Atenção!</strong> Você não tem permissão para acessar esta página.', 'danger');
         //$this->redirect(array('controller'=>'principal','action'=>'index'));
     }
     AuthComponent::$sessionKey = "Auth.Indicadores";
     Security::setHash('md5');
 }
Пример #4
0
 public function _setupAuth()
 {
     if (!$this->Auth->user()) {
         $this->Auth->loginAction = array('admin' => false, 'controller' => 'users', 'action' => 'login');
         $this->Auth->authenticate = array('Form' => array('fields' => array('username' => 'email', 'pwd' => 'password')));
         AuthComponent::$sessionKey = 'Auth.User.user';
     } else {
         $this->Auth->allow('*');
     }
 }
Пример #5
0
 public function beforeFilter()
 {
     $this->Cookie->httpOnly = true;
     $this->Cookie->type('aes');
     if (isset($this->request->params['advisor']) && $this->request->params['advisor']) {
         // Setup authentication for Advisor
         $this->Auth->loginRedirect = array('controller' => 'accounts', 'action' => 'mypage', 'advisor' => true);
         $this->Auth->logoutRedirect = array('controller' => 'top', 'action' => 'index', 'advisor' => false);
         $this->Auth->loginAction = array('controller' => 'accounts', 'action' => 'login', 'advisor' => true);
         $this->Auth->authenticate = array('Form' => array('passwordHasher' => 'Blowfish', 'userModel' => 'Advisor', 'fields' => array('username' => 'mail_address'), 'scope' => array('Advisor.delete_flag' => 0), 'contain' => array('AdvisorProfile.fullname', 'AdvisorProfile.image_url')));
         AuthComponent::$sessionKey = 'Auth.Advisor';
         if (!$this->Auth->loggedIn()) {
             $cookie = $this->Cookie->read('advisor_remember_me_cookie');
             if ($cookie) {
                 $this->loadModel('Advisor');
                 $advisor = $this->Advisor->find('first', array('recursive' => -1, 'conditions' => array('Advisor.mail_address' => $cookie['mail_address'], 'Advisor.password' => $cookie['password'])));
                 if ($advisor && !$this->Auth->login($advisor['Advisor'])) {
                     $this->redirect(array('controller' => 'accounts', 'action' => 'logout'));
                     // destroy session & cookie
                 }
             }
         }
         $this->__getUnreadMessage();
     } elseif (isset($this->request->params['admin']) && $this->request->params['admin']) {
         $this->helpers['Form'] = array('className' => 'BoostCake.BoostCakeForm');
         $this->helpers['Html'] = array('className' => 'BoostCake.BoostCakeHtml');
         // Setup authentication for Admin
         $this->Auth->loginRedirect = '/admin/';
         $this->Auth->logoutRedirect = array('controller' => 'admin_login', 'action' => 'login', 'admin' => true);
         $this->Auth->loginAction = array('controller' => 'admin_login', 'action' => 'login', 'admin' => true);
         $this->Auth->authenticate = array('Form' => array('passwordHasher' => 'Blowfish', 'userModel' => 'Administrator', 'fields' => array('username' => 'mail_address'), 'scope' => array('Administrator.delete_flag' => 0)));
         AuthComponent::$sessionKey = 'Auth.Admin';
         $this->layout = 'admin';
     } else {
         // Setup authentication for USER
         $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'mypage');
         $this->Auth->logoutRedirect = '/';
         $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
         $this->Auth->authenticate = array('Form' => array('passwordHasher' => 'Blowfish', 'userModel' => 'User', 'fields' => array('username' => 'mail_address'), 'scope' => array('User.delete_flag' => 0), 'contain' => array('UserProfile.fullname', 'UserProfile.image_url')));
         AuthComponent::$sessionKey = 'Auth.User';
         if (!$this->Auth->loggedIn()) {
             $cookie = $this->Cookie->read('user_remember_me_cookie');
             if ($cookie) {
                 $this->loadModel('User');
                 $user = $this->User->find('first', array('recursive' => -1, 'conditions' => array('User.mail_address' => $cookie['mail_address'], 'User.password' => $cookie['password'])));
                 if ($user && !$this->Auth->login($user['User'])) {
                     $this->redirect(array('controller' => 'users', 'action' => 'logout'));
                     // destroy session & cookie
                 }
             }
         }
         $this->__getUnreadMessage();
     }
 }
Пример #6
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     AuthComponent::$sessionKey = 'Auth.Manager';
     $this->Auth->allow('login');
     $this->layout = 'Admin.admin';
     if ($this->Session->read('Auth.Manager')) {
         $user['id'] = $this->Session->read('Auth.Manager.id');
         $user['username'] = $this->Session->read('Auth.Manager.username');
         $this->set('user', $user);
     }
 }
Пример #7
0
	function beforeFilter(){
		if(isset($this->params['prefix']) && $this->params['prefix'] == 'admin'){
			$this->Auth->loginAction = array('controller'=>'admins', 'action'=>'sign_in');
			AuthComponent::$sessionKey = 'Auth.Admin';
			$this->layout = 'Admin/default';
		}else{
			$this->Auth->loginAction = array('controller'=>'users', 'action'=>'home');
			if($this->Session->check('Auth.User.User.id'))
				$this->layout = 'FrontEnd/Inner/default';
			else
				$this->layout = 'FrontEnd/default';
			AuthComponent::$sessionKey = 'Auth.User';
		}
	}
Пример #8
0
 /**
  * Initialize Controller and CakeRequest
  *
  * This method applies Controller attributes.
  * Should be called in Component::initialize() or Controller::beforeFilter()
  *
  * @param Controller $controller
  * @param CakeRequest $request
  * @return boolean
  */
 public function initialize(Controller $controller)
 {
     // attach event listeners
     $controller->getEventManager()->attach(new BackendEventListener());
     // add backend detector
     $controller->request->addDetector('backend', array('callback' => array($this, 'isBackendRequest')));
     $controller->request->addDetector('iframe', array('callback' => array($this, 'isIframeRequest')));
     // is a plugin using backend?
     if ($controller->request->params['plugin']) {
         $this->plugin = $controller->request->params['plugin'];
     }
     if ($controller->request->is('backend')) {
         $this->_isBackendRequest = true;
         // Load plugin specif config
         if ($this->plugin && $this->plugin != "backend") {
             try {
                 Configure::load(Inflector::camelize($this->plugin) . '.backend');
             } catch (Exception $e) {
                 // this plugin has no backend configuration
             }
         }
         // Controller
         $controller->layout = $this->layout;
         $controller->viewClass = 'Backend.Backend';
         // load AuthComponent
         if (Configure::read('Backend.Auth.enabled') === true && !$controller->Components->loaded('Auth')) {
             $controller->Auth = $controller->Components->load('Auth');
             $controller->Auth->initialize($controller);
         }
         // Auth
         if (Configure::read('Backend.Auth.enabled') === true && $controller->Auth) {
             //TODO check if backend auth sessionkey overwrite can be avoided
             AuthComponent::$sessionKey = "Auth.Backend";
             $controller->Auth->authenticate = $this->authenticate;
             $controller->Auth->loginAction = $this->loginAction;
             // enable Access Control List
             if (Configure::read('Backend.Acl.enabled') === true) {
                 //TODO check if acl tables are present
                 $controller->Auth = $this->authorize;
             }
         }
         // Error Handling
         if (is_a($controller, 'CakeErrorController')) {
             // use backend error layout
             $controller->layout = $this->errorLayout;
         }
     }
 }
 /**
  * Configurações necessarias para o componente
  * de autenticação de usuário, AuthComponent
  */
 private function authComponentConfig()
 {
     // Índice onde será salvo as informações de sessão do usuário. Este deve
     // ser único, para que não ocorra colisão de sessões de outras aplicações
     // que utilizam está mesma base.
     // Pode-se basear pelo nome da aplicação e o IP do cliente.
     AuthComponent::$sessionKey = PROJECT_NAME . str_replace('.', '', $this->RequestHandler->getClientIp());
     $this->Auth->authenticate = array(AuthComponent::ALL => array('userModel' => 'User', 'fields' => array('username' => 'email'), 'scope' => array('User.enable' => TRUE)), 'Form');
     $this->Auth->authorize = 'Controller';
     $this->Auth->loginAction = array('controller' => 'Users', 'action' => 'login', 'prefix' => 'visitor');
     $this->Auth->logoutRedirect = array('controller' => 'Users', 'action' => 'login', 'prefix' => 'visitor');
     $this->Auth->flash['element'] = 'flash/mini/error';
     // Caso o prefixo de uma ação requisitada pela URL seja
     // igual a  hierarqui do usuaŕio, devemos permitir sua execução.
     if ($this->request->prefix == SupportComponent::userHierarchy()) {
         $this->Auth->allow($this->request->action);
     }
 }
Пример #10
0
 public function beforeFilter()
 {
     $controller = $this->params['controller'];
     $action = $this->params['action'];
     $this->set("controller", $controller);
     $this->set("action", $action);
     if (isset($this->request->params['admin'])) {
         $this->layout = 'admin';
         AuthComponent::$sessionKey = 'Auth.Admin';
         $this->Auth->loginAction = array('admin' => true, 'controller' => 'users', 'action' => 'login');
         $this->Auth->loginRedirect = array('admin' => true, 'controller' => 'users', 'action' => 'dashboard');
         $this->Auth->logoutRedirect = array('admin' => true, 'controller' => 'users', 'action' => 'login');
     }
     if ($this->RequestHandler->isAjax()) {
         $this->layout = 'ajax';
     }
     $this->SiteSettings();
     $this->Auth->authorize = array('Controller');
 }
Пример #11
0
 function beforeFilter()
 {
     /* if($_SERVER['HTTP_HOST'] == 'fusedpage.ca'){
     			$siteRedirectUrl = 'http://fusedpage.com'.$_SERVER['REQUEST_URI'];
     			$this->redirect($siteRedirectUrl);
     		} */
     //$this->Session->write('Auth.User.User.social_facebook', '1');
     if (isset($this->params['prefix']) && $this->params['prefix'] == 'admin') {
         $this->Auth->loginAction = array('controller' => 'admins', 'action' => 'sign_in');
         AuthComponent::$sessionKey = 'Auth.Admin';
         $this->layout = 'Admin/default';
     } else {
         $this->Auth->loginAction = array('controller' => 'users', 'action' => 'home');
         if ($this->Session->check('Auth.User.User.id')) {
             $this->layout = 'FrontEnd/Inner/default';
         } else {
             $this->layout = 'FrontEnd/default';
         }
         AuthComponent::$sessionKey = 'Auth.User';
     }
 }
 private function _manageAuthConfigs()
 {
     $this->Auth->authError = 'Área restrita, identifique-se primeiro.';
     $this->Auth->authorize = array('Controller');
     $this->Auth->flash = array_merge($this->Auth->flash, array('element' => 'alerts/inline', 'params' => array('class' => 'error')));
     AuthComponent::$sessionKey = 'Auth.Customer';
     $this->Auth->loginAction = array('controller' => 'customers', 'action' => 'login', 'customer' => true);
     $this->Auth->loginRedirect = '/';
     $this->Auth->logoutRedirect = '/';
     $this->Auth->authenticate = array('Form' => array('userModel' => 'Customer', 'fields' => array('username' => 'email')));
     if ($this->isPrefix('admin')) {
         AuthComponent::$sessionKey = 'Auth.Admin';
         $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login', 'admin' => true);
         $this->Auth->loginRedirect = '/';
         $this->Auth->logoutRedirect = '/login';
         $this->Auth->authenticate = array('Form' => array('userModel' => 'User', 'scope' => array('status' => '1')));
         $this->Auth->allow('login');
     } elseif ($this->isPrefix('customer')) {
         $this->Auth->deny();
     } else {
         $this->Auth->allow();
     }
 }
 public function initialize(Controller $Controller, $settings = array())
 {
     $this->controller = $Controller;
     $this->isBrwPanel = (!empty($Controller->request->params['prefix']) and $Controller->request->params['prefix'] == 'brw' or $Controller->params['plugin'] == 'brownie');
     ClassRegistry::init('BrwUser')->Behaviors->attach('Brownie.BrwUser');
     ClassRegistry::init('BrwImage')->Behaviors->attach('Brownie.BrwUpload');
     ClassRegistry::init('BrwFile')->Behaviors->attach('Brownie.BrwUpload');
     if (!empty($Controller->request->params['prefix']) and $Controller->request->params['prefix'] == 'brw') {
         if (!class_exists('AuthComponent')) {
             $Controller->Components->load('Auth', Configure::read('brwAuthConfig'));
         } else {
             foreach (Configure::read('brwAuthConfig') as $key => $value) {
                 $Controller->Auth->{$key} = $value;
             }
         }
         App::build(array('views' => ROOT . DS . APP_DIR . DS . 'Plugin' . DS . 'Brownie' . DS . 'View' . DS));
         $Controller->helpers[] = 'Js';
         $Controller->layout = 'brownie_default';
         if (!empty($Controller->modelClass)) {
             $Controller->{$Controller->modelClass}->attachBackend();
         }
     }
     if ($this->isBrwPanel) {
         AuthComponent::$sessionKey = 'Auth.BrwUserLogged';
         $this->_menuConfig();
     }
     if (Configure::read('Config.languages')) {
         $langs3chars = array();
         $l10n = new L10n();
         foreach ((array) Configure::read('Config.languages') as $lang) {
             $catalog = $l10n->catalog($lang);
             $langs3chars[$lang] = $catalog['localeFallback'];
         }
         Configure::write('Config.langs', $langs3chars);
     }
 }
 /**
  * testStatelessAuthNoSessionStart method
  *
  * @return void
  */
 public function testStatelessAuthNoSessionStart()
 {
     if (CakeSession::id()) {
         session_destroy();
         CakeSession::$id = null;
     }
     $_SESSION = null;
     $_SERVER['PHP_AUTH_USER'] = '******';
     $_SERVER['PHP_AUTH_PW'] = 'cake';
     AuthComponent::$sessionKey = false;
     $this->Auth->authenticate = array('Basic' => array('userModel' => 'AuthUser'));
     $this->Controller->request['action'] = 'admin_add';
     $result = $this->Auth->startup($this->Controller);
     $this->assertTrue($result);
     $this->assertNull(CakeSession::id());
 }
Пример #15
0
 public function beforeFilter()
 {
     AuthComponent::$sessionKey = 'Auth.admins';
     parent::beforeFilter();
 }
Пример #16
0
 /**
  * To filter url request
  * @author Gaurav
  */
 public function beforeFilter()
 {
     $headersInformation = getallheaders();
     // admin email
     $this->set('AdminEmail', AdminEmail);
     if (isset($this->params['prefix']) && $this->params['prefix'] == 'admin') {
         //$this->Auth->loginRedirect = array('plugin' => false, 'controller' => 'dashboard', 'action' => 'index');
         $this->layout = 'admin';
         AuthComponent::$sessionKey = 'Auth.User';
         $this->isAdmin = TRUE;
         Configure::write('isAdmin', TRUE);
     } else {
         //$this->Auth->loginRedirect = array('plugin' => false, 'controller' => 'pages', 'action' => 'home');
         $this->layout = 'front';
         // get group change request status
         $bizOwnerId = $this->Session->read('Auth.Front.BusinessOwners.id');
         //$crCount = $this->Session->read('Auth.Front.BusinessOwners.group_change');
         //$this->set(compact('crCount'));
         Configure::write('isAdmin', FALSE);
         AuthComponent::$sessionKey = 'Auth.Front';
     }
     $roleType = $this->Session->read('Auth.User.user_type');
     $this->set('common', $this->Common);
     $frontUserRole = $this->Session->read('Auth.Front.user_type');
     $isUserLogin = $frontUserRole == "businessOwner" ? true : false;
     $this->set(compact("isUserLogin"));
     $loginUserId = $this->Session->read('Auth.Front.id');
     $this->set(compact("loginUserId"));
     if (empty($headersInformation['HASHKEY']) && $this->params['prefix'] != 'api') {
         // redirect session after login
         $checkUrl = Router::fullbaseUrl() . $this->here;
         if (strpos($checkUrl, Configure::read('SITE_URL') . 'referrals/referralDetails/sent/') !== false) {
             $this->Session->write('BackUrlAfterLogin', $checkUrl);
         } elseif (strpos($checkUrl, Configure::read('SITE_URL') . 'referrals/referralDetails/received/') !== false) {
             $this->Session->write('BackUrlAfterLogin', $checkUrl);
         } elseif (strpos($checkUrl, Configure::read('SITE_URL') . 'messages/viewMessage/') !== false) {
             $this->Session->write('BackUrlAfterLogin', $checkUrl);
         } elseif (strpos($checkUrl, Configure::read('SITE_URL') . 'reviews/index') !== false) {
             $this->Session->write('BackUrlAfterLogin', $checkUrl);
         } elseif (strpos($checkUrl, Configure::read('SITE_URL') . 'meetings') !== false) {
             $this->Session->write('BackUrlAfterLogin', $checkUrl);
         }
         if (empty($roleType)) {
             $this->Auth->allow(array('admin_login', 'admin_forgotPassword', 'admin_resetPassword', 'home', 'login', 'subscribe', 'aboutUs', 'contactUs', 'privacyPolicy', 'termsOfServices', 'careers', 'partners', 'faq', 'faqView', 'faqSearch', 'getCountryList', 'getCountryName', 'getStateList', 'getStateName', 'trainingVideoReminderMail', 'recurringTransaction', 'rating', 'deactivateUser', 'getProfessionList'));
         }
     } else {
         if ($this->params['prefix'] == 'api') {
             $this->RequestHandler->ext = Configure::read('SERVICEFORMAT');
             if (!isset($headersInformation['HASHKEY']) || $headersInformation['HASHKEY'] != Configure::read('HASHKEY')) {
                 echo json_encode(array('code' => Configure::read('RESPONSE_ERROR'), 'message' => 'Invalid Hash Key'));
                 die;
             }
             $this->Auth->allow($this->action);
             //API Post Data in Json
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $this->__getPostContent();
             }
             //fetch the headers data
             $this->__getHeaderInformation();
         }
     }
     // Login user get counter for different entity (ex- message, referrals etc.)
     if (empty($this->request->data) && empty($this->request->form)) {
         $this->Common->clearDropzoneData();
     }
     $messageCounter = 0;
     $referalCounter = 0;
     if ($loginUserId != "") {
         $loginUserId = $this->Encryption->decode($loginUserId);
         $userGroup = $this->Groups->getUserGroupId($loginUserId);
         // logout user after shuffling
         $beforeShuffling = $this->Session->read('Auth.Front.BusinessOwner.group_id');
         $afterShuffling = $userGroup['BusinessOwner']['group_id'];
         if (!empty($beforeShuffling) && $beforeShuffling != $afterShuffling) {
             $this->Auth->logout();
         }
         if ($this->action == "viewMessage") {
             if (isset($this->params->pass[0])) {
                 $messageId = $this->Encryption->decode($this->params->pass[0]);
                 $this->loadModel('MessageRecipient');
                 $this->MessageRecipient->updateAll(array('MessageRecipient.is_read' => 1, 'MessageRecipient.is_total_read' => 1), array('MessageRecipient.message_id' => $messageId, 'MessageRecipient.recipient_user_id' => $loginUserId));
             }
         }
         if ($this->action == "referralDetails") {
             if (isset($this->params->pass[0]) && isset($this->params->pass[1])) {
                 if ($this->params->pass[0] == "received") {
                     $referralId = $this->Encryption->decode($this->params->pass[1]);
                     $this->loadModel('ReceivedReferral');
                     $this->ReceivedReferral->updateAll(array('ReceivedReferral.is_read' => 1, 'ReceivedReferral.is_total_read' => 1), array('ReceivedReferral.id' => $referralId, 'ReceivedReferral.to_user_id' => $loginUserId));
                 }
             }
         }
         $messageCounter = $this->Common->unreadCounter('messages', $loginUserId);
         $referalCounter = $this->Common->unreadCounter('referrals', $loginUserId);
         $this->set('userGroup', $userGroup['BusinessOwner']['group_id']);
         // get profile picture path
         $profileImage = $this->Businessowner->getProfilePicture($loginUserId);
         $this->set(compact("profileImage"));
         // get login user info
         $loginUserInfo = $this->BusinessOwner->findByUserId($loginUserId);
         $loginUserName = $loginUserInfo['BusinessOwner']['fname'] . ' ' . $loginUserInfo['BusinessOwner']['lname'];
         $loginUserRole = $loginUserInfo['BusinessOwner']['group_role'];
         $this->set(compact("loginUserName", "loginUserRole", "loginUserInfo"));
     }
     $this->set(compact("messageCounter"));
     $this->set(compact("referalCounter"));
     /*if($this->request->is('ajax')) {
           $ajaxRinningUrl = parse_url($this->referer());
           $serverUrl = parse_url(Configure::read('SITE_URL'));
           if($ajaxRinningUrl['host'] != $serverUrl['host']){
               $result = array(
                   'response' => __('Unauthorize Access'),
                   'responsecode' => Configure::read('RESPONSE_ERROR'),
                   );
               echo json_encode($result);die;
           }
       }*/
 }
Пример #17
0
 public function beforeFilter()
 {
     AuthComponent::$sessionKey = 'Auth.admins';
     parent::beforeFilter();
     $this->set("banner_size", $this->banner_size);
 }
Пример #18
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     AuthComponent::$sessionKey = 'Auth.admins';
     $this->Auth->allow('login', 'logout');
 }
Пример #19
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     $this->Auth->allow('index', 'captcha', 'about', 'truthful', 'our_team', 'career', 'login', 'facebook_login', 'register', 'forgot_password', 'activate', 'open_shop', 'getByCategoryFront', 'getBySubCategoryFront', 'getByCityFront', 'affiliate', 'category', 'browse_product_subcategorysub', 'browse_product_subcategory', 'browse_product_category', 'product_new', 'product_popular', 'shop_detail', 'user_profile', 'getBySubdistrictFront', 'getBySubdistrictEditFront', 'getByCityFront', 'getByCityEditFront', 'shop_browse', 'search', 'send_activation', 'test', 'detail_product', 'load_comment', 'load_commentdetail');
     /* SET LANGUAGE */
     $this->loadModel('Language');
     $default_language = $this->Language->find('first', array('conditions' => array('Language.lg_default' => 1)));
     $this->default_language = $default_language;
     if (isset($this->params['language'])) {
         $check_language = $this->Language->find('first', array('conditions' => array('Language.lg_code' => $this->params['language'], 'Language.lg_active' => 1)));
         if (!empty($check_language)) {
             $param_language = strtoupper($this->params['language']);
         } else {
             $param_language = strtoupper($default_language["Language"]["lg_code"]);
         }
         Configure::write('Config.language', $param_language);
         $this->default_language_id = $param_language;
     } else {
         Configure::write('Config.language', $default_language["Language"]["lg_code"]);
         $this->default_language_id = $default_language["Language"]["lg_code"];
     }
     $all_language = $this->Language->find('all', array('conditions' => array('Language.lg_active' => 1), 'order' => array('Language.id' => 'asc')));
     $this->all_language = $all_language;
     $this->set('all_language', $all_language);
     $this->set('default_language_id', $this->default_language_id);
     /* ADMIN */
     if (isset($this->params['admin'])) {
         $this->Auth->loginAction = array('controller' => 'accounts', 'action' => 'login');
         $this->Auth->logoutRedirect = array('controller' => 'accounts', 'action' => 'logout');
         $this->Auth->authError = "<div class='form-login-error' style='display : block; height : auto'><h3>You are not authorized to access that location.</h3></div>";
     } else {
         /* FRONTEND */
         $this->Auth->loginAction = Router::url('/', true) . strtolower($this->default_language_id) . "/login/";
         $this->Auth->logoutRedirect = array('controller' => 'homes', 'action' => 'logout');
         $this->Auth->authError = "You are not authorized to access that location";
         $this->Auth->flash = array('element' => 'flash_message_error', 'key' => 'auth', 'params' => array());
     }
     /* GET COUNTRY*/
     // $IP2Location = new IP2LocationCore();
     // $record = $IP2Location->get($this->request->clientIp());
     // $this->country_code = $record->{'countryCode'};
     $this->country_code = "ID";
     $this->set("country_code", $this->country_code);
     /* CONFIG */
     $this->user = $this->Session->read('Auth.Admin');
     $this->user_front = $this->Session->read('Auth.User');
     $this->web_title = $this->_getData('title');
     $this->web_logo = $this->_getData('logo');
     $this->copyright = $this->_getData('copyright');
     $this->email_server = $this->_getData('email_server');
     $this->email_admin = $this->_getData('email_admin');
     $this->google_code = $this->_getData('google_code');
     $this->zpanel_skin = $this->_getData('zpanel_skin');
     $this->multi_language = $this->_getData('multi_language');
     $this->right_sidebar = $this->_getData('right_sidebar');
     $this->auto_publish = $this->_getData('auto_publish');
     $this->facebook_url = $this->_getData('facebook_url');
     $this->twitter_url = $this->_getData('twitter_url');
     $this->instagram_url = $this->_getData('instagram_url');
     $this->pinterest_url = $this->_getData('pinterest_url');
     $this->kurs = $this->_getData('kurs');
     $this->kurs_shipping = $this->_getData('kurs_shipping');
     $this->rate_up = $this->_getData('rate_up');
     $this->min_stock = $this->_getData('min_stock');
     $this->production_time_1 = 1;
     $this->production_time_5 = 5;
     $this->production_time_10 = 10;
     $this->production_time_25 = 25;
     $this->production_time_100 = 100;
     /* KEYWORD */
     $this->home_keyword = $this->_getData('home_keyword');
     $this->home_desc = $this->_getData('home_description');
     $this->contact_keyword = $this->_getData('contact_keyword');
     $this->contact_desc = $this->_getData('contact_description');
     $this->news_keyword = $this->_getData('news_keyword');
     $this->news_desc = $this->_getData('news_description');
     $this->about_keyword = $this->_getData('about_keyword');
     $this->about_desc = $this->_getData('about_description');
     $this->our_team_keyword = $this->_getData('our_team_keyword');
     $this->our_team_desc = $this->_getData('our_team_description');
     $this->career_keyword = $this->_getData('career_keyword');
     $this->career_desc = $this->_getData('career_description');
     $this->shop_keyword = $this->_getData('shop_keyword');
     $this->shop_desc = $this->_getData('shop_description');
     $this->setting_keyword = $this->_getData('setting_keyword');
     $this->setting_desc = $this->_getData('setting_description');
     $this->affiliate_keyword = $this->_getData('affiliate_keyword');
     $this->affiliate_desc = $this->_getData('affiliate_description');
     $this->category_keyword = $this->_getData('category_keyword');
     $this->category_desc = $this->_getData('category_description');
     $this->product_keyword = $this->_getData('product_keyword');
     $this->product_desc = $this->_getData('product_description');
     $this->inbox_keyword = $this->_getData('inbox_keyword');
     $this->inbox_desc = $this->_getData('inbox_description');
     $this->forum_keyword = $this->_getData('forum_keyword');
     $this->forum_desc = $this->_getData('forum_description');
     $this->ticket_keyword = $this->_getData('ticket_keyword');
     $this->ticket_desc = $this->_getData('ticket_description');
     /* PAGING */
     $this->user_level_page = $this->_getData('user_level_page');
     $this->user_page = $this->_getData('user_page');
     $this->account_page = $this->_getData('account_page');
     $this->news_page = $this->_getData('news_page');
     $this->tag_page = $this->_getData('tag_page');
     $this->media_library_page = $this->_getData('media_library_page');
     $this->contact_page = $this->_getData('contact_page');
     $this->contact_count = $this->_getContactCount();
     $this->page_page = $this->_getData('page_page');
     $this->slideshow_page = $this->_getData('slideshow_page');
     $this->gallery_page = $this->_getData('gallery_page');
     $this->testimonial_page = $this->_getData('testimonial_page');
     $this->know_page = $this->_getData('know_page');
     $this->team_page = $this->_getData('team_page');
     $this->career_page = $this->_getData('career_page');
     $this->category_page = $this->_getData('category_page');
     $this->subcategory_page = $this->_getData('subcategory_page');
     $this->subcategorysub_page = $this->_getData('subcategorysub_page');
     $this->faq_page = $this->_getData('faq_page');
     $this->category_help_page = $this->_getData('category_help_page');
     $this->subcategory_help_page = $this->_getData('subcategory_help_page');
     $this->help_center_page = $this->_getData('help_center_page');
     $this->gender_page = $this->_getData('gender_page');
     $this->new_product_page = $this->_getData('new_product_page');
     $this->all_product_page = $this->_getData('all_product_page');
     $this->bank_page = $this->_getData('bank_page');
     $this->shipping_page = $this->_getData('shipping_page');
     $this->shop_page = $this->_getData('shop_page');
     $this->coach_page = $this->_getData('coach_page');
     $this->browse_shop_page = $this->_getData('browse_shop_page');
     $this->shop_report_page = $this->_getData('shop_report_page');
     $this->product_report_page = $this->_getData('product_report_page');
     $this->forum_report_page = $this->_getData('forum_report_page');
     $this->forum_request_page = $this->_getData('forum_request_page');
     $this->ticket_category_page = $this->_getData('ticket_category_page');
     $this->ticket_priority_page = $this->_getData('ticket_priority_page');
     $this->ticket_list_page = $this->_getData('ticket_list_page');
     $this->set('copyright', $this->copyright);
     $this->set('google_code', $this->google_code);
     $this->set('facebook_url', $this->facebook_url);
     $this->set('twitter_url', $this->twitter_url);
     $this->set('instagram_url', $this->instagram_url);
     $this->set('pinterest_url', $this->pinterest_url);
     $this->set('default_language', $default_language);
     $this->set('multi_language', $this->multi_language);
     $this->set('right_sidebar', $this->right_sidebar);
     $this->set('default_profile_picture', $this->default_profile_picture);
     $this->set('default_shop_logo_picture', $this->default_shop_logo_picture);
     $this->set('default_shop_banner_picture', $this->default_shop_banner_picture);
     $this->set('kurs', $this->kurs);
     $this->set('kurs_shipping', $this->kurs_shipping);
     $this->set('rate_up', $this->rate_up);
     $this->set('min_stock', $this->min_stock);
     $this->set('production_time_1', $this->production_time_1);
     $this->set('production_time_5', $this->production_time_5);
     $this->set('production_time_10', $this->production_time_10);
     $this->set('production_time_25', $this->production_time_25);
     $this->set('production_time_100', $this->production_time_1);
     /* START YOUR SHOP */
     $this->loadModel("Page");
     $start_shop = $this->Page->find('first', array('fields' => array('Page.id', 'Page.p_image', 'media_image_1.*', 'page_detail_many.*'), 'joins' => array("LEFT JOIN `ca_page_detail` AS `page_detail_many` ON `Page`.`id` = `page_detail_many`.`pd_p_id`"), 'conditions' => array('(page_detail_many.pd_active = 3) AND page_detail_many.pd_language="' . $this->default_language_id . '" AND Page.id=5'), 'recursive' => 0));
     $this->set("start_shop", $start_shop);
     /* HALAMAN ADMIN */
     if (isset($this->params['admin'])) {
         $this->set('admin_keyword', $this->home_keyword);
         $this->set('admin_description', $this->home_desc);
         $this->set('admin_web_logo', $this->web_logo);
         /*GENERAL*/
         $this->set('web_title', $this->web_title);
         $this->set('web_logo', $this->web_logo);
         $this->set('copyright', $this->copyright);
         $this->set('email_admin', $this->email_admin);
         $this->set('email_server', $this->email_server);
         $this->set('google_code', $this->google_code);
         $this->set('zpanel_skin', $this->zpanel_skin);
         $this->set('multi_language', $this->multi_language);
         $this->set('right_sidebar', $this->right_sidebar);
         $this->set('auto_publish', $this->auto_publish);
         /*KEYWORD DESCRIPTION*/
         $this->set('home_keyword', $this->home_keyword);
         $this->set('home_desc', $this->home_desc);
         $this->set('news_keyword', $this->news_keyword);
         $this->set('news_desc', $this->news_desc);
         $this->set('contact_keyword', $this->contact_keyword);
         $this->set('contact_desc', $this->contact_desc);
         $this->set('about_keyword', $this->about_keyword);
         $this->set('about_desc', $this->about_desc);
         $this->set('our_team_keyword', $this->our_team_keyword);
         $this->set('our_team_desc', $this->our_team_desc);
         $this->set('career_keyword', $this->career_keyword);
         $this->set('career_desc', $this->career_desc);
         $this->set('shop_keyword', $this->shop_keyword);
         $this->set('shop_desc', $this->shop_desc);
         $this->set('setting_keyword', $this->setting_keyword);
         $this->set('setting_desc', $this->setting_desc);
         $this->set('affiliate_keyword', $this->affiliate_keyword);
         $this->set('affiliate_desc', $this->affiliate_desc);
         $this->set('category_keyword', $this->category_keyword);
         $this->set('category_desc', $this->category_desc);
         $this->set('product_keyword', $this->product_keyword);
         $this->set('product_desc', $this->product_desc);
         $this->set('inbox_keyword', $this->inbox_keyword);
         $this->set('inbox_desc', $this->inbox_desc);
         $this->set('forum_keyword', $this->forum_keyword);
         $this->set('forum_desc', $this->forum_desc);
         $this->set('ticket_keyword', $this->ticket_keyword);
         $this->set('ticket_desc', $this->ticket_desc);
         /* PAGING */
         $this->set('user_level_page', $this->user_level_page);
         $this->set('user_page', $this->user_page);
         $this->set('account_page', $this->account_page);
         $this->set('news_page', $this->news_page);
         $this->set('tag_page', $this->tag_page);
         $this->set('media_library_page', $this->media_library_page);
         $this->set('contact_page', $this->contact_page);
         $this->set('page_page', $this->page_page);
         $this->set('slideshow_page', $this->slideshow_page);
         $this->set('gallery_page', $this->gallery_page);
         $this->set('testimonial_page', $this->testimonial_page);
         $this->set('know_page', $this->know_page);
         $this->set('team_page', $this->team_page);
         $this->set('career_page', $this->career_page);
         $this->set('category_page', $this->category_page);
         $this->set('subcategory_page', $this->subcategory_page);
         $this->set('subcategorysub_page', $this->subcategorysub_page);
         $this->set('faq_page', $this->faq_page);
         $this->set('category_help_page', $this->category_help_page);
         $this->set('subcategory_help_page', $this->subcategory_help_page);
         $this->set('help_center_page', $this->help_center_page);
         $this->set('gender_page', $this->gender_page);
         $this->set('new_product_page', $this->new_product_page);
         $this->set('all_product_page', $this->all_product_page);
         $this->set('bank_page', $this->bank_page);
         $this->set('shipping_page', $this->shipping_page);
         $this->set('shop_page', $this->shop_page);
         $this->set('coach_page', $this->coach_page);
         $this->set('browse_shop_page', $this->browse_shop_page);
         $this->set('shop_report_page', $this->shop_report_page);
         $this->set('product_report_page', $this->product_report_page);
         $this->set('forum_report_page', $this->forum_report_page);
         $this->set('forum_request_page', $this->forum_request_page);
         $this->set('ticket_category_page', $this->ticket_category_page);
         $this->set('ticket_priority_page', $this->ticket_priority_page);
         $this->set('ticket_list_page', $this->ticket_list_page);
         if (isset($this->user["id"])) {
             /* CHECK USER LEVEL */
             $user_level = $this->_getUserLevel($this->user["id"]);
             $this->user_level = $user_level;
             $controller = strtolower($this->params['controller']);
             $action = strtolower($this->params['action']);
             if (isset($this->request->params["pass"][0])) {
                 $param = $this->request->params["pass"][0];
             }
             if (($controller == "userlevels" || $controller == "genders") && $user_level != 1) {
                 throw new NotFoundException();
             }
             if ($controller == "accounts" && $user_level != 1 && ($action == "admin_edit" || $action == "admin_delete")) {
                 throw new NotFoundException();
             }
             $this->set('user_level', $this->_getUserLevel($this->user["id"]));
             $this->set('contact_count', $this->contact_count);
         }
         /* AUTHENTICATION */
         $this->Auth->authenticate = array('Form' => array('fields' => array('username' => 'a_email', 'password' => 'a_password'), 'userModel' => 'Account', 'scope' => array('Account.a_active' => 1, 'Account.a_level < 3')));
         AuthComponent::$sessionKey = 'Auth.Admin';
     } else {
         /* AUTHENTICATION */
         $this->Auth->authenticate = array('Form' => array('fields' => array('username' => 'a_email', 'password' => 'a_password'), 'userModel' => 'Account', 'scope' => array('Account.a_active' => 1)));
         AuthComponent::$sessionKey = 'Auth.User';
         $this->set('loggedIn', $this->Auth->loggedIn());
         $this->loadModel('Wishlist');
         $this->wishlist_count = $this->Wishlist->find('count', array('conditions' => array('Wishlist.id_account' => $this->user_front["id"])));
         $this->set("wishlist_count", $this->wishlist_count);
         $this->loadModel('Shop');
         $this->shop_count = $this->Shop->find('count', array('conditions' => array('Shop.sh_u_id_created' => $this->user_front["id"]), 'recursive' => 0));
         $this->set("shop_count", $this->shop_count);
         if (isset($this->user_front["id"])) {
             $this->loadModel('Message');
             $this->message_count = $this->Message->find('count', array('conditions' => array('Message.ms_inbox_owner' => $this->user_front["id"], 'Message.ms_read' => 0), 'group' => 'Message.ms_group'));
             $this->set("message_count", $this->message_count);
             $this->loadModel("PaginateCommentInbox");
             $this->PaginateCommentInbox->recursive = 0;
             // $this->paginate = array('PaginateCommentInbox'=>array(
             // 'user_id'=>$this->user_front["id"],
             // 'language'=>$this->default_language_id
             // ));
             $this->set('comment_count', 0);
         }
         $this->set("user_front", $this->user_front);
         if (isset($this->user_front["id"])) {
             $this->set('havePass', $this->_getPassword($this->user_front["id"]));
         }
     }
 }
Пример #20
0
 /**
  * testStatelessAuthNoRedirect method
  *
  * @expectedException UnauthorizedException
  * @expectedExceptionCode 401
  * @return void
  */
 public function testStatelessAuthNoRedirect()
 {
     if (CakeSession::id()) {
         session_destroy();
         CakeSession::$id = null;
     }
     $_SESSION = null;
     AuthComponent::$sessionKey = false;
     $this->Auth->authenticate = array('Basic');
     $this->Controller->request['action'] = 'admin_add';
     $this->Auth->startup($this->Controller);
 }
Пример #21
0
 public function admin_logout()
 {
     AuthComponent::$sessionKey = 'Auth.Admin';
     $this->redirect($this->Auth->logout());
 }
Пример #22
0
 function beforeFilter()
 {
     AuthComponent::$sessionKey = "Auth.Indicadores";
     $this->paginate['limit'] = 20;
     $this->usuarioLogado = $this->Auth->user();
 }