From c8704dd82422b7b5401bd4424ad76bc1bf7b8b08 Mon Sep 17 00:00:00 2001 From: d47081 Date: Thu, 27 Oct 2022 16:25:04 +0300 Subject: [PATCH] remove mod rewrite relations --- public/index.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/public/index.php b/public/index.php index d3cd76a..8dd0d04 100755 --- a/public/index.php +++ b/public/index.php @@ -4,24 +4,23 @@ require_once('../config.php'); require_once('../library/icon.php'); require_once('../library/sqlite.php'); -$query = isset($_GET['q']) ? preg_replace('/[^\w\s]+/u', '', $_GET['q']) : ''; -$ns = isset($_GET['ns']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['ns']) : ''; -$tx = isset($_GET['tx']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['tx']) : ''; -$page = (int) isset($_GET['page']) ? $_GET['page'] : 0; -$rss = isset($_GET['rss']) ? true : false; +$query = isset($_GET['q']) ? preg_replace('/[^\w\s]+/u', '', urldecode($_GET['q'])) : ''; +$ns = ''; +$tx = ''; +$page = 0; -if (isset($_SERVER['QUERY_STRING'])) { +if (isset($_SERVER['REQUEST_URI'])) { - $q = explode('/', $_SERVER['QUERY_STRING']); + $q = explode('/', $_SERVER['REQUEST_URI']); if (isset($q[1])) { if ($q[1] == 'rss') { $rss = true; } else if (strlen($q[1]) == 34) { $ns = preg_replace('/[^a-zA-Z0-9]+/', '', $q[1]); - } else if (strlen($q[1]) > 34) { + } else if (strlen($q[1]) == 64) { $tx = preg_replace('/[^a-zA-Z0-9]+/', '', $q[1]); - } else { + } else if (preg_match('/[0-9]+/', $q[1])) { $page = (int) $q[1]; } } @@ -31,12 +30,16 @@ if (isset($_SERVER['QUERY_STRING'])) { $rss = true; } else if (strlen($q[2]) == 34) { $ns = preg_replace('/[^a-zA-Z0-9]+/', '', $q[2]); - } else { + } else if (preg_match('/[0-9]+/', $q[2])) { $page = (int) $q[2]; } } } +if ($query) { + $rss = isset($_GET['rss']) ? true : false; +} + if ($page > 0) { $limit = PAGE_LIMIT * $page - PAGE_LIMIT; } else {