Exemplo n.º 1
0
function view_stats()
{
    if (!privs()) {
        die;
    }
    $ou = $_GET["ou"];
    $users = new usersMenus();
    sql_domain($ou);
    $sql = "SELECT COUNT( ID ) AS tcount, DATE_FORMAT( time_stamp, '%m-%d' ) AS tday\nFROM smtp_logs\nWHERE {$GLOBALS["SQL_DOMAINS"]}\nAND time_stamp > DATE_ADD( NOW( ) , INTERVAL -7\nDAY )\nGROUP BY DATE_FORMAT( time_stamp, '%m-%d' )";
    $q = new mysql();
    //echo $sql;
    $g = new artica_graphs($fileName, 60);
    $results = $q->QUERY_SQL($sql, "artica_events");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $g->ydata[] = $ligne["tcount"];
        $g->xdata[] = $ligne["tday"];
    }
    //print_r($g->ydata);
    $fileName = "/usr/share/artica-postfix/ressources/logs/web/{$ou}-stats-7.png";
    $g->title = "Inbound messages";
    $g->x_title = "messages number";
    $g->y_title = "days-month";
    $g->width = 700;
    $g->filename = $fileName;
    $g->line_green();
    echo "<img src='ressources/logs/web/{$ou}-stats-7.png'>";
}
function page()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $t = time();
    $sql = "SELECT zDate,not_categorized FROM tables_day ORDER BY zDate";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["tdate"];
        $ydata[] = $ligne["not_categorized"];
    }
    $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . ".png";
    $gp = new artica_graphs();
    $gp->width = 880;
    $gp->height = 350;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->_ENGINE_parse_body("{days}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    if (!is_file($targetedfile)) {
        writelogs("Fatal \"{$targetedfile}\" no such file!", __FUNCTION__, __FILE__, __LINE__);
        $targetedfile = "img/kas-graph-no-datas.png";
    }
    $sql = "SELECT zDate,not_categorized FROM tables_day WHERE not_categorized>0 ORDER BY zDate DESC";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    $c = 0;
    $table = null;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $c++;
        $table = $table . "<tr>\n\t\t\t<td style='font-size:14px' width=99%><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.visited.php?day={$ligne["zDate"]}&onlyNot=yes');\" style='font-size:14px;text-decoration:underline'>{$ligne["zDate"]}</a></td>\n\t\t\t<td style='font-size:14px' width=1%><strong>{$ligne["not_categorized"]}</strong></td>\n\t\t</tr>\n\t\t";
        if ($c > 10) {
            $c = 0;
            $tr[] = "<table style='width:20%' class=form><tbody>{$table}</tbody></table>";
            $table = null;
        }
    }
    if ($c > 0) {
        $tr[] = "<table style='width:20%' class=form><tbody>{$table}</tbody></table>";
    }
    $t = time();
    echo $tpl->_ENGINE_parse_body("\n\t<div id='{$t}'>\n\t<div style='font-size:18px'>{not_categorized}/{days}</div>\n\t\n\t<center>\n\t<div style='margin:8px;float-right;width:100%'>" . button("{analyze}", "NoCategorizedAnalyze()") . "</div>\n\t<img src='{$targetedfile}?t=" . time() . "'>\n\t</center>\n\t" . CompileTrGen($tr, 6) . "\n\t</div>\n\t</div>\n\t<script>\n\t\t\n\tvar x_NoCategorizedAnalyze= function (obj) {\n\t\t\tvar tempvalue=obj.responseText;\n\t\t\tif(tempvalue.length>3){alert(tempvalue)};\n\t\t\tif(document.getElementById('squid_stats_consumption')){\n\t    \t\tRefreshTab('squid_stats_consumption');\n\t\t\t}\n\t\t\t\n\t\t\tif(document.getElementById('squid_stats_central')){\n\t    \t\tRefreshTab('squid_stats_central');\n\t\t\t}\t\t\t\n\t\t}\t\n\n\t\tfunction NoCategorizedAnalyze(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('NoCategorizedAnalyze','yes');\n\t\t\tAnimateDiv('{$t}');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_NoCategorizedAnalyze);\n\t\t}\n\t</script>\t\t\n\t\n\t");
}
Exemplo n.º 3
0
function popup()
{
    $tpl = new templates();
    $time = time();
    echo "<div style='width:98%' class=form>";
    $sql = "SELECT DATE_FORMAT(zDate,'%H') as tdate,AVG(download) as tbandwith FROM speedtests \n\tWHERE DATE_FORMAT(zDate,'%Y-%m-%d')=DATE_FORMAT(NOW(),'%Y-%m-%d') \n\tGROUP BY DATE_FORMAT(zDate,'%H')\n\tORDER BY zDate";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><code>{$sql}</code>";
        return;
    }
    $fileName = "ressources/logs/web/bandwith-day.png";
    $g = new artica_graphs($fileName, 10);
    if (mysql_num_rows($results) > 1) {
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $g->ydata[] = round($ligne["tbandwith"], 0);
            $g->xdata[] = $ligne["tdate"];
        }
        $g->title = $tpl->_ENGINE_parse_body("{today}: {bandwith} KBi/s");
        $g->x_title = "hours";
        $g->y_title = null;
        $g->width = 650;
        $g->line_green();
        @chmod($fileName, 0777);
        echo "<center style='margin:5px'><img src='ressources/logs/web/bandwith-day.png?{$time}'</center>";
    }
    $sql = "SELECT YEARWEEK(zDate) as tweek,AVG(download) as tbandwith,DAYOFMONTH(zDate) as tdate \nFROM speedtests WHERE YEARWEEK(zDate)=YEARWEEK(NOW()) GROUP BY DAYOFMONTH(zDate) ORDER BY DAYOFMONTH(zDate) ";
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><code>{$sql}</code>";
        return;
    }
    $fileName = "ressources/logs/web/bandwith-week.png";
    $g = new artica_graphs($fileName, 10);
    if (mysql_num_rows($results) > 1) {
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $g->ydata[] = round($ligne["tbandwith"], 0);
            $g->xdata[] = $ligne["tdate"];
        }
        $g->title = $tpl->_ENGINE_parse_body("{this_week}: {bandwith} KBi/s");
        $g->x_title = "day";
        $g->y_title = null;
        $g->width = 650;
        $g->line_green();
        @chmod($fileName, 0777);
        echo "<center style='margin:5px'><img src='ressources/logs/web/bandwith-week.png?{$time}'</center>";
    }
    echo "</div>";
}
Exemplo n.º 4
0
function GraphLast24H()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $uid = $_GET["uid"];
    $cmp = new computers($uid);
    $MAC = $cmp->ComputerMacAddress;
    $sql = "SELECT DATE_FORMAT(zDate,'%Y-%m-%d %H') as tdate , SUM(live) as tl,MAC FROM computers_available\n\tGROUP BY DATE_FORMAT(zDate,'%Y-%m-%d %H'),MAC\n\tHAVING MAC='{$MAC}' AND tdate>DATE_SUB(NOW(),INTERVAL 24 HOUR) ORDER BY tdate";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) == 0) {
        echo $tpl->_ENGINE_parse_body("{$title}<center style='margin:50px'><H2>{error_no_datas}</H2>{$sql}</center>");
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $ttdate = explode(" ", $ligne["tdate"]);
        $xdata[] = $ttdate[1];
        $ydata[] = $ligne["tl"];
    }
    $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . ".day." . md5("{$_GET["uid"]}") . ".png";
    $gp = new artica_graphs();
    $gp->width = 550;
    $gp->height = 220;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->_ENGINE_parse_body("{hours}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    $image = "<center style='margin-top:10px'><img src='{$targetedfile}'></center>";
    if (!is_file($targetedfile)) {
        writelogs("Fatal \"{$targetedfile}\" no such file!", __FUNCTION__, __FILE__, __LINE__);
        $image = null;
    }
    echo $tpl->_ENGINE_parse_body($html . $image);
}
Exemplo n.º 5
0
function category_details_period()
{
    $tpl = new templates();
    $page = CurrentPageName();
    if ($_GET["period"] == "month") {
        $tri = "MONTH(days)=MONTH(NOW()) AND YEAR(days)=YEAR(NOW())";
    }
    $q = new mysql();
    $sql = "SELECT SUM(hits) as thits,days,category FROM kav4proxyDays WHERE {$tri} AND category='{$_GET["category"]}' GROUP BY days ORDER BY days";
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2>";
    }
    if (mysql_num_rows($results) < 2) {
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["days"];
        $ydata[] = $ligne["thits"];
        $c++;
    }
    $md = md5("{$_GET["category"]}{$_GET["period"]}");
    $targetedfile = "ressources/logs/" . basename(__FILE__) . ".{$md}.png";
    if (is_file($targetedfile)) {
        @unlink($targetedfile);
    }
    $gp = new artica_graphs();
    $gp->RedAreas = $area;
    $gp->width = 650;
    $gp->height = 450;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = "Mn";
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    $tpl = new templates();
    echo "<center style='margin:3px;padding:5px;border:1px solid #CCCCCC'><img src='{$targetedfile}'></center>";
}
function members_first_graph(){
	$page=CurrentPageName();
	$tpl=new templates();	
	$q=new mysql_squid_builder();
	$gp=new artica_graphs();
	if(!isset($_GET["month"])){
		$currentmonth=date('Y-m');
		$currentmonthText=date('F');
		$tablesrc=date("Ym")."_members";
	}else{
		$date=strtotime($_GET["month"]."-". date('d'). "00:00:00");
		$currentmonth=$_GET["month"];
		$currentmonthText=date('F',$date);
		$tablesrc=date('Ym',$date)."_members";
	}
	
	if(!$q->TABLE_EXISTS($tablesrc)){$q->CreateMembersDayTable();}
	
	if(!$q->TABLE_EXISTS($tablesrc)){
		echo $tpl->_ENGINE_parse_body("<center style='margin:50px'><H2>L.".__LINE__." {error_no_datas}<hr>$tablesrc No such table</hr></H2></center><script>LoadAjax('month-list-members','$page?month-list-members=yes');</script>");
		return;
	}
	
	
	$sql="SELECT COUNT(zMD5) as tcount,`day` FROM `$tablesrc` GROUP BY `day` ORDER BY `day`";
	$results=$q->QUERY_SQL($sql);
	if(!$q->ok){echo "<H2>$q->mysql_error</H2><center style='font-size:11px'><code>$sql</code></center>";}
	$table="
	<center>
<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:10%'>
<thead class='thead'>
	<tr>
	<th width=1%>{days}</th>
	<th>{members}</th>
	</tr>
</thead>
<tbody>";	
	
	
	while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
		
		if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";}
		$table=$table."
			<tr class=$classtr>
				<td width=1%  style='font-size:14px' nowrap align=center><strong>{$ligne["day"]}</strong></td>
				<td  style='font-size:14px' nowrap width=99% align=center><strong>{$ligne["tcount"]}</td>
			</tr>
			";		
			
			$gp->xdata[]=$ligne["day"];
			$gp->ydata[]=$ligne["tcount"];
	}
	
	
	$targetedfile="ressources/logs/".basename(__FILE__).".".__FUNCTION__.".$tablesrc.png";
	$gp->width=550;
	$gp->height=350;
	$gp->filename="$targetedfile";
	$gp->y_title=null;
	$gp->x_title=$tpl->_ENGINE_parse_body("{days}");
	$gp->title=null;
	$gp->margin0=true;
	$gp->Fillcolor="blue@0.9";
	$gp->color="146497";
	$gp->line_green();
	if(!is_file($targetedfile)){writelogs("Fatal \"$targetedfile\" no such file!",__FUNCTION__,__FILE__,__LINE__);$targetedfile="img/kas-graph-no-datas.png";}

	$html="
	<center style='font-size:14px;font-weight:bold'>{months}</center>
	<div id='month-list-members'></div>
	<div style='font-size:16px'>{number_of_users} {{$currentmonthText}} $currentmonth</div>
	<center>
		<img src='$targetedfile'>
	</center>
	$table</tbody></table>
	</center>

	
	<script>
		LoadAjax('month-list-members','$page?month-list-members=yes');
	</script>
	";
	
	echo $tpl->_ENGINE_parse_body($html);
	
		
}
function generate_graph()
{
    include_once 'ressources/class.artica.graphs.inc';
    $q = new mysql_squid_builder();
    $page = CurrentPageName();
    $tpl = new templates();
    $t = $_GET["t"];
    $ff = time();
    $xtime = $_GET["xtime"];
    $tablename = "youtubeday_" . date("Ymd", $xtime);
    $sql = "SELECT SUM(hits) as thits, hour FROM {$tablename} GROUP BY hour ORDER BY hour";
    $c = 0;
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) > 0) {
        $nb_events = mysql_num_rows($results);
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $xdata[] = $ligne["hour"];
            $ydata[] = $ligne["thits"];
            $c++;
        }
        $t = time();
        $targetedfile = "ressources/logs/" . md5(basename(__FILE__) . "." . __FUNCTION__ . ".day.{$tablename}") . ".png";
        $gp = new artica_graphs();
        $gp->width = 920;
        $gp->height = 350;
        $gp->filename = "{$targetedfile}";
        $gp->xdata = $xdata;
        $gp->ydata = $ydata;
        $gp->y_title = null;
        $gp->x_title = $tpl->_ENGINE_parse_body("{hours}");
        $gp->title = null;
        $gp->margin0 = true;
        $gp->Fillcolor = "blue@0.9";
        $gp->color = "146497";
        $gp->line_green();
        if (is_file($targetedfile)) {
            echo "<center>\n\t\t\t<div style='font-size:18px;margin-bottom:10px'>" . $tpl->_ENGINE_parse_body("{hits}/{hours}") . "</div>\n\t\t\t<img src='{$targetedfile}'></center>";
        }
    }
}
Exemplo n.º 8
0
function week_categories()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $year = date("Y");
    $week = intval(date('W'));
    if ($_GET["table"] == null) {
        $table = "{$year}{$week}_week";
    } else {
        $table = $_GET["table"];
    }
    $q = new mysql_squid_builder();
    if ($q->COUNT_ROWS($table) == 0) {
        echo $tpl->_ENGINE_parse_body("{$title}<center style='margin:50px'><H2>{error_no_datas}</H2>{$sql} ({$table} {empty})</center>");
        return;
    }
    $separator = "<center><hr style='border:1px dotted #CCCCCC;width:80%'></center>";
    if (!$q->TABLE_EXISTS($table)) {
        echo "<H3>" . $tpl->_ENGINE_parse_body("{week_table_was_not_builded}{$field}") . "</h3>";
    }
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM {$table}"));
    $downloadedINT = $ligne["tsize"];
    $downloaded = FormatBytes($downloadedINT / 1024);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM {$table} WHERE cached=1"));
    $cachedINT = $ligne["tsize"];
    $cached = FormatBytes($cachedINT / 1024);
    $pourc = $cachedINT / $downloadedINT;
    $pourc = $pourc * 100;
    $pourc = round($pourc, 2);
    $line = $tpl->_ENGINE_parse_body("{$field}{this_week_your_users_has_downloadedXD-XS-XP}{$separator}");
    $line = str_replace("XD", "<strong>{$downloaded}</strong>", $line);
    $line = str_replace("XS", "<strong>{$cached}</strong>", $line);
    $line = str_replace("XP", "<strong style='color:#CF1717'>{$pourc}%</strong>", $line);
    $html[] = "<div style='font-size:12px;text-align:justify;margin-bottom:5px'>{$line}</div>";
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize,familysite FROM {$table} GROUP BY familysite ORDER BY tsize DESC LIMIT 0,1"));
    $XXWWWS = $ligne["familysite"];
    $XWSZE = FormatBytes($ligne["tsize"] / 1024);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(hits) as tsize,familysite FROM {$table} GROUP BY familysite ORDER BY tsize DESC LIMIT 0,1"));
    $XXWWWR = $ligne["familysite"];
    $XWSZR = $ligne["tsize"];
    $XWSCAT = familysite_MergeCategories(array($XXWWWS, $XXWWWR));
    $linkWebsite1 = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.traffic.statistics.week.website.php?table={$table}&field=familysite&www={$XXWWWS}');\"\n\tstyle='font-weight:bold;text-decoration:underline'\n\t>";
    $linkWebsite2 = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.traffic.statistics.week.website.php?table={$table}&field=familysite&www={$XXWWWR}');\"\n\tstyle='font-weight:bold;text-decoration:underline'\n\t>";
    $line = $tpl->_ENGINE_parse_body("{phrase_the_most_websites}");
    $line = str_replace("XXWWWS", "{$linkWebsite1}{$XXWWWS}</a>", $line);
    $line = str_replace("XWSZE", "<strong>{$XWSZE}</strong>", $line);
    $line = str_replace("XXWWWR", "{$linkWebsite2}{$XXWWWR}</a>", $line);
    $line = str_replace("XWSZR", "<strong>{$XWSZR}</strong>", $line);
    $line = str_replace("XWSCAT", "<strong>{$XWSCAT}</strong>", $line);
    $html[] = "<div style='font-size:12px;text-align:justify'>{$line}</div>";
    $line = $tpl->_ENGINE_parse_body("{phrase_the_most_website_represent}");
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM {$table} WHERE familysite='{$XXWWWS}'"));
    $XXWWWSPRC_bin = $ligne["tsize"];
    $XXWWWSPRC_size = FormatBytes($XXWWWSPRC_bin / 1024);
    $XXWWWSPRC = $XXWWWSPRC_bin / $downloadedINT;
    $XXWWWSPRC = $XXWWWSPRC * 100;
    $XXWWWSPRC = round($XXWWWSPRC, 2);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM {$table} WHERE familysite='{$XXWWWS}' AND cached=1"));
    $XXWWWSCHE_bin = $ligne["tsize"];
    $XXWWWSCHE_size = FormatBytes($XXWWWSCHE_bin / 1024);
    $line = str_replace("XXWWWSPRC", "<strong>{$XXWWWSPRC}% ({$XXWWWSPRC_size})</strong>", $line);
    $line = str_replace("XXWWWSCHE", "<strong>{$XXWWWSCHE_size}</strong>", $line);
    $line = str_replace("XXWWWS", "{$linkWebsite1}{$XXWWWS}</a>", $line);
    $html[] = "<div style='font-size:12px;text-align:justify;margin-top:10px'>\n\t<div style='color:#CF1717;font-weight:bold;margin-top:5px;font-size:13.5px'>{$XXWWWS}:</div>\n\t{$line}</div>";
    // ******************************************************************************************************
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT `day`,SUM(hits) as thits,SUM(size) as tsize  FROM {$table} GROUP BY `day` ORDER BY thits DESC LIMIT 0,1"));
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    $MostActiveDayNum = $ligne["day"] - 1;
    $MostActiveDaySize = FormatBytes($ligne["tsize"] / 1024);
    $Cyear = substr($table, 0, 4);
    $Cweek = substr($table, 4, 2);
    $Cweek = str_replace("_", "", $Cweek);
    $days = getDaysInWeek($Cweek, $Cyear);
    $dayText = date('{l}', $days[$MostActiveDayNum]);
    $TimeWeek = strtotime($Cyear . '0104 +' . ($Cweek - 1) . ' weeks');
    $DayTime = date('Y-m', $TimeWeek) . "-" . date('d', $days[$MostActiveDayNum]);
    $DayTable = date('Ymd', strtotime($DayTime)) . "_hour";
    $dayText = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.traffic.panel.day.php?js=yes&table={$DayTable}');\"\n\tstyle='color:#CF1717;font-weight:bold;text-decoration:underline'>{$dayText}</a>";
    $title = "{$dayText} {phrase_most_day_activeday}";
    $prc = round($ligne["tsize"] / $downloadedINT, 2) * 100;
    $html[] = "<div style='color:#CF1717;font-weight:bold;margin-top:5px;font-size:13.5px'>{$title}</div>\n\t<div style='font-size:12px;text-align:justify;'>\n\t{with} <strong>{$ligne["thits"]} {hits}</strong> {or} <strong>{$MostActiveDaySize}</strong> {it_represents} <strong>{$prc}%</strong> {of_bandwith}</div>\n\t\n\t<div style='font-size:12px;text-align:justify;margin-top:10px;margin-bottom:15px'>{phrase_thisisthegraph1}:</div>";
    $sql = "SELECT `day`,SUM(hits) as thits FROM {$table} GROUP BY `day` ORDER BY `day`";
    $results = $q->QUERY_SQL($sql);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $day = $ligne["day"] - 1;
        $dayText = date('{l} d', $days[$day]);
        $DayTable = date('Ymd', $days[$day]) . "_hour";
        $TimeWeek = strtotime($Cyear . '0104 +' . ($Cweek - 1) . ' weeks');
        $DayTime = date('Y-m', $TimeWeek) . "-" . date('d', $days[$day]);
        $dayText = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.traffic.panel.day.php?js=yes&table={$DayTable}');\" style='font-weight:bold;text-decoration:underline'>{$dayText}</a>";
        $tr[] = "\n\t\t<tr>\n\t\t\t<td class=legend nowrap>{$dayText}:</td>\n\t\t\t<td nowrap><strong style='font-size:13px'>" . numberFormat($ligne["thits"], 0, "", " ") . " {hits}</td>\n\t\t</tr>\n\t\t";
        $xdata[] = $ligne["day"];
        $ydata[] = $ligne["thits"];
    }
    $time = time();
    $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$table}.{$time}.png";
    $gp = new artica_graphs();
    $gp->width = 270;
    $gp->height = 150;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->_ENGINE_parse_body("{days}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    if (!is_file($targetedfile)) {
        $targetedfile = "img/nograph-000.png";
    }
    $html[] = "<center style='margin-top:5px'><img src='{$targetedfile}'></center>\n\t<table style='width:50%'><tbody>" . @implode("\n", $tr) . "</tbody></table>\n\t";
    $html[] = "\n\t<script>\n\t\tLoadAjax('panel-middle-top','{$page}?panel-topwebistes-week=yes&table={$table}');\n\t</script>";
    echo $tpl->_ENGINE_parse_body(@implode("\n", $html));
}
function general_status_cache_graphs(){
	$page=CurrentPageName();
	$tpl=new templates();		
	
	
	
	$q=new mysql_squid_builder();	
	$selected_date="{last_30days}";
	$filter="zDate>DATE_SUB(NOW(),INTERVAL 30 DAY) AND zDate<DATE_SUB(NOW(),INTERVAL 1 DAY)";
	$file_prefix="default";
	
	if($_GET["from"]<>null){
		$filter="zDate>='{$_GET["from"]}' AND zDate<='{$_GET["to"]}'";
		$selected_date="{from_date} {$_GET["from"]} - {to_date} {$_GET["to"]}";
		$default_from_date=$_GET["from"];
		$default_to_date=$_GET["to"];
		$file_prefix="$default_from_date-$default_to_date";
	}
	
	if($_GET["type"]<>null){
		if($_GET["type"]=="req"){
			$field="requests as totalsize";
			$prefix_title="{requests}";
			$hasSize=false;
		}
	}	
	
	
	$sql="SELECT size_cached as totalsize,DATE_FORMAT(zDate,'%d') as tdate FROM tables_day WHERE $filter ORDER BY zDate";
	
	$results=$q->QUERY_SQL($sql);

	if(!$q->ok){echo "<H2>$q->mysql_error</H2>";}
	while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
		$xdata[]=$ligne["tdate"];
		$ydata[]=round(($ligne["totalsize"]/1024)/1000);
	}
	
	$targetedfile="ressources/logs/".basename(__FILE__).".".__FUNCTION__.".cache-perf.$file_prefix.png";
	$gp=new artica_graphs();
	$gp->width=550;
	$gp->height=350;
	$gp->filename="$targetedfile";
	$gp->xdata=$xdata;
	$gp->ydata=$ydata;
	$gp->y_title=null;
	$gp->x_title=$tpl->_ENGINE_parse_body("{days}");
	$gp->title=null;
	$gp->margin0=true;
	$gp->Fillcolor="blue@0.9";
	$gp->color="146497";

	$gp->line_green();
	if(!is_file($targetedfile)){writelogs("Fatal \"$targetedfile\" no such file!",__FUNCTION__,__FILE__,__LINE__);return;}
	echo $tpl->_ENGINE_parse_body("<div ><h3>{cache} (MB) /{days} - $selected_date</h3>
	<center>
	<img src='$targetedfile'>
	</center>
	</div>");
	
}
Exemplo n.º 10
0
function day_categories()
{
    $tpl = new templates();
    $page = CurrentPageName();
    if ($_GET["table"] == null) {
        $_GET["table"] = date('Ymd', strtotime($_GET["day"])) . "_hour";
    }
    $table = $_GET["table"];
    $q = new mysql_squid_builder();
    if ($q->COUNT_ROWS($table) == 0) {
        echo $tpl->_ENGINE_parse_body("{$title}<center style='margin:50px'><H2>{error_no_data}</H2>{$sql}</center>");
        return;
    }
    $separator = "<center><hr style='border:1px dotted #CCCCCC;width:80%'></center>";
    if (!$q->TABLE_EXISTS($table)) {
        echo "<H3>" . $tpl->_ENGINE_parse_body("{ERROR_NO_DATA}{$field}") . "</h3>";
    }
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM {$table}"));
    $downloadedINT = $ligne["tsize"];
    $downloaded = FormatBytes($downloadedINT / 1024);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM {$table} WHERE cached=1"));
    $cachedINT = $ligne["tsize"];
    $cached = FormatBytes($cachedINT / 1024);
    $pourc = $cachedINT / $downloadedINT;
    $pourc = $pourc * 100;
    $pourc = round($pourc, 2);
    $line = $tpl->_ENGINE_parse_body("{$field}{your_users_has_downloadedXD-XS-XP}{$separator}");
    $line = str_replace("XD", "<strong>{$downloaded}</strong>", $line);
    $line = str_replace("XS", "<strong>{$cached}</strong>", $line);
    $line = str_replace("XP", "<strong style='color:#CF1717'>{$pourc}%</strong>", $line);
    $html[] = "<div style='font-size:12px;text-align:justify;margin-bottom:5px'>{$line}</div>";
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize,familysite FROM {$table} GROUP BY familysite ORDER BY tsize DESC LIMIT 0,1"));
    $XXWWWS = $ligne["familysite"];
    $XWSZE = FormatBytes($ligne["tsize"] / 1024);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(hits) as tsize,familysite FROM {$table} GROUP BY familysite ORDER BY tsize DESC LIMIT 0,1"));
    $XXWWWR = $ligne["familysite"];
    $XWSZR = $ligne["tsize"];
    $XWSCAT = familysite_MergeCategories(array($XXWWWS, $XXWWWR));
    $linkWebsite1 = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.traffic.statistics.week.website.php?table={$table}&field=familysite&www={$XXWWWS}');\"\n\tstyle='font-weight:bold;text-decoration:underline'\n\t>";
    $linkWebsite2 = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.traffic.statistics.week.website.php?table={$table}&field=familysite&www={$XXWWWR}');\"\n\tstyle='font-weight:bold;text-decoration:underline'\n\t>";
    $line = $tpl->_ENGINE_parse_body("{phrase_the_most_websites}");
    $line = str_replace("XXWWWS", "{$linkWebsite1}{$XXWWWS}</a>", $line);
    $line = str_replace("XWSZE", "<strong>{$XWSZE}</strong>", $line);
    $line = str_replace("XXWWWR", "{$linkWebsite2}{$XXWWWR}</a>", $line);
    $line = str_replace("XWSZR", "<strong>{$XWSZR}</strong>", $line);
    $line = str_replace("XWSCAT", "<strong>{$XWSCAT}</strong>", $line);
    $html[] = "<div style='font-size:12px;text-align:justify'>{$line}</div>";
    $line = $tpl->_ENGINE_parse_body("{phrase_the_most_website_represent}");
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM {$table} WHERE familysite='{$XXWWWS}'"));
    $XXWWWSPRC_bin = $ligne["tsize"];
    $XXWWWSPRC_size = FormatBytes($XXWWWSPRC_bin / 1024);
    $XXWWWSPRC = $XXWWWSPRC_bin / $downloadedINT;
    $XXWWWSPRC = $XXWWWSPRC * 100;
    $XXWWWSPRC = round($XXWWWSPRC, 2);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM {$table} WHERE familysite='{$XXWWWS}' AND cached=1"));
    $XXWWWSCHE_bin = $ligne["tsize"];
    $XXWWWSCHE_size = FormatBytes($XXWWWSCHE_bin / 1024);
    $line = str_replace("XXWWWSPRC", "<strong>{$XXWWWSPRC}% ({$XXWWWSPRC_size})</strong>", $line);
    $line = str_replace("XXWWWSCHE", "<strong>{$XXWWWSCHE_size}</strong>", $line);
    $line = str_replace("XXWWWS", "{$linkWebsite1}{$XXWWWS}</a>", $line);
    $html[] = "<div style='font-size:12px;text-align:justify;margin-top:10px'>\n\t<div style='color:#CF1717;font-weight:bold;margin-top:5px;font-size:13.5px'>{$XXWWWS}:</div>\n\t{$line}</div>";
    // ******************************************************************************************************
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT `hour`,SUM(hits) as thits,SUM(size) as tsize  \n\tFROM {$table} GROUP BY `hour` ORDER BY thits DESC LIMIT 0,1"));
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    $MostActiveHourNum = $ligne["hour"];
    $MostActiveHourNumText = $MostActiveHourNum;
    if (strlen($MostActiveHourNumText) == 1) {
        $MostActiveHourNumText = "0{$MostActiveHourNumText}";
    }
    $MostActiveDaySize = FormatBytes($ligne["tsize"] / 1024);
    $time = $q->DAY_TABLENAME_TO_TIME($table);
    $hourQuery = $ligne["hour"];
    $title = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.traffic.panel.hour.php?js=yes&time={$time}&hour={$hourQuery}');\"\n\tstyle='color:#CF1717;font-weight:bold;text-decoration:underline'>\n\t{$MostActiveHourNumText}h00</a> {phrase_most_hour_activehour}";
    $prc = round($ligne["tsize"] / $downloadedINT, 2) * 100;
    $html[] = "<div style='color:#CF1717;font-weight:bold;margin-top:5px;font-size:13.5px'>{$title}</div>\n\t<div style='font-size:12px;text-align:justify;'>{with} <strong>{$ligne["thits"]} {hits}</strong> {or} <strong>{$MostActiveDaySize}</strong> {it_represents} <strong>{$prc}%</strong> {of_bandwith}</div>\n\t\n\t<div style='font-size:12px;text-align:justify;margin-top:10px;margin-bottom:15px'>{phrase_thisisthegraph2}:</div>";
    $sql = "SELECT `hour`,SUM(hits) as thits FROM {$table} GROUP BY `hour` ORDER BY `hour`";
    $results = $q->QUERY_SQL($sql);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["hour"];
        $ydata[] = $ligne["thits"];
    }
    $time = time();
    $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$table}.{$time}.png";
    $gp = new artica_graphs();
    $gp->width = 270;
    $gp->height = 150;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->_ENGINE_parse_body("{hours}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    if (!is_file($targetedfile)) {
        $targetedfile = "img/nograph-000.png";
    }
    $html[] = "<center style='margin-top:5px'><img src='{$targetedfile}'></center>";
    $id = md5($_GET["table"]);
    $html[] = "\n\t<script>\n\t\tif(!document.getElementById('panel-middle-{$id}')){alert('panel-middle-{$id}, no such id');}\n\t\tLoadAjax('panel-middle-{$id}','{$page}?panel-topwebistes-day=yes&table={$table}');\n\t</script>";
    echo $tpl->_ENGINE_parse_body(@implode("\n", $html));
}
Exemplo n.º 11
0
function week()
{
    $page = CurrentPageName();
    $GLOBALS["CPU_NUMBER"] = intval($users->CPU_NUMBER);
    $cpunum = $GLOBALS["CPU_NUMBER"] + 1;
    $sql = "SELECT AVG( `load` ) AS sload, DATE_FORMAT( stime, '%d' ) AS ttime FROM `loadavg` WHERE `stime` > DATE_SUB( NOW( ) , INTERVAL 7 DAY ) GROUP BY ttime ORDER BY `ttime` ASC";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $count = mysql_num_rows($results);
    if (mysql_num_rows($results) == 0) {
        return;
    }
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    $c = 0;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $size = $ligne["tsize"] / 1024;
        $size = $size / 1000;
        $xdata[] = $ligne["ttime"];
        $ydata[] = $ligne["sload"];
        $c++;
        if ($ligne["sload"] > $cpunum) {
            if ($GLOBALS["VERBOSE"]) {
                echo "<li>!!!! {$ligne["stime"]} -> {$c}</LI>";
            }
            if (!isset($red["START"])) {
                $red["START"] = $c;
            }
        } else {
            if (isset($red["START"])) {
                $area[] = array($red["START"], $c);
                unset($red);
            }
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "<li>{$ligne["stime"]} -> {$ligne["ttime"]} -> {$ligne["sload"]}</LI>";
        }
    }
    $tpl = new templates();
    if ($c < 2) {
        echo "<H2>" . $tpl->_ENGINE_parse_body("{error_no_datas}") . "</H2>";
        return;
    }
    if (isset($red["START"])) {
        $area[] = array($red["START"], $c);
    }
    $file = time();
    $gp = new artica_graphs();
    $gp->RedAreas = $area;
    $gp->width = 650;
    $gp->height = 350;
    $gp->filename = "ressources/logs/loadavg-7d.png";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->javascript_parse_text("{days}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    //$gp->SetFillColor('green');
    $gp->line_green();
    $time = time();
    echo "<img src='ressources/logs/loadavg-7d.png'></div>";
}
Exemplo n.º 12
0
function status()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $infos = unserialize(base64_decode($sock->getFrameWork("cmd.php?virtualbox-showvminfo=yes&uuid=" . base64_encode($_GET["uuid"]))));
    $paragraphe = Paragraphe(oslistIMG($infos["GUEST OS"]), "{$infos["NAME"]}", "<hr>{$infos["GUEST OS"]}");
    $kill_process = $tpl->javascript_parse_text("{kill_process}");
    $pid_array = unserialize(base64_decode($sock->getFrameWork("cmd.php?VboxPid={$_GET["uuid"]}")));
    if ($pid_array["PID"] > 1) {
        $ini = new Bs_IniHandler();
        $ini->loadString($pid_array["INFOS"]);
        $status = "\n\t\t<table class=form style='width:218px'>\n\t\t\t<tr>\n\t\t\t<td align='right' nowrap class=legend><strong>{pid}:</strong></td>\n\t\t\t<td><strong style='font-size:13px'>{$ini->_params["APP_VIRTUALBOX"]["master_pid"]}</strong></td>\n\t\t\t<td>" . imgtootltip("ed_delete.gif", "{kill_process}", "VirtBoxKill('{$ini->_params["APP_VIRTUALBOX"]["master_pid"]}');") . "</td>\n\t\t</tr>\t\t\t\n\t\t<tr>\n\t\t\t<td align='right' class=legend><strong>{memory}:</strong></td>\n\t\t\t<td colspan=2><strong style='font-size:13px'>" . FormatBytes($ini->_params["APP_VIRTUALBOX"]["master_memory"]) . "</strong></td>\n\t\t</tr>\t\t\n\t\t<tr>\n\t\t\t<td align='right' class=legend><strong>{virtual_memory}:</strong></td>\n\t\t\t<td colspan=2><strong style='font-size:13px'>" . FormatBytes($ini->_params["APP_VIRTUALBOX"]["master_cached_memory"]) . "</strong></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td colspan=3><div style='text-align:right'><i style='font-size:13px'>{since}: {$ini->_params["APP_VIRTUALBOX"]["uptime"]}</i></div></td>\n\t\t</tr>\n\t\t</table>\n\t\t\n\t\t<script>\n\t\t\n\tvar X_VirtBoxKill= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>0){alert(results);}\n\t\tRefreshTab('main_config_{$_GET["uuid"]}');\n\t\tRefreshVirtualBoxList();\n\t}\n\t\t\n\t\t\tfunction VirtBoxKill(pid){\n\t\t\t\tif(confirm('{$kill_process} '+pid+'?')){\n\t\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\t\tXHR.appendData('pid-kill',pid);\n\t\t\t\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\t\t\t\tXHR.sendAndLoad('{$page}', 'GET',X_VirtBoxKill);\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t</script>\n\t\t";
    }
    $APP_NO_VBOXADDITIONS = $tpl->javascript_parse_text("{APP_NO_VBOXADDITIONS}");
    if (preg_match("#([0-9]+)#", $infos["CONFIGURED MEMORY BALLOON SIZE"], $re)) {
        $memoryballon = $re[1];
    }
    if (preg_match("#([0-9]+)#", $infos["MEMORY SIZE"], $re)) {
        $memory_size = $re[1];
    }
    if (preg_match("#([0-9]+)#", $infos["VRAM SIZE"], $re)) {
        $vram = $re[1];
    }
    $MEMORY_BALLON_ASK_MB = $tpl->_ENGINE_parse_body("{MEMORY_BALLON_ASK_MB}");
    $MEMORY_SIZE_ASK = $tpl->_ENGINE_parse_body("{MEMORY_SIZE_ASK}");
    $virtual_box_cpus = $tpl->_ENGINE_parse_body("{virtual_box_cpus}");
    if (strlen($infos["ADDITIONS ACTIVE"]) > 0) {
        if ($infos["ADDITIONS ACTIVE"] == "no") {
            $ADDITIONSimg = "<img src='img/status_warning.gif'>";
        }
        $infos["ADDITIONS ACTIVE"] = "{{$infos["ADDITIONS ACTIVE"]}}";
    }
    if ($infos["PAGE FUSION"] == "off") {
        $pagefusion = 0;
    }
    if ($infos["PAGE FUSION"] == "on") {
        $pagefusion = 1;
    }
    if ($infos["NESTED PAGING"] == "off") {
        $nestedpaging = 0;
    }
    if ($infos["NESTED PAGING"] == "on") {
        $nestedpaging = 1;
    }
    if ($infos["LARGE PAGES"] == "on") {
        $largepages = 1;
    }
    if ($infos["LARGE PAGES"] == "off") {
        $largepages = 0;
    }
    if ($infos["VT-X VPID"] == "on") {
        $vtxvpid = 1;
    }
    if ($infos["VT-X VPID"] == "off") {
        $vtxvpid = 0;
    }
    if ($infos["ACPI"] == "on") {
        $acpi = 1;
    }
    if ($infos["ACPI"] == "off") {
        $acpi = 0;
    }
    if ($infos["IOAPIC"] == "on") {
        $ioapic = 1;
    }
    if ($infos["IOAPIC"] == "off") {
        $ioapic = 0;
    }
    if ($infos["HPET"] == "on") {
        $hpet = 1;
    }
    if ($infos["HPET"] == "off") {
        $hpet = 0;
    }
    $html = "\n\n\n\n<table style='width:100%'>\n<tr>\n<td valign='top'>{$paragraphe}<br>{$status}</td>\n<td valign='top'>\n\t<table style='width:100%'>\n\t\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap>{APP_VBOXADDITIONS}:</td>\n\t\t<td style='font-size:13px;' nowrap>{$infos["ADDITIONS ACTIVE"]}</td>\n\t\t<td align='center'>{$ADDITIONSimg}</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap>\n\t\t\t<a href='javascript:blur();' OnClick=\"javascript:VboxMemory()\" \n\t\t\tstyle='text-decoration:underline'>{physical_memory}</a>:</td>\n\t\t<td style='font-size:13px;'>{$infos["MEMORY SIZE"]}</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap><a href='javascript:blur();' OnClick=\"javascript:VboxVram()\" \n\t\t\tstyle='text-decoration:underline'>{vramsize}:</td>\n\t\t<td style='font-size:13px;'>{$infos["VRAM SIZE"]}</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap><a href='javascript:blur();' OnClick=\"javascript:guestmemoryballoon()\" style='text-decoration:underline'>{guestmemoryballoon}:</a></td>\n\t\t<td style='font-size:13px;' nowrap>{$infos["CONFIGURED MEMORY BALLOON SIZE"]}</a></td>\n\t\t<td>" . help_icon("{guestmemoryballoon_text}") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap>{pagefusion}:</td>\n\t\t<td style='font-size:13px;'>" . Field_checkbox("pagefusion", 1, $pagefusion, "pagefusion()") . "</td>\n\t\t<td></td>\n\t</tr>\t\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap>\n\t\t<a href='javascript:blur();' OnClick=\"javascript:VboxCpus()\" style='text-decoration:underline'>{virtual_box_cpus}:</a></td>\n\t\t<td style='font-size:13px;'>{$infos["NUMBER OF CPUS"]}</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap>{vtxvpid}:</td>\n\t\t<td style='font-size:13px;'>" . Field_checkbox("vtxvpid", 1, $vtxvpid, "vtxvpid()") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap>{acpi}:</td>\n\t\t<td style='font-size:13px;'>" . Field_checkbox("acpi", 1, $acpi, "acpi()") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap>{ioapic}:</td>\n\t\t<td style='font-size:13px;'>" . Field_checkbox("ioapic", 1, $ioapic, "ioapic()") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap>{hpet}:</td>\n\t\t<td style='font-size:13px;'>" . Field_checkbox("hpet", 1, $hpet, "hpet()") . "</td>\n\t\t<td>" . help_icon("{hpet_text}") . "</td>\n\t</tr>\n\n\t\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap>{nestedpaging}:</td>\n\t\t<td style='font-size:13px;'>" . Field_checkbox("nestedpaging", 1, $nestedpaging, "nestedpaging()") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t</tr>\t\n\t\t<td class=legend style='font-size:13px;' nowrap>{largepages}:</td>\n\t\t<td style='font-size:13px;'>" . Field_checkbox("largepages", 1, $largepages, "largepages()") . "</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\t\t\n\t<tr>\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:13px;' nowrap>{accelerate3d}:</td>\n\t\t<td style='font-size:13px;'>{$infos["3D ACCELERATION"]}</td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t</table>\n\t</td>\n</tr>\n</table>\n<script>\n\nvar X_guestmemoryballoon= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>0){alert(results);}\n\tRefreshTab('main_config_{$_GET["uuid"]}');\n\t}\n\t\n\t\n\tfunction guestmemoryballoon(){\n\t\tvar additions='{$infos["ADDITIONS ACTIVE"]}';\n\t\tif(additions.length>0){\n\t\t\tif(additions!=='yes'){\n\t\t\t\talert('{$APP_NO_VBOXADDITIONS}');\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t\n\t\tvar ballon=prompt('{$MEMORY_BALLON_ASK_MB}','{$memoryballon}');\n\t\tif(ballon){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('guestmemoryballoon',ballon);\n\t\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\t\n\t\t}\n\t}\n\t\n\tfunction VboxMemory(){\n\t\tvar ballon=prompt('{$MEMORY_SIZE_ASK}','{$memory_size}');\n\t\tif(ballon){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('guestmemory',ballon);\n\t\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\t\n\t\t}\n\t}\n\n\tfunction VboxCpus(){\n\tvar ballon=prompt('{$virtual_box_cpus}','{$infos["NUMBER OF CPUS"]}');\n\t\tif(ballon){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('VboxCpus',ballon);\n\t\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\t\n\t\t}\n\t\n\t}\n\t\n\t\n\tfunction VboxVram(){\n\t\tvar ballon=prompt('{$MEMORY_SIZE_ASK}','{$vram}');\n\t\tif(ballon){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('vram',ballon);\n\t\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\t\n\t\t}\n\t}\t\t\n\t\n\t\n\t\n\t\n\tfunction nestedpaging(){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById('nestedpaging').checked){XHR.appendData('nestedpaging',1);}else{XHR.appendData('nestedpaging',0);}\n\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\n\t}\n\t\n\tfunction vtxvpid(){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById('vtxvpid').checked){XHR.appendData('vtxvpid',1);}else{XHR.appendData('vtxvpid',0);}\n\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\n\t}\n\n\tfunction acpi(){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById('acpi').checked){XHR.appendData('acpi',1);}else{XHR.appendData('acpi',0);}\n\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\n\t}\t\n\tfunction ioapic(){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById('ioapic').checked){XHR.appendData('ioapic',1);}else{XHR.appendData('ioapic',0);}\n\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\n\t}\t\t\n\tfunction pagefusion(){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById('pagefusion').checked){XHR.appendData('pagefusion',1);}else{XHR.appendData('pagefusion',0);}\n\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\n\t}\n\tfunction hpet(){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById('hpet').checked){XHR.appendData('hpet',1);}else{XHR.appendData('hpet',0);}\n\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\n\t}\t\t\n\t\n\t\n\t\n\tfunction largepages(){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById('largepages').checked){XHR.appendData('largepages',1);}else{XHR.appendData('largepages',0);}\n\t\tXHR.appendData('uuid','{$_GET["uuid"]}');\n\t\tXHR.sendAndLoad('{$page}', 'GET',X_guestmemoryballoon);\n\t}\t\n</script>\n\n\n\n\t";
    $stats = unserialize(base64_decode($sock->getFrameWork("cmd.php?virtualbox-showcpustats=yes&virtual-machine=" . base64_encode($infos["NAME"]))));
    if (is_array($stats["CPU_LOAD_KERNEL_TABLE"])) {
        $fileName = dirname(__FILE__) . "/ressources/logs/{$_GET["uuid"]}-cpu-kernel.png";
        $g = new artica_graphs($fileName, 1);
        while (list($index, $data) = each($stats["CPU_LOAD_KERNEL_TABLE"])) {
            $g->ydata[] = $data;
            $g->xdata[] = "";
        }
        $g->title = 'CPU Kernel';
        $g->x_title = "%";
        $g->y_title = $tpl->_ENGINE_parse_body("{seconds}");
        $g->width = 600;
        $g->line_green();
        $html = $html . "<hr><center style='margin-top:10px'><img src='ressources/logs/{$_GET["uuid"]}-cpu-kernel.png'></center>";
    }
    echo $tpl->_ENGINE_parse_body($html);
}
Exemplo n.º 13
0
function week()
{
    $type = $_GET["type"];
    $page = CurrentPageName();
    $GLOBALS["CPU_NUMBER"] = intval($users->CPU_NUMBER);
    $cpunum = $GLOBALS["CPU_NUMBER"] + 1;
    $sql = "SELECT AVG( `{$type}` ) AS sload, DATE_FORMAT( zDate, '%d' ) AS ttime FROM `kav4proxy_av_stats` WHERE `zDate` > DATE_SUB( NOW( ) , INTERVAL 7 DAY ) GROUP BY ttime ORDER BY `ttime` ASC";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $count = mysql_num_rows($results);
    if (mysql_num_rows($results) == 0) {
        return;
    }
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    $c = 0;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $size = $ligne["tsize"] / 1024;
        $size = $size / 1000;
        $xdata[] = $ligne["ttime"];
        $ydata[] = $ligne["sload"];
        $c++;
    }
    $tpl = new templates();
    $file = time();
    $gp = new artica_graphs();
    $gp->RedAreas = $area;
    $gp->width = 650;
    $gp->height = 350;
    $gp->filename = "ressources/logs/kav4-{$type}-7d.png";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->javascript_parse_text("{days}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    //$gp->SetFillColor('green');
    $gp->line_green();
    $time = time();
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body("<div class=explain>{kav4_{$type}_text}</div>");
    echo "<img src='ressources/logs/kav4-{$type}-7d.png'></div>";
}
function instant_update_daily()
{
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $page = CurrentPageName();
    $sql = "SELECT SUM(CountItems) as tcount FROM instant_updates WHERE DATE_FORMAT(zDate,'%Y-%m-%d')=DATE_FORMAT(NOW(),'%Y-%m-%d')";
    $TOTALITEMOS = $q->COUNT_ROWS("instant_updates");
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    $itemsToday = $ligne["tcount"];
    if (!is_numeric($itemsToday)) {
        $itemsToday = 0;
    }
    writelogs("{$sql}=`{$itemsToday}/{$TOTALITEMOS}`", __FUNCTION__, __FILE__, __LINE__);
    if (!$q->ok) {
        $html[] = "<span style='color:#AE0000'>{$q->mysql_error}</span>";
    }
    $sql = "SELECT ID,DATE_FORMAT(zDate,'%H:%i:%s') as tcount \n\tFROM instant_updates \n\tWHERE DATE_FORMAT(zDate,'%Y-%m-%d')=DATE_FORMAT(NOW(),'%Y-%m-%d') ORDER BY zDate DESC LIMIT 0,1";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    $itemsH = $ligne["tcount"];
    $idt = date("Y-m-d H:i:s", $ligne["ID"]);
    $itemsH = $itemsH . " (v {$idt})";
    if (!$q->ok) {
        $html[] = "<span style='color:#AE0000'>{$q->mysql_error}</span>";
    }
    if ($itemsToday > 0) {
        $text = $tpl->_ENGINE_parse_body("{today_squid_instant_update}");
        $text = str_replace("XX", "<strong>{$itemsToday}</strong>", $text);
        $text = str_replace("YY", "<strong>{$itemsH}</strong>", $text);
        $html[] = "<div style='font-size:16px'>{$text}</div>";
        $sql = "SELECT SUM(CountItems) as tcount , HOUR(zDate) as thour,\n\tDATE_FORMAT(zDate,'%Y-%m-%d') as tday FROM instant_updates \n\tGROUP BY thour,tday HAVING tday=DATE_FORMAT(NOW(),'%Y-%m-%d') ORDER BY thour";
        $results = $q->QUERY_SQL($sql);
        if (!$q->ok) {
            echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
        }
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $xdata[] = $ligne["thour"];
            $ydata[] = $ligne["tcount"];
        }
        $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . "." . time() . ".png";
        $gp = new artica_graphs();
        $gp->width = 620;
        $gp->height = 250;
        $gp->leftMargin = 100;
        $gp->TopMargin = 10;
        $gp->filename = "{$targetedfile}";
        $gp->xdata = $xdata;
        $gp->ydata = $ydata;
        $gp->y_title = null;
        $gp->x_title = $tpl->_ENGINE_parse_body("{hours}");
        $gp->title = null;
        $gp->margin0 = false;
        $gp->Fillcolor = "blue@0.9";
        $gp->color = "146497";
        $gp->line_green();
        if (is_file($targetedfile)) {
            $html[] = $tpl->_ENGINE_parse_body("<center style='font-size:13px;margin-top:8px'>{graph_instant_update_squid_byhour}</center>");
            $html[] = "<center style='width:98%' class=form><img src='{$targetedfile}'></center>";
        }
    }
    $t = time();
    $html[] = "<div id='{$t}'></div>\n\t<script>\n\t\tLoadAjax('{$t}','{$page}?instant-update-weekly=yes');\n\t</script>\n\t\n\t";
    echo @implode("\n", $html);
}
function paragraphe1()
{
    $table = $_GET["table"];
    $user = $_GET["user"];
    $field = $_GET["field"];
    $page = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM {$table}"));
    $downloadedINT = $ligne["tsize"];
    $sql = "SELECT SUM(size) as tsize FROM {$table} WHERE `{$field}`='{$user}' AND cached=1";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    $X3_bin = $ligne["tsize"];
    $X3_text = "<strong>" . FormatBytes($X3_bin / 1024) . "</strong>";
    $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM {$table} WHERE `{$field}`='{$user}'"));
    $X1_bin = $ligne2["tsize"];
    $X1_text = "<strong>" . FormatBytes($X1_bin / 1024) . "</strong>";
    $PRC = $X3_bin / $X1_bin * 100;
    $PRC = round($PRC, 3);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(hits) as tsize FROM {$table} WHERE `{$field}`='{$user}'"));
    $X2_bin = $ligne["tsize"];
    $X2_text = "<strong>{$X2_bin}</strong>";
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(familysite) as familysite,`{$field}` FROM {$table} WHERE `{$field}`='{$user}'"));
    $X0_bin = $ligne["familysite"];
    $X0_text = "<strong>{$X0_bin}</strong>";
    $webstatsUserIntro1 = $tpl->_ENGINE_parse_body("{webstatsUserIntro1}");
    $webstatsUserIntro1 = str_replace("X3PRC", "<strong style='color:#CF1717'>{$PRC}%</strong>", $webstatsUserIntro1);
    $webstatsUserIntro1 = str_replace("X0", $X0_text, $webstatsUserIntro1);
    $webstatsUserIntro1 = str_replace("X1", $X1_text, $webstatsUserIntro1);
    $webstatsUserIntro1 = str_replace("X2", $X2_text, $webstatsUserIntro1);
    $webstatsUserIntro1 = str_replace("X3", $X3_text, $webstatsUserIntro1);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize,familysite,`{$field}` FROM {$table} GROUP BY familysite,`{$field}` HAVING `{$field}`='{$user}' ORDER BY tsize DESC LIMIT 0,1"));
    $XXWWWS = $ligne["familysite"];
    $XWSZE = FormatBytes($ligne["tsize"] / 1024);
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(hits) as tsize,familysite,`{$field}` FROM {$table} GROUP BY familysite,`{$field}` HAVING `{$field}`='{$user}' ORDER BY tsize DESC LIMIT 0,1"));
    $XXWWWR = $ligne["familysite"];
    $XWSZR = $ligne["tsize"];
    $XWSCAT = familysite_MergeCategories(array($XXWWWS, $XXWWWR));
    $line = $tpl->_ENGINE_parse_body("{phrase_the_most_websites}");
    $line = str_replace("XXWWWS", "<strong>{$XXWWWS}</strong>", $line);
    $line = str_replace("XWSZE", "<strong>{$XWSZE}</strong>", $line);
    $line = str_replace("XXWWWR", "<strong>{$XXWWWR}</strong>", $line);
    $line = str_replace("XWSZR", "<strong>{$XWSZR}</strong>", $line);
    $line = str_replace("XWSCAT", "<strong>{$XWSCAT}</strong>", $line);
    $webstatsUserIntro2 = "<div style='font-size:12px;text-align:justify'>{$line}</div>";
    //*********************************************************************** GRAPHIQUE PAR JOUR
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT `day`,SUM(hits) as thits,SUM(size) as tsize,`{$field}`  \n\tFROM {$table} GROUP BY `day`,`{$field}`  HAVING `{$field}`='{$user}' ORDER BY thits DESC LIMIT 0,1"));
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    $MostActiveDayNum = $ligne["day"] - 1;
    $MostActiveDaySize = FormatBytes($ligne["tsize"] / 1024);
    $Cyear = substr($table, 0, 4);
    $Cweek = substr($table, 4, 2);
    $Cweek = str_replace("_", "", $Cweek);
    $days = $q->getDaysInWeek($Cweek, $Cyear);
    $dayText = date('{l}', $days[$MostActiveDayNum]);
    $title = "{$dayText} {phrase_most_day_activeday} {for} {$user}";
    $prc = round($ligne["tsize"] / $downloadedINT, 2) * 100;
    $webstatsUserIntro3 = "<div style='color:#CF1717;font-weight:bold;margin-top:5px;font-size:13.5px'>{$title}</div>\n\t<div style='font-size:12px;text-align:justify;'>{with} <strong>{$ligne["thits"]} {hits}</strong> {or} <strong>{$MostActiveDaySize}</strong> {it_represents} <strong>{$prc}%</strong> {of_bandwith}</div>\n\t<div style='font-size:12px;text-align:justify;margin-top:10px;margin-bottom:15px'>{phrase_thisisthegraph1}:</div>";
    $sql = "SELECT `day`,SUM(hits) as thits,`{$field}` FROM {$table} GROUP BY `day`,`{$field}` HAVING  `{$field}`='{$user}' ORDER BY `day`";
    $results = $q->QUERY_SQL($sql);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["day"];
        $ydata[] = $ligne["thits"];
    }
    $time = time();
    $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$table}.{$time}.png";
    $gp = new artica_graphs();
    $gp->width = 270;
    $gp->height = 150;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->_ENGINE_parse_body("{days}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    if (!is_file($targetedfile)) {
        $targetedfile = "img/nograph-000.png";
    }
    $graph1 = "<center style='margin-top:5px'><img src='{$targetedfile}'></center>";
    $HTML = "<p style='font-size:12px'>{$webstatsUserIntro1}</p>\n\t<p style='font-size:12px'>{$webstatsUserIntro2}</p>\n\t{$webstatsUserIntro3}\n\t{$graph1}\n\t<script>LoadUserReport2()</script>\n\t";
    echo $tpl->_ENGINE_parse_body($HTML);
}
function trentedayssize()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sql = "SELECT zDate,SUM(QuerySize) as hits,{$_GET["field"]} FROM UserAuthDays GROUP BY \n\tzDate,{$_GET["field"]}\n\tHAVING {$_GET["field"]}='{$_GET["value"]}' \n\tAND zDate>DATE_SUB(NOW(),interval 31 DAY) ORDER BY zDate";
    if (isset($_COOKIE["android-NavCalendar-month"])) {
        $month = intval($_COOKIE["android-NavCalendar-month"]);
        $year = $_COOKIE["android-NavCalendar-year"];
        $sql = "SELECT zDate,DAY(zDate) as tday,MONTH(zDate) as tmonth,YEAR(zDate) as tyear,SUM(QuerySize) as hits,{$_GET["field"]} \n\t\tFROM UserAuthDays GROUP BY \n\t\tzDate,{$_GET["field"]},tday,tmonth,tyear\n\t\tHAVING {$_GET["field"]}='{$_GET["value"]}' \n\t\tAND\ttyear='{$year}' AND tmonth='{$month}' ORDER BY zDate";
        $zDate = strtotime("{$year}-{$month}-01");
        $title_date = $tpl->_ENGINE_parse_body(date("{F} Y", $zDate));
    }
    $q = new mysql_squid_builder();
    if (!$q->ok) {
        echo "<H1 style='color:#d32d2d'>{$q->mysql_error}</H1>";
    }
    $results = $q->QUERY_SQL($sql);
    $nbdays = mysql_num_rows($results);
    if ($nbdays == 0) {
        echo $tpl->_ENGINE_parse_body("<strong style='color:#d32d2d'>{$title_date} {no_surffor} {{$_GET["field"]}}:{$_GET["value"]}</strong>");
        return;
    }
    $title = $tpl->_ENGINE_parse_body("{$title_date} ({$nbdays} {days}) - MB");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $ligne["hits"] = $ligne["hits"] / 1024;
        $ligne["hits"] = round($ligne["hits"] / 1024);
        $t = strtotime($ligne["zDate"]);
        $xdata[] = date("d", $t);
        $ydata[] = $ligne["hits"];
    }
    $time = time();
    $targetedfile = "ressources/logs/" . md5(basename(__FILE__) . "." . __FUNCTION__ . ".UserAuthDays.{$time}") . ".png";
    $gp = new artica_graphs();
    $gp->width = 890;
    $gp->height = 350;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->_ENGINE_parse_body("{days}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    echo "<center><div style='margin:5px'>{$title}</div>";
    if (!is_file($targetedfile)) {
        echo "<strong style='font-size:13px'>{$targetedfile} no such file</strong>";
    } else {
        echo "<img src='{$targetedfile}'>";
    }
    echo "</center>";
}
Exemplo n.º 17
0
function blocked_ip_stats()
{
    $tpl = new templates();
    $page = CurrentPageName();
    switch ($_GET["time"]) {
        case 1:
            $sql = "SELECT SUM(conx) as conx,zhour as ttime FROM mail_con_err_stats WHERE zday=DAY(NOW()) AND YEAR(zDate)=YEAR(NOW()) GROUP BY zhour ORDER BY zhour";
            $x_title = "Hours";
            $sql2 = "\n\t\t\tSELECT SUM( conx ) AS conx, ipaddr\n\t\t\tFROM mail_con_err_stats\n\t\t\tWHERE zday = DAY( NOW( ) )\n\t\t\tAND YEAR( zDate ) = YEAR( NOW( ) )\n\t\t\tGROUP BY ipaddr\n\t\t\tORDER BY conx DESC\n\t\t\tLIMIT 0 , 10";
            break;
        case 2:
            $sql = "SELECT COUNT(conx) AS conx, zday AS ttime\n\t\t\tFROM mail_con_err_stats\n\t\t\tWHERE YEAR( zDate ) = YEAR( NOW( ) ) \n\t\t\tAND zDate>=DATE_SUB(NOW(),INTERVAL 7 DAY)\n\t\t\tGROUP BY zDate,zday\n\t\t\tORDER BY zDate\n\t\t\tLIMIT 0 , 8";
            $x_title = "Days";
            $sql2 = "\n\t\t\tSELECT SUM( conx ) AS conx, ipaddr\n\t\t\tFROM mail_con_err_stats\n\t\t\tWHERE YEAR( zDate ) = YEAR( NOW( ) )\n\t\t\tAND zDate>=DATE_SUB(NOW(),INTERVAL 7 DAY)\n\t\t\tGROUP BY ipaddr\n\t\t\tORDER BY conx DESC\n\t\t\tLIMIT 0 , 10";
            break;
        default:
            break;
    }
    echo $tpl->_ENGINE_parse_body("<span style='font-size:16px'>{GRAPH_POSTFIX_REJECTED_CONNEXIONS}</span><hr>");
    $gp = new artica_graphs(dirname(__FILE__) . "/ressources/logs/web/postfix.{$_GET["time"]}.hits.png", 50);
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo "<span style='font-size:16px'>{$q->mysql_error}</span>";
    }
    $count = mysql_num_rows($results);
    writelogs($count . " rows", __FUNCTION__, __FILE__, __LINE__);
    if (mysql_num_rows($results) == 0) {
        $tpl = new templates();
        echo $tpl->_ENGINE_parse_body("<H2>{NO_DATA_COME_BACK_LATER}</H2>");
        return;
    }
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["ttime"];
        $ydata[] = $ligne["conx"];
    }
    $gp->width = 600;
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = "Connexions";
    $gp->x_title = $x_title;
    $gp->title = null;
    //$gp->Fillcolor="blue@0.9";
    //$gp->color="146497";
    $gp->line_green();
    $time = time();
    echo "<center><img src='ressources/logs/web/postfix.{$_GET["time"]}.hits.png?time={$time}'></center>";
    echo "<hr>";
    $gp = new artica_graphs(dirname(__FILE__) . "/ressources/logs/web/postfix.{$_GET["time"]}.top-hits.png", 50);
    $table[] = "\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t\t<th>{connexions}</th>\n\t\t<th>{ipaddr}</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    $results = $q->QUERY_SQL($sql2, "artica_events");
    if (!$q->ok) {
        echo "<span style='font-size:16px'>{$q->mysql_error}</span>";
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $js = "Loadjs('{$page}?blocked-ip-single=" . urlencode($ligne["ipaddr"]) . "')";
        $style = " style='text-decoration:underline' ";
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $table[] = "\n\t<tr class={$classtr}>\n\t\t\t<td style='font-size:14px;font-weight:bold' nowrap width=1%><a href=\"javascript:blur()\" OnClick=\"javascript:{$js}\" {$style}>{$ligne["conx"]}</a></td>\n\t\t\t<td style='font-size:14px;font-weight:bold' nowrap width=99%><a href=\"javascript:blur()\" OnClick=\"javascript:{$js}\" {$style}>{$ligne["ipaddr"]}</a></td>\n\t\t</tr>\n\t";
        $gp->xdata[] = $ligne["conx"];
        $gp->ydata[] = $ligne["ipaddr"];
    }
    $table[] = "</table>";
    $time = time();
    $gp->width = 560;
    $gp->height = 580;
    $gp->ViewValues = false;
    $gp->x_title = "{ipaddr}";
    $gp->pie();
    echo $tpl->_ENGINE_parse_body("\n\t<center>\n\t<img src='ressources/logs/web/postfix.{$_GET["time"]}.top-hits.png?time={$time}'  border=0>\n\t<hr>" . @implode("\n", $table));
}
function report_history_by_day($pdf, $report_id)
{
    $q = new mysql_squid_reports($report_id);
    $unix = new unix();
    $pdf->AddPage('P');
    $pdf->SetFontSize(22);
    $pdf->Write(5, "History");
    $pdf->Ln();
    $pdf->Ln();
    $TMP_FILE = $unix->FILE_TEMP() . ".png";
    $gp = new artica_graphs($TMP_FILE, 0);
    $sql = "SELECT SUM(size) as size,zDate FROM dayz GROUP BY zDate ORDER BY zDate";
    $results = $q->QUERY_SQL($sql);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $pdf->SetFontSize(14);
        $size = FormatBytes($ligne["size"] / 1024, true);
        $sizeK = $ligne["size"] / 1024;
        $sizeM = round($sizeK / 1024);
        $timeDtr = strtotime($ligne["zDate"] . " 00:00:00");
        $gp->ydata[] = $sizeM;
        $gp->xdata[] = $ligne["zDate"];
    }
    $gp->width = 700;
    $gp->height = 300;
    $gp->PieLegendHide = false;
    $gp->ViewValues = true;
    $gp->title = null;
    $gp->line_green();
    if (is_file($TMP_FILE)) {
        $pdf->Ln();
        $pdf->Cell(0, 6, "History in MB/Day", 0, 0, 'C');
        $pdf->Ln();
        $pdf->Image($TMP_FILE);
        @unlink($TMP_FILE);
    }
    return $pdf;
}
function generate_graph()
{
    include_once 'ressources/class.artica.graphs.inc';
    $q = new mysql_squid_builder();
    $page = CurrentPageName();
    $tpl = new templates();
    $t = $_GET["t"];
    $ff = time();
    $year = $_GET["year"];
    $week = $_GET["week"];
    $tablename_prod = "{$year}{$week}_blocked_week";
    $WEEKZ = $q->WEEK_TOTIMEHASH_FROM_TABLENAME($tablename_prod);
    $sql = "SELECT SUM(hits) as tcount,`day` FROM {$tablename_prod} GROUP BY `day` ORDER BY `day`";
    $c = 0;
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) > 0) {
        $nb_events = mysql_num_rows($results);
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $xdata[] = $tpl->_ENGINE_parse_body(date("{l}", $WEEKZ[$ligne["day"]]));
            $ydata[] = $ligne["tcount"];
            $c++;
        }
        $t = time();
        $targetedfile = "ressources/logs/" . md5(basename(__FILE__) . "." . __FUNCTION__ . ".day.{$tablename}") . ".png";
        $gp = new artica_graphs();
        $gp->width = 920;
        $gp->height = 350;
        $gp->filename = "{$targetedfile}";
        $gp->xdata = $xdata;
        $gp->ydata = $ydata;
        $gp->y_title = null;
        $gp->x_title = $tpl->_ENGINE_parse_body("{days}");
        $gp->title = null;
        $gp->margin0 = true;
        $gp->Fillcolor = "blue@0.9";
        $gp->color = "146497";
        $gp->line_green();
        if (is_file($targetedfile)) {
            echo "<center>\n\t\t\t<div style='font-size:18px;margin-bottom:10px'>" . $tpl->_ENGINE_parse_body("{blocked}/{day}") . "</div>\n\t\t\t<img src='{$targetedfile}'></center>";
        }
    }
}
Exemplo n.º 20
0
function hour()
{
    $page = CurrentPageName();
    $GLOBALS["CPU_NUMBER"] = intval($users->CPU_NUMBER);
    $cpunum = $GLOBALS["CPU_NUMBER"] + 1;
    $sql = "SELECT AVG( `load` ) AS sload, DATE_FORMAT( stime, '%i' ) AS ttime FROM `loadavg` WHERE `stime` > DATE_SUB( NOW( ) , INTERVAL 60 MINUTE ) GROUP BY ttime ORDER BY `ttime` ASC";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $count = mysql_num_rows($results);
    if (mysql_num_rows($results) == 0) {
        return;
    }
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    $c = 0;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $size = $ligne["tsize"] / 1024;
        $size = $size / 1000;
        $xdata[] = $ligne["ttime"];
        $ydata[] = $ligne["sload"];
        $c++;
        if ($ligne["sload"] > $cpunum) {
            if ($GLOBALS["VERBOSE"]) {
                echo "<li>!!!! {$ligne["stime"]} -> {$c}</LI>";
            }
            if (!isset($red["START"])) {
                $red["START"] = $c;
            }
        } else {
            if (isset($red["START"])) {
                $area[] = array($red["START"], $c);
                unset($red);
            }
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "<li>{$ligne["stime"]} -> {$ligne["ttime"]} -> {$ligne["sload"]}</LI>";
        }
    }
    if (isset($red["START"])) {
        $area[] = array($red["START"], $c);
    }
    $file = time();
    $gp = new artica_graphs();
    $gp->RedAreas = $area;
    $gp->width = 650;
    $gp->height = 350;
    $gp->filename = "ressources/logs/loadavg-hour.png";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = "Mn";
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $tpl = new templates();
    //$gp->SetFillColor('green');
    $gp->line_green();
    echo "\n\t<div id='loadavg-clean'>\n\t<img src='ressources/logs/loadavg-hour.png'></div></div>\n\t<div style='text-align:right'><hr>" . $tpl->_ENGINE_parse_body(button("{clean_datas}", "LoadAvgClean()")) . "</div>\n\t<script>\n\t\n\tvar x_LoadAvgClean=function(obj){\n      var tempvalue=obj.responseText;\n\t  if(tempvalue.length>3){alert(tempvalue);}\n      YahooWin3Hide();\n      document.getElementById('loadavggraph').innerHTML='';\n      }\t\n\t\n\tfunction LoadAvgClean(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('LoadAvgClean','yes');\n\t\t\n\t\tAnimateDiv('loadavg-clean');\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_LoadAvgClean);\t\t\n\t\t}\t\n\t\n\t\n\t</script>";
}
function right()
{
    $q = new mysql_squid_builder();
    $page = CurrentPageName();
    $tpl = new templates();
    if (!isset($_GET["day"])) {
        $_GET["day"] = date('Y-m-d');
    }
    $title_style = "font-size:16px;width:100%;font-weight:bold;text-decoration:underline";
    $day = $_GET["day"];
    $time = strtotime("{$day} 00:00:00");
    $table = date("YW", $time) . "_week";
    echo "<!-- LINE:" . __LINE__ . ">\n";
    $_GET["week"] = date("W", $time);
    $_GET["year"] = date("Y", $time);
    $tt = getDaysInWeek($_GET["week"], $_GET["year"]);
    foreach ($tt as $dayTime) {
        $f[] = date('{l} d {F}', $dayTime);
    }
    if ($_GET["field-user"] != null) {
        $title_add = "<br>{{$_GET["field-user"]}}:{$_GET["field-user-value"]}";
        $fieldadd = "{$_GET["field-user"]},";
        $GROUP_SELECT = " HAVING `{$_GET["field-user"]}`='{$_GET["field-user-value"]}'";
    }
    echo "<script>\n\t\tLoadAjax('statistics-week-left-status','{$page}?left-status=yes&day={$_GET["day"]}');\n\t</script>\n\t";
    echo "<!-- LINE:" . __LINE__ . ">\n";
    $sourcetable = "{$_GET["year"]}{$_GET["week"]}_week";
    $title00 = $tpl->_ENGINE_parse_body("\n\t<center style='font-size:16px;width:100%;font-weight:bold;margin:10px'>\n\t\t\t{week}:&nbsp;{from}&nbsp;{$f[0]}&nbsp;{to}&nbsp;{$f[6]}{$title_add}\n\t</center>");
    if (!$q->TABLE_EXISTS($sourcetable)) {
        echo $tpl->_ENGINE_parse_body("{$title}<center style='margin:50px'>\n\t\t<H2>{$sourcetable}:{error_no_datas} ({$sourcetable} no such table)</H2></center>");
    }
    echo "<!-- LINE:" . __LINE__ . ">\n";
    $sql = "SELECT {$fieldadd}category,SUM(hits) as totalsize FROM {$sourcetable} GROUP BY {$fieldadd}category {$GROUP_SELECT} ORDER BY totalsize DESC LIMIT 0,10";
    $title0 = TITLE_SQUID_STATSTABLE($sql, "{statistics}:&nbsp;{week}:{$_GET["week"]} ({categories} TOP 10){$title_add}");
    $results = $q->QUERY_SQL($sql);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["totalsize"];
        $ydata[] = $ligne["category"];
    }
    echo "<!-- LINE:" . __LINE__ . ">\n";
    $targetedfilePie = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . "." . md5($sql) . ".pie.png";
    $gp = new artica_graphs($targetedfilePie);
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->width = 550;
    $gp->height = 550;
    $gp->ViewValues = true;
    $gp->x_title = $tpl->_ENGINE_parse_body("{top_websites}");
    $gp->pie();
    echo "<!-- LINE:" . __LINE__ . ">\n";
    $sql = "SELECT {$fieldadd}SUM(hits) as totalsize,`day` FROM {$sourcetable} GROUP BY {$fieldadd}`day` {$GROUP_SELECT} ORDER BY `day`";
    $title1 = TITLE_SQUID_STATSTABLE($sql, "{statistics}:&nbsp;{week}:{$_GET["week"]} ({requests}){$title_add}");
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) == 0) {
        echo $tpl->_ENGINE_parse_body("{$title00}\n\t<center style='margin:50px'>\n\t\t<H2>{error_no_datas}</H2>\n\t\t<i>{$sourcetable} (no such data in line " . __LINE__ . ")</i>\n\t</center>");
        return;
    }
    $weeksd = array(1 => "Sunday", 2 => "Monday", 3 => "Tuesday", 4 => "Wednesday", 5 => "Thursday", 6 => "Friday", 7 => "Saturday");
    $xdata = array();
    $ydata = array();
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $tpl->_ENGINE_parse_body("{{$weeksd[$ligne["day"]]}}");
        $ydata[] = $ligne["totalsize"];
    }
    $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . "." . md5($sql) . ".png";
    $gp = new artica_graphs();
    $gp->width = 550;
    $gp->height = 350;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->_ENGINE_parse_body("{days}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    if (!is_file($targetedfile)) {
        writelogs("Fatal \"{$targetedfile}\" no such file!", __FUNCTION__, __FILE__, __LINE__);
    }
    $sql = "SELECT {$fieldadd}SUM(size) as totalsize,`day` FROM {$sourcetable} GROUP BY {$fieldadd}`day` {$GROUP_SELECT} ORDER BY `day`";
    $title2 = TITLE_SQUID_STATSTABLE($sql, "{statistics}:&nbsp;{week}:{$_GET["week"]} ({downloaded_flow} MB){$title_add}");
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) == 0) {
        echo $tpl->_ENGINE_parse_body("\n\t\t{$title00}\n\t\t<center style='margin:50px'>\n\t\t\t<H2>{error_no_datas}</H2><i>{$sourcetable} no such data (no such data in line " . __LINE__ . ")</i>\n\t\t</center>");
    }
    $weeksd = array(1 => "Sunday", 2 => "Monday", 3 => "Tuesday", 4 => "Wednesday", 5 => "Thursday", 6 => "Friday", 7 => "Saturday");
    $xdata = array();
    $ydata = array();
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $tpl->_ENGINE_parse_body("{{$weeksd[$ligne["day"]]}}");
        $ydata[] = round($ligne["totalsize"] / 1024 / 1000);
    }
    $targetedfile2 = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . "." . md5($sql) . ".png";
    $gp = new artica_graphs();
    $gp->width = 550;
    $gp->height = 350;
    $gp->filename = "{$targetedfile2}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->_ENGINE_parse_body("{days}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    if (!is_file($targetedfile2)) {
        writelogs("Fatal \"{$targetedfile2}\" no such file!", __FUNCTION__, __FILE__, __LINE__);
    }
    $html = "\n\t{$title00}\n\t<div class=RoundedGrey>\n\t\t{$title0}\n\t\t<img src='{$targetedfilePie}' style='margin:10px'>\n\t</div>\n\t<div class=RoundedGrey>\n\t{$title1}<img src='{$targetedfile}' style='margin:10px'>\n\t</div>\n\t<div class=RoundedGrey>\n\t{$title2}\n\t<img src='{$targetedfile2}' style='margin:10px'>\n\t</div>\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
function graphs()
{
    include_once 'ressources/class.artica.graphs.inc';
    $q = new mysql_squid_builder();
    $page = CurrentPageName();
    $tpl = new templates();
    $t = $_GET["t"];
    $ff = time();
    $graph1 = null;
    $graph2 = null;
    $day = $_GET["day"];
    $ttime = strtotime("{$day} 00:00:00");
    $table = date("Ymd", $ttime) . "_hour";
    $familysite = $_GET["familysite"];
    if ($familysite != null) {
        $familysite2 = $q->GetFamilySites($familysite);
    }
    $F = array();
    if ($_GET["filterby"] != null) {
        $OP = "=";
        $field_site0 = "`{$_GET["filterby"]}`,";
        if ($_GET["filterby"] == "ipaddr") {
            $_GET["filterby"] = "client";
            $field_site0 = "`client`,";
        }
        $titleadd = "&nbsp;&raquo;{$_GET["filterby"]}&nbsp;&raquo;{$_GET["filterdata"]}&nbsp;&raquo;";
        if (strpos(" {$_GET["filterdata"]}", "*") > 0) {
            $OP = " LIKE ";
            $_GET["filterdata"] = str_replace("*", "%", $_GET["filterdata"]);
        }
        $display = null;
        $F[] = "AND {$_GET["filterby"]}{$OP}'{$_GET["filterdata"]}'";
    }
    if ($familysite != null) {
        if ($familysite2 == $familysite) {
            $field_site = "familysite,";
            $F[] = "AND familysite ='{$familysite}'";
        } else {
            $field_site = "sitename,";
            $F[] = "AND sitename ='{$familysite}'";
        }
    }
    if (count($F) > 0) {
        $HAVING = "HAVING thits>0 " . @implode(" ", $F);
    }
    $sql = "SELECT SUM(hits) as thits, {$field_site}{$field_site0} `hour` FROM `{$table}` GROUP BY {$field_site}{$field_site0},`hour` {$HAVING} ORDER BY `hour`";
    $sql = str_replace(", ,", ",", $sql);
    $sql = str_replace(",,", ",", $sql);
    $unknown = $tpl->_ENGINE_parse_body("{unknown}");
    $c = 0;
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) > 1) {
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $ydata[] = $ligne["thits"];
            $xdata[] = $ligne["hour"];
            $c++;
        }
        $t = time();
        $targetedfile = "ressources/logs/" . md5(basename(__FILE__) . "." . __FUNCTION__ . ".{$sql}.1{$tablename}") . ".png";
        $gp = new artica_graphs();
        $gp->width = 900;
        $gp->height = 350;
        $gp->filename = "{$targetedfile}";
        $gp->xdata = $xdata;
        $gp->ydata = $ydata;
        $gp->y_title = null;
        $gp->x_title = $tpl->_ENGINE_parse_body("{hits}/{hours}");
        $gp->title = null;
        $gp->margin0 = true;
        $gp->Fillcolor = "blue@0.9";
        $gp->color = "146497";
        $gp->line_green();
        if (is_file("{$targetedfile}")) {
            $graph1 = "\n\t\t\t\t<center style='font-size:18px;margin:10px'>{$gp->x_title}</center>\n\t\t\t\t<img src='{$targetedfile}'>";
        } else {
            $graph1 = "{$targetedfile} no such file<hr>{$sql}<hr>";
        }
    } else {
        $graph1 = $tpl->_ENGINE_parse_body("{only_one_value_no_graph}<hr><span style='font-size:11px'>{$sql}</span>");
    }
    $xdata = array();
    $ydata = array();
    $sql = "SELECT SUM(size) as thits, {$field_site}{$field_site0} `hour` FROM `{$table}` GROUP BY {$field_site}{$field_site0},`hour` {$HAVING} ORDER BY `hour`";
    $sql = str_replace(", ,", ",", $sql);
    $sql = str_replace(",,", ",", $sql);
    $unknown = $tpl->_ENGINE_parse_body("{unknown}");
    $c = 0;
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) > 1) {
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $ydata[] = $ligne["thits"];
            $xdata[] = $ligne["hour"];
            $c++;
        }
        $t = time();
        $targetedfile = "ressources/logs/" . md5(basename(__FILE__) . "." . __FUNCTION__ . ".{$sql}.2{$tablename}") . ".png";
        $gp = new artica_graphs();
        $gp->width = 900;
        $gp->height = 350;
        $gp->filename = "{$targetedfile}";
        $gp->xdata = $xdata;
        $gp->ydata = $ydata;
        $gp->y_title = null;
        $gp->x_title = $tpl->_ENGINE_parse_body("{size}/{hours}");
        $gp->title = null;
        $gp->margin0 = true;
        $gp->Fillcolor = "blue@0.9";
        $gp->color = "146497";
        $gp->line_green();
        if (is_file("{$targetedfile}")) {
            $graph2 = "\n\t\t<center style='font-size:18px;margin:10px'>{$gp->x_title}</center>\n\t\t<img src='{$targetedfile}'>";
        }
    } else {
        $graph2 = $tpl->_ENGINE_parse_body("{only_one_value_no_graph}<hr><span style='font-size:11px'>{$sql}</span>");
    }
    $html = "<table style='width:100%'>\n\t<tr>\n\t\t<td width=50% style='font-size:16px'>{$graph1}</td>\n\t</tr>\n\t<tr>\n\t\t<td width=50% style='font-size:16px'>{$graph2}</td>\n\t</tr>\n\t</table>";
    echo $html;
}
Exemplo n.º 23
0
function user_hits_graph()
{
    $xtime = $_GET["time"];
    if ($xtime == 0) {
        $timesql = "AND WEEK(days)=WEEK(NOW()) AND YEAR(days)=YEAR(NOW())";
    }
    if ($xtime == 1) {
        $timesql = "AND MONTH(days)=MONTH(NOW()) AND YEAR(days)=YEAR(NOW())";
    }
    $sql = "SELECT SUM(hits) as thits,DATE_FORMAT(days,'%d') as tday FROM squid_events_clients_sites WHERE client='{$_GET["client"]}' {$timesql} GROUP BY days ORDER BY UNIX_TIMESTAMP(days)";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $count = mysql_num_rows($results);
    writelogs($count . " rows", __FUNCTION__, __FILE__, __LINE__);
    if (mysql_num_rows($results) == 0) {
        $tpl = new templates();
        return $tpl->_ENGINE_parse_body("<H2 style='color:black'>{NO_DATA_COME_BACK_LATER}</H2>");
    }
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["tday"];
        $ydata[] = $ligne["thits"];
    }
    $md = md5("{$_GET["client"]}{$xtime}");
    $cachefile = "ressources/logs/web/squid.{$md}.client.hits.png";
    $gp = new artica_graphs(dirname(__FILE__) . "/{$cachefile}", 0);
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = "hits";
    $gp->x_title = "days";
    $gp->title = null;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    return "<img src='{$cachefile}'>";
}
Exemplo n.º 24
0
function InstantIptablesStats()
{
    $tpl = new templates();
    echo "<CENTER><div style='font-size:16px'>Instant Iptables Month " . date("Y-m") . "</div>";
    include_once 'ressources/class.artica.graphs.inc';
    $sql = "SELECT COUNT(ID) as tcount,DATE_FORMAT(saved_date,'%d') as tdate \n\tFROM iptables WHERE local_port=25 AND disable=0 \n\tAND DATE_FORMAT(saved_date,'%Y-%m')=DATE_FORMAT(NOW(),'%Y-%m') GROUP BY tdate ORDER BY tdate";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    $gp = new artica_graphs(dirname(__FILE__) . "/ressources/logs/web/instant-iptables-graphs.png", 0);
    $time = time();
    $count = mysql_num_rows($results);
    writelogs($count . " rows", __FUNCTION__, __FILE__, __LINE__);
    if (mysql_num_rows($results) == 0) {
        $tpl = new templates();
        echo $tpl->_ENGINE_parse_body("<H2>{NO_DATA_COME_BACK_LATER}</H2>");
        return;
    }
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["tdate"];
        $ydata[] = $ligne["tcount"];
    }
    $gp->width = 700;
    $gp->height = 550;
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = "IP blocked";
    $gp->x_title = "Days";
    $gp->title = null;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    echo "<img src='ressources/logs/web/instant-iptables-graphs.png?{$time}'></CENTER>";
}
Exemplo n.º 25
0
function details_today($timerq)
{
    $tpl = new templates();
    $page = CurrentPageName();
    $q = new mysql();
    $now = date('Y-m-d');
    $field = $_GET["field"];
    $value = $_GET["value"];
    $t = time();
    $ssubsql = "SELECT size,HOUR(zDate) as hour,DATE_FORMAT(zDate,'%Y-%m-%d') as zDate FROM ipband WHERE {$field}='{$value}' AND DATE_FORMAT(zDate,'%Y-%m-%d')=DATE_FORMAT(NOW(),'%Y-%m-%d')";
    $sql = "SELECT AVG(size) as kbs,hour as tdate\n\t\tFROM ({$ssubsql}) as t GROUP BY\n\t\ttdate\n\t\tORDER BY hour";
    if ($timerq == "week") {
        $ssubsql = "SELECT size,DAY(zDate) as zDate FROM ipband WHERE {$field}='{$value}' AND WEEK(zDate)=WEEK(NOW())";
        $sql = "SELECT AVG(size) as kbs,zDate as tdate FROM ({$ssubsql}) as t GROUP BY tdate ORDER BY tdate";
    }
    if ($timerq == "month") {
        $ssubsql = "SELECT size,DAY(zDate) as zDate FROM ipband WHERE {$field}='{$value}' AND MONTH(zDate)=MONTH(NOW())";
        $sql = "SELECT AVG(size) as kbs,zDate as tdate FROM ({$ssubsql}) as t GROUP BY tdate ORDER BY tdate";
    }
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) == 0) {
        echo $tpl->_ENGINE_parse_body("{$title}<center style='margin:50px'><H2>{error_no_datas}</H2>{$sql}</center>");
        return;
    }
    $nb_events = mysql_num_rows($results);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["tdate"];
        $ydata[] = round($ligne["kbs"] / 1024, 2);
    }
    $t = time();
    $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . ".day.{$field}.{$value}.png";
    $gp = new artica_graphs();
    $gp->width = 550;
    $gp->height = 220;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->_ENGINE_parse_body("{hours}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    if (is_file($targetedfile)) {
        $image = "<center style='margin-top:10px' class=form><img src='{$targetedfile}?{$t}'></center>";
    }
    $html = "\n\t{$image}\n\t<div id='ttable{$t}'></div>\n\t<script>\n\tLoadAjax('ttable{$t}','{$page}?details-table=yes&time={$timerq}&field={$_GET["field"]}&value={$_GET["value"]}');\n\t</script>\n";
    echo $tpl->_ENGINE_parse_body($html);
}
Exemplo n.º 26
0
function zoom_day()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $field = $_GET["field"];
    $value = $_GET["value"];
    $familysite = $_GET["familysite"];
    $daytime = $_GET["daytime"];
    $table_name = date("Ymd", $daytime) . "_hour";
    $daytitle = date("{l} d {F}", $daytime);
    $q = new mysql_squid_builder();
    $month_table = "quotamonth_" . date("Ym");
    $month_text = date("{F}");
    if ($q->COUNT_ROWS($month_table) == 0) {
        $month_text = date("{F}", strtotime('first day of previous month'));
        $month_table = "quotamonth_" . date("Ym", strtotime('first day of previous month'));
    }
    $sql = "SELECT `hour` as thour,SUM(size) as QuerySize,SUM(hits) as hits FROM \n\t`{$table_name}`  WHERE `{$field}`='{$value}' AND familysite='{$familysite}' GROUP BY thour ORDER BY thour";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H3>Warning<hr>{$sql}<hr>{$q->mysql_error}</H3>";
    }
    if (mysql_num_rows($results) == 0) {
        $reqests = "{search} {requests} {from} {$value} {to} {$familysite} {$title_add}";
        echo FATAL_ERROR_SHOW_128("{this_request_contains_no_data}<hr>{$reqests}");
        return;
    }
    if (mysql_num_rows($results) < 2) {
        if (mysql_num_rows($results) == 1) {
            while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
                $size = FormatBytes($ligne["QuerySize"] / 1024);
                $day = $ligne["thour"];
                $timstr = strtotime(date("Y-m-d", $daytime) . " {$day}:00:00");
                $html = $html . "<div style='width:99%' style='font-size:16px;' class=form>\n\t\t\t\t{$field}:{$value}&nbsp;&raquo; {size}:{$size}, {$ligne["hits"]} {hits} " . date('{l} d {F} H:00', $timstr) . "\n\t\t\t\n\t\t\t</div>";
            }
            echo $tpl->_ENGINE_parse_body($html);
            return;
        }
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $size = round($ligne["QuerySize"] / 1024 / 1000);
        $day = $ligne["thour"];
        $xdata[] = $day;
        $xdata2[] = $day;
        $ydata[] = $size;
        $ydata2[] = $ligne["hits"];
    }
    $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . "." . md5($sql) . ".png";
    $targetedfile2 = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . "." . md5($sql) . ".2.png";
    $gp = new artica_graphs();
    $gp->width = 650;
    $gp->height = 350;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = $tpl->_ENGINE_parse_body("{size}");
    $gp->x_title = $tpl->_ENGINE_parse_body("{hours}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    $gp2 = new artica_graphs();
    $gp2->width = 650;
    $gp2->height = 350;
    $gp2->filename = "{$targetedfile2}";
    $gp2->xdata = $xdata2;
    $gp2->ydata = $ydata2;
    $gp2->y_title = $tpl->_ENGINE_parse_body("{hits}");
    $gp2->x_title = $tpl->_ENGINE_parse_body("{hours}");
    $gp2->title = null;
    $gp2->margin0 = true;
    $gp2->Fillcolor = "blue@0.9";
    $gp2->color = "146497";
    $gp2->line_green();
    if (!is_file($targetedfile)) {
        writelogs("Fatal \"{$targetedfile}\" no such file!", __FUNCTION__, __FILE__, __LINE__);
    } else {
        $html = $html . "\n\t\t<center>\n\t\t\t<div style='width:99%' class=form>\n\t\t\t\t<div style='font-size:18px;margin:8px'>&laquo;{$value}&raquo;{$familysite}&nbsp;{downloaded_size_per_hour} (MB)</div>\n\t\t\t\t<img src='{$targetedfile}'>\n\t\t\t</div>\n\t\t\t\n\t\t\t<div style='width:99%' class=form>\n\t\t\t\t<div style='font-size:18px;margin:8px'>&laquo;{$value}&raquo;{$familysite}&nbsp;{requests_per_hour}</div>\n\t\t\t\t<img src='{$targetedfile2}'>\n\t\t\t</div>\t\t\t\n\t\t</center>\n\t\t\n\t\t";
    }
    echo $tpl->_ENGINE_parse_body($html);
}
function popup()
{
    echo "<div class=BodyContent style='padding:3px'>";
    include_once 'ressources/class.artica.graphs.inc';
    $q = new mysql_squid_builder();
    $page = CurrentPageName();
    $tpl = new templates();
    $t = $_GET["t"];
    $ff = time();
    $ID = $_GET["ID"];
    $sitename = $_GET["sitename"];
    $tablename = "WebTrackMem{$ID}";
    $sql = "SELECT SUM(hits) as thits, zDate,sitename FROM {$tablename} GROUP BY zDate,sitename HAVING sitename='{$sitename}' ORDER BY zDate";
    $year = date("Y");
    $c = 0;
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) > 0) {
        $nb_events = mysql_num_rows($results);
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $ligne["zDate"] = str_replace("{$year}-", "", $ligne["zDate"]);
            $xdata[] = $ligne["zDate"];
            $ydata[] = $ligne["thits"];
            $c++;
        }
        $t = time();
        $targetedfile = "ressources/logs/" . md5(basename(__FILE__) . "." . __FUNCTION__ . ".day.{$sql}") . ".png";
        $gp = new artica_graphs();
        $gp->width = 920;
        $gp->height = 350;
        $gp->filename = "{$targetedfile}";
        $gp->xdata = $xdata;
        $gp->ydata = $ydata;
        $gp->y_title = null;
        $gp->x_title = $tpl->_ENGINE_parse_body("{days}");
        $gp->title = null;
        $gp->margin0 = true;
        $gp->Fillcolor = "blue@0.9";
        $gp->color = "146497";
        $gp->line_green();
        if (is_file($targetedfile)) {
            echo "<center>\n\t\t\t<div style='font-size:18px;margin-bottom:10px'>" . $tpl->_ENGINE_parse_body("{hits}/{day}") . "</div>\n\t\t\t<img src='{$targetedfile}'></center>";
        }
    }
    $sql = "SELECT SUM(size) as thits, zDate,sitename FROM {$tablename} GROUP BY zDate,sitename HAVING sitename='{$sitename}' ORDER BY zDate";
    $xdata = array();
    $ydata = array();
    $c = 0;
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    if (mysql_num_rows($results) > 0) {
        $nb_events = mysql_num_rows($results);
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $ligne["zDate"] = str_replace("{$year}-", "", $ligne["zDate"]);
            $xdata[] = $ligne["zDate"];
            $ydata[] = round($ligne["thits"] / 1024 / 1000);
            $c++;
        }
        $t = time();
        $targetedfile = "ressources/logs/" . md5(basename(__FILE__) . "." . __FUNCTION__ . ".day.{$sql}") . ".png";
        $gp = new artica_graphs();
        $gp->width = 920;
        $gp->height = 350;
        $gp->filename = "{$targetedfile}";
        $gp->xdata = $xdata;
        $gp->ydata = $ydata;
        $gp->y_title = null;
        $gp->x_title = $tpl->_ENGINE_parse_body("{days}");
        $gp->title = null;
        $gp->margin0 = true;
        $gp->Fillcolor = "blue@0.9";
        $gp->color = "146497";
        $gp->line_green();
        if (is_file($targetedfile)) {
            echo "<center>\n\t\t\t<div style='font-size:18px;margin-bottom:10px'>" . $tpl->_ENGINE_parse_body("{size}/{day} (MB)") . "</div>\n\t\t\t<img src='{$targetedfile}'></center>";
        }
    }
    echo "</div>\n\t<div class=BodyContent style='padding:3px' id='{$t}'></div>\n\t<script>\n\t\tLoadAjax('{$t}','{$page}?table=yes&ID={$ID}&sitename={$sitename}');\n\t</script>\n\t\n\t\n\t";
}
Exemplo n.º 28
0
function squid_events_hours()
{
    $today = date('Y-m-d');
    $gp = new artica_graphs(dirname(__FILE__) . "/ressources/logs/web/squid.{$today}.wwsize.png", 50);
    if (!$gp->checkfile()) {
        return "<img src='ressources/logs/web/squid.{$today}.wwsize.png'>";
    }
    $sql = "SELECT hour,hits,www_size FROM squid_events_hours WHERE `day`='{$today}'";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    $count = mysql_num_rows($results);
    writelogs($count . " rows", __FUNCTION__, __FILE__, __LINE__);
    if (mysql_num_rows($results) == 0) {
        $tpl = new templates();
        return $tpl->_ENGINE_parse_body("<H2>{NO_DATA_COME_BACK_LATER}</H2>");
    }
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["hour"];
        $ziz = round($ligne["www_size"] / 1024);
        $ziz = $ziz / 1000;
        $ydata[] = $ziz;
    }
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = "MB";
    $gp->x_title = "Hours";
    $gp->title = null;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    return "<img src='ressources/logs/web/squid.{$today}.wwsize.png'>";
}
Exemplo n.º 29
0
function panel_categories(){
	$tpl=new templates();
	$page=CurrentPageName();
	$hour=$_GET["hour"];
	if(strlen($hour)==1){$hour="0$hour";}		
	$table=$_GET["table"];
	$q=new mysql_squid_builder();
	if($q->COUNT_ROWS($table)==0){
		echo $tpl->_ENGINE_parse_body("$title<center style='margin:50px'><H2>{error_no_data}</H2>$sql</center>");
		return;
	}
	
	$separator="<center><hr style='border:1px dotted #CCCCCC;width:80%'></center>";
	
	if(!$q->TABLE_EXISTS($table)){echo "<H3>".$tpl->_ENGINE_parse_body("{ERROR_NO_DATA}$field")."</h3>";}
	
	$ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM $table WHERE `hour`={$_GET["hour"]}"));
	$downloadedINT=$ligne["tsize"];
	$downloaded=FormatBytes($downloadedINT/1024);
	
	$ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM $table WHERE `hour`={$_GET["hour"]} AND cached=1"));
	$cachedINT=$ligne["tsize"];
	$cached=FormatBytes($cachedINT/1024);
	$pourc=$cachedINT/$downloadedINT;
	$pourc=$pourc*100;
	$pourc=round($pourc,2);
		
	$line=$tpl->_ENGINE_parse_body("$field{your_users_has_downloadedXD-XS-XP}$separator");
	$line=str_replace("XD", "<strong>$downloaded</strong>", $line);
	$line=str_replace("XS", "<strong>$cached</strong>", $line);
	$line=str_replace("XP", "<strong style='color:#CF1717'>$pourc%</strong>", $line);
	$html[]="<div style='font-size:12px;text-align:justify;margin-bottom:5px'>$line</div>";
	
	
	$ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize,familysite,`hour` FROM $table 
	GROUP BY familysite,`hour` HAVING `hour`={$_GET["hour"]} ORDER BY tsize DESC LIMIT 0,1"));
	$XXWWWS=$ligne["familysite"];
	$XWSZE=FormatBytes($ligne["tsize"]/1024);
	
	$ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(hits) as tsize,familysite,`hour` FROM $table 
	GROUP BY familysite,`hour` HAVING `hour`={$_GET["hour"]} ORDER BY tsize DESC LIMIT 0,1"));
	$XXWWWR=$ligne["familysite"];
	$XWSZR=$ligne["tsize"];
	$XWSCAT=familysite_MergeCategories(array($XXWWWS,$XXWWWR));
	
	$linkWebsite1="<a href=\"javascript:blur();\" 
	OnClick=\"javascript:Loadjs('squid.traffic.statistics.week.website.php?table=$table&field=familysite&www=$XXWWWS');\"
	style='font-weight:bold;text-decoration:underline'
	>";
	
	$linkWebsite2="<a href=\"javascript:blur();\" 
	OnClick=\"javascript:Loadjs('squid.traffic.statistics.week.website.php?table=$table&field=familysite&www=$XXWWWR');\"
	style='font-weight:bold;text-decoration:underline'
	>";	
	
	$line=$tpl->_ENGINE_parse_body("{phrase_the_most_websites}");
	$line=str_replace("XXWWWS", "$linkWebsite1$XXWWWS</a>", $line);
	$line=str_replace("XWSZE", "<strong>$XWSZE</strong>", $line);
	$line=str_replace("XXWWWR", "$linkWebsite2$XXWWWR</a>", $line);
	$line=str_replace("XWSZR", "<strong>$XWSZR</strong>", $line);
	$line=str_replace("XWSCAT", "<strong>$XWSCAT</strong>", $line);		
	$html[]="<div style='font-size:12px;text-align:justify'>$line</div>";
	
	$line=$tpl->_ENGINE_parse_body("{phrase_the_most_website_represent}");
	$ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM $table WHERE familysite='$XXWWWS' AND `hour`={$_GET["hour"]}"));
	$XXWWWSPRC_bin=$ligne["tsize"];
	$XXWWWSPRC_size=FormatBytes($XXWWWSPRC_bin/1024);
	$XXWWWSPRC=$XXWWWSPRC_bin/$downloadedINT;
	$XXWWWSPRC=$XXWWWSPRC*100;
	$XXWWWSPRC=round($XXWWWSPRC,2);	
	
	$ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM $table WHERE familysite='$XXWWWS' AND `hour`={$_GET["hour"]} AND cached=1"));
	$XXWWWSCHE_bin=$ligne["tsize"];
	$XXWWWSCHE_size=FormatBytes($XXWWWSCHE_bin/1024);

	

	
	$line=str_replace("XXWWWSPRC", "<strong>$XXWWWSPRC% ($XXWWWSPRC_size)</strong>", $line);
	$line=str_replace("XXWWWSCHE", "<strong>$XXWWWSCHE_size</strong>", $line);	
	$line=str_replace("XXWWWS", "$linkWebsite1$XXWWWS</a>", $line);

	$html[]="<div style='font-size:12px;text-align:justify;margin-top:10px'>
	<div style='color:#CF1717;font-weight:bold;margin-top:5px;font-size:13.5px'>$XXWWWS:</div>
	$line</div>";
	
// ******************************************************************************************************	
	$tabledetails="dansguardian_events_".date("Ymd");
	$sql="SELECT mins,COUNT(ID) as thits,SUM(QuerySize) as tsize 
	FROM (SELECT MINUTE(zDate) as mins,ID,QuerySize FROM $tabledetails WHERE HOUR(zDate)={$_GET["hour"]}) as t
	GROUP BY `mins` ORDER BY `mins` LIMIT 0,1";
	
	$ligne=mysql_fetch_array($q->QUERY_SQL($sql));
	if(!$q->ok){echo $q->mysql_error;}
	$MostActiveMinNum=$ligne["mins"];
	if(!is_numeric($MostActiveMinNum)){$MostActiveMinNum=0;}
	$MostActiveMinNumText=$MostActiveMinNum;
	if(strlen($MostActiveMinNumText)==1){$MostActiveMinNumText="0$MostActiveMinNumText";}
	$MostActiveDaySize=FormatBytes($ligne["tsize"]/1024);
	$title="{$hour}h$MostActiveMinNumText {phrase_most_time_activehour}";
	$prc=round($ligne["tsize"]/$downloadedINT,2)*100;
	
	$html[]="<div style='color:#CF1717;font-weight:bold;margin-top:5px;font-size:13.5px'>$title</div>
	<div style='font-size:12px;text-align:justify;'>{with} <strong>{$ligne["thits"]} {hits}</strong> {or} <strong>$MostActiveDaySize</strong> {it_represents} <strong>$prc%</strong> {of_bandwith}</div>
	
	<div style='font-size:12px;text-align:justify;margin-top:10px;margin-bottom:15px'>{phrase_thisisthegraph2}:</div>"; 
	
	$sql="SELECT mins,COUNT(ID) as thits 
	FROM (SELECT MINUTE(zDate) as mins,ID FROM $tabledetails WHERE HOUR(zDate)={$_GET["hour"]}) as t
	GROUP BY `mins` ORDER BY `mins`";
		$results=$q->QUERY_SQL($sql);
		while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){	
		$xdata[]=$ligne["mins"];
		$ydata[]=$ligne["thits"];
	}	
	$time=time();
	$targetedfile="ressources/logs/".basename(__FILE__).".".__FUNCTION__.".$table.$time.png";
	$gp=new artica_graphs();
	$gp->width=270;
	$gp->height=150;
	$gp->filename="$targetedfile";
	$gp->xdata=$xdata;
	$gp->ydata=$ydata;
	$gp->y_title=null;
	$gp->x_title=$tpl->_ENGINE_parse_body("{minutes}");
	$gp->title=null;
	$gp->margin0=true;
	$gp->Fillcolor="blue@0.9";
	$gp->color="146497";
	$gp->line_green();
	
	
	if(!is_file($targetedfile)){$targetedfile="img/nograph-000.png";}
	$html[]="<center style='margin-top:5px'><img src='$targetedfile'></center>";
	
	
	$id=md5($_GET["table"].$_GET["hour"]);
	$html[]="
	<script>
		if(!document.getElementById('panel-middle-$id')){alert('panel-middle-$id, no such id');}
		LoadAjax('panel-middle-$id','$page?panel-topwebistes=yes&time={$_GET["time"]}&hour={$_GET["hour"]}&table={$_GET["table"]}');
	</script>";
	
	
	echo $tpl->_ENGINE_parse_body(@implode("\n", $html));
	
}
function query_perform(){
	$page=CurrentPageName();
	$tpl=new templates();
	$q=new mysql_squid_builder();
	$day=$_GET["day"];
	$time=strtotime("$day 00:00:00");
	$tableWeek=date("YW",$time)."_week";	
	$tableDay=date("Ymd",$time)."_day";
	$category=$_GET["category"];
	$DAYNUM=false;
	$weeksd=array(1 => "Sunday", 2 => "Monday",3=>"Tuesday",4=>"Wednesday",5=>"Thursday",6=>"Friday",7=>"Saturday");
	
	if($_GET["field-search"]<>null){
		$title_add="{$_GET["field-search"]}:{$_GET["data-search"]}";
		$FIELDADD="`{$_GET["field-search"]}`,";
		$HAVING=" AND `{$_GET["field-search"]}`='{$_GET["data-search"]}'";
	}
	
	switch ($_GET["TimeType"]) {
		case "week":$table=$tableWeek;$FIELD_TIME="day";$DAYNUM=true; break;
		default:$table=$tableDay;$FIELD_TIME="hour";
		break;
	}
	
	
	$sql="SELECT {$FIELDADD}SUM(hits) as thits,category,$FIELD_TIME FROM $table GROUP BY {$FIELDADD}category,$FIELD_TIME HAVING `category`='$category'$HAVING   ORDER BY $FIELD_TIME";
	$results=array();
	$results=$q->QUERY_SQL($sql);
	if(!$q->ok){echo "<H2>$q->mysql_error</H2><hr><code style='font-size:12px'>$sql</code><hr>";}
	$title=TITLE_SQUID_STATSTABLE($sql,"{statistics}:&nbsp;$category&nbsp;{{$_GET["TimeType"]}}:{$_GET["day"]} ({requests})&nbsp;$title_add");
	if(mysql_num_rows($results)>1){
		while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
			$x=$ligne[$FIELD_TIME];
			if($DAYNUM){$x=$weeksd[$ligne[$FIELD_TIME]];}
			$xdata[]=$x;
			$ydata[]=$ligne["thits"];
		}
		$targetedfile="ressources/logs/".basename(__FILE__).".".__FUNCTION__.".". md5($sql).".png";
		$gp=new artica_graphs();
		$gp->width=400;
		$gp->height=350;
		$gp->filename="$targetedfile";
		$gp->xdata=$xdata;
		$gp->ydata=$ydata;
		$gp->y_title=null;
		$gp->x_title=$tpl->_ENGINE_parse_body("{days}");
		$gp->title=null;
		$gp->margin0=true;
		$gp->Fillcolor="blue@0.9";
		$gp->color="146497";
	
		$gp->line_green();
		if(!is_file($targetedfile)){writelogs("Fatal \"$targetedfile\" no such file!",__FUNCTION__,__FILE__,__LINE__);}		
		
			
		$html[]="<div class=RoundedGrey>$title<img src='$targetedfile' style='margin:10px'></div>";
	}else{
		
		$ligne=array();
		$ligne=mysql_fetch_array($results);
		$htmlHeader="<center><table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'><thead class='thead'><tr>";
		while (list ($a, $b) = each ($ligne) ){if(is_numeric($a)){continue;}if($a=="category"){continue;}$heads[]="<th>{{$a}}</th>";$datas[]="<td style='font-size:14px'>$b</td>";}
		$html[]="<div class=RoundedGrey>$title$htmlHeader". @implode("\n", $heads)."</tr><tr>". @implode("\n", $datas)."</tr></tbody></table></div>";
		
		
	}
		
	
// ------------------------------------------------------------------------------------------------------------------------------------------------
	@mysql_free_result($results);
	$sql="SELECT {$FIELDADD}SUM(size) as tsize,category,$FIELD_TIME FROM $table GROUP BY {$FIELDADD}category,$FIELD_TIME HAVING `category`='$category'$HAVING   ORDER BY $FIELD_TIME";
	$results=array();
	
	$results=$q->QUERY_SQL($sql);
	if(!$q->ok){echo "<H2>$q->mysql_error</H2><hr><code style='font-size:12px'>$sql</code><hr>";}
	unset($xdata);unset($ydata);
	$title=TITLE_SQUID_STATSTABLE($sql,"{statistics}:&nbsp;$category&nbsp;{{$_GET["TimeType"]}}:{$_GET["day"]} ({downloaded_flow} MB)&nbsp;$title_add");
if(mysql_num_rows($results)>1){	
		while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
			$x=$ligne[$FIELD_TIME];
			if($DAYNUM){$x=$weeksd[$ligne[$FIELD_TIME]];}		
			$xdata[]=$x;
			$ydata[]=round(($ligne["tsize"]/1024)/1000);
		}
		$targetedfile="ressources/logs/".basename(__FILE__).".".__FUNCTION__.".". md5($sql).".png";
		$gp=new artica_graphs();
		$gp->width=400;
		$gp->height=350;
		$gp->filename="$targetedfile";
		$gp->xdata=$xdata;
		$gp->ydata=$ydata;
		$gp->y_title=null;
		$gp->x_title=$tpl->_ENGINE_parse_body("{days}");
		$gp->title=null;
		$gp->margin0=true;
		$gp->Fillcolor="blue@0.9";
		$gp->color="146497";
	
		$gp->line_green();
		if(!is_file($targetedfile)){writelogs("Fatal \"$targetedfile\" no such file!",__FUNCTION__,__FILE__,__LINE__);}		
		
			
		$html[]="<div class=RoundedGrey>$title<img src='$targetedfile' style='margin:10px'></div>";	
	}else{
		$ligne=array();
		$ligne=mysql_fetch_array($results);
		$htmlHeader="<center><table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'><thead class='thead'><tr>";
		while (list ($a, $b) = each ($ligne) ){
			if(isset($already[$a])){continue;}
			if($a=="category"){continue;}
			if(is_numeric($a)){continue;}
			$heads[]="<th>{{$a}}</th>";
			$datas[]="<td style='font-size:14px'>$b</td>";
		}
		$html[]="<div class=RoundedGrey>$title$htmlHeader". @implode("\n", $heads)."</tr><tr>". @implode("\n", $datas)."</tr></tbody></table></div>";
		
		
	}
	
// ------------------------------------------------------------------------------------------------------------------------------------------------	
	@mysql_free_result($results);unset($xdata);unset($ydata);
	$sql="SELECT {$FIELDADD}SUM(hits) as requests,category,familysite as sitename FROM $table GROUP BY {$FIELDADD}category,familysite HAVING `category`='$category'$HAVING   ORDER BY requests DESC LIMIT 0,10";
	$results=array();
	
	$results=$q->QUERY_SQL($sql);
	if(!$q->ok){echo "<H2>$q->mysql_error</H2><hr><code style='font-size:12px'>$sql</code><hr>";}
	unset($xdata);unset($ydata);
	$title=TITLE_SQUID_STATSTABLE($sql,"{statistics}:&nbsp;$category&nbsp;{{$_GET["TimeType"]}}:{$_GET["day"]} (TOP 10 {websites} {requests})&nbsp;$title_add");
if(mysql_num_rows($results)>1){	
		while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
		$xdata[]=$ligne["requests"];
		$ydata[]=$ligne["sitename"];
		}
		$targetedfile="ressources/logs/".basename(__FILE__).".".__FUNCTION__.".". md5($sql).".png";
		$gp=new artica_graphs();
		$gp->width=400;
		$gp->height=350;
		$gp->filename="$targetedfile";
		$gp->xdata=$xdata;
		$gp->ydata=$ydata;
		$gp->y_title=null;
		$gp->x_title=$tpl->_ENGINE_parse_body("{days}");
		$gp->title=null;
		$gp->margin0=true;
		$gp->Fillcolor="blue@0.9";
		$gp->color="146497";
	
		$gp->pie();
		if(!is_file($targetedfile)){writelogs("Fatal \"$targetedfile\" no such file!",__FUNCTION__,__FILE__,__LINE__);}		
		
			
		$html2[]="<div class=RoundedGrey>$title<img src='$targetedfile' style='margin:10px'></div>";	
	}else{
		$ligne=array();
		$ligne=mysql_fetch_array($results);
		$htmlHeader="<center><table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'><thead class='thead'><tr>";
		while (list ($a, $b) = each ($ligne) ){
			if(isset($already[$a])){continue;}
			if($a=="category"){continue;}
			if(is_numeric($a)){continue;}
			$heads[]="<th>{{$a}}</th>";
			$datas[]="<td style='font-size:14px'>$b</td>";
		}
		$html2[]="<div class=RoundedGrey>$title$htmlHeader". @implode("\n", $heads)."</tr><tr>". @implode("\n", $datas)."</tr></tbody></table></div>";
		
		
	}	
	
// ------------------------------------------------------------------------------------------------------------------------------------------------	
	@mysql_free_result($results);unset($xdata);unset($ydata);
	$sql="SELECT {$FIELDADD}SUM(size) as totalsize,category,familysite as sitename FROM $table GROUP BY {$FIELDADD}category,familysite HAVING `category`='$category'$HAVING   ORDER BY totalsize DESC LIMIT 0,10";
	$results=array();
	
	$results=$q->QUERY_SQL($sql);
	if(!$q->ok){echo "<H2>$q->mysql_error</H2><hr><code style='font-size:12px'>$sql</code><hr>";}
	unset($xdata);unset($ydata);
	$title=TITLE_SQUID_STATSTABLE($sql,"{statistics}:&nbsp;$category&nbsp;{{$_GET["TimeType"]}}:{$_GET["day"]} (TOP 10 {websites} {downloaded_flow})&nbsp;$title_add");
if(mysql_num_rows($results)>1){	
		while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
		$xdata[]=$ligne["totalsize"];
		$ydata[]=$ligne["sitename"];
		}
		$targetedfile="ressources/logs/".basename(__FILE__).".".__FUNCTION__.".". md5($sql).".png";
		$gp=new artica_graphs();
		$gp->width=400;
		$gp->height=350;
		$gp->filename="$targetedfile";
		$gp->xdata=$xdata;
		$gp->ydata=$ydata;
		$gp->y_title=null;
		$gp->x_title=$tpl->_ENGINE_parse_body("{days}");
		$gp->title=null;
		$gp->margin0=true;
		$gp->Fillcolor="blue@0.9";
		$gp->color="146497";
	
		$gp->pie();
		if(!is_file($targetedfile)){writelogs("Fatal \"$targetedfile\" no such file!",__FUNCTION__,__FILE__,__LINE__);}		
		
			
		$html2[]="<div class=RoundedGrey>$title<img src='$targetedfile' style='margin:10px'></div>";	
	}else{
		$ligne=array();
		$ligne=mysql_fetch_array($results);
		$htmlHeader="<center><table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'><thead class='thead'><tr>";
		while (list ($a, $b) = each ($ligne) ){
			if(isset($already[$a])){continue;}
			if($a=="category"){continue;}
			if(is_numeric($a)){continue;}
			$heads[]="<th>{{$a}}</th>";
			$datas[]="<td style='font-size:14px'>$b</td>";
		}
		$html2[]="<div class=RoundedGrey>$title$htmlHeader". @implode("\n", $heads)."</tr><tr>". @implode("\n", $datas)."</tr></tbody></table></div>";
		
		
	}	
	echo 
	"<table style='width:100%'>
	<tbody>
	<tr>
	<td width=50% valign='top'>".$tpl->_ENGINE_parse_body(@implode("\n", $html))."</td>
	<td width=50% valign='top'>".$tpl->_ENGINE_parse_body(@implode("\n", $html2))."</td>
	</tr>
	</tbody>
	</table>
	";
	
	
}