M classes/Page.php +5 -4
@@ 9,14 9,15 @@ class Page
$this->db = $db;
}
- public function getAll($id)
+ public function getAll($name)
{
$sql = "SELECT
- slug, content
+ slug, content, name
FROM pages
- WHERE user_id=?
+ LEFT JOIN users on pages.user_id = users.id
+ WHERE name=?
ORDER BY slug";
- return $this->db->runSQL($sql, [$id])->fetchAll();
+ return $this->db->runSQL($sql, [$name])->fetchAll();
}
public function getActivity()
M includes/app.php +1 -14
@@ 67,22 67,9 @@ function form_errors($errors)
echo '</ul>';
}
-function get_id()
-{
- if (!($id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT))) {
- page_not_found();
- }
-
- return $id;
-}
-
function get_param($param)
{
- if (!($rv = filter_input(INPUT_GET, $param, FILTER_SANITIZE_SPECIAL_CHARS))) {
- page_not_found();
- }
-
- return $rv;
+ return filter_input(INPUT_GET, $param, FILTER_SANITIZE_SPECIAL_CHARS);
}
function timeAgo($dateString)
M +1 -1
@@ 15,7 15,7 @@
<header>
<nav>
<?=site_link($site_user['name'], null, "Home")?>
<a href="pages_index.php?id=<?=$site_user['id']?>">Pages</a>
<a href="pages.php?u=<?=$site_user['name']?>">Pages</a>
<a href="changelog.php?u=<?=$site_user['name']?>">Changelog</a>
</nav>
</header>
M pages_index.php => pages.php +3 -3
@@ 1,9 1,9 @@
<?php
require 'includes/app.php';
-$id = get_id();
-$pages = $App->getPage()->getAll($id);
-$site_user = $App->getUser()->get($id) or page_not_found();
+$u = get_param("u");
+$pages = $App->getPage()->getAll($u);
+$site_user = $App->getUser()->getFromUsername($u) or page_not_found();
?>
<?php include 'includes/site_header.php'; ?>
M site.php +1 -1
@@ 2,7 2,7 @@
require 'includes/app.php';
$u = get_param("u");
-$p = filter_input(INPUT_GET, 'p', FILTER_SANITIZE_SPECIAL_CHARS);
+$p = get_param("p");
$site_user = $App->getUser()->getFromUsername($u) or page_not_found();
$is_admin = is_site_admin($site_user);