htdocs/24hours.php
changeset 37 c3cbefda414a
parent 34 a8daa2016cf1
equal deleted inserted replaced
36:a7d884914a74 37:c3cbefda414a
     1 <?php
     1 <?php
     2 
     2 
     3 require('../stats-fe.php');
     3 $_GET['mode'] = 'lastday';
     4 require('../graphs.php');
     4 require('graph.php');
     5 require('../timezone.php');
       
     6 
     5 
     7 $channel_list = stats_channel_list();
       
     8 $first_channel = $channel_list[0];
       
     9 $channel = ( isset($_REQUEST['channel']) && in_array($_REQUEST['channel'], $channel_list) ) ? $_REQUEST['channel'] : $first_channel;
       
    10 
       
    11 // generate the data
       
    12 // we're doing this by absolute hours, not by strictly "24 hours ago", e.g. on-the-hour stats
       
    13 $this_hour = gmmktime(gmdate('H'), 0, 0);
       
    14 $graphdata = array();
       
    15 
       
    16 for ( $i = 23; $i >= 0; $i-- )
       
    17 {
       
    18   $basetime = $this_hour - ( $i * 3600 );
       
    19   $ts = date('H:i', $basetime);
       
    20   $basetime += 3600;
       
    21   $graphdata[$ts] = stats_message_count($channel, 60, $basetime);
       
    22 }
       
    23 
       
    24 $max = max($graphdata);
       
    25 
       
    26 // Determine axis interval
       
    27 $interval = 2;
       
    28 if ( $max > 20 )
       
    29   $interval = 4;
       
    30 if ( $max > 25 )
       
    31   $interval = 5;
       
    32 if ( $max > 50 )
       
    33   $interval = 10;
       
    34 if ( $max > 200 )
       
    35   $interval = 40;
       
    36 if ( $max > 500 )
       
    37   $interval = 80;
       
    38 if ( $max > 1000 )
       
    39   $interval = 100;
       
    40 if ( $max > 2000 )
       
    41   $interval = 200;
       
    42 if ( $max > 5000 )
       
    43   $interval = 1000;
       
    44 if ( $max > 15000 )
       
    45   $interval = 1500;
       
    46 if ( $max > 30000 )
       
    47   $interval = round($max / 10);
       
    48 
       
    49 $g = new GraphMaker(); // _Compat();
       
    50 
       
    51 $g->SetGraphPadding(20, 30, 20, 15);
       
    52 $g->SetGraphAreaHeight(200);
       
    53 $g->SetBarDimensions(26, 0);
       
    54 $g->SetBarPadding(7);
       
    55 $g->SetBarData($graphdata);
       
    56 $g->SetGraphBackgroundTransparent(240, 250, 255, 0);
       
    57 $g->SetGraphTransparency(25);
       
    58 $g->SetAxisStep($interval);
       
    59 $g->SetGraphTitle($channel . ' message count - last 24 hours');
       
    60 
       
    61 $g->DrawGraph();