onDispatch() public method

Execute the request
public onDispatch ( MvcEvent $e ) : mixed
$e Zend\Mvc\MvcEvent
return mixed
 /**
  * @param MvcEvent $event
  *
  * @return parent::onDispatch
  */
 public function onDispatch(MvcEvent $event)
 {
     $request = $event->getRequest();
     $remoteAddr = $request->getServer('REMOTE_ADDR');
     // check IP address is allowed
     $application = $event->getApplication();
     $config = $application->getConfig();
     $autoDeployConfig = $config['auto_deploy'];
     $allowedIpAddresses = $autoDeployConfig['ipAddresses'];
     // error if ip is not allowed
     if (!in_array($remoteAddr, $allowedIpAddresses, true)) {
         $baseModel = new \Zend\View\Model\ViewModel();
         $baseModel->setTemplate('layout/output');
         $model = new \Zend\View\Model\ViewModel();
         $model->setTemplate('error/403');
         $baseModel->addChild($model);
         $baseModel->setTerminal(true);
         $event->setViewModel($baseModel);
         $response = $event->getResponse();
         $response->setStatusCode(403);
         $response->sendHeaders();
         $event->setResponse($response);
         exit;
     }
     return parent::onDispatch($event);
 }
Example #2
0
 /**
  * @param \Zend\Mvc\MvcEvent $e
  */
 public function onDispatch(MvcEvent $e)
 {
     $layout = $this->layout();
     $layout->setTemplate('default/layout');
     $layout->bodyCls = '';
     parent::onDispatch($e);
 }
 public function onDispatch(\Zend\Mvc\MvcEvent $event)
 {
     self::$instance = $this;
     if (!isset($_COOKIE['language'])) {
         $headers = $this->getRequest()->getHeaders();
         $defaultLanguage = 'en';
         $supportedLanguages = array('en', 'pl');
         $match = false;
         $this->setLanguage($defaultLanguage);
         setcookie('language', $this->getLanguage(), time() + 60 * 60 * 24 * 365, '/');
     } else {
         $this->setLanguage($_COOKIE['language']);
         setcookie('language', $this->getLanguage(), time() + 60 * 60 * 24 * 365, '/');
     }
     $referer = $this->getRequest()->getHeader('Referer');
     if ($referer) {
         $referer = $referer->uri()->getPath();
     } else {
         $referer = '/';
     }
     $request = $this->getRequest();
     $response = $this->getResponse();
     if ($request->getHeaders()->get('Cookie') !== false && isset($request->getHeaders()->get('Cookie')->previous_link)) {
         $this->setPreviousLink($request->getHeaders()->get('Cookie')->previous_link);
     } else {
         $cookie = new SetCookie('previous_link', $referer, time() + 3600);
         $response->getHeaders()->addHeader($cookie);
         $this->setPreviousLink($referer);
     }
     parent::onDispatch($event);
 }
use Zend\Barcode\Barcode;
//added by Yesh
class UserController extends AbstractActionController
{
    protected $em;
    protected $authservice;
    public function onDispatch(MvcEvent $e)
    {
        /* Set Default layout for all the actions */
        $this->layout('layout/layout');
        $em = $this->getEntityManager();
        $cities = $em->getRepository('\\Admin\\Entity\\City')->findBy(array('countryId' => 2));
        $categories = $em->getRepository('\\Admin\\Entity\\Categories')->findBy(array('status' => 1));
        $this->layout()->cities = $cities;
        $this->layout()->categories = $categories;
        $user_session = new Container('user');
        $userid = $user_session->userId;
        if (empty($userid)) {
            return $this->redirect()->toRoute('home');
        } else {
            $msg = 'You are already logged in.';
            $status = 1;
            $this->layout()->setVariable('userId', $user_session->userId);
            $this->layout()->setVariable('username', $user_session->userName);
            $username = $user_session->userName;
            $tmp_user = $em->getRepository('\\Admin\\Entity\\Users')->find($user_session->userId);
            $city = $tmp_user->getCity();
            if (!empty($city)) {
Example #5
0
 public function onDispatch(MvcEvent $e)
 {
     if (!$this->getRequest() instanceof ConsoleRequest) {
         throw new \RuntimeException('You can only use this action from a console!');
     }
     return parent::onDispatch($e);
 }
 /**
  * check if the admin is login otherwise redirect it to login page
  **/
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     if (!isset($this->container->admin_id)) {
         return $this->redirect()->toRoute('adminlogin');
     }
     return parent::onDispatch($e);
 }
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $install = setupUtility::checkInstall();
     if ($install == true) {
         return $this->redirect()->toRoute('install');
     }
     //get doctrine service
     $this->serviceLocatorStr = 'doctrine';
     $this->sm = $this->getServiceLocator();
     $this->doctrineService = $this->sm->get($this->serviceLocatorStr);
     //get translate service
     $this->translator = Utility::translate();
     //check login
     $user = Utility::checkLogin();
     if (!is_object($user) && $user == 0) {
         $this->redirect()->toRoute('frontend/child', array('controller' => 'login'));
     }
     //start acl
     //        $acl = new myAcl();
     //        $currentRoute  =  $this->getModuleCurrentRoute($e);
     //        $isOk = $acl->checkRole(UtilityRoleLevel::convertUserTypeToRole($user->userType)['role'],$currentRoute);
     //        if(!$isOk || $isOk == '' || $isOk == null){
     //           return $this->redirect()->toRoute('frontend/child', array('controller' => 'login'));
     //        }
     //end check login
     //end acl
     $this->init();
     return parent::onDispatch($e);
 }
Example #8
0
 /**
  * @param \Zend\Mvc\MvcEvent $e
  * @return mixed
  */
 public function onDispatch(MvcEvent $e, $validate = true)
 {
     if ($validate && !$this->getServiceLocator()->get('ServiceLocator')->hasIdentity()) {
         $this->redirect()->toRoute(self::ROUTE_DEFAULT);
     }
     return parent::onDispatch($e);
 }
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     parent::onDispatch($e);
     $routeMatch = $e->getRouteMatch();
     $ar = $routeMatch->getParams();
     // $this->accesslLog();
 }
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     //$logged_block = array('index');
     //if(!$this->identity() && !in_array($e->getRouteMatch()->getParam("action"), $logged_block)) return $this->redirect()->toRoute('home');
     die("Em Manutenção.");
     return parent::onDispatch($e);
 }
Example #11
0
 /**
  * Seta variáveis para o layout
  */
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     /**
      * Chamada do parent no inicio do método para primeiro setar
      * os valores das variáveis antes de renderizar a tela
      */
     parent::onDispatch($e);
 }
Example #12
0
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $this->authService = new AuthenticationService();
     if (!$this->authService->hasIdentity()) {
         $this->redirect()->toRoute("auth");
     }
     return parent::onDispatch($e);
 }
Example #13
0
 /**
  * (non-PHPdoc)
  * @see \Zend\Mvc\Controller\AbstractActionController::onDispatch()
  */
 public function onDispatch(MvcEvent $event)
 {
     $request = $event->getRequest();
     if (!$request instanceof HttpRequest || !$request->isXmlHttpRequest()) {
         //throw new \RuntimeException('This controller must only be called with ajax requests.');
     }
     return parent::onDispatch($event);
 }
Example #14
0
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $sessionUser = new container('user');
     if (!$sessionUser->connected) {
         $this->redirect()->toRoute('home');
     }
     return parent::onDispatch($e);
 }
 public function onDispatch(MvcEvent $e)
 {
     $logged_block = array('view', 'all');
     if (!$this->identity() && !in_array($e->getRouteMatch()->getParam("action"), $logged_block)) {
         return $this->redirect()->toRoute('home');
     }
     return parent::onDispatch($e);
 }
Example #16
0
 public function onDispatch(MvcEvent $e)
 {
     $this->authService->auth();
     $this->user = $this->authService->getUser();
     $this->layout()->user = $this->user;
     $this->layout()->userMessages = $this->authService->getUnreadMessages();
     parent::onDispatch($e);
 }
Example #17
0
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $this->user = new Container('user');
     if (!$this->user->boolLogged) {
         return $this->redirect()->toRoute('admin', array('controller' => 'login'));
     }
     return parent::onDispatch($e);
 }
 /**
  * Executa a requisicao
  *
  * @param \Zend\Mvc\MvcEvent $e
  *
  * @return mixed
  */
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $actionResponse = parent::onDispatch($e);
     $this->layout()->setVariable('breadcrumb', $this->getBreadcrumbOutput());
     $this->layout()->setVariable('title', $this->montarTitle($this->getTitle()));
     $this->layout()->setVariable('pageDescription', $this->getPageDescription());
     return $actionResponse;
 }
Example #19
0
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $this->msg = new Msg();
     $this->user = new Container('user');
     if (!$this->user->admin) {
         return $this->redirect()->toRoute('application/login');
     }
     return parent::onDispatch($e);
 }
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $user_session = new Container('A_Login');
     if (!$user_session->email || !$user_session->username) {
         return $this->redirect()->toUrl('cpanel/login');
         exit;
     }
     return parent::onDispatch($e);
 }
Example #21
0
 /**
  * @param MvcEvent $event
  *
  * @return mixed|void
  */
 public function onDispatch(MvcEvent $event)
 {
     if (getenv('APPLICATION_ENV') !== 'development') {
         $this->isAdmin();
     }
     parent::onDispatch($event);
     $this->initMenus();
     $this->getView()->setVariable('breadcrumbs', $this->breadcrumbs);
 }
 /**
  * Check Login
  *
  * @see \Zend\Mvc\Controller\AbstractActionController::onDispatch()
  */
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $username = $this->request->getServer()->get('REMOTE_USER', 'NoUser');
     if (false === $this->getHtpasswdService()->isUserAllowedToManageUsers($username)) {
         $this->getResponse()->setStatusCode(401);
         return;
     }
     return parent::onDispatch($e);
 }
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $service_locator_str = 'doctrine';
     $this->sm = $this->getServiceLocator();
     $doctrineService = $this->sm->get($service_locator_str);
     $this->modelOrder = new orderModel($doctrineService);
     $this->modelOrderDetail = new orderdetailModel($doctrineService);
     return parent::onDispatch($e);
 }
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $this->authservice = new AuthenticationService();
     if (!$this->authservice->hasIdentity()) {
         $this->redirect()->toRoute("login", array('action' => 'index'));
     }
     $this->layout()->setVariables(array("activemodule" => $this->getEvent()->getRouteMatch()->getMatchedRouteName()));
     parent::onDispatch($e);
 }
Example #25
0
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $this->msg = new Msg();
     $this->logged = new Container('user');
     if (!isset($this->logged->nick)) {
         return $this->redirect()->toRoute('application/login');
     }
     return parent::onDispatch($e);
 }
 /**
  * Check Login
  *
  * @see \Zend\Mvc\Controller\AbstractActionController::onDispatch()
  */
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $username = $this->getUserService()->getCurrentUser();
     if (false === $this->getUserService()->isUserAllowedToManageUsers($username)) {
         $this->getResponse()->setStatusCode(401);
         return;
     }
     return parent::onDispatch($e);
 }
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $layout = $this->layout();
     $layout->setTemplate('layout/master');
     $layout->setVariables(['menu' => $this->getServiceLocator()->get('Config')['menu']]);
     //        echo "<pre>";
     //        var_dump($this->getServiceLocator()->get('Config')['menu']);die();
     return parent::onDispatch($e);
 }
 /**
  * (non-PHPdoc)
  * @see \Zend\Mvc\Controller\AbstractActionController::onDispatch()
  */
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $routeMatch = $e->getRouteMatch();
     $action = $this->params()->fromQuery('action');
     if ($routeMatch && $action) {
         $routeMatch->setParam('action', $action);
     }
     return parent::onDispatch($e);
 }
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $this->acl = (new Acl())->getAcl();
     //        if (!$this->getServiceLocator()
     //                        ->get('AuthService')->hasIdentity()) {
     //            return $this->redirect()->toRoute('login');
     //        }
     return parent::onDispatch($e);
 }
Example #30
0
 public function onDispatch(\Zend\Mvc\MvcEvent $e)
 {
     $service_locator_str = 'doctrine';
     $this->postPerPage = 10;
     $this->sm = $this->getServiceLocator();
     $this->doctrineService = $this->sm->get($service_locator_str);
     $this->translator = Utility::translate();
     $this->init();
     return parent::onDispatch($e);
 }