~xibo-maintainers/xibo/tempel

« back to all changes in this revision

Viewing changes to lib/data/bandwidth.data.class.php

  • Committer: Dan Garner
  • Date: 2015-03-26 14:08:33 UTC
  • Revision ID: git-v1:70d14044444f8dc5d602b99890d59dea46d9470c
Moved web servable files to web folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * Xibo - Digital Signage - http://www.xibo.org.uk
 
4
 * Copyright (C) 2009-2012 Daniel Garner
 
5
 *
 
6
 * This file is part of Xibo.
 
7
 *
 
8
 * Xibo is free software: you can redistribute it and/or modify
 
9
 * it under the terms of the GNU Affero General Public License as published by
 
10
 * the Free Software Foundation, either version 3 of the License, or
 
11
 * any later version. 
 
12
 *
 
13
 * Xibo is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU Affero General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Affero General Public License
 
19
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
use Xibo\Helper\Log;
 
22
 
 
23
defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
 
24
 
 
25
class Bandwidth extends Data {
 
26
 
 
27
    public static $REGISTER = 1;
 
28
    public static $RF = 2;
 
29
    public static $SCHEDULE = 3;
 
30
    public static $GETFILE = 4;
 
31
    public static $GETRESOURCE = 5;
 
32
    public static $MEDIAINVENTORY = 6;
 
33
    public static $NOTIFYSTATUS = 7;
 
34
    public static $SUBMITSTATS = 8;
 
35
    public static $SUBMITLOG = 9;
 
36
    public static $BLACKLIST = 10;
 
37
    public static $SCREENSHOT = 11;
 
38
 
 
39
        public function Log($displayId, $type, $sizeInBytes) {
 
40
        try {
 
41
            $dbh = \Xibo\Storage\PDOConnect::init();
 
42
        
 
43
            $sth = $dbh->prepare('
 
44
                INSERT INTO `bandwidth` (Month, Type, DisplayID, Size) VALUES (:month, :type, :displayid, :size)
 
45
                ON DUPLICATE KEY UPDATE Size = Size + :size2
 
46
                ');
 
47
 
 
48
            $sth->execute(array(
 
49
                    'month' => strtotime(date('m').'/02/'.date('Y').' 00:00:00'), 
 
50
                    'type' => $type, 
 
51
                    'displayid' => $displayId, 
 
52
                    'size' => $sizeInBytes,
 
53
                    'size2' => $sizeInBytes
 
54
                ));
 
55
            
 
56
            return true;  
 
57
        }
 
58
        catch (Exception $e) {
 
59
            Log::error($e->getMessage());
 
60
            return false;
 
61
        }
 
62
    }
 
63
 
64
?>