diff --git a/history.php b/history.php
index 3640ce1..20e97d0 100644
--- a/history.php
+++ b/history.php
@@ -73,6 +73,20 @@ $page->name = "Recent Punishments for $name";
$page->print_title();
$page->print_page_header();
+$from = null;
+$from_title = null;
+$from_href = null;
+
+if (isset($_GET['from'])) {
+ // sanitize $_GET['from']
+ $info = $page->type_info($_GET['from']);
+ if ($info['type'] !== null) {
+ $from_title = $info['title'];
+ $from = lcfirst($from_title);
+ $from_href = "$from.php";
+ }
+}
+
try {
$all = array();
$counts = array();
@@ -133,20 +147,18 @@ try {
// print pager
if ($page->settings->show_pager) {
$page->name = "history";
- $page->print_pager($total, "&uuid=$uuid");
+ $args = "&uuid=$uuid";
+ if ($from !== null) {
+ $args .= "&from=$from";
+ }
+ $page->print_pager($total, $args);
}
} else {
echo "No punishments found.
";
}
- if (isset($_GET['from'])) {
- // sanitize $_GET['from']
- $info = $page->type_info($_GET['from']);
- if ($info['type'] !== null) {
- $title = $info['title'];
- $href = lcfirst($title) . ".php";
- echo "Return to $title";
- }
+ if ($from_href !== null) {
+ echo "
Return to $from_title";
}
$page->print_footer();