Skip to content

Commit

Permalink
fixed UIController for missing action/subaction, index for missing ta…
Browse files Browse the repository at this point in the history
…rget
  • Loading branch information
RocketMan committed Dec 12, 2023
1 parent ee7810a commit b52a1b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
use ZK\Controllers\Dispatcher;

$dispatcher = new Dispatcher();
$dispatcher->processRequest($_REQUEST["target"]);
$dispatcher->processRequest($_REQUEST["target"] ?? '');
14 changes: 7 additions & 7 deletions ui/UIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function setContext($menu = null, $menuItem = null, $html = null) {
$this->app->content->template = $menuItem ? $menuItem->getTemplate() : null;
$this->app->content->title = $menuItem ? $menuItem->getTitle() : null;
$this->app->menu = $menu ?? [];
$this->app->submenu = $menuItem ? $menuItem->composeSubmenu($_REQUEST['action'], $_REQUEST['subaction']) : [];
$this->app->submenu = $menuItem ? $menuItem->composeSubmenu($_REQUEST['action'] ?? '', $_REQUEST['subaction'] ?? '') : [];
$this->app->tertiary = $menuItem ? $menuItem->getTertiary() : null;
$this->app->extra = $menuItem ? $menuItem->getExtra() : null;
}
Expand Down Expand Up @@ -171,7 +171,7 @@ public function processRequest() {
ob_end_clean();

$templateFact = new TemplateFactoryUI();
$templateFact->setContext($this->composeMenu($_REQUEST['action']), $this->menuItem, $data);
$templateFact->setContext($this->composeMenu($_REQUEST['action'] ?? ''), $this->menuItem, $data);
$template = $templateFact->load('index.html');
echo $template->render($this->menuItem ? $this->menuItem->getTemplateVars() : []);
}
Expand All @@ -185,10 +185,10 @@ protected function preProcessRequest() {
$_REQUEST["action"] != "loginValidate" &&
$_REQUEST["action"] != "logout") {
$_REQUEST["action"] = "invalidAction";
}
}

// Setup/teardown a session
switch($_REQUEST["action"]) {
switch($_REQUEST["action"] ?? '') {
case "loginValidate":
if(!$this->session->isAuth("u"))
$this->doLogin($_REQUEST["user"], $_REQUEST["password"]);
Expand All @@ -206,12 +206,12 @@ protected function preProcessRequest() {
break;
case "find":
// redirect full-text search URLs from v2.x
$qs = "?action=search&s=all&n=".urlencode($_REQUEST["search"]??'');
$qs = "?action=search&s=all&n=".urlencode($_REQUEST["search"] ?? '');
header("Location: ".Engine::getBaseUrl().$qs, true, 301); // 301 Moved Permanently
exit;
case "viewDJReviews";
// redirect DJ review URLs from v2.x
$qs = "?action=viewRecent&subaction=viewDJ&seq=selUser&viewuser=".urlencode($_REQUEST["n"]??'');
$qs = "?action=viewRecent&subaction=viewDJ&seq=selUser&viewuser=".urlencode($_REQUEST["n"] ?? '');
header("Location: ".Engine::getBaseUrl().$qs, true, 301); // 301 Moved Permanently
exit;
case "viewList":
Expand Down Expand Up @@ -376,7 +376,7 @@ protected function emitLogout() {
}

protected function checkCookiesEnabled() {
if($_REQUEST["checkCookie"]) {
if($_REQUEST["checkCookie"] ?? 0) {
if(isset($_COOKIE["testcookie"])) {
// the cookie test was successful!

Expand Down

0 comments on commit b52a1b1

Please sign in to comment.