Skip to content

Commit

Permalink
Fixed not working links from database, introduced in 0.8.10
Browse files Browse the repository at this point in the history
  • Loading branch information
slawkens committed Aug 7, 2023
1 parent a338fd9 commit 1e874c7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
}

// handle ?fbclid=x, etc. (show news page)
if (!$found && count($_GET) > 0 && !isset($_REQUEST['subtopic']) && !isset($_REQUEST['p'])) {
if (!$found && count($_GET) > 0 && !isset($_REQUEST['subtopic']) && !isset($_REQUEST['p']) && !in_array($_SERVER['QUERY_STRING'], getDatabasePages())) {
$_REQUEST['p'] = $_REQUEST['subtopic'] = 'news';
$found = true;
}
Expand Down
22 changes: 22 additions & 0 deletions system/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,28 @@ function displayErrorBoxWithBackButton($errors, $action = null) {
]);
}

function getDatabasePages($withHidden = false): array
{
global $db, $logged_access;

if (!isset($logged_access)) {
$logged_access = 1;
}

$pages = $db->query('SELECT `name` FROM ' . TABLE_PREFIX . 'pages WHERE ' . ($withHidden ? '' : '`hidden` != 1 AND ') . '`access` <= ' . $db->quote($logged_access));
$ret = [];

if ($pages->rowCount() < 1) {
return $ret;
}

foreach($pages->fetchAll() as $page) {
$ret[] = $page['name'];
}

return $ret;
}

// validator functions
require_once LIBS . 'validator.php';
require_once SYSTEM . 'compat/base.php';

0 comments on commit 1e874c7

Please sign in to comment.