function page() { $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); if (!isset($_GET["day"])) { $_GET["day"] = $q->HIER(); } if ($_GET["day"] == null) { $_GET["day"] = $q->HIER(); } $member = $tpl->_ENGINE_parse_body("{member}"); $delete = $tpl->_ENGINE_parse_body("{delete}"); $hits = $tpl->_ENGINE_parse_body("{hits}"); $size = $tpl->_ENGINE_parse_body("{size}"); $sitename = $tpl->_ENGINE_parse_body("{sitename}"); $ipaddr = $tpl->_ENGINE_parse_body("{ipaddr}"); $members = $tpl->_ENGINE_parse_body("{members}"); $hostname = $tpl->_ENGINE_parse_body("{hostname}"); $mac = $tpl->_ENGINE_parse_body("{MAC}"); $week = $tpl->_ENGINE_parse_body("{week}"); $month = $tpl->_ENGINE_parse_body("{month}"); $TB_WIDTH = 550; $t = time(); $buttons = "\n\tbuttons : [\n\t{name: '<b>{$week}</b>', bclass: 'Calendar', onpress : ChangeWeek{$t}},\n\t{name: '<b>{$month}</b>', bclass: 'Calendar', onpress : ChangeMonth{$t}},\n\t\n\t\t],"; $html = "\n\t<table class='{$t}' style='display: none' id='{$t}' style='width:99%'></table>\n<script>\n\n\$(document).ready(function(){\n\$('#{$t}').flexigrid({\n\turl: '{$page}?search=yes',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$member}', name : 'uid', width : 120, sortable : true, align: 'left'},\n\t\t{display: '{$ipaddr}', name : 'ipaddr', width : 120, sortable : true, align: 'left'},\n\t\t{display: '{$hostname}', name : 'hostname', width : 167, sortable : true, align: 'left'},\n\t\t{display: '{$mac}', name : 'MAC', width : 139, sortable : true, align: 'left'},\n\t\t{display: '{$size}', name : 'QuerySize', width : 132, sortable : false, true: 'left'},\n\t\t{display: '{$hits}', name : 'hits', width : 101, sortable : false, true: 'left'},\n\t\t\n\t\t\n\t],{$buttons}\n\tsearchitems : [\n\t\t{display: '{$member}', name : 'uid'},\n\t\t{display: 'TCP/IP', name : 'ipaddr'},\n\t\t{display: '{$hostname}', name : 'hostname'},\n\t\t{display: '{$mac}', name : 'MAC'},\n\t\t],\n\tsortname: 'QuerySize',\n\tsortorder: 'desc',\n\tusepager: true,\n\ttitle: '{$members}»',\n\tuseRp: true,\n\trp: 15,\n\tshowTableToggleBtn: false,\n\twidth: 872,\n\theight: 450,\n\tsingleSelect: true\n\t\n\t});\n});\n\nfunction RefreshNodesSquidTbl(){\n\t\$('#{$t}').flexReload();\n}\n\nfunction ChangeDay{$t}(){\n\tYahooWin(400,'{$page}?change-day=yes&t={$t}','{$day}');\n}\n\nfunction ChangeWeek{$t}(){\n\tYahooWin(650,'{$page}?change-week=yes&t={$t}','{$week}');\n}\nfunction ChangeMonth{$t}(){\n\tYahooWin(400,'{$page}?change-month=yes&t={$t}','{$month}');\n}\n</script>"; echo $html; }
function page() { $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $member = $tpl->_ENGINE_parse_body("{member}"); $delete = $tpl->_ENGINE_parse_body("{delete}"); $hits = $tpl->_ENGINE_parse_body("{hits}"); $size = $tpl->_ENGINE_parse_body("{size}"); $sitename = $tpl->_ENGINE_parse_body("{sitename}"); $date = $tpl->_ENGINE_parse_body("{date}"); $members = $tpl->_ENGINE_parse_body("{members}"); $hostname = $tpl->_ENGINE_parse_body("{hostname}"); $day = $tpl->_ENGINE_parse_body("{day}"); $week = $tpl->_ENGINE_parse_body("{week}"); $ipaddr = $tpl->_ENGINE_parse_body("{ipaddr}"); $hosts = $tpl->_ENGINE_parse_body("{hosts}"); $cache = $tpl->_ENGINE_parse_body("{cached}"); $websites = $tpl->_ENGINE_parse_body("{websites}"); $TB_WIDTH = 550; $t = time(); if (!isset($_GET["day"])) { $_GET["day"] = $q->HIER(); } $buttons = "\n\t\tbuttons : [\n\t\t{name: '<b>{$day}</b>', bclass: 'Calendar', onpress : ChangeDay{$t}},\n\t\n\t\t],"; $html = "\n\t\t<table class='{$t}' style='display: none' id='{$t}' style='width:99%'></table>\n<script>\n\nfunction LoadTable{$t}(){\n\t\t\$('#{$t}').flexigrid({\n\t\turl: '{$page}?rows=yes&day={$_GET["day"]}',\n\t\tdataType: 'json',\n\t\tcolModel : [\n\t\t{display: '{$websites}', name : 'site', width : 490, sortable : true, true: 'left'},\n\t\t{display: '{$members}', name : 'users', width : 73, sortable : true, align: 'left'},\n\t\t{display: '{$hosts}', name : 'hosts', width : 57, sortable : true, align: 'left'},\n\t\t{display: '{$size}', name : 'hosts', width : 90, sortable : true, align: 'left'},\n\t\t{display: '{$cache}', name : 'cachePercent', width : 58, sortable : true, true: 'left'},\n\t\t\n\t\n\t\n\t\t],{$buttons}\n\t\tsearchitems : [\n\t\t{display: '{$websites}', name : 'site'},\t\n\t\t],\n\t\tsortname: 'bytes',\n\t\tsortorder: 'desc',\n\t\tusepager: true,\n\t\ttitle: '{$websites}»{$_GET["day"]}',\n\t\tuseRp: true,\n\t\trp: 15,\n\t\tshowTableToggleBtn: false,\n\t\twidth: 842,\n\t\theight: 450,\n\t\tsingleSelect: true\n\t\n\t});\n}\n\t\n\tfunction RefreshNodesSquidTbl(){\n\t\$('#{$t}').flexReload();\n\t}\n\t\n\tfunction ChangeDay{$t}(){\n\t\tYahooWin(400,'{$page}?change-day=yes&t={$t}','{$day}');\n\t}\n\t\n\tfunction ChangeWeek{$t}(){\n\t\tYahooWin(624,'{$page}?change-week=yes&t={$t}','{$week}');\n\t}\n\tfunction ChangeMonth{$t}(){\n\t\tYahooWin(400,'{$page}?change-month=yes&t={$t}','{$month}');\n\t}\n\t\n\t\n\tLoadTable{$t}()\n\t</script>"; echo $html; }
function today_zoom_popup() { $page = CurrentPageName(); $q = new mysql_squid_builder(); $tpl = new templates(); if (!isset($_GET["day"])) { $_GET["day"] = $q->HIER(); } $t = time(); $today = "{today}"; if ($_GET["day"] != date("Y-m-d")) { $time = strtotime("{$_GET["day"]} 00:00:00"); $today = date("{l} d {F}", $time); } $tpl = new templates(); $array["website-zoom"] = '{website}'; $array["website-catz"] = '{categories}'; $array["today-zoom-popup-history"] = "{history}:{$today}"; $array["today-zoom-popup-members"] = "{members}:{$today}"; while (list($num, $ligne) = each($array)) { if ($num == "website-zoom") { $html[] = "<li><a href=\"squid.website-zoom.php?sitename={$_GET["familysite"]}&day={$_GET["day"]}\"><span>{$ligne}</span></a></li>\n"; continue; } if ($num == "website-catz") { $html[] = "<li><a href=\"squid.categorize.php?popup=yes&www={$_GET["familysite"]}&bykav=&day={$_GET["day"]}&group=&table-size=993&row-explain=764\"><span>{$ligne}</span></a></li>\n"; continue; } $html[] = "<li><a href=\"{$page}?{$num}=yes&day={$_GET["day"]}&type={$_GET["type"]}&familysite={$_GET["familysite"]}\"><span style='font-size:14px'>{$ligne}</span></a></li>\n"; } $t = time(); echo build_artica_tabs($html, $t); }
function tabs() { $q = new mysql_squid_builder(); $page = CurrentPageName(); $tpl = new templates(); if (!isset($_GET["day"])) { $_GET["day"] = $q->HIER(); } $t = time(); $tpl = new templates(); $array["panel"] = '{panel}'; $array["graph"] = '{graphs}'; while (list($num, $ligne) = each($array)) { $ligne = $tpl->_ENGINE_parse_body("{$ligne}"); $html[] = "<li><a href=\"{$page}?familysite={$_GET["familysite"]}&filterby={$_GET["filterby"]}&filterdata={$_GET["filterdata"]}&sitename={$_GET["sitename"]}&{$num}=yes&day={$_GET["day"]}&t={$t}&urisize={$_GET["urisize"]}\"><span>{$ligne}</span></a></li>\n"; } $t = time(); echo $tpl->_ENGINE_parse_body("\n\t<div id={$t} style='width:97%;font-size:14px;margin-left:10px;margin-right:-15px;margin-top:-5px'>\n\t\t<ul>" . implode("\n", $html) . "</ul>\n\t</div>\n\t\t<script>\n\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\t\$('#{$t}').tabs();\n\t\t\t\n\t\t\t\n\t\t\t});\n\t\t</script>"); }
function page() { $hour_table = date('Ymd') . "_hour"; $q = new mysql_squid_builder(); $defaultday = $q->HIER(); $page = CurrentPageName(); $tpl = new templates(); $webservers = $tpl->_ENGINE_parse_body("{webservers}"); $rule = $tpl->_ENGINE_parse_body("{rule}"); $size = $tpl->_ENGINE_parse_body("{size}"); $time = $tpl->_ENGINE_parse_body("{time}"); $member = $tpl->_ENGINE_parse_body("{member}"); $country = $tpl->_ENGINE_parse_body("{country}"); $url = $tpl->_ENGINE_parse_body("{url}"); $ipaddr = $tpl->_ENGINE_parse_body("{ipaddr}"); $hostname = $tpl->_ENGINE_parse_body("{hostname}"); $title = $tpl->_ENGINE_parse_body("{today}: {requests} {since} " . date("H") . "h"); $change_day = $tpl->_ENGINE_parse_body("{change_day}"); $t = time(); $html = "\n\t<input type='hidden' id='daycache{$t}' value='{$defaultday}'>\n\t<div style='margin:-10px;margin-left:-15px'>\n\t<table class='flexRT{$t}' style='display: none' id='flexRT{$t}' style='width:100%'></table>\n\t</div>\n\t\n<script>\n\$(document).ready(function(){\n\$('#flexRT{$t}').flexigrid({\n\turl: '{$page}?search=yes&MAC={$_GET["MAC"]}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$rule}', name : 'hour', width :60, sortable : true, align: 'left'},\n\t\t{display: '{$country}', name : 'country', width : 70, sortable : false, align: 'left'},\n\t\t{display: '{$webservers}', name : 'sitename', width : 282, sortable : true, align: 'left'},\n\t\t{display: '{$size}', name : 'size', width : 73, sortable : true, align: 'left'},\n\t\t{display: 'hits', name : 'hits', width : 60, sortable : true, align: 'left'}\n\n\t\t],\n\t\t\nbuttons : [\n\t\t{name: '{$change_day}', bclass: 'add', onpress : ChangeDay},\n\t\t],\t\t\t\n\t\n\tsearchitems : [\n\t\t{display: '{$webservers}', name : 'sitename'},\n\t\t],\n\tsortname: 'hour',\n\tsortorder: 'desc',\n\tusepager: true,\n\ttitle: '',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: 625,\n\theight: 420,\n\tsingleSelect: true,\n\trpOptions: [10, 20, 30, 50,100,200]\n\t\n\t}); \n});\n\n\nfunction ChangeDay(){\n\tYahooWin6('375','{$page}?change-day-popup=yes&t={$t}&MAC={$_GET["MAC"]}','{$change_day}');\n}\n\n</script>\n\t\n\t\n\t"; echo $html; }
function page() { $hour_table = date('Ymd') . "_hour"; $q = new mysql_squid_builder(); $defaultday = $q->HIER(); $page = CurrentPageName(); $tpl = new templates(); $webservers = $tpl->_ENGINE_parse_body("{webservers}"); $hits = $tpl->_ENGINE_parse_body("{hits}"); $size = $tpl->_ENGINE_parse_body("{size}"); $time = $tpl->_ENGINE_parse_body("{day}"); $member = $tpl->_ENGINE_parse_body("{member}"); $country = $tpl->_ENGINE_parse_body("{country}"); $url = $tpl->_ENGINE_parse_body("{url}"); $ipaddr = $tpl->_ENGINE_parse_body("{ipaddr}"); $hostname = $tpl->_ENGINE_parse_body("{hostname}"); $title = $tpl->_ENGINE_parse_body("{today}: {requests} {since} " . date("H") . "h"); $change_day = $tpl->_ENGINE_parse_body("{change_day}"); $this_week = $tpl->javascript_parse_text("{this_week}"); $title = "{$this_week} {$_GET["MAC"]} {$_GET["ipaddr"]}"; $t = time(); $html = "\n\t<input type='hidden' id='daycache{$t}' value='{$defaultday}'>\n\t<table class='flexRT{$t}' style='display: none' id='flexRT{$t}' style='width:100%'></table>\n\t\n<script>\n\$(document).ready(function(){\n\$('#flexRT{$t}').flexigrid({\n\turl: '{$page}?search=yes&day={$defaultday}&MAC={$_GET["MAC"]}&ipaddr={$_GET["ipaddr"]}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$time}', name : 'day', width :301, sortable : true, align: 'left'},\n\t\t{display: '{$size}', name : 'size', width : 204, sortable : true, align: 'left'},\n\t\t],\n\t\t\n\t\t\t\n\t\n\tsearchitems : [\n\t\t{display: '{$time}', name : 'day'},\n\t\t],\n\tsortname: 'day',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '<span style=font-size:18px>{$title}</span>',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 420,\n\tsingleSelect: true,\n\trpOptions: [10, 20, 30, 50,100,200]\n\t\n\t}); \n});\n\n\nfunction ChangeDay(){\n\tYahooWin6('375','{$page}?change-day-popup=yes&t={$t}&MAC={$_GET["MAC"]}&ipaddr={$_GET["ipaddr"]}','{$change_day}');\n}\n\n</script>\n\t\n\t\n\t"; echo $html; }
function events_search(){ $page=CurrentPageName(); $tpl=new templates(); $sock=new sockets(); $q=new mysql_squid_builder(); $GLOBALS["Q"]=$q; $table=date("Ymd")."_hour"; if(!$q->TABLE_EXISTS($table)){ $hierx=strtotime($q->HIER()." 00:00:00"); $table=date("Ymd",$hierx)."_hour"; } if(isset($_POST['page'])) {$page = $_POST['page'];} if(isset($_POST['rp'])) {$rp = $_POST['rp'];} $searchstring=string_to_flexquery(); if($searchstring<>null){ $sql="SELECT COUNT(*) as TCOUNT FROM `$table` WHERE 1 $searchstring"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; }else{ $total = $q->COUNT_ROWS($table); } if(!is_numeric($rp)){$rp=50;} $pageStart = ($page-1)*$rp; $limitSql = "LIMIT $pageStart, $rp"; if(isset($_POST["sortname"])){if($_POST["sortname"]<>null){$ORDER="ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";}} $sql="SELECT * FROM `$table` WHERE 1 $searchstring $ORDER $limitSql"; $results = $q->QUERY_SQL($sql); if(!$q->ok){json_error_show($q->mysql_error);} $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $today=date("Y-m-d"); $tcp=new IP(); $cachedT=$tpl->_ENGINE_parse_body("{cached}"); $c=0; while ($ligne = mysql_fetch_assoc($results)) { $color="black"; $return_code_text=null; $ff=array(); $color="black"; $uri=$ligne["sitename"]; $date=$ligne["hour"]; $mac=$ligne["MAC"]; $ip=$ligne["client"]; $user=$ligne["uid"]; $dom=$ligne["familysite"]; if(intval($ligne["size"])>1024){ $size=FormatBytes(intval($ligne["size"])/1024); }else{ $size="{$ligne["size"]} bytes"; } if($size=="0 KB"){$size="{$ligne["size"]} bytes";} $category=$ligne["category"]; //sitename | familysite | client //| hostname | account | hour | remote_ip | MAC | country | size | hits | uid | category $ident=array(); $md=md5(serialize($ligne)); $ident[]="<a href=\"javascript:blur()\" OnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&ipaddr=$ip',true);\" style='text-decoration:underline;color:$color'>$ip</a>"; $spanON="<span style='color:$color'>"; $spanOFF="</span>"; $cached_text=null; $size=FormatBytes($size/1024); $return_code_text="<div style='color:$color;font-size:11px'><i>$size</i></div>"; if($user<>null){ $GLOBALS["IPUSERS"][$ip]=$user; }else{ if(isset($GLOBALS["IPUSERS"][$ip])){ $ident[]="<i>{$GLOBALS["IPUSERS"][$ip]}</i>"; } } if($user<>null){ if($tcp->isValid($user)){ $ident[]="<a href=\"javascript:blur()\" OnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&ipaddr=$user',true);\" style='text-decoration:underline;color:$color'>$user</a>"; }else{ $ident[]="<a href=\"javascript:blur()\" OnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&uid=$user',true);\" style='text-decoration:underline;color:$color'>$user</a>"; } } if($mac<>null){ $ident[]="<a href=\"javascript:blur()\" OnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&MAC=$mac',true);\" style='text-decoration:underline;color:$color'>$mac</a>"; } $colorDiv=$color; if($colorDiv=="black"){$colorDiv="transparent";} $identities=@implode(" | ", $ident); $www=$q->PostedServerToHost($uri); $time=time(); $uri=str_replace($www, "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.website-zoom.php?js=yes&sitename=$www&xtime=$time')\" style='text-decoration:underline;color:$color;font-weight:bold'>$www</a>",$uri); if($category<>null){$category=" ($category)";} $data['rows'][] = array( 'id' => $md, 'cell' => array( "<div style='background-color:$colorDiv;margin-top:-5px;margin-left:-5px;margin-right:-5px;margin-bottom:-5px;'> </div>", "$spanON{$date}h$spanOFF", "$spanON$uri$category$spanOFF", "$spanON$size$spanOFF", "$spanON$identities$spanOFF" ) ); } echo json_encode($data); }
function nodes_list() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $defaultday = $q->HIER(); $TableActive = date('Ymd', strtotime($defaultday . " 00:00:00")) . "_hour"; $t = $_GET["t"]; $filterby = $_GET["filterby"]; $search = '%'; $table = "UserAutDB"; $page = 1; $FORCE_FILTER = null; $total = 0; if ($q->COUNT_ROWS($table) == 0) { json_error_show("No data"); } $table = "(SELECT {$filterby} FROM {$table} GROUP BY {$filterby} HAVING LENGTH({$filterby})>0) as t"; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $searchstring = string_to_flexquery(); if ($searchstring != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show("{$q->mysql_error}"); } $ipClass = new IP(); while ($ligne = mysql_fetch_assoc($results)) { $js = null; $Link = null; $TextDeco = "none"; $value = utf8_encode($ligne[$filterby]); $md5 = md5($value); $valueEnc = urlencode($ligne[$filterby]); $member = $q->UID_FROM_ALL($ligne[$filterby]); if ($filterby == "MAC") { if (!$ipClass->IsvalidMAC($ligne[$filterby])) { continue; } $js = "Loadjs('squid.nodes.php?node-infos-js=yes&MAC={$ligne[$filterby]}',true);"; } if ($js != null) { $Link = "OnClick=\"javascript:{$js}\""; $TextDeco = "underline"; } $data['rows'][] = array('id' => $md5, 'cell' => array("<a href=\"javascript:blur();\" {$Link} style='font-size:16px;text-decoration:{$TextDeco}'>{$value}</a></span>", "<a href=\"javascript:blur();\" {$Link} style='font-size:16px;text-decoration:{$TextDeco}'>{$member}</a></span>")); } echo json_encode($data); }
function events_list() { $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $search = $_GET["search"]; if ($search != null) { $search = "*{$search}*"; $search = str_replace("**", "%", $search); $search = str_replace("**", "%", $search); $search = str_replace("*", "%", $search); } else { $search = "%"; } if ($_GET["cat"] != null) { $cat = " AND category='{$_GET["cat"]}'"; } if ($_GET["func"] != null) { $func = " AND `function`='{$_GET["func"]}'"; } $today = date("Y-m-d"); $hier = $q->HIER(); $sql = "SELECT * FROM updateblks_events WHERE `text` LIKE '{$search}' {$cat} {$func} ORDER BY zDate DESC LIMIT 0,75"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>"; } $html = "\n\t<center>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t\t<th width=1%>{date}</th>\n\t\t<th width=99%>{event}</th>\n\t</tr>\n</thead>\n<tbody>"; while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { if ($classtr == "oddRow") { $classtr = null; } else { $classtr = "oddRow"; } $ligne["zDate"] = str_replace($today, "{today}", $ligne["zDate"]); $ligne["zDate"] = str_replace($hier, "{yesterday}", $ligne["zDate"]); $soustext = "<div style='font-size:11px;text-align:right'>PID:{$ligne["PID"]} | F:{$ligne["function"]} | {category}:{$ligne["category"]}</div>"; $ligne["text"] = nl2br($ligne["text"]); $html = $html . "\n\t\t\t\t<tr class={$classtr}>\n\t\t\t\t\t<td width=1% style='font-size:12px;' nowrap valign='middle'>{$ligne["zDate"]}</td>\n\t\t\t\t\t<td width=99% style='font-size:13px;'><div>{$ligne["text"]}</div>{$soustext}</td>\n\t\t\t\t</tr>\n\t\t\t\t"; } $html = $html . "</tbody></table></div>"; echo $tpl->_ENGINE_parse_body($html); }
function view_table(){ $q=new mysql_squid_builder(); $Mypage=CurrentPageName(); $tpl=new templates(); if(!isset($_GET["view-table"])){$_GET["view-table"]=$q->HIER();} $search='%'; $table=date('Ymd',strtotime($_GET["view-table"]))."_blocked"; $page=1; $ORDER="ORDER BY zDate DESC"; if($q->COUNT_ROWS($table)==0){$data['page'] = $page;$data['total'] = $total;$data['rows'] = array();echo json_encode($data);return ;} if(isset($_POST["sortname"])){ if($_POST["sortname"]<>null){ $ORDER="ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) {$page = $_POST['page'];} if($_POST["query"]<>null){ $_POST["query"]=str_replace("*", "%", $_POST["query"]); $search=$_POST["query"]; $searchstring="WHERE (`{$_POST["qtype"]}` LIKE '$search')"; $sql="SELECT COUNT(ID) as TCOUNT FROM `$table` $searchstring"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; }else{ $total = $q->COUNT_ROWS($table); } if (isset($_POST['rp'])) {$rp = $_POST['rp'];} $pageStart = ($page-1)*$rp; $limitSql = "LIMIT $pageStart, $rp"; $sql="SELECT * FROM `$table` $searchstring $ORDER $limitSql"; writelogs($sql,__FUNCTION__,__FILE__,__LINE__); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $results = $q->QUERY_SQL($sql); while ($ligne = mysql_fetch_assoc($results)) { $linkZoom="<a href=\"javascript:Loadjs('$Mypage?Zoom-js={$ligne['ID']}&table=$table');\" style='font-size:12px;text-decoration:underline'>"; $data['rows'][] = array( 'id' => $ligne['ID'], 'cell' => array($ligne['zDate'], $linkZoom.$ligne['website']."</a>", $ligne["client"], $ligne['category'],$ligne['rulename'],$ligne['uri']) ); } echo json_encode($data); }
function start6() { $cacheFile = "/usr/share/artica-postfix/ressources/logs/web/INTERFACE_WEBFILTER_BLOCKED.db"; @unlink($cacheFile); $unix = new unix(); $squid = $unix->LOCATE_SQUID_BIN(); if (!is_file($squid)) { if ($GLOBALS["VERBOSE"]) { echo "start6: squid no such binary\n"; } return; } $sock = new sockets(); if ($sock->EnableUfdbGuard() == 0) { return; } $zday = date('Ymd'); $table = $zday . "_blocked"; $q = new mysql_squid_builder(); if (!$q->TABLE_EXISTS($table)) { $hier = strtotime($q->HIER() . " 00:00:00"); $zday = date('Ymd', $hier); $table = $zday . "_blocked"; } if (!$q->TABLE_EXISTS($table)) { return; } $sql = "SELECT COUNT(*) as hits,HOUR(zDate) as `hour` FROM {$table} GROUP BY `hour` ORDER BY `hour`"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "{$q->mysql_error}"; return; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $hits = $ligne["hits"]; $xdata[] = $ligne["hour"]; $ydata[] = $hits; } if (count($xdata) < 2) { if ($GLOBALS["VERBOSE"]) { echo "start4(): " . count($xdata) . " < 2\n"; } return; } $array = array($xdata, $ydata); @file_put_contents($cacheFile, serialize($array)); @chmod($cacheFile, 0755); }
function nodes_list() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $defaultday = $q->HIER(); $TableActive = date('Ymd', strtotime($defaultday . " 00:00:00")) . "_hour"; $t = $_GET["t"]; $filterby = $_GET["filterby"]; $fieldname = $_GET["fieldname"]; $search = '%'; $table = "webfilters_nodes"; $page = 1; $FORCE_FILTER = null; $total = 0; if ($q->COUNT_ROWS($table) == 0) { writelogs("{$table}, no row", __FILE__, __FUNCTION__, __FILE__, __LINE__); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); echo json_encode($data); return; } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if ($_POST["query"] != null) { $_POST["query"] = "*" . $_POST["query"] . "*"; $_POST["query"] = str_replace("**", "*", $_POST["query"]); $_POST["query"] = str_replace("**", "*", $_POST["query"]); $_POST["query"] = str_replace("*", "%", $_POST["query"]); $search = $_POST["query"]; $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')"; $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { $data['rows'][] = array('id' => $ligne[time() + 1], 'cell' => array($q->mysql_error, "", "", "")); $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($sql, "", "", "")); echo json_encode($data); return; } $uptime = $tpl->_ENGINE_parse_body("{uptime}"); $ports = $tpl->_ENGINE_parse_body("{ports}"); if (!isset($_SESSION["PROXY_MAC_ACTIVE"])) { $results3 = $q->QUERY_SQL("SELECT COUNT(sitename) AS TCOUNT,MAC FROM {$TableActive} GROUP BY MAC"); while ($ligne = mysql_fetch_assoc($results3)) { $_SESSION["PROXY_MAC_ACTIVE"][$ligne["MAC"]] = true; } } while ($ligne = mysql_fetch_assoc($results)) { $ID = $ligne["MAC"]; $md5 = md5($ligne["MAC"]); $ligne["uid"] = utf8_encode($ligne["uid"]); $enabled = 0; $textToAdd = null; $js = "Loadjs('{$MyPage}?node-infos-js=yes&MAC={$ligne["MAC"]}');"; $results2 = $q->QUERY_SQL("SELECT hostname FROM (SELECT hostname FROM UserAutDB WHERE MAC='{$ligne["MAC"]}') as t GROUP BY hostname"); if (!$q->ok) { $tt[] = $q->mysql_error; } $tt = array(); $ArrayNMap = array(); $NMAPS = array(); $ArrayNMap = unserialize(base64_decode($ligne["nmapreport"])); if (is_array($ArrayNMap)) { if ($ArrayNMap["OS"] != null) { $NMAPS[] = "OS:{$ArrayNMap["OS"]}"; } if ($ArrayNMap["UPTIME"] != null) { $NMAPS[] = "{$uptime}:{$ArrayNMap["UPTIME"]}"; } if (count($ArrayNMap["PORTS"]) > 0) { $NMAPS[] = count($ArrayNMap["PORTS"]) . " {$ports}"; } if (count($NMAPS) > 0) { $textToAdd = "<div style='font-size:10px'>" . @implode(" ", $NMAPS) . "</div>"; } } $img_active = "<img src='img/20-check-grey.png'>"; if ($_SESSION["PROXY_MAC_ACTIVE"][$ligne["MAC"]]) { $img_active = "<img src='img/20-check.png'>"; } while ($ligne2 = mysql_fetch_assoc($results2)) { $link = null; if (trim($ligne2["hostname"]) == null) { continue; } if (preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+#", $ligne2["hostname"])) { if ($filterby == "ipaddr") { $link = "<a href=\"javascript:blur();\" \n\t\t\t\t\tOnClick=\"javascript:SelectUser{$t}('{$ligne2["hostname"]}');\" \n\t\t\t\t\tstyle='text-decoration:underline'>"; } $tt[] = "{$link}{$ligne2["hostname"]}</a>"; continue; } if (strpos($ligne2["hostname"], ".") > 0) { $ss = explode(".", $ligne2["hostname"]); $hostname = $ss[0]; } else { $hostname = $ligne2["hostname"]; } if ($filterby == "hostname") { $link = "<a href=\"javascript:blur();\" \n\t\t\t\t\tOnClick=\"javascript:SelectUser{$t}('{$hostname}');\" \n\t\t\t\t\tstyle='text-decoration:underline'>"; } $tt[] = "{$link}{$hostname}</a>"; } $maclink = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='font-size:18px;text-decoration:underline'>"; if ($filterby != null) { if ($filterby == "MAC") { $maclink = "<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:SelectUser{$t}('{$ligne["MAC"]}');\" \n\t\t\t\tstyle='font-size:18px;text-decoration:underline'>"; } if ($filterby == "uid") { $uidlink = "<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:SelectUser{$t}('{$ligne["uid"]}');\" \n\t\t\t\tstyle='font-size:18px;text-decoration:underline'>"; } } $data['rows'][] = array('id' => $md5, 'cell' => array("{$maclink}{$ligne["MAC"]}</a></span>", "<span style='font-size:11px'>" . @implode(", ", $tt) . "</span>{$textToAdd}", "<span style='font-size:18px'>{$uidlink}{$ligne["uid"]}</a></span>", $img_active)); } echo json_encode($data); }
function webcacheperfs() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timeF = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = @file_get_contents($pidfile); if ($pid < 100) { $pid = null; } $unix = new unix(); if ($unix->process_exists($pid)) { if ($GLOBALS["VERBOSE"]) { ufdbguard_admin_events("Fatal Already executed pid {$pid}", __FUNCTION__, __FILE__, __LINE__, "stats"); echo "Already executed pid {$pid}\n"; } return; } $prefix = date("Ymd"); $currenttable = "{$prefix}_hour"; $q = new mysql_squid_builder(); $currentHour = date("H"); $currentDay = date('d'); $currentMonth = date('m'); $currentYear = date('Y'); $hierT = strtotime($q->HIER() . " 00:00:00"); $hierDay = date("d", $hierT); $hierMonth = date("m", $hierT); $hierYear = date("Y", $hierT); $Hiertable = date("Ymd", $hierT) . "_hour"; $sql = "SELECT SUM( size ) AS tsize, cached, `HOUR` FROM {$currenttable} GROUP BY cached, `HOUR` HAVING HOUR <{$currentHour} LIMIT 0 , 30"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n"; return; } if (mysql_num_rows($results) == 0) { return; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $HASH[$ligne["HOUR"]][$ligne["cached"]] = $ligne["tsize"]; } if (!$q->TABLE_EXISTS("webcacheperfs")) { $q->CheckTables(); } $prefix = "INSERT IGNORE INTO webcacheperfs (zTimeInt,zHour,zDay,zMonth,zYear,notcached,cached,pourc) VALUES"; while (list($hour, $array) = each($HASH)) { if (!isset($array[1])) { $array[1] = 0; } $zTimeInt = "{$hour}{$currentDay}{$currentMonth}{$currentYear}"; if ($array[1] == 0) { ufdbguard_admin_events("Today {$hour}h 0% cache performance...", __FUNCTION__, __FILE__, __LINE__, "stats"); $sqlQuery = "{$prefix} ('{$zTimeInt}','{$hour}','{$currentDay}','{$currentMonth}','{$currentYear}','{$array[0]}',0,0)"; $q->QUERY_SQL($sqlQuery); if (!$q->ok) { ufdbguard_admin_events("Fatal: {$q->mysql_error}\n{$sqlQuery}", __FUNCTION__, __FILE__, __LINE__, "stats"); return; } continue; } $sum = $array[1] + $array[0]; $p1 = $array[1] / $sum; $p1 = round($p1 * 100); ufdbguard_admin_events("Today {$hour}h {$p1}% cache performance...", __FUNCTION__, __FILE__, __LINE__, "stats"); $sqlQuery = "{$prefix} ({$zTimeInt},{$hour},{$currentDay},{$currentMonth},{$currentYear},{$array[0]},{$array[1]},'{$p1}')"; $q->QUERY_SQL($sqlQuery); if (!$q->ok) { ufdbguard_admin_events("Fatal: {$q->mysql_error}\n{$sqlQuery}", __FUNCTION__, __FILE__, __LINE__, "stats"); return; } } unset($HASH); $sql = "SELECT SUM( size ) AS tsize, cached, `HOUR` FROM {$Hiertable} GROUP BY cached, `HOUR` LIMIT 0 , 30"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n"; return; } if (mysql_num_rows($results) == 0) { return; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $HASH[$ligne["HOUR"]][$ligne["cached"]] = $ligne["tsize"]; } while (list($hour, $array) = each($HASH)) { if (!isset($array[1])) { $array[1] = 0; } $zTimeInt = "{$hour}{$currentDay}{$currentMonth}{$currentYear}"; if ($array[1] == 0) { $q->QUERY_SQL("{$prefix} ({$zTimeInt},{$hour},{$hierDay},{$hierMonth},{$hierYear},{$array[0]},0,0)"); if (!$q->ok) { ufdbguard_admin_events("Fatal: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "stats"); return; } continue; } $sum = $array[1] + $array[0]; $p1 = $array[1] / $sum; $p1 = round($p1 * 100); $q->QUERY_SQL("{$prefix} ({$zTimeInt},{$hour},{$hierDay},{$hierMonth},{$hierYear},{$array[0]},{$array[1]},'{$p1}')"); if (!$q->ok) { ufdbguard_admin_events("Fatal: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "stats"); return; } } }
function graph_web_sites(){ if($GLOBALS["VERBOSE"]){echo __FUNCTION__."<br>\n";} $q=new mysql_squid_builder(); $page=CurrentPageName(); $tpl=new templates(); if(!isset($_GET["day"])){$_GET["day"]=$q->HIER();} if(!isset($_GET["type"])){$_GET["type"]="size";} if($_GET["type"]==null){$_GET["type"]="size";} $type=$_GET["type"]; $field_query="size"; $today=date("Y-m-d"); if($_GET["day"]==$today){$_GET["day"]=$q->HIER();} if($type=="req"){$field_query="hits";} $hour_table=date('Ymd',strtotime($_GET["day"]))."_hour"; $sourcetable="dansguardian_events_".date('Ymd',strtotime($_GET["day"])); $sql="SELECT SUM($field_query) as totalsize,familysite FROM $hour_table GROUP BY familysite ORDER BY totalsize DESC LIMIT 0,10"; $results=$q->QUERY_SQL($sql); $data=array(); while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){ if(trim($ligne["familysite"])==null){continue;} $familysite=$ligne["familysite"]; if($_GET["type"]=="size"){$size=round(($ligne["totalsize"]/1024)); $size_text=FormatBytes(($ligne["totalsize"]/1024)); }else{$size=$ligne["totalsize"];$size_text=$size;} if($_GET["type"]=="size"){$tsize=round(($ligne["totalsize"]/1024));}else{$tsize=$ligne["totalsize"];} $data[$familysite]=$tsize; } $highcharts=new highcharts(); $highcharts->container=$_GET["container"]; $highcharts->PieDatas=$data; $highcharts->ChartType="pie"; $highcharts->PiePlotTitle="{websites}"; $highcharts->Title="{top} {websites} ({$GLOBALS["title_array"][$type]})"; echo $highcharts->BuildChart(); }
function gencache_TOP() { $file = "/usr/share/artica-postfix/ressources/logs/web/TOP_CACHED.db"; @unlink($file1); @unlink($file2); $q = new mysql_squid_builder(); $current_table = date("Ymd") . "_gcache"; if (!$q->TABLE_EXISTS($current_table)) { $xtime = strtotime($q->HIER() . " 00:00:00"); $current_table = date("Ymd", $xtime) . "_gcache"; } if (!$q->TABLE_EXISTS($current_table)) { if ($GLOBALS["VERBOSE"]) { echo "{$current_table} no such table...\n"; } return; } $sql = "SELECT familysite,cached,SUM(size) as size FROM\n\t{$current_table} GROUP BY cached,familysite HAVING cached=1 ORDER BY `size` DESC LIMIT 0,10"; $results = $q->QUERY_SQL($sql); $Count = mysql_num_rows($results); if ($GLOBALS["VERBOSE"]) { echo $sql . "\n{$Count} items \n"; } if ($Count < 2) { return; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $size = $ligne["size"]; $size = $size / 1024; $size = $size / 1024; $size = round($size); $ARRAY[$ligne["familysite"]] = $size; } @file_put_contents($file1, serialize($ARRAY)); @chmod($file1, 0755); $ARRAY = array(); $sql = "SELECT familysite,cached,SUM(size) as size FROM\n\t{$current_table} GROUP BY cached,familysite HAVING cached=0 ORDER BY `size` DESC LIMIT 0,10"; $results = $q->QUERY_SQL($sql); $Count = mysql_num_rows($results); if ($GLOBALS["VERBOSE"]) { echo $sql . "\n{$Count} items \n"; } if ($Count < 2) { return; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $size = $ligne["size"]; $size = $size / 1024; $size = $size / 1024; $size = round($size); $ARRAY[$ligne["familysite"]] = $size; } @file_put_contents($file2, serialize($ARRAY)); @chmod($file2, 0755); $ARRAY = array(); }
function squidhour_tables_rows(){ $q=new mysql_squid_builder(); $Mypage=CurrentPageName(); $tpl=new templates(); if(!isset($_GET["view-table"])){$_GET["view-table"]=$q->HIER();} $search='%'; $time=strtotime("{$_GET["day"]} 00:00:00"); $table="(SELECT table_name as c FROM information_schema.tables WHERE table_schema = 'squidlogs' AND table_name LIKE 'squidhour_%') as t"; $page=1; $ORDER="ORDER BY zDate DESC"; if(isset($_POST["sortname"])){ if($_POST["sortname"]<>null){ $ORDER="ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) {$page = $_POST['page'];} $searchstring=string_to_flexquery(); if($searchstring<>null){ $sql="SELECT COUNT(*) as TCOUNT FROM $table WHERE 1 $searchstring"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; }else{ $sql="SELECT COUNT(*) as TCOUNT FROM $table"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) {$rp = $_POST['rp'];} $pageStart = ($page-1)*$rp; $limitSql = "LIMIT $pageStart, $rp"; $sql="SELECT * FROM $table WHERE 1 $searchstring $ORDER $limitSql"; $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $results = $q->QUERY_SQL($sql); if(!$q->ok){json_error_show($q->mysql_error."\n$sql");} while ($ligne = mysql_fetch_assoc($results)) { $linkZoom="<a href=\"javascript:Loadjs('squid.blocked.statistics.days.php?Zoom-js={$ligne['zMD5']}&ID={$ligne['zMD5']}&table=$table&key=zMD5');\" style='font-size:12px;text-decoration:underline'>"; $table=$ligne["c"]; $time=$q->TIME_FROM_HOUR_TEMP_TABLE($table); $date=date("Y-m-d H:i:s",$time); $sum=$q->COUNT_ROWS($table); $sum=FormatNumber($sum); $data['rows'][] = array( 'id' => $table, 'cell' => array($date,$table,$sum,'') ); } echo json_encode($data); }
function page(){ $page=CurrentPageName(); $tpl=new templates(); $q=new mysql_squid_builder(); if(!isset($_GET["day"])){$_GET["day"]=$q->HIER();} if($_GET["day"]==null){$_GET["day"]=$q->HIER();} $member=$tpl->_ENGINE_parse_body("{member}"); $delete=$tpl->_ENGINE_parse_body("{delete}"); $new_rule=$tpl->_ENGINE_parse_body("{new_rule}"); $size=$tpl->_ENGINE_parse_body("{size}"); $sitename=$tpl->_ENGINE_parse_body("{sitename}"); $date=$tpl->_ENGINE_parse_body("{date}"); $members=$tpl->_ENGINE_parse_body("{members}"); $hostname=$tpl->_ENGINE_parse_body("{hostname}"); $day=$tpl->_ENGINE_parse_body("{day}"); $week=$tpl->_ENGINE_parse_body("{week}"); $duration=$tpl->_ENGINE_parse_body("{duration}"); $quotas=$tpl->_ENGINE_parse_body("{quotas}"); $maxquota=$tpl->_ENGINE_parse_body("{maxquota}"); $parameters=$tpl->_ENGINE_parse_body("{parameters}"); $apply_parameters=$tpl->_ENGINE_parse_body("{apply_parameters}"); $online_help=$tpl->_ENGINE_parse_body("{online_help}"); $destination=$tpl->_ENGINE_parse_body("{destination}"); $enabled=$tpl->_ENGINE_parse_body("{enabled}"); $TB_WIDTH=550; $t=time(); $buttons=" buttons : [ {name: '<b>$new_rule</b>', bclass: 'add', onpress : NewRule$t}, {name: '<b>$parameters</b>', bclass: 'Settings', onpress :Params$t}, {name: '<b>$apply_parameters</b>', bclass: 'Reconf', onpress :Reconf$t}, {name: '<b>$online_help</b>', bclass: 'Help', onpress :help$t}, ],"; $html=" <center id='anim-$t'><img src='img/wait_verybig_old.gif'></center> <table class='$t' style='display: none' id='$t' style='width:99%'></table> <script> var mem$t=''; function StartTable$t(){ document.getElementById('anim-$t').innerHTML=''; $('#$t').flexigrid({ url: '$page?list-items=yes&t=$t', dataType: 'json', colModel : [ {display: '$member', name : 'value', width : 184, sortable : true, align: 'left'}, {display: '$destination', name : 'xdes', width : 211, sortable : false, align: 'left'}, {display: '$duration', name : 'duration', width : 161, sortable : true, align: 'left'}, {display: '$maxquota', name : 'maxquota', width : 124, sortable : false, true: 'left'}, {display: '$enabled', name : 'enabled', width : 31, sortable : false, true: 'center'}, {display: ' ', name : 'del', width : 31, sortable : false, true: 'center'}, ],$buttons searchitems : [ {display: '$member', name : 'value'}, ], sortname: 'maxquota', sortorder: 'asc', usepager: true, title: '$members»{$quotas}', useRp: true, rp: 15, showTableToggleBtn: false, width: 832, height: 450, singleSelect: true }); } function RefreshNodesSquidTbl(){ $('#$t').flexReload(); } function NewRule$t(){ Loadjs('$page?new-quota-rule=yes&t=$t'); } function GetRule$t(ID){ Loadjs('$page?get-quota-rule=yes&t=$t&ID='+ID); } function Reconf$t(){ Loadjs('squid.compile.php'); } function Params$t(){ Loadjs('$page?quota-params=yes&t=$t'); } var x_DeleteQuota$t= function (obj) { var results=obj.responseText; if(results.length>2){alert(results);return;} $('#row'+mem$t).remove(); } function DeleteQuota$t(ID){ mem$t=ID; var XHR = new XHRConnection(); XHR.appendData('delete',ID); XHR.sendAndLoad('$page', 'POST',x_DeleteQuota$t); } var x_Enable$t= function (obj) { var results=obj.responseText; if(results.length>2){alert(results);return;} $('#$t').flexReload(); } function EnableQuota$t(ID){ mem$t=ID; var XHR = new XHRConnection(); XHR.appendData('EnableDisable',ID); XHR.sendAndLoad('$page', 'POST',x_Enable$t); } function help$t(){ s_PopUpFull('http://www.youtube.com/watch?v=wYXGwKB9SPk&feature=c4-overview&list=UUYbS4gGDNP62LsEuDWOMN1Q','1024','900'); } setTimeout('StartTable$t()',500); </script>"; echo $html; }
function right(){ if($GLOBALS["VERBOSE"]){echo __FUNCTION__."<br>\n";} $q=new mysql_squid_builder(); $page=CurrentPageName(); $tpl=new templates(); if(!isset($_GET["day"])){$_GET["day"]=$q->HIER();} if(!isset($_GET["type"])){$_GET["type"]="size";} if($_GET["type"]==null){$_GET["type"]="size";} $type=$_GET["type"]; $field_query="size"; $today=date("Y-m-d"); if($_GET["day"]==$today){$_GET["day"]=$q->HIER();} $time=strtotime($_GET["day"]."00:00:00"); $buttonRepair=button("{rescan_database}","Loadjs('squid.stats.repair.day.php?time=$time')",18); $hour_table=date('Ymd',strtotime($_GET["day"]))."_hour"; $sourcetable="dansguardian_events_".date('Ymd',strtotime($_GET["day"])); if($GLOBALS["VERBOSE"]){echo "Table=$hour_table<br>\n";} if(!$q->TABLE_EXISTS($hour_table)){ if($q->TABLE_EXISTS($sourcetable)){ $button="<hr>".button("{repair}","RepairTableDay('$sourcetable')",16); }else{ $button="<div style='font-size:10px'>$sourcetable no such table...$buttonRepair</div>"; } echo $tpl->_ENGINE_parse_body("<input type='hidden' id='squid-stats-day-hide-type' value='{$_GET["type"]}'>$title<center style='margin:50px'><H2>{error_no_datas}</H2> <div style='font-size:10px'>$hour_table no such table..</div>$button</center><script>LoadAjax('statistics-days-left-status','$page?statistics-days-left-status=yes&day={$_GET["day"]}');</script>"); return; } if($type=="req"){$field_query="hits";} $tG=time(); $t=time(); $html=" <input type='hidden' id='squid-stats-day-hide-type' value='$type'> <div id='graph-$tG' style='width:650px;height:350px'><center style='margin:50px'><img src='img/wait-clock.gif'></center></div> <div id='graph2-$tG' style='width:650px;height:350px'><center style='margin:50px'><img src='img/wait-clock.gif'></center></div> <div id='$t'></div> <script> function WaitAndLaunch$t(){ Loadjs('squid.traffic.statistics.days.graphs.php?getsize=yes&container=graph-$tG&day={$_GET["day"]}&type={$_GET["type"]}'); Loadjs('squid.traffic.statistics.days.graphs.php?getwebsites=yes&container=graph2-$tG&day={$_GET["day"]}&type={$_GET["type"]}'); LoadAjax('$t','squid.traffic.statistics.days.table.php?field_query=$field_query&hour_table=$hour_table'); } LoadAjax('statistics-days-left-status','$page?statistics-days-left-status=yes&day={$_GET["day"]}'); setTimeout(\"WaitAndLaunch$t()\",1000); </script> "; echo $tpl->_ENGINE_parse_body($html); }
function day_graphs_perform(){ $page=CurrentPageName(); $tpl=new templates(); $q=new mysql_squid_builder(); $title="{number_of_users}"; if(!isset($_GET["day"])){$_GET["day"]=$q->HIER();} if($_GET["day"]==null){$_GET["day"]=$q->HIER();} $dayfull="{$_GET["day"]} 00:00:00"; $date=strtotime($dayfull); $script="<div id='top-members-day'></div><script>LoadAjax('top-members-day','$page?day-top-members=yes&day={$_GET["day"]}');</script>"; $tablesrc=date("Ymd",$date)."_members"; if($q->TABLE_EXISTS($tablesrc)){ $sql="SELECT COUNT(zMD5) as tcount, `hour` FROM `$tablesrc` GROUP BY `hour` ORDER BY `hour`"; if(isset($_GET["user-field"])){ $script="<div id='top-members-day'></div><script>LoadAjax('top-members-day','$page?day-top-member-site=yes&day={$_GET["day"]}&user-field={$_GET["user-field"]}&user={$_GET["user"]}');</script>"; $sql="SELECT SUM(hits) as tcount, `hour`,`{$_GET["user-field"]}` FROM `$tablesrc` GROUP BY `{$_GET["user-field"]}`,`hour` HAVING `{$_GET["user-field"]}`='{$_GET["user"]}' ORDER BY `hour`"; $title="{hits} {member}: {$_GET["user"]}"; $mdF=".".md5("{$_GET["user-field"]}:{$_GET["user"]}").".hits."; } $gp=new artica_graphs(); $dayText=date('l',$date); $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)){ $gp->xdata[]=$ligne["hour"]; $gp->ydata[]=$ligne["tcount"]; } $targetedfile="ressources/logs/".basename(__FILE__).".".__FUNCTION__.".$mdF$tablesrc.png"; $gp->width=550; $gp->height=350; $gp->filename="$targetedfile"; $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)){writelogs("Fatal \"$targetedfile\" no such file!",__FUNCTION__,__FILE__,__LINE__);$targetedfile="img/kas-graph-no-datas.png";} $html=" <div style='font-size:16px'>$title {{$dayText}} {$_GET["day"]}</div> <center> <img src='$targetedfile'> </center> <script>LoadAjax('squid-members-graphs-left-menu','$page?day-left-menu=yes&day={$_GET["day"]}');</script> $script"; echo $tpl->_ENGINE_parse_body($html); }
function right() { $q = new mysql_squid_builder(); $page = CurrentPageName(); $tpl = new templates(); if (!isset($_GET["day"])) { $_GET["day"] = $q->HIER(); } if (!isset($_GET["type"])) { $_GET["type"] = "size"; } if ($_GET["type"] == null) { $_GET["type"] = "size"; } $type = $_GET["type"]; $field_query = "size"; $SourceTable = date('Ymd', strtotime($_GET["day"])) . "_blocked"; $title = "<div style='font-size:16px;width:100%;font-weight:bold'>{statistics}: " . strtolower(date('{l} d {F} Y', strtotime($_GET["day"]))) . " ({hits})</div>"; if (!$q->TABLE_EXISTS($SourceTable)) { echo $tpl->_ENGINE_parse_body("<input type='hidden' id='squid-stats-day-hide-type' value='{$_GET["type"]}'>{$title}<center style='margin:50px'><H2>{error_no_datas}</H2></center>"); return; } if ($type == "req") { $field_query = "hits"; } $sql = "SELECT COUNT(ID) as tcount,HOUR(zDate) as `hour` FROM {$SourceTable} GROUP BY HOUR(zDate) ORDER BY HOUR(zDate) "; $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("{$title}<center style='margin:50px'><H2>{error_no_datas}</H2></center>"); return; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $xdata[] = $ligne["tdate"]; $ydata[] = $ligne["tcount"]; } $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . ".day.{$SourceTable}.{$type}.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("{hours}"); $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; } $sql = "SELECT COUNT(ID) as tcount,category FROM {$SourceTable} GROUP BY category ORDER BY tcount DESC LIMIT 0,10"; $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("{$title}<center style='margin:50px'><H2>{error_no_datas}</H2></center>"); return; } $table = "\n\t<input type='hidden' id='squid-stats-day-hide-type' value='{$_GET["type"]}'>\n\t<center>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:350px'>\n<thead class='thead'>\n\t<tr>\n\t<th width=1%>{hits}</th>\n\t<th>{category}</th>\n\t</tr>\n</thead>\n<tbody>"; $xdata = array(); $ydata = array(); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { if (trim($ligne["category"]) == null) { continue; } $ydata[] = $ligne["category"]; $xdata[] = $ligne["tcount"]; if ($classtr == "oddRow") { $classtr = null; } else { $classtr = "oddRow"; } $table = $table . "\n\t\t<tr class={$classtr}>\n\t\t\t\n\t\t\t<td width=1% style='font-size:14px' nowrap><strong>{$ligne["tcount"]}</strong></td>\n\t\t\t<td style='font-size:14px' nowrap width=99%>\n\t\t\t\t<strong><a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:Loadjs('{$page}?today-zoom=yes&category={$ligne["category"]}&day={$_GET["day"]}')\" \n\t\t\t\tstyle='font-size:14px;font-weight:bold;text-decoration:underline'>{$ligne["category"]}</a></strong></td>\n\t\t</tr>\n\t\t"; } $table = $table . "</tbody></table>"; $targetedfile2 = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . ".day.top.10.websites.{$SourceTable}.{$type}.png"; $gp = new artica_graphs($targetedfile2); $gp->xdata = $xdata; $gp->ydata = $ydata; $gp->width = 550; $gp->height = 550; $gp->ViewValues = true; $gp->x_title = $tpl->_ENGINE_parse_body("{top_categories}"); $gp->pie(); $html = "\n\t<input type='hidden' id='squid-stats-day-hide-type' value='{$type}'>\n\t{$title}\n\t<center style='margin:10px'><img src='{$targetedfile}'></center>\n\t<center style='margin:10px'><img src='{$targetedfile2}'></center>\n\t{$table}\n\t<script>\n\t\tLoadAjax('statistics-days-left-status','squid.traffic.statistics.days.php?statistics-days-left-status=yes&day={$_GET["day"]}');\n\t</script>\n\t\n"; echo $tpl->_ENGINE_parse_body($html); }
function page() { $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); if (!isset($_GET["day"])) { $_GET["day"] = $q->HIER(); } if ($_GET["day"] == null) { $_GET["day"] = $q->HIER(); } $member = $tpl->_ENGINE_parse_body("{member}"); $delete = $tpl->_ENGINE_parse_body("{delete}"); $new_rule = $tpl->_ENGINE_parse_body("{new_rule}"); $size = $tpl->_ENGINE_parse_body("{size}"); $sitename = $tpl->_ENGINE_parse_body("{sitename}"); $date = $tpl->_ENGINE_parse_body("{date}"); $members = $tpl->_ENGINE_parse_body("{members}"); $hostname = $tpl->_ENGINE_parse_body("{hostname}"); $day = $tpl->_ENGINE_parse_body("{day}"); $week = $tpl->_ENGINE_parse_body("{week}"); $duration = $tpl->_ENGINE_parse_body("{duration}"); $quotas = $tpl->_ENGINE_parse_body("{quotas}"); $maxquota = $tpl->_ENGINE_parse_body("{maxquota}"); $parameters = $tpl->_ENGINE_parse_body("{parameters}"); $apply_parameters = $tpl->_ENGINE_parse_body("{apply_parameters}"); $online_help = $tpl->_ENGINE_parse_body("{online_help}"); $destination = $tpl->_ENGINE_parse_body("{destination}"); $enabled = $tpl->_ENGINE_parse_body("{enabled}"); $TB_WIDTH = 550; $t = time(); $buttons = "\n\tbuttons : [\n\t{name: '<b>{$new_rule}</b>', bclass: 'add', onpress : NewRule{$t}},\n\t{name: '<b>{$parameters}</b>', bclass: 'Settings', onpress :Params{$t}},\n\t{name: '<b>{$apply_parameters}</b>', bclass: 'Reconf', onpress :Reconf{$t}},\n\t{name: '<b>{$online_help}</b>', bclass: 'Help', onpress :help{$t}},\n\t\n\t\n\t\t],"; $html = "\n\t<center id='anim-{$t}'><img src='img/wait_verybig_old.gif'></center>\n\t<table class='{$t}' style='display: none' id='{$t}' style='width:99%'></table>\n<script>\nvar mem{$t}='';\nfunction StartTable{$t}(){\ndocument.getElementById('anim-{$t}').innerHTML='';\n\n\$('#{$t}').flexigrid({\n\turl: '{$page}?list-items=yes&t={$t}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$member}', name : 'value', width : 184, sortable : true, align: 'left'},\n\t\t{display: '{$destination}', name : 'xdes', width : 211, sortable : false, align: 'left'},\n\t\t{display: '{$duration}', name : 'duration', width : 161, sortable : true, align: 'left'},\n\t\t{display: '{$maxquota}', name : 'maxquota', width : 124, sortable : false, true: 'left'},\n\t\t{display: '{$enabled}', name : 'enabled', width : 31, sortable : false, true: 'center'},\n\t\t{display: ' ', name : 'del', width : 31, sortable : false, true: 'center'},\n\t\t\n\t\t\n\t\t\n\t],{$buttons}\n\tsearchitems : [\n\t\t{display: '{$member}', name : 'value'},\n\t\t],\n\tsortname: 'maxquota',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '{$members}»{$quotas}',\n\tuseRp: true,\n\trp: 15,\n\tshowTableToggleBtn: false,\n\twidth: 832,\n\theight: 450,\n\tsingleSelect: true\n\t\n\t});\n}\n\nfunction RefreshNodesSquidTbl(){\n\t\$('#{$t}').flexReload();\n}\n\nfunction NewRule{$t}(){\n\tLoadjs('{$page}?new-quota-rule=yes&t={$t}');\n}\nfunction GetRule{$t}(ID){\n\tLoadjs('{$page}?get-quota-rule=yes&t={$t}&ID='+ID);\n}\n\nfunction Reconf{$t}(){\n\tLoadjs('squid.compile.php');\n}\n\nfunction Params{$t}(){\n\tLoadjs('{$page}?quota-params=yes&t={$t}');\n}\n\n\tvar x_DeleteQuota{$t}= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>2){alert(results);return;}\n\t\t\$('#row'+mem{$t}).remove();\n\t\t\n\t}\n\nfunction DeleteQuota{$t}(ID){\n\tmem{$t}=ID;\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('delete',ID);\n\tXHR.sendAndLoad('{$page}', 'POST',x_DeleteQuota{$t});\t\n\t\n}\n\tvar x_Enable{$t}= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>2){alert(results);return;}\n\t\t\$('#{$t}').flexReload();\n\t\t\n\t}\n\nfunction EnableQuota{$t}(ID){\n\tmem{$t}=ID;\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('EnableDisable',ID);\n\tXHR.sendAndLoad('{$page}', 'POST',x_Enable{$t});\t\n}\n\nfunction help{$t}(){\n\ts_PopUpFull('http://www.youtube.com/watch?v=wYXGwKB9SPk&feature=c4-overview&list=UUYbS4gGDNP62LsEuDWOMN1Q','1024','900');\n}\n\nsetTimeout('StartTable{$t}()',500);\n\n</script>"; echo $html; }
function webstats_left() { $t = $_GET["t"]; $year = $_GET["year"]; $day = $_GET["day"]; $month = $_GET["month"]; $tpl = new templates(); $q = new mysql_squid_builder(); $page = CurrentPageName(); if ($day == null) { $dayfull = $q->HIER(); $xdate = strtotime("{$dayfull} 00:00:00"); $day = date("d", $xdate); $month = date("m", $xdate); $year = date("Y", $xdate); } if (!is_numeric($month)) { if (!is_numeric($_GET["week"])) { $youtube_objects = $q->COUNT_ROWS("youtube_objects"); $youtube_objects = numberFormat($youtube_objects, 0, "", " "); $UserAuthDaysGrouped = $q->COUNT_ROWS("UserAuthDaysGrouped"); $UserAuthDaysGrouped = numberFormat($UserAuthDaysGrouped, 0, "", " "); $tR[] = Paragraphe32("{$youtube_objects} Youtube {objects}", "{youtube_objects_statistics_text}", "document.location.href='miniadm.webstats.youtube.php'", "youtube-32.png"); $members = Paragraphe("{$UserAuthDaysGrouped} {members}", "{display_access_by_members}", "document.location.href='miniadm.webstats.members.php'", "member-32.png"); } } if (is_numeric($_GET["week"])) { $month = null; $xdate = strtotime("{$year}-{$month}-{$day} 00:00:00"); $tablename = "{$_GET["year"]}{$_GET["week"]}_week"; $dateT = $q->WEEK_TITLE($_GET["week"], $_GET["year"]); if ($q->TABLE_EXISTS($tablename)) { $tR1[] = "<div id='week-{$t}' style='width:700px'></div><script>LoadAjax('week-{$t}','{$page}?buildiconsof-week=yes&tablename={$tablename}&year={$_GET["year"]}&day={$_GET["day"]}&week={$_GET["week"]}&t={$t}');</script>"; } } if (is_numeric($month)) { $xdate = strtotime("{$year}-{$month}-{$day} 00:00:00"); $tablename = date("Ymd", $xdate) . "_hour"; $dateT = date("{l} {F} d", $xdate); if ($tpl->language == "fr") { $dateT = date("{l} d {F} ", $xdate); } if ($q->TABLE_EXISTS($tablename)) { $tR1[] = "<div id='day-{$t}'></div><script>LoadAjax('day-{$t}','{$page}?buildiconsof=yes&tablename={$tablename}&xtime={$xdate}&t={$t}');</script>"; } } $t = time(); $title = $tpl->javascript_parse_text("{statistics}: {$dateT}"); $html = "\n\t" . CompileTr4($tR, "none") . "\n\t" . @implode("", $tR1) . "\n\t<div id='{$t}'></div>\n\t<script>\n\t\tif(document.getElementById('TitleOfMainPage')){document.getElementById('TitleOfMainPage').innerHTML='{$title}';}\n\t\tLoadAjax('{$t}','squid.traffic.statistics.days.php?day-right-tabs=yes&day={$year}-{$month}-{$day}&type=size');\n\t</script>\n\t"; echo $tpl->_ENGINE_parse_body($html); }