diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index b3ba22263..57ff42b0d 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -52,6 +52,7 @@ Application_Model_Auth::pinSessionToClient(Zend_Auth::getInstance()); $front = Zend_Controller_Front::getInstance(); $front->registerPlugin(new RabbitMqPlugin()); +$front->throwExceptions(false); //localization configuration Application_Model_Locale::configureLocalization(); diff --git a/airtime_mvc/application/controllers/ErrorController.php b/airtime_mvc/application/controllers/ErrorController.php index 70829db63..8a62d9ea6 100644 --- a/airtime_mvc/application/controllers/ErrorController.php +++ b/airtime_mvc/application/controllers/ErrorController.php @@ -1,26 +1,40 @@ view->layout()->disableLayout(); + $this->setupCSS(); + + } + + public function errorAction() { $errors = $this->_getParam('error_handler'); - switch ($errors->type) { - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: - case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: + if ($errors) { + // log error message and stack trace + Logging::error($errors->exception->getMessage()); + Logging::error($errors->exception->getTraceAsString()); - // 404 error -- controller or action not found - $this->getResponse()->setHttpResponseCode(404); - $this->view->message = _('Page not found'); - break; - default: - // application error - $this->getResponse()->setHttpResponseCode(500); - $this->view->message = _('Application error'); - break; + switch ($errors->type) { + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE : + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER : + $this->error404Action(); + break; + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION : + $this->error400Action(); + break; + default : + $this->error500Action(); + break; + } + } else { + $exceptions = $this->_getAllParams(); + Logging::error($exceptions); + $this->error500Action(); + return; } // Log exception, if logger available @@ -33,11 +47,17 @@ class ErrorController extends Zend_Controller_Action $this->view->exception = $errors->exception; } - $this->view->request = $errors->request; + $this->view->request = $errors->request; } - public function getLog() + private function setupCSS() { + $CC_CONFIG = Config::getConfig(); + $staticBaseDir = Application_Common_OsPath::formatDirectoryWithDirectorySeparators($CC_CONFIG['staticBaseDir']); + $this->view->headLink()->appendStylesheet($staticBaseDir . 'css/styles.css?' . $CC_CONFIG['airtime_version']); + } + + public function getLog() { $bootstrap = $this->getInvokeArg('bootstrap'); if (!$bootstrap->hasPluginResource('Log')) { return false; @@ -47,9 +67,43 @@ class ErrorController extends Zend_Controller_Action return $log; } - public function deniedAction() - { - // action body + /** + * 404 error - route or controller + */ + public function error404Action() { + $this->_helper->viewRenderer('error-404'); + $this->getResponse()->setHttpResponseCode(404); + $this->view->message = _('Page not found.'); } + /** + * 400 error - no such action + */ + public function error400Action() { + $this->_helper->viewRenderer('error-400'); + $this->getResponse()->setHttpResponseCode(400); + $this->view->message = _('The requested action is not supported.'); + + } + + /** + * 403 error - permission denied + */ + public function error403Action() { + + $this->_helper->viewRenderer('error-403'); + $this->getResponse()->setHttpResponseCode(403); + $this->view->message = _('You do not have permission to access this resource.'); + } + + /** + * 500 error - internal server error + */ + public function error500Action() { + + $this->_helper->viewRenderer('error-500'); + + $this->getResponse()->setHttpResponseCode(500); + $this->view->message = _('An internal application error has occurred.'); + } } diff --git a/airtime_mvc/application/controllers/ProvisioningController.php b/airtime_mvc/application/controllers/ProvisioningController.php index 0ecd185d2..4aa02fa39 100644 --- a/airtime_mvc/application/controllers/ProvisioningController.php +++ b/airtime_mvc/application/controllers/ProvisioningController.php @@ -26,7 +26,7 @@ class ProvisioningController extends Zend_Controller_Action $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); - if (!RestAuth::verifyAuth(true, true, $this)) { + if (!RestAuth::verifyAuth(true, false, $this)) { return; } @@ -65,12 +65,12 @@ class ProvisioningController extends Zend_Controller_Action } $CC_CONFIG = Config::getConfig(); - + foreach ($CC_CONFIG["supportedStorageBackends"] as $storageBackend) { $proxyStorageBackend = new ProxyStorageBackend($storageBackend); $proxyStorageBackend->deleteAllCloudFileObjects(); } - + $this->getResponse() ->setHttpResponseCode(200) ->appendBody("OK"); diff --git a/airtime_mvc/application/controllers/plugins/Acl_plugin.php b/airtime_mvc/application/controllers/plugins/Acl_plugin.php index 10910fb73..7ea1336d0 100644 --- a/airtime_mvc/application/controllers/plugins/Acl_plugin.php +++ b/airtime_mvc/application/controllers/plugins/Acl_plugin.php @@ -28,7 +28,7 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract { $this->_errorPage = array('module' => 'default', 'controller' => 'error', - 'action' => 'denied'); + 'action' => 'error'); $this->_roleName = $roleName; @@ -111,7 +111,16 @@ class Zend_Controller_Plugin_Acl extends Zend_Controller_Plugin_Abstract $controller = strtolower($request->getControllerName()); Application_Model_Auth::pinSessionToClient(Zend_Auth::getInstance()); - if (in_array($controller, array("api", "auth", "locale", "upgrade", 'whmcs-login', "provisioning"))) { + if (in_array($controller, array( + "api", + "auth", + "error", + "locale", + "upgrade", + 'whmcs-login', + "provisioning" + ))) + { $this->setRoleName("G"); } elseif (!Zend_Auth::getInstance()->hasIdentity()) { diff --git a/airtime_mvc/application/views/scripts/error/error-400.phtml b/airtime_mvc/application/views/scripts/error/error-400.phtml new file mode 100644 index 000000000..329b55228 --- /dev/null +++ b/airtime_mvc/application/views/scripts/error/error-400.phtml @@ -0,0 +1,18 @@ + + + + + <?php echo _("An error has occurred.") ?> + headLink(); ?> + + +
+

+

+
+ +
+
+ + diff --git a/airtime_mvc/application/views/scripts/error/error-403.phtml b/airtime_mvc/application/views/scripts/error/error-403.phtml new file mode 100644 index 000000000..0e8d781fd --- /dev/null +++ b/airtime_mvc/application/views/scripts/error/error-403.phtml @@ -0,0 +1,18 @@ + + + + + <?php echo _("An error has occurred.") ?> + headLink(); ?> + + +
+

+

+
+ +
+
+ + diff --git a/airtime_mvc/application/views/scripts/error/error-500.phtml b/airtime_mvc/application/views/scripts/error/error-500.phtml new file mode 100644 index 000000000..fe5bd9f39 --- /dev/null +++ b/airtime_mvc/application/views/scripts/error/error-500.phtml @@ -0,0 +1,18 @@ + + + + + <?php echo _("An error has occurred.") ?> + headLink(); ?> + + +
+

+

+
+ +
+
+ + diff --git a/airtime_mvc/application/views/scripts/error/error.phtml b/airtime_mvc/application/views/scripts/error/error.phtml index 4c5146296..7a17ae7c6 100644 --- a/airtime_mvc/application/views/scripts/error/error.phtml +++ b/airtime_mvc/application/views/scripts/error/error.phtml @@ -3,7 +3,8 @@ - <?php echo _("Zend Framework Default Application") ?> + <?php echo _("An error has occurred.") ?> + headLink(); ?>
diff --git a/airtime_mvc/public/css/images/maintenance.png b/airtime_mvc/public/css/images/maintenance.png new file mode 100644 index 000000000..0a000c6c6 Binary files /dev/null and b/airtime_mvc/public/css/images/maintenance.png differ diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 31a3f8383..d709bf038 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -899,20 +899,19 @@ input[type="checkbox"] { /* Remove any visible csrf form token footprint */ #csrf-label { - height: 0; - padding: 0; - margin: 0; + display: none; } #csrf-element { - height: 8px; padding: 0; margin: 0; + display: inline-block; } +/* #csrf-label .errors li, #csrf-element .errors li { margin: 0; -} +}*/ .login_box { margin: 0 auto 0 auto; @@ -1031,7 +1030,6 @@ input[type="checkbox"] { #pref_form p.description { color: #3b3b3b; font-size: 12px; - float: left; } dt.block-display, dd.block-display { @@ -2193,7 +2191,7 @@ dd.radio-inline-list, .preferences dd.radio-inline-list, .stream-config dd.radio width: 98.5%; } -.preferences dd#SoundCloudTags-element.block-display .input_text_area { +.preferences dd.block-display .input_text_area { height: 120px; } @@ -2202,14 +2200,10 @@ dd.radio-inline-list, .preferences dd.radio-inline-list, .stream-config dd.radio } .preferences #logo-remove-btn { - float: right; + /*float: left;*/ margin-bottom: 4px; } -.preferences #Logo-img-container { - margin-top: 30px; -} - #show_time_info { font-size:12px; height:30px; @@ -2570,19 +2564,21 @@ dt.block-display.info-block { /*---//////////////////// ERROR PAGE ////////////////////---*/ -.error-content { - background:url(images/404.png) no-repeat 0 0; - width:300px; - margin: 24px 15px; - padding: 0px 10px 0 420px; +.error-content { + background:url(images/maintenance.png) no-repeat 0 0; + width:360px; + height:350px; + margin:auto; + margin-top:25px; + padding:auto; } .error-content h2 { margin:0; - padding:0 0 10px 0; + padding:350px 0 10px 0; font-size:36px; font-weight:bold; color:#3e3e3e; - text-align:left; + text-align:center; letter-spacing:-.3px; text-shadow: rgba(248,248,248,.3) 0 1px 0, rgba(0,0,0,.8) 0 -1px 0; rgba(51,51,51,.9) @@ -2590,12 +2586,14 @@ dt.block-display.info-block { .error-content p { color: #272727; font-size: 16px; + text-align:center; margin: 0; padding:8px 2px; } -.error-content .button-bar { +.error-content .button-bar { margin-top:47px; padding-left:2px; + text-align:center; } .error-content .toggle-button { border: 1px solid #434343; @@ -3142,3 +3140,4 @@ dd .stream-status { } .quota-reached { font-size: 14px !important; +}