Содержание

XML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/plugin-install.dtd">
<install version="1.5" type="plugin" group="content">
	<name>Отчет по HTTP трафику</name>
	<author>Kayfolom</author>
	<authorEmail>ekorepov@ukhta-inform.ru</authorEmail>
	<authorUrl>authorUrl</authorUrl>
	<creationDate>2009</creationDate>
	<copyright>c</copyright>
	<license>license</license>
	<version>1.0</version>
	<description>HTTP lightsquid report</description>
	<files>
		<filename plugin="user_report_http">user_report_http.php</filename>
	</files>
    <params />
</install>

PHP

<?php
 
@ini_set("display_errors", "1");
error_reporting(E_ALL);
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
$mainframe->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 = '<FORM METHOD="POST">';
		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>';
		$form_body = '';
        $form_body = $form_body.'Выберите дату : <SELECT NAME="date_select"> ';
        $date_select = JRequest::getVar('date_select');
        foreach($array_dates as $str) {
			$array_date = sscanf($str, "%4s%2s%2s");
			if (isset($date_select) & ($date_select==$str)) {
				$form_body = $form_body.'<OPTION VALUE='.$str.' selected>'.$array_date[2].".".$array_date[1].".".$array_date[0].'г.</OPTION>';
			} else {
				$form_body = $form_body.'<OPTION VALUE='.$str.'>'.$array_date[2].".".$array_date[1].".".$array_date[0].'г.</OPTION>';
			}
		}
        $form_body = $form_body."</SELECT>";
        $form_body = $form_body.'       Выберите адрес : <SELECT NAME="IP_select"> ';
        foreach($_SESSION['URFA']['IP'] as $IP) {
			$form_body = $form_body.'<OPTION VALUE='.$IP.'>'.$IP.'</OPTION>';
		}
        $form_body = $form_body."</SELECT>       ";
        $form_body = $form_body."<input type='submit' value='Выполнить'>";
		$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 = '<table border="1" cellpadding="4" style="background-color:#8db3e2"><tbody>';
				$report_table = $report_table.'</tr>';
				$report_table = $report_table.'<tr><th align=center>Посещённые сайты</th><th align=center>Соединений</th><th align=center>Объем</th>';
				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.'<tr style="background-color:#dbe5f1">';
					$report_table = $report_table.'<td align=left><A HREF="http://'.$content_array['0']['0'].'" target="_blank">'.$content_array['0']['0'].'</A></td>';
					$report_table = $report_table.'<td align=right>'.$content_array['0']['2'].'</td>';
					if (($content_array['0']['1']/1024)>1024) {
						$report_table = $report_table.'<td align=right>'.sprintf("%01.3f Mб",$content_array['0']['1']/1024/1024).'</td>';
					} else {
						$report_table = $report_table.'<td align=right>'.sprintf("%01.3f Kб",$content_array['0']['1']/1024).'</td>';
					}
					$report_table = $report_table.'</tr>';
				}
				$report_table = $report_table.'</tbody></table>';
			} 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}

Пример

 
/home/u18456/wiki.flintnet.ru/www/data/pages/joomla_plugin/user_report_http.txt · Последние изменения: 2009/08/30 13:59 От 195.22.104.13
 
За исключением случаев, когда указано иное, содержимое этой вики предоставляется на условиях следующей лицензии:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki