From 485d0e1da3f52b0bdfb03547f739d7dd9a99cb8c Mon Sep 17 00:00:00 2001 From: aftercase <74765798+aftercase@users.noreply.github.com> Date: Mon, 12 Jul 2021 11:49:17 +0100 Subject: [PATCH] code clean up Removed unneeded code. --- includes/common.php | 9 +++++++++ theme/bulma/footer.php | 18 +++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/includes/common.php b/includes/common.php index 04fb377..483b812 100644 --- a/includes/common.php +++ b/includes/common.php @@ -26,6 +26,12 @@ function getSiteAds(PDO $conn) : array | bool { function getSiteTotalPastes(PDO $conn) : int { return intval($conn->query('SELECT COUNT(*) FROM pastes')->fetch(PDO::FETCH_NUM)[0]); } +function getSiteTotalviews(PDO $conn) : int { + return intval($conn->query('SELECT tpage FROM page_view ORDER BY id DESC LIMIT 1')->fetch(PDO::FETCH_NUM)[0]); +} +function getSiteTotal_unique_views(PDO $conn) : int { + return intval($conn->query('SELECT tvisit FROM page_view ORDER BY id DESC LIMIT 1')->fetch(PDO::FETCH_NUM)[0]); +} function updatePageViews(PDO $conn) : void { $ip = $_SERVER['REMOTE_ADDR']; @@ -132,3 +138,6 @@ if (isset($_GET['logout'])) { } $site_ads = getSiteAds($conn); +$total_pastes = getSiteTotalPastes($conn); +$total_page_views = getSiteTotalviews($conn); +$total_unique_views= getSiteTotal_unique_views($conn); \ No newline at end of file diff --git a/theme/bulma/footer.php b/theme/bulma/footer.php index 0c25cff..2ce85d0 100644 --- a/theme/bulma/footer.php +++ b/theme/bulma/footer.php @@ -1,15 +1,3 @@ -query("SELECT * FROM page_view"); - while ($row = $get_view_count->fetch()) { - $total_page = Trim($row['tpage']); - $total_un = Trim($row['tvisit']); - } - - $paste_counter = $conn->query("SELECT COUNT(id) from pastes"); - while ($row = $paste_counter->fetch()) { - $get_paste_count = $row['COUNT(id)']; - } -?>