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}: {from} {$f[0]} {to} {$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}: {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}: {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}: {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 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}: $category {{$_GET["TimeType"]}}:{$_GET["day"]} ({requests}) $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}: $category {{$_GET["TimeType"]}}:{$_GET["day"]} ({downloaded_flow} MB) $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}: $category {{$_GET["TimeType"]}}:{$_GET["day"]} (TOP 10 {websites} {requests}) $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}: $category {{$_GET["TimeType"]}}:{$_GET["day"]} (TOP 10 {websites} {downloaded_flow}) $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> "; }