From 8b5df2f728b1daf69d932bc5803fde11a7ada1ab Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 18 Jan 2025 20:47:44 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20remove=20the=20simple=20stat=20p?= =?UTF-8?q?lugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-plugins/hit-counter/plugin.php | 6 +- bl-plugins/simple-stats/css/chartist.min.css | 1 - bl-plugins/simple-stats/css/style.css | 36 --- bl-plugins/simple-stats/js/chartist.min.js | 9 - bl-plugins/simple-stats/languages/da.json | 14 - bl-plugins/simple-stats/languages/de_CH.json | 15 - bl-plugins/simple-stats/languages/de_DE.json | 15 - bl-plugins/simple-stats/languages/en.json | 15 - bl-plugins/simple-stats/languages/es.json | 13 - bl-plugins/simple-stats/languages/fa_IR.json | 13 - bl-plugins/simple-stats/languages/fr_FR.json | 15 - bl-plugins/simple-stats/languages/it.json | 13 - bl-plugins/simple-stats/languages/ja_JP.json | 13 - bl-plugins/simple-stats/languages/nl_NL.json | 15 - bl-plugins/simple-stats/languages/ru_RU.json | 13 - bl-plugins/simple-stats/languages/tr.json | 13 - bl-plugins/simple-stats/metadata.json | 10 - bl-plugins/simple-stats/plugin.php | 275 ------------------- bl-plugins/visits-stats/plugin.php | 4 +- 19 files changed, 5 insertions(+), 503 deletions(-) delete mode 100644 bl-plugins/simple-stats/css/chartist.min.css delete mode 100644 bl-plugins/simple-stats/css/style.css delete mode 100644 bl-plugins/simple-stats/js/chartist.min.js delete mode 100644 bl-plugins/simple-stats/languages/da.json delete mode 100644 bl-plugins/simple-stats/languages/de_CH.json delete mode 100644 bl-plugins/simple-stats/languages/de_DE.json delete mode 100644 bl-plugins/simple-stats/languages/en.json delete mode 100644 bl-plugins/simple-stats/languages/es.json delete mode 100644 bl-plugins/simple-stats/languages/fa_IR.json delete mode 100644 bl-plugins/simple-stats/languages/fr_FR.json delete mode 100644 bl-plugins/simple-stats/languages/it.json delete mode 100644 bl-plugins/simple-stats/languages/ja_JP.json delete mode 100644 bl-plugins/simple-stats/languages/nl_NL.json delete mode 100644 bl-plugins/simple-stats/languages/ru_RU.json delete mode 100644 bl-plugins/simple-stats/languages/tr.json delete mode 100644 bl-plugins/simple-stats/metadata.json delete mode 100644 bl-plugins/simple-stats/plugin.php diff --git a/bl-plugins/hit-counter/plugin.php b/bl-plugins/hit-counter/plugin.php index f59e9428..c0fe7a97 100644 --- a/bl-plugins/hit-counter/plugin.php +++ b/bl-plugins/hit-counter/plugin.php @@ -16,7 +16,7 @@ class pluginHitCounter extends Plugin global $L; // Check if the plugin Simple Stats is activated - if (!pluginActivated('pluginSimpleStats')) { + if (!pluginActivated('pluginVisitsStats')) { // Show an alert about the dependency of the plugin $html = ' -EOF; - - $numberOfDays = $this->getValue('numberOfDays'); - $numberOfDays = $numberOfDays - 1; - for ($i = $numberOfDays; $i >= 0; $i--) { - $dateWithOffset = Date::currentOffset('Y-m-d', '-' . $i . ' day'); - $visits[$i] = $this->visits($dateWithOffset); - $unique[$i] = $this->uniqueVisitors($dateWithOffset); - $days[$i] = Date::format($dateWithOffset, 'Y-m-d', 'D'); - } - - $labels = "'" . implode("','", $days) . "'"; - $seriesVisits = implode(',', $visits); - $seriesUnique = implode(',', $unique); - - $script = << - var data = { - labels: [$labels], - series: [ - [$seriesVisits], - [$seriesUnique] - ] - }; - - var options = { - height: 250, - axisY: { - onlyInteger: true, - } - }; - - new Chartist.Line('.ct-chart', data, options); - -EOF; - - /** - * Optional Content Stats Feature - */ - if ($this->getValue('showContentStats')) { - global $pages, $categories, $tags; - - $data['title'] = $L->get('Statistics'); - $data['tabTitleChart'] = $L->get('Chart'); - $data['tabTitleTable'] = $L->get('Table'); - $data['data'][$L->get('published')] = count($pages->getPublishedDB()); - $data['data'][$L->get('static')] = count($pages->getStaticDB()); - $data['data'][$L->get('drafts')] = count($pages->getDraftDB()); - $data['data'][$L->get('scheduled')] = count($pages->getScheduledDB()); - $data['data'][$L->get('sticky')] = count($pages->getStickyDB()); - $data['data'][$L->get('categories')] = count($categories->keys()); - $data['data'][$L->get('tags')] = count($tags->keys()); - $html .= $this->renderContentStatistics($data); - } - - $this->deleteOldLogs(); - - return $html . PHP_EOL . $script . PHP_EOL; - } - - public function siteBodyEnd() - { - $this->addVisitor(); - } - - // Keep only 7 days of logs - public function deleteOldLogs() - { - $logs = Filesystem::listFiles($this->workspace(), '*', 'log', true); - $remove = array_slice($logs, 7); - - foreach ($remove as $log) { - Filesystem::rmfile($log); - } - } - - // Returns the amount of visits by date - public function visits($date) - { - $file = $this->workspace() . $date . '.log'; - $handle = @fopen($file, 'rb'); - if ($handle === false) { - return 0; - } - - // The amount of visits are the number of lines on the file - $lines = 0; - while (!feof($handle)) { - $lines += substr_count(fread($handle, 8192), PHP_EOL); - } - @fclose($handle); - return $lines; - } - - // Returns the amount of unique visitors by date - public function uniqueVisitors($date) - { - $file = $this->workspace() . $date . '.log'; - $lines = @file($file); - if (empty($lines)) { - return 0; - } - - $tmp = array(); - foreach ($lines as $line) { - $data = json_decode($line); - $hashIP = $data[0]; - $tmp[$hashIP] = true; - } - return count($tmp); - } - - // Add a line to the current log - // The line is a json array with the hash IP of the visitor and the time - public function addVisitor() - { - if (Cookie::get('KOBLOG-KEY') && defined('KOBLOG_PRO') && $this->getValue('excludeAdmins')) { - return false; - } - $currentTime = Date::current('Y-m-d H:i:s'); - $ip = TCP::getIP(); - $hashIP = md5($ip); - - $line = json_encode(array($hashIP, $currentTime)); - $currentDate = Date::current('Y-m-d'); - $logFile = $this->workspace() . $currentDate . '.log'; - - return file_put_contents($logFile, $line . PHP_EOL, FILE_APPEND | LOCK_EX) !== false; - } - - public function renderContentStatistics($data) - { - global $L; - $diskUsage = Filesystem::bytesToHumanFileSize( - Filesystem::getSize(PATH_ROOT) - ); - - $html = '
'; - $html .= "

{$data['title']}

"; - $html .= ' - - - -
- - '; - - return $html; - } -} diff --git a/bl-plugins/visits-stats/plugin.php b/bl-plugins/visits-stats/plugin.php index 09071213..078bc841 100644 --- a/bl-plugins/visits-stats/plugin.php +++ b/bl-plugins/visits-stats/plugin.php @@ -102,7 +102,7 @@ EOF; $html .= '
' . $L->get('This title is almost always used in the sidebar of the site') . '
'; $html .= ''; - if (defined('KOBLOG_PRO')) { + if (defined('BLUDIT_PRO')) { $html .= '
'; $html .= ''; $html .= '