From 004aabaae93386c8cb424f878718013261e99961 Mon Sep 17 00:00:00 2001 From: Banana Date: Tue, 22 Oct 2019 10:36:41 +0200 Subject: [PATCH] init of stats --- webroot/lib/management.class.php | 80 ++++++++++++++++++++++++++++++++ webroot/view/stats.inc.php | 37 +++++++++++++++ webroot/view/stats.php | 77 ++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 webroot/view/stats.inc.php create mode 100644 webroot/view/stats.php diff --git a/webroot/lib/management.class.php b/webroot/lib/management.class.php index 68d5602..07ad6c4 100644 --- a/webroot/lib/management.class.php +++ b/webroot/lib/management.class.php @@ -460,6 +460,86 @@ class Management { return $ret; } + /** + * amount of links in the DB. Status 1 and 2 only + * @return int + */ + public function linkAmount() { + $ret = 0; + + $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_link`"; + if($this->_showPrivate === true) { + $queryStr .= " WHERE `status` IN (2,1)"; + } + else { + $queryStr .= " WHERE `status` = 2"; + } + + $query = $this->DB->query($queryStr); + if(!empty($query) && $query->num_rows > 0) { + $result = $query->fetch_assoc(); + $ret = $result['amount']; + } + + return $ret; + } + + + /** + * amount of tags + * @return int + */ + public function tagAmount() { + $ret = 0; + + $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_tag`"; + + $query = $this->DB->query($queryStr); + if(!empty($query) && $query->num_rows > 0) { + $result = $query->fetch_assoc(); + $ret = $result['amount']; + } + + return $ret; + } + + /** + * amount of categories + * @return int + */ + public function categoryAmount() { + $ret = 0; + + $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_category`"; + + $query = $this->DB->query($queryStr); + if(!empty($query) && $query->num_rows > 0) { + $result = $query->fetch_assoc(); + $ret = $result['amount']; + } + + return $ret; + } + + /** + * Amount of links need moderation + * @return int + */ + public function moderationAmount() { + $ret = 0; + + $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_link`"; + $queryStr .= " WHERE `status` = 3"; + + $query = $this->DB->query($queryStr); + if(!empty($query) && $query->num_rows > 0) { + $result = $query->fetch_assoc(); + $ret = $result['amount']; + } + + return $ret; + } + /** * for simpler management we have the search data in a separate column * it is not fancy or even technical nice but it damn works diff --git a/webroot/view/stats.inc.php b/webroot/view/stats.inc.php new file mode 100644 index 0000000..e72953a --- /dev/null +++ b/webroot/view/stats.inc.php @@ -0,0 +1,37 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0. + * + */ +$_displayEditButton = false; +if(Summoner::simpleAuthCheck() === true) { + $_displayEditButton = true; + $moderationAmount = $Management->moderationAmount(); +} + +$linkAmount = $Management->linkAmount(); +$tagAmount = $Management->tagAmount(); +$categoryAmount = $Management->categoryAmount(); + diff --git a/webroot/view/stats.php b/webroot/view/stats.php new file mode 100644 index 0000000..dcf7628 --- /dev/null +++ b/webroot/view/stats.php @@ -0,0 +1,77 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0. + * + */ +?> +
+
+
+

+ + + + + + + + + +

+
+
+ +
+
+

Stats

+
+
+
+ +
+
+
+

Links

+

# of Links:

+

View all

+
+
+

Tags

+

# of Tags:

+

View all

+
+
+

Categories

+

# of Categories:

+

View all

+
+ +
+

Moderation

+

# Moderation needed:

+
+ +
+
-- 2.39.5