==== XML ==== Отчет по HTTP трафику Kayfolom ekorepov@ukhta-inform.ru authorUrl 2009 c license 1.0 HTTP lightsquid report user_report_http.php ==== PHP ==== registerEvent( 'onPrepareContent', 'plgUserReportHTTP' ); function plgUserReportHTTP(&$row, &$params, $page=0){ $lightsquid_report = "/var/www/html/lightsquid/report/"; // Путь к отчетам lightsquid $pos = strpos($row->text, '{user_report_http}'); if ($pos!==false) { $row->text = preg_replace('/{user_report_http}/', '', $row->text); //******************************* Форма начало $i = 0; $dir = opendir ($lightsquid_report); while ( $file = readdir ($dir)) { if (( $file != ".") && ($file != "..")) { $done = false; $array_dates[$i] = $file; $i++; } } closedir ($dir); rsort($array_dates); $form_title = '
'; if (isset($uri->_vars['date_select'])) { unset($uri->_vars['date_select']); } if (isset($uri->_vars['IP_select'])) { unset($uri->_vars['IP_select']); } $form_footer = '
'; $form_body = ''; $form_body = $form_body.'Выберите дату : "; $form_body = $form_body.' Выберите адрес : "; $form_body = $form_body.""; $date_select_form = $form_title.$form_body.$form_footer; //******************************* Форма конец //******************************* Формирование отчета начало $http_report_message = ''; $report_table = ''; $date_select = JRequest::getVar('date_select'); $IP_select = JRequest::getVar('IP_select'); if (isset($date_select) & isset($IP_select)) { $array_date = sscanf($date_select, "%4s%2s%2s"); $array_date = sscanf($date_select, "%4s%2s%2s"); $list = @file($lightsquid_report.$date_select."/".$IP_select); if ($list!='') { $http_report_message = "Отчет по HTTP-трафику за ".$array_date[2].".".$array_date[1].".".$array_date[0].'г. по IP-адресу '.$IP_select; @array_splice($list, 0, 1); $report_table = ''; $report_table = $report_table.''; $report_table = $report_table.''; foreach($list as $str) { preg_match_all("/\S{1,}/i", $str, $content_array); // $content_array = explode (" ", $str); // $content_array = split ('[ ]', $str); $report_table = $report_table.''; $report_table = $report_table.''; $report_table = $report_table.''; if (($content_array['0']['1']/1024)>1024) { $report_table = $report_table.''; } else { $report_table = $report_table.''; } $report_table = $report_table.''; } $report_table = $report_table.'
Посещённые сайтыСоединенийОбъем
'.$content_array['0']['0'].''.$content_array['0']['2'].''.sprintf("%01.3f Mб",$content_array['0']['1']/1024/1024).''.sprintf("%01.3f Kб",$content_array['0']['1']/1024).'
'; } else { $http_report_message = "Данные за период ".$array_date[2].".".$array_date[1].".".$array_date[0].'г. по IP-адресу '.$IP_select." отсутствуют"; } } //******************************* Формирование отчета конец $row->text = preg_replace('/{http_report_message}/', $http_report_message, $row->text); $row->text = preg_replace('/{report_table}/', $report_table, $row->text); $row->text = preg_replace('/{date_select_form}/', $date_select_form, $row->text); } }
==== SQL ==== ==== HTML ==== Отчет по HTTP-трафику Внимание, отчет по HTTP-трафику не отражает общее количество потребленного трафика, обычно он несколько меньше общего количества. {user_report_http} {date_select_form} {http_report_message} {report_table} ==== Пример ====