Merge branch '2.0'
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / stat / AttachmentDiskUsageStatDailyHandler.class.php
1 <?php
2 namespace wcf\system\stat;
3 use wcf\system\WCF;
4
5 /**
6 * Stat handler implementation for attachment disk usage.
7 *
8 * @author Marcel Werk
9 * @copyright 2001-2014 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package com.woltlab.wcf
12 * @subpackage system.stat
13 * @category Community Framework
14 */
15 class AttachmentDiskUsageStatDailyHandler extends AbstractStatDailyHandler {
16 /**
17 * @see \wcf\system\stat\IStatDailyHandler::getData()
18 */
19 public function getData($date) {
20 $sql = "SELECT CEIL(SUM(filesize) / 1000)
21 FROM wcf".WCF_N."_attachment
22 WHERE uploadTime BETWEEN ? AND ?";
23 $statement = WCF::getDB()->prepareStatement($sql);
24 $statement->execute(array($date, $date + 86399));
25 $counter = intval($statement->fetchColumn());
26
27 $sql = "SELECT CEIL(SUM(filesize) / 1000)
28 FROM wcf".WCF_N."_attachment
29 WHERE uploadTime < ?";
30 $statement = WCF::getDB()->prepareStatement($sql);
31 $statement->execute(array($date + 86400));
32 $total = intval($statement->fetchColumn());
33
34 return array(
35 'counter' => $counter,
36 'total' => $total
37 );
38 }
39
40 /**
41 * @see \wcf\system\stat\IStatDailyHandler::getFormattedCounter()
42 */
43 public function getFormattedCounter($counter) {
44 return round($counter / 1000, 2); // return mb
45 }
46 }