Exemplo n.º 1
0
 /**
  * print the whole summary table
  */
 private function summary($from = '', $to = '')
 {
     $this->R->table_open();
     $this->R->tablerow_open();
     $this->head($this->getLang('summaryMonth'), 10);
     $this->R->tablerow_close();
     $this->R->tablerow_open();
     $this->head($this->getLang('month'), 1, 2);
     $this->head($this->getLang('dailyavg'), 4);
     $this->head($this->getLang('totals'), 5);
     $this->R->tablerow_close();
     $this->R->tablerow_open();
     $this->head($this->getLang('hits'));
     $this->head($this->getLang('files'));
     $this->head($this->getLang('pages'));
     $this->head($this->getLang('visitors'));
     $this->head($this->getLang('hits'));
     $this->head($this->getLang('files'));
     $this->head($this->getLang('pages'));
     $this->head($this->getLang('visitors'));
     $this->head($this->getLang('bytes'));
     $this->R->tablerow_close();
     foreach ((array) $this->log->logdata as $month => $data) {
         if ($month[0] == '_') {
             continue;
         }
         if ($from && $month < $from) {
             continue;
         }
         if ($to && $month > $to) {
             break;
         }
         $this->R->tablerow_open();
         $this->cell($month, 1, false);
         // Month
         // ---- averages ----
         $this->cell(round($this->log->avg($data['hits']['day'], 'count')));
         // Hits
         $this->cell(round($this->log->avg($data['media']['day'], 'count')));
         // Files
         $this->cell(round($this->log->avg($data['page']['day'], 'count')));
         // Pages
         $this->cell(round($this->log->avg($data['hits']['day'], 'visitor')));
         // Visits
         // ---- totals ----
         $this->cell($data['hits']['all']['count']);
         // Hits
         $this->cell($data['media']['all']['count']);
         // Files
         $this->cell($data['page']['all']['count']);
         // Pages
         $this->cell($data['hits']['all']['visitor']);
         // Visitors
         $this->cell(filesize_h($data['hits']['all']['bytes']));
         // kBytes
         $this->R->tablerow_close();
     }
     $this->R->table_close();
 }
Exemplo n.º 2
0
 /**
  * @param string $date month to display
  */
 private function userdownloads($date)
 {
     $usertraffic = $this->log->usertraffic($date);
     if (!$usertraffic) {
         $this->nograph($this->getLang('t_usertraffic') . ': no data');
     }
     $tomb = create_function('$in', 'return $in / 1024 /1024;');
     $usertraffic = array_map($tomb, $usertraffic);
     // get work day average
     if (count($usertraffic)) {
         $avg = $this->log->avg($usertraffic);
         // $avg = $avg / 7 *5; //work day average
     } else {
         $avg = 0;
     }
     arsort($usertraffic);
     // highest first
     // limit number of users shown
     $maxusers = 10;
     if (count($usertraffic) > $maxusers + 1) {
         $others = array_slice($usertraffic, $maxusers);
         $usertraffic = array_slice($usertraffic, 0, $maxusers);
         $other = 0;
         foreach ($others as $user => $traffic) {
             $other += $traffic;
         }
         $usertraffic[sprintf($this->getLang('others'), count($others))] = $other;
     }
     // prepare the graph datasets
     $DataSet = new pData();
     $DataSet->addPoints(array_values($usertraffic), "traffic");
     // setup axis
     $DataSet->AddPoints(array_keys($usertraffic), 'names');
     $DataSet->AddAllSeries();
     $DataSet->SetAbscissaLabelSeries('names');
     $DataSet->removeSeries('names');
     $DataSet->removeSeriesName('names');
     // create the bar graph
     $Canvas = new GDCanvas(600, 300, false);
     $Chart = new pChart(600, 300, $Canvas);
     $Chart->setFontProperties(dirname(__FILE__) . '/../pchart/Fonts/DroidSans.ttf', 8);
     $Chart->setGraphArea(50, 40, 600, 200);
     $Chart->drawScale($DataSet, new ScaleStyle(SCALE_NORMAL, new Color(127)), 45, 1, true);
     $Chart->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription());
     //$Chart->drawLegend(500, 40, $DataSet->GetDataDescription(), new Color(250));
     $Chart->drawTreshold($avg, new Color(128, 0, 0));
     $Chart->setFontProperties(dirname(__FILE__) . '/../pchart/Fonts/DroidSans.ttf', 12);
     $Chart->drawTitle(10, 10, $this->getLang('t_usertraffic') . ' (MB)', new Color(0), 590, 30);
     $Chart->Render(null);
 }