Example #1
0
 function init()
 {
     $auth = Zend_Auth::getInstance();
     $this->_userInfo = $auth->getIdentity();
     $this->_dirApp = Zend_Registry::get('dirApp')->toArray();
     $this->view = Myapp_View_Smarty::getInstance();
     $this->view->setView($this->_dirApp['template_front'] . $this->_dirApp['style'] . '/');
     $smarty = $this->view->getEngine();
     $smarty->compile_dir = $this->_dirApp['template_front_cache'];
     $viewRenderer = $this->_helper->getHelper('viewRenderer');
     $viewRenderer->setView($this->view)->setViewBasePathSpec($smarty->template_dir)->setViewScriptPathSpec(':controller/:action.:suffix')->setViewScriptPathNoControllerSpec(':action.:suffix')->setViewSuffix($this->_dirApp['template_extension']);
     $this->_base_url = $this->_dirApp['base_url'];
     $this->view->assign('base_url', $this->_base_url);
     $this->view->assign('base_tpl', $this->_dirApp['base_tpl']);
     $this->_model = Front_Model_Lang::getInstance();
     $this->_module = $this->_getParam('module');
     $this->_control = $this->_getParam('controller');
     $action = $this->_getParam('action');
     $this->view->assign('form', array('module' => $this->_module, 'control' => $this->_control, 'action' => $action, 'lang' => $_SESSION['lang']));
     $this->_lable = Zend_Registry::get('lable');
     $this->view->assign('lable', $this->_lable);
     if (empty($this->_userInfo->adminId)) {
         $this->_redirect($this->_base_url . 'login/');
     }
     if ($this->_userInfo->adminId != '') {
         $file_name = $this->_dirApp['dir_auth'] . $this->_userInfo->adminLogin . '.ini';
         $sessionAuth = Myapp_File_Createauth::getInstance()->compareSession($file_name);
         if ($sessionAuth == true) {
             $this->_redirect($this->_base_url . 'logout/');
         }
     }
     $this->view->assign('userInfo', $this->_userInfo);
 }
Example #2
0
 function init()
 {
     $this->_dirApp = Zend_Registry::get('dirApp')->toArray();
     $this->view = Myapp_View_Smarty::getInstance();
     $this->view->setView($this->_dirApp['template_front'] . $this->_dirApp['style'] . '/');
     $smarty = $this->view->getEngine();
     $smarty->compile_dir = $this->_dirApp['template_front_cache'];
     $viewRenderer = $this->_helper->getHelper('viewRenderer');
     $viewRenderer->setView($this->view)->setViewBasePathSpec($smarty->template_dir)->setViewScriptPathSpec(':controller/:action.:suffix')->setViewScriptPathNoControllerSpec(':action.:suffix')->setViewSuffix($this->_dirApp['template_extension']);
     $this->view->assign('base_url', $this->_dirApp['base_url']);
     $this->view->assign('base_tpl', $this->_dirApp['base_tpl']);
     $this->_module = $this->_getParam('module');
     $this->_control = $this->_getParam('controller');
     $action = $this->_getParam('action');
     $this->view->assign('form', array('module' => $this->_module, 'control' => $this->_control, 'action' => $action, 'lang' => $_SESSION['lang']));
     $this->_lable = Zend_Registry::get('lable');
     $this->view->assign('lable', $this->_lable);
 }
Example #3
0
    function errorAction()
    {
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_dirApp = Zend_Registry::get('dirApp')->toArray();
        $this->view = Myapp_View_Smarty::getInstance();
        $this->view->setView($this->_dirApp['template_front'] . $this->_dirApp['style'] . '/');
        $smarty = $this->view->getEngine();
        $smarty->compile_dir = $this->_dirApp['template_front_cache'];
        $viewRenderer = $this->_helper->getHelper('viewRenderer');
        $viewRenderer->setView($this->view)->setViewBasePathSpec($smarty->template_dir)->setViewScriptPathSpec(':controller/:action.:suffix')->setViewScriptPathNoControllerSpec(':action.:suffix')->setViewSuffix($this->_dirApp['template_extension']);
        $this->view->assign('base_url', $this->_dirApp['base_url']);
        $this->view->assign('base_tlp_front', $this->_dirApp['file_template_front']);
        $this->module = $this->_getParam('module');
        $this->control = $this->_getParam('controller');
        $action = $this->_getParam('action');
        $this->view->assign('form', array('module' => $this->module, 'control' => $this->control, 'action' => $action, 'lang' => $_SESSION['lang']));
        $this->_lable = Zend_Registry::get('lable');
        $this->view->assign('lable', $this->_lable);
        $errors = $this->_getParam('error_handler');
        $exception = $errors->exception;
        $controllerError = $this->getRequest()->getRequestUri();
        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
                $this->getResponse()->setHttpResponseCode(404);
                $msg = $exception->getMessage();
                //$log = new Zend_Log( new Zend_Log_Writer_Stream($pathLog) );
                //$log->debug( date('Y-m-d H:i:s') .$controllerError ."\n" .$msg ."\n");
                break;
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
                $this->getResponse()->setHttpResponseCode(404);
                $msg = 'Đường dẫn bạn truy cập không tồn tại!<br />
						<a href="' . $this->_dirApp['base_url'] . '">Nhấp chuột vào đẩy</a> để trở về trang chủ hoặc form tìm kiếm bên trên';
                $msg = $exception->getMessage();
                //$log = new Zend_Log( new Zend_Log_Writer_Stream($pathLog) );
                //$log->debug( date('Y-m-d H:i:s') .$controllerError ."\n" .$msg ."\n");
                break;
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                $this->getResponse()->setHttpResponseCode(404);
                $msg = $exception->getMessage();
                //$this->lable['lang']['2_user_access_record'];
                $this->getResponse()->clearBody();
                //$log = new Zend_Log( new Zend_Log_Writer_Stream($pathLog) );
                //$log->debug( date('Y-m-d H:i:s') .$controllerError ."\n" .$msg ."\n");
                break;
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_OTHER:
                $this->getResponse()->setHttpResponseCode(404);
                $msg = $exception->getMessage();
                //$log = new Zend_Log( new Zend_Log_Writer_Stream($pathLog) );
                //$log->debug( date('Y-m-d H:i:s') .$controllerError ."\n" .$msg ."\n");
                break;
            case 500:
                $this->getResponse()->setHttpResponseCode(404);
                $msg = $exception->getMessage();
                //$log = new Zend_Log( new Zend_Log_Writer_Stream($pathLog) );
                //$log->debug( date('Y-m-d H:i:s') .$controllerError ."\n" .$msg ."\n");
                break;
            default:
                $this->getResponse()->setHttpResponseCode(404);
                $msg = $exception->getMessage();
                //$log = new Zend_Log( new Zend_Log_Writer_Stream($pathLog) );
                //$log->debug( date('Y-m-d H:i:s') .$controllerError ."\n" .$msg ."\n". $exception->getTraceAsString());
                break;
        }
        // Step 1:
        // using redirect home page
        echo $msg;
        //$this->_redirect($this->_dirApp['base_url']);
        // Step 2:
        //header("refresh:".$this->lable['lang']['timewait'].";url=".$this->_dirApp['base_url'] );
        // Using show error message on web browser
        $this->view->assign('msg', $msg);
        $this->view->assign('msg_classbox', 'error_box');
    }