diff --git a/app/Config/routes.php b/app/Config/routes.php index 58d91a36..f0c1d865 100755 --- a/app/Config/routes.php +++ b/app/Config/routes.php @@ -14,6 +14,8 @@ Router::connect('/p/*', ['controller' => 'pages', 'action' => 'index']); + Router::connect('/maintenance/*', ['controller' => 'maintenance', 'action' => 'index']); + Router::connect('/profile', ['controller' => 'user', 'action' => 'profile']); Router::connect('/profile/modify', ['controller' => 'user', 'action' => 'modify_profile']); diff --git a/app/Controller/AppController.php b/app/Controller/AppController.php index 42c73af3..fa74e035 100755 --- a/app/Controller/AppController.php +++ b/app/Controller/AppController.php @@ -60,6 +60,7 @@ public function beforeFilter() 'action' => 'index', 'plugin' => false, 'admin' => false, + explode("/", $this->here)[1] ]); } @@ -532,7 +533,11 @@ public function __initSeoConfiguration() $this->loadModel('Seo'); $default = $this->Seo->find('first', ["conditions" => ['page' => null]]); $current_url = $this->here; - $get_page = $this->Seo->find('first', ["conditions" => ['page LIKE' => $current_url . "%"]]); + $get_page = []; + $start_url = "/" . explode("/", $current_url)[1]; + $check = $this->Seo->find('first', ["conditions" => ['page LIKE' => $start_url . "%"]]); + if ($check && ($check['Seo']["url"] == $current_url || $current_url != "/")) + $get_page = $check; $seo_config['title'] = (!empty($default['Seo']['title']) ? $default['Seo']['title'] : "{TITLE} - {WEBSITE_NAME}"); $seo_config['title'] = (!empty($get_page['Seo']['title']) ? $get_page['Seo']['title'] : $seo_config['title']); $seo_config['description'] = (!empty($get_page['Seo']['description']) ? $get_page['Seo']['description'] : (!empty($default['Seo']['description']) ? $default['Seo']['description'] : "")); diff --git a/app/Controller/MaintenanceController.php b/app/Controller/MaintenanceController.php index 94457d73..5ffb669b 100755 --- a/app/Controller/MaintenanceController.php +++ b/app/Controller/MaintenanceController.php @@ -9,11 +9,12 @@ public function index($url = "") { $this->set('title_for_layout', $this->Lang->get('MAINTENANCE__TITLE')); $this->loadModel("Maintenance"); - - if ($this->Permissions->can("BYPASS_MAINTENANCE") || !$this->Maintenance->checkMaintenance("/" . $url)) + $check = $this->Maintenance->checkMaintenance("/" . $url); + if ($this->Permissions->can("BYPASS_MAINTENANCE") || !$check) { $this->redirect("/"); + } - $msg = $this->Maintenance->checkMaintenance("/" . $url)["Maintenance"]["reason"]; + $msg = $check["reason"]; $this->set(compact('msg')); } diff --git a/app/Model/Maintenance.php b/app/Model/Maintenance.php index 39932558..53d15973 100644 --- a/app/Model/Maintenance.php +++ b/app/Model/Maintenance.php @@ -4,20 +4,20 @@ class Maintenance extends AppModel { function checkMaintenance($url = "") { - $check = $this->find("first", ["conditions" => ["url LIKE" => $url . "%", "active" => 1]])["Maintenance"]; - if ($check) { - if (!$check["sub_url"] && $check["url"] != $url) - return false; - return true; - } + $start_url = "/" . explode("/", $url)[1]; + $check = $this->find("first", ["conditions" => ["url LIKE" => $start_url . "%", "active" => 1]])["Maintenance"]; + + if ($check && (($check["url"] == $url) || ($check["sub_url"] && $url != "/"))) + return $check; + $is_full = $this->isFullMaintenance(); if ($is_full) - return true; + return $is_full; return false; } function isFullMaintenance() { - return $this->find("first", ["conditions" => ["url" => "", "active" => 1]]); + return $this->find("first", ["conditions" => ["url" => "", "active" => 1]])["Maintenance"]; } } \ No newline at end of file diff --git a/app/View/Maintenance/admin_add.ctp b/app/View/Maintenance/admin_add.ctp index 9381969d..3dc1b36b 100644 --- a/app/View/Maintenance/admin_add.ctp +++ b/app/View/Maintenance/admin_add.ctp @@ -33,7 +33,7 @@