Fixed multiple issues
authorMarcel Werk <burntime@woltlab.com>
Sat, 19 Apr 2014 22:51:20 +0000 (00:51 +0200)
committerMarcel Werk <burntime@woltlab.com>
Sat, 19 Apr 2014 22:51:20 +0000 (00:51 +0200)
wcfsetup/install/files/lib/acp/page/StatPage.class.php
wcfsetup/install/files/lib/data/stat/daily/StatDailyAction.class.php
wcfsetup/install/files/lib/system/stat/AttachmentDiskUsageStatDailyHandler.class.php
wcfsetup/install/files/lib/system/stat/LikeStatDailyHandler.class.php

index 715acd9ace23ba21e5189a75b84468c0db8bf385..b96cc97b93ebff628c23bd26c34afb4fa781c29c 100644 (file)
@@ -51,7 +51,7 @@ class StatPage extends AbstractPage {
                parent::readData();
                
                // set default values
-               $d = DateUtil::getDateTimeByTimestamp(1366416000); // @todo TIME_NOW
+               $d = DateUtil::getDateTimeByTimestamp(TIME_NOW);
                $d->setTimezone(WCF::getUser()->getTimeZone());
                $this->endDate = $d->format('Y-m-d');
                $d->sub(new \DateInterval('P1M'));
index 6183c22ff46c432013f3e3824ebeec1508391b16..772fec6c4fc82f63088fd5eb7ca905ca464ceeff 100644 (file)
@@ -29,12 +29,12 @@ class StatDailyAction extends AbstractDatabaseObjectAction {
                WCF::getSession()->checkPermissions(array('admin.system.canViewLog'));
                
                // validate start date
-               if (empty($this->parameters['startDate']) || !preg_match('/^\d{4}\-\d{2}\-\d{2}$/')) {
+               if (empty($this->parameters['startDate']) || !preg_match('/^\d{4}\-\d{2}\-\d{2}$/', $this->parameters['startDate'])) {
                        throw new UserInputException('startDate');
                }
                
                // validate end date
-               if (empty($this->parameters['endDate']) || !preg_match('/^\d{4}\-\d{2}\-\d{2}$/')) {
+               if (empty($this->parameters['endDate']) || !preg_match('/^\d{4}\-\d{2}\-\d{2}$/', $this->parameters['endDate'])) {
                        throw new UserInputException('endDate');
                }
                
index f53c58ceeb6586e806c1a9f686a229f54b9857f7..ffc0c0b1bf1b81c6a87ed99d7e4781cc9cbc5ffe 100644 (file)
@@ -17,14 +17,14 @@ class AttachmentDiskUsageStatDailyHandler extends AbstractStatDailyHandler {
         * @see \wcf\system\stat\IStatDailyHandler::getData()
         */
        public function getData($date) {
-               $sql = "SELECT  SUM(filesize)
+               $sql = "SELECT  CEIL(SUM(filesize) / 1000)
                        FROM    wcf".WCF_N."_attachment
                        WHERE   uploadTime BETWEEN ? AND ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(array($date, $date + 86399));
                $counter = intval($statement->fetchColumn());
                
-               $sql = "SELECT  SUM(filesize)
+               $sql = "SELECT  CEIL(SUM(filesize) / 1000)
                        FROM    wcf".WCF_N."_attachment
                        WHERE   uploadTime < ?";
                $statement = WCF::getDB()->prepareStatement($sql);
@@ -41,6 +41,6 @@ class AttachmentDiskUsageStatDailyHandler extends AbstractStatDailyHandler {
         * @see \wcf\system\stat\IStatDailyHandler::getFormattedCounter()
         */
        public function getFormattedCounter($counter) {
-               return round($counter / 1000000); // return mb
+               return round($counter / 1000, 2); // return mb
        }
 }
index 57daad62739b1f03172abfdbb15da59e9d45162c..89f57cc028a7ac52c6ceeb19b7e2c7c504b78e41 100644 (file)
@@ -23,14 +23,15 @@ class LikeStatDailyHandler extends AbstractStatDailyHandler {
                $sql = "SELECT  COUNT(*)
                        FROM    wcf".WCF_N."_like
                        WHERE   time BETWEEN ? AND ?
-                               AND likeValue";
+                               AND likeValue = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(array($date, $date + 86399, $this->likeValue));
                $counter = intval($statement->fetchColumn());
                
                $sql = "SELECT  COUNT(*)
                        FROM    wcf".WCF_N."_like
-                       WHERE   time < ?";
+                       WHERE   time < ?
+                               AND likeValue = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(array($date + 86400, $this->likeValue));
                $total = intval($statement->fetchColumn());