public function getPlans($where = '', $limit = ' LIMIT 3', $full_detail = true) { $plans = $this->db->query("SELECT\n \t\t\t\ta.id AS id,\n \t\t\t\ta.id_status AS id_status,\n \t\t\t\ta.name AS name,\n \t\t\t\ta.monthly AS month,\n a.quarterly AS quarter,\n a.semesterly AS semester,\n a.yearly AS year,\n a.content_id,\n (SELECT c.text_small FROM contents c WHERE c.id = a.content_id) AS text_small\n \t\t\tFROM {$this->table} a\n \t\t\t{$where}\n \t\t\tORDER BY id\n \t\t\t{$limit}\n \t\t"); $i = 0; foreach ($plans->result_array() as $array) { //plans $i = $array['id']; $result[$i]['id'] = $array['id']; $result[$i]['name'] = formatString($array['name']); $result[$i]['month'] = numberFormat($array['month'], 2); $result[$i]['quarter'] = numberFormat($array['quarter'], 2); $result[$i]['semester'] = numberFormat($array['semester'], 2); $result[$i]['year'] = numberFormat($array['year'], 2); $result[$i]['text_small'] = $array['text_small']; $result[$i]['content_id'] = $array['content_id']; $details = $this->db->query('SELECT description FROM ' . $this->table . "_details\n \t\t\t\tWHERE id_plan = '" . $array['id'] . "'\n \t\t\t\tORDER BY id\n \t\t\t\t" . ($full_detail ? '' : ' LIMIT 3') . ' '); $j = 0; foreach ($details->result_array() as $detail) { //details $result[$i]['details'][$j++] = formatString($detail['description']); } $i++; } return $result; }
function page() { $sock = new sockets(); $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance"); $MalwarePatrolDatabasesCount = $sock->getFrameWork("cmd.php?MalwarePatrolDatabasesCount=yes"); if (GET_CACHED(__FILE__, __FUNCTION__, __FUNCTION__)) { return; } $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $users = new usersMenus(); $websitesnums = $q->COUNT_ROWS("visited_sites"); $websitesnums = numberFormat($websitesnums, 0, "", " "); $sql = "DELETE FROM categorize WHERE LENGTH(pattern)=0"; $q->QUERY_SQL($sql); $export = $q->COUNT_ROWS("categorize"); $export = numberFormat($export, 0, "", " "); $categories = $q->COUNT_CATEGORIES(); $categories = numberFormat($categories, 0, "", " "); $tablescat = $q->LIST_TABLES_CATEGORIES(); $tablescatNUM = numberFormat(count($tablescat), 0, "", " "); $q = new mysql_squid_builder(); $requests = $q->EVENTS_SUM(); $requests = numberFormat($requests, 0, "", " "); $PhishingURIS = $q->COUNT_ROWS("uris_phishing"); $PhishingURIS = numberFormat($PhishingURIS, 0, "", " "); $MalwaresURIS = $q->COUNT_ROWS("uris_malwares"); $MalwaresURIS = numberFormat($MalwaresURIS, 0, "", " "); $Computers = $q->COUNT_ROWS("webfilters_nodes"); $Computers = numberFormat($Computers, 0, "", " "); $DAYSNumbers = $q->COUNT_ROWS("tables_day"); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(totalsize) as tsize FROM tables_day")); $totalsize = FormatBytes($ligne["tsize"] / 1024); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT AVG(cache_perfs) as pourc FROM tables_day")); $pref = round($ligne["pourc"]); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(sitename) as tcount FROM visited_sites WHERE LENGTH(category)=0")); $websitesnumsNot = numberFormat($ligne["tcount"], 0, "", " "); $CachePermformance = $q->CachePerfHour(); if ($CachePermformance > -1) { $color = "#E01313"; if ($CachePermformance > 20) { $color = "#6DBB6A"; } $cachePerfText = "\n\t\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b style='color:{$color}'>{$CachePermformance}%</b> {cache_performance} ({now})</td>\n\t\t</tr>\n\t\t"; } $mouse = "OnMouseOver=\";this.style.cursor='pointer';\" OnMouseOut=\";this.style.cursor='default';\""; $submenu = "\t\n\t<tr>\n\t\t<td valign='top' style='font-size:14px'><b>{$totalsize}</b> {downloaded_flow}</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='top' style='font-size:14px'><b>{$pref}%</b> {cache_performance}</td>\n\t</tr>\n\t"; $main_table = "\n\t<table style='width:98%' class=form>\n\t<tr><td style='font-size:16px'>{statistics}::{status}</td></tr>\n\t{$cachePerfText}\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;><b>{$DAYSNumbers}</b> {daysOfStatistics}</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='top' style='font-size:14px'><b>{$requests}</b> {requests}</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='top' style='font-size:14px'><b>{$Computers}</b> {computers}</td>\n\t</tr>\t\t\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$websitesnums}</b> {visited_websites}</td>\n\t</tr>\t\n\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$categories}</b> {websites_categorized}</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$PhishingURIS}</b> {phishing_uris}</td>\n\t</tr>\t\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$MalwaresURIS}</b> {viruses_uris}</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$MalwarePatrolDatabasesCount}</b> Malware Patrol</td>\n\t</tr>\t\t\t\t\t\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$websitesnumsNot}</b> {not_categorized}</td>\n\t</tr>\t\t\t\t\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$tablescatNUM}</b> {categories}</td>\n\t</tr>\n\t</table>\t\n"; $main_table = $tpl->_ENGINE_parse_body($main_table); SET_CACHED(__FILE__, __FUNCTION__, __FUNCTION__, $main_table); echo $main_table; }
function page() { $users = new usersMenus(); $title = $users->hostname . " For Android/Tablets Login."; include_once dirname(__FILE__) . "/ressources/class.page.builder.inc"; $p = new pagebuilder(); $jsArtica = $p->jsArtica(); $yahoo = $p->YahooBody(); $css = $p->headcss(); $q = new mysql_squid_builder(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(sitename) as tcount FROM visited_sites WHERE LENGTH(category)=0")); $websitesnumsNot = numberFormat($ligne["tcount"], 0, "", " "); $html = "\n\t<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=9; IE=8\">\n <meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-type\" />\n <link rel=\"stylesheet\" type=\"text/css\" href=\"/css/artica-theme/jquery-ui.custom.css\" />\n <link rel=\"stylesheet\" type=\"text/css\" href=\"/css/jquery.jgrowl.css\" />\n\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/jquery.cluetip.css\" />\n\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/jquery.treeview.css\" />\n\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/thickbox.css\" media=\"screen\"/>\n\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/jquery.qtip.css\" />\n\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"/fonts.css.php\"/>\n\t\t\n{$css}\n <title>{$title}</title>\n{$jsArtica}\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/android.css\" />\n</head>\n\n<body style=\"margin:0px;padding:0px\">\n<div style=\"postition:absolute;top:0px;left:80%;width:980px;min-height:490px;overflow-y:auto\">\n\t\n\t<table style='width:980px;'>\n\t<tr>\n\t<td valign='top' width=5%>\n\t <ul class=\"vertical fl\" rel=\"ver1\">\n <li><a href=\"android.index.php\">{home}</a><span>{main_page}</span></li>\n <li><a href=\"javascript:LoadAjax('mainpage','android.squidstats.members.php')\">{members}</a><span>{list_your_members}</span></li>\n <li><a href=\"#\">Under construction</a><span>to define</span></li>\n <li><a href=\"#\">Under construction</a><span>Under construction</span></li>\n <li><a href=\"javascript:LoadAjax('mainpage','android.squidstats.nocat.php')\"\">{not_categorized}</a><span><b>{$websitesnumsNot}</b> {websites} {not_categorized}</span></li>\n <li><a rel=\"#\">About</a><span>{parameters}</span></li>\n </ul>\n </td>\n <td valign='top' width=95%>\n \t<table style='width:103.5%;margin-left:-23px;margin-top:2px' class=form>\n \t\t<tr>\n \t\t\t<td style='margin:0px;padding:0px;border:0px'>\n \t\t\t\t<div style='margin:0px;padding:0px;border:0px;min-height:475px;height:475px;overflow:auto' id='mainpage'></div>\n \t\t\t</td>\n \t\t</tr>\n \t</table>\n </tr>\n\t</table>\n</div>\n<script>\n\tLoadAjax('mainpage','android.index.server.php');\n</script>\n{$yahoo}\n</body>\n</html>\n\t\n\t"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html); }
function table() { $page = CurrentPageName(); $tpl = new templates(); $description = $tpl->_ENGINE_parse_body("{description}"); $select = $tpl->javascript_parse_text("{select}"); $date = $tpl->_ENGINE_parse_body("{date}"); $empty = $tpl->javascript_parse_text("{empty}"); $t = time(); $tablesize = 629; $descriptionsize = 465; $bts = array(); if (is_numeric($_GET["tablesize"])) { $tablesize = $_GET["tablesize"]; } if (is_numeric($_GET["descriptionsize"])) { $descriptionsize = $_GET["descriptionsize"]; } if ($_GET["table"] != null) { if ($_GET["taskid"] == 0) { $bts[] = "{name: '{$select}', bclass: 'Search', onpress : SelectFields{$t}},"; } } $tablejs = "ufdbguard_admin_events"; if ($_GET["table"] != null) { $tablejs = $_GET["table"]; } if ($_GET["taskid"] > 0) { $bts[] = "{name: '{$empty}', bclass: 'Delz', onpress : EmptyTask{$t}},"; } if (count($bts) > 0) { $buttons = "buttons : [" . @implode("\n", $bts) . " ],"; } $q = new mysql(); if ($q->COUNT_ROWS("ufdbguard_admin_events", "artica_events") > 0) { $q->QUERY_SQL("TRUNCATE TABLE ufdbguard_admin_events", "artica_events"); } if ($q->COUNT_ROWS("system_admin_events", "artica_events") > 0) { $q->QUERY_SQL("TRUNCATE TABLE system_admin_events", "artica_events"); } $CountEvents = $q->COUNT_ROWS($tablejs, "artica_events"); $CountEvents = numberFormat($CountEvents, 0, '.', ' '); $title = $tpl->_ENGINE_parse_body("{$CountEvents} {events}"); $html = "\n\t<div style='margin-left:5px'>\n\t<table class='update-events-{$t}' style='display: none' id='update-events-{$t}' style='width:99%'></table>\n\t</div>\n\t<script>\n\t\$(document).ready(function(){\n\t\$('#update-events-{$t}').flexigrid({\n\turl: '{$page}?search=yes&filename={$_GET["filename"]}&taskid={$_GET["taskid"]}&category={$_GET["category"]}&table={$_GET["table"]}',\n\tdataType: 'json',\n\tcolModel : [\n\t{display: '{$date}', name : 'zDate', width : 120, sortable : true, align: 'left'},\n\t{display: '{$description}', name : 'description', width : 767, sortable : false, align: 'left'},\n\t],{$buttons}\n\tsearchitems : [\n\t{display: '{$description}', name : 'description'},\n\t],\n\tsortname: 'zDate',\n\tsortorder: 'desc',\n\tusepager: true,\n\ttitle: '{$title}',\n\tuseRp: true,\n\trp: 25,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 350,\n\tsingleSelect: true\n\t\n\t});\n\t});\n\t\n\tfunction SelectFields{$t}(){\n\tYahooWin2('550','{$page}?Select-fields=yes&table={$_GET["table"]}&t={$t}&taskid={$_GET["taskid"]}','{$select}');\n\t\n\t}\n\t\n\tvar x_EmptyTask{$t}=function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>0){alert(results);return;}\n\t\$('#ufdbguard-events-{$t}').flexReload();\n\t}\n\t\n\tfunction EmptyTask{$t}(){\n\tif(confirm('{$empty}::{$_GET["taskid"]}')){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('EmptyTask','{$_GET["taskid"]}');\n\t\t\tXHR.appendData('Table','{$_GET["table"]}');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_EmptyTask{$t});\n\t}\n\t}\n\t\n\t</script>\n\t\n\t"; echo $tpl->_ENGINE_parse_body($html); // webfilter_updateev }
function WeightedPhraseEdit_search() { $search = $_GET["search"]; $search = "*{$search}*"; $search = str_replace("**", "*", $search); $search = str_replace("**", "*", $search); $search = str_replace("*", "%", $search); $language = $_GET["language"]; $category = $_GET["category"]; $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); if ($language != null) { $language_q = " AND language='{$language}'"; } $sql = "SELECT zmd5,category,language,pattern,score FROM phraselists_weigthed WHERE category='{$category}' \n\tAND language='{$language}' AND pattern LIKE '{$search}' ORDER BY zDate DESC LIMIT 0,50"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "<H2>Fatal Error: {$q->mysql_error}</H2>"; } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { if ($classtr == "oddRow") { $classtr = null; } else { $classtr = "oddRow"; } $select = imgsimple("32-parameters.png", "{apply}", "WeightedPhraseEdit('{$ligne["language"]}','{$ligne["category"]}')"); $delete = imgsimple("delete-32.png", "{delete}", "DeleteWords('{$ligne["zmd5"]}')"); $compile = imgsimple("compile-distri-32.png", "{saveToDisk}", "DansGuardianCompileDB('{$categoryname}')"); $color = "black"; if (trim($ligne["pattern"] == null)) { continue; } $ligne["pattern"] = htmlentities($ligne["pattern"]); $js = "<a href=\"javascript:blur();\" OnClick=\"javascript:EditWords('{$ligne["zmd5"]}','{$ligne["language"]}','{$ligne["category"]}')\" style='font-size:14px;font-weight:bold;color:{$color};font-family:Courier New;text-decoration:underline'>"; $html = $html . "\n\t\t<tr class={$classtr} id='{$ligne["zmd5"]}'>\n\t\t\t<td style='font-size:14px;font-weight:bold;color:{$color};font-family:Courier New' width=99% colspan=2>{$js}{$ligne["pattern"]}</a></td>\n\t\t\t<td style='font-size:14px;font-weight:bold;color:{$color};font-family:Courier New' width=1%>{$ligne["score"]}</td>\n\t\t\t<td style='font-size:14px;font-weight:bold;color:{$color}' width=1% nowrap align='left'>{$delete}</td>\n\t\t</tr>\n\t\t"; } $TOTAL_ITEMS = numberFormat($TOTAL_ITEMS, 0, "", " "); $add = imgtootltip("plus-24.png", "{add} {words}", "EditWords('','{$_GET["language"]}','{$_GET["category"]}')"); $header = "<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%>{$add}</th>\n\t\t<th width=99%>{items}</th>\n\t\t<th width=1%>{score}</th>\n\t\t<th width=1%> </th>\n\t</tr>\n</thead>\n<tbody class='tbody'>"; $html = $header . $html . "</table>\n\t</center>\n\t\n\t<script>\n\t\tvar xzmd5='';\n\t\tfunction EditWords(zmd5,language,category){\n\t\t\tYahooWin5('600','{$page}?WeightedPhraseEdit-edit=yes&zmd5='+zmd5+'&language='+language+'&category='+category+'&t={$_GET["t"]}',zmd5);\n\t\t}\n\t\t\n\tvar x_DeleteWords=function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){alert(res);}\n\t\t\$('#'+xzmd5).remove();\n\t\t\n\t}\t\n\t\tfunction DeleteWords(zmd5){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('WeightedPhraseEdit-delete','yes');\n\t\tXHR.appendData('zmd5',zmd5);\n\t\txzmd5=zmd5;\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_DeleteWords);\t\n\t}\t\n\t\t\n\t\tfunction CheckStatsApplianceC(){\n\t\t\tLoadAjax('CheckStatsAppliance','{$page}?CheckStatsAppliance=yes');\n\t\t}\n\t\t\n\t\tfunction WeightedPhraseEdit(lang,cat){\n\t\t\tLoadjs('{$page}?WeightedPhraseEdit-js=yes&language='+lang+'&category='+cat);\n\t\t\n\t\t}\n\t\t\n\t</script>\n\t"; echo $tpl->_ENGINE_parse_body($html); }
function json_familysite() { $q = new mysql_squid_builder(); $search = '%'; $table = "visited_sites"; $page = 1; $ORDER = "ORDER BY HitsNumber DESC"; if ($q->COUNT_ROWS($table) == 0) { echo "<H2>" . $tpl->_ENGINE_parse_body("TABLE:{$table}<br>{error_no_datas}") . "</H2>"; 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"]; $sql = "SELECT COUNT(sitename) as TCOUNT FROM `{$table}` WHERE (`sitename` LIKE '{$search}') AND familysite='{$_GET["familysite"]}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(sitename) as TCOUNT FROM `{$table}` WHERE familysite='{$_GET["familysite"]}'"; $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 sitename,HitsNumber ,Querysize,category FROM `{$table}` WHERE (`sitename` LIKE '{$search}') AND familysite='{$_GET["familysite"]}' {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $div = "<div style=\"padding-top:10px;font-size:14px\">"; $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $results = $q->QUERY_SQL($sql); while ($ligne = mysql_fetch_assoc($results)) { $thumbs = $q->GET_THUMBNAIL($ligne['sitename'], 48); $ligne["Querysize"] = FormatBytes($ligne["Querysize"] / 1024); $ligne['HitsNumber'] = numberFormat($ligne['HitsNumber'], 0, "", " "); $data['rows'][] = array('id' => $ligne['sitename'], 'cell' => array($thumbs, "{$div}{$ligne['sitename']}</div>", $div . $ligne['HitsNumber'] . "</div>", $div . $ligne["Querysize"] . "</div>", $div . $ligne['category'] . "</div>")); } echo json_encode($data); }
function categories_search() { $MyPage = CurrentPageName(); $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql_squid_builder(); $dans = new dansguardian_rules(); $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance"); if (!is_numeric($EnableWebProxyStatsAppliance)) { $EnableWebProxyStatsAppliance = 0; } $t = $_GET["t"]; $OnlyPersonal = 0; $artica = $forceArtica; if (isset($_GET["OnlyPersonal"])) { $OnlyPersonal = 1; } $rp = 200; if (isset($_GET["artica"])) { $artica = true; } if ($_POST["sortname"] == "table_name") { $_POST["sortname"] = "categorykey"; } if (!$q->BD_CONNECT()) { json_error_show("Testing connection to MySQL server failed...", 1); } $sql = "SELECT * FROM personal_categories"; $table = "personal_categories"; if ($_POST["sortname"] == "categorykey") { $_POST["sortname"] = "category"; } $prefix = "INSERT IGNORE INTO webfilters_categories_caches (`categorykey`,`description`,`picture`,`master_category`,`categoryname`) VALUES "; $searchstring = string_to_flexquery(); $page = 1; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if ($searchstring != null) { $sql = "SELECT COUNT( * ) AS tcount FROM {$table} WHERE 1 {$searchstring}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if (!$q->ok) { json_error_show("Mysql Error [" . __LINE__ . "]: {$q->mysql_error}.<br>{$sql}", 1); } $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} WHERE 1 {$searchstring} {$ORDER} {$limitSql} "; writelogs("{$q->mysql_admin}:{$q->mysql_password}:{$sql}", __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { if ($q->mysql_error != null) { json_error_show(date("H:i:s") . "<br>SORT:{$_POST["sortname"]}:<br>Mysql Error [L." . __LINE__ . "]: {$q->mysql_error}<br>{$sql}", 1); } } if (mysql_num_rows($results) == 0) { json_error_show("Not found...", 1); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $enc = new mysql_catz(); $field = "category"; $field_description = "category_description"; $CATZ_ARRAY = unserialize(@file_get_contents("/home/artica/categories_databases/CATZ_ARRAY")); $TransArray = $enc->TransArray(); while (list($tablename, $items) = each($CATZ_ARRAY)) { if (!isset($TransArray[$tablename])) { continue; } $CATZ_ARRAY2[$TransArray[$tablename]] = $items; } while ($ligne = mysql_fetch_assoc($results)) { $color = "black"; $categorykey = $ligne["category"]; if ($categorykey == null) { $categorykey = "UnkNown"; } //Array ( [category] => [category_description] => Ma catégorie [master_category] => [sended] => 1 ) if ($GLOBALS["VERBOSE"]) { echo "Found {$field}:{$categorykey}<br>\n"; } $categoryname = $categorykey; $text_category = null; $table = $q->cat_totablename($categorykey); if ($GLOBALS["VERBOSE"]) { echo "Scanning table {$table}<br>\n"; } $itemsEncTxt = null; $items = $q->COUNT_ROWS($table); if (!preg_match("#^category_(.+)#", $table, $re)) { continue; } $compile = imgsimple("compile-distri-32.png", "{saveToDisk}", "DansGuardianCompileDB('{$categoryname}')"); if ($dans->array_pics[$categoryname] != null) { $pic = "<img src='img/{$dans->array_pics[$categoryname]}'>"; } else { $pic = " "; } $sizedb_org = $q->TABLE_SIZE($table); $sizedb = FormatBytes($sizedb_org / 1024); $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.categories.php?category={$categoryname}&t={$t}',true)\"\n\t\t\tstyle='font-size:18px;font-weight:bold;color:{$color};text-decoration:underline'>"; $text_category = $tpl->_ENGINE_parse_body(utf8_decode($ligne[$field_description])); $text_category = trim($text_category); $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?add-perso-cat-js=yes&cat={$categoryname}&t={$t}',true)\"\n\t\t\tstyle='font-size:18px;font-weight:bold;color:{$color};text-decoration:underline'>"; $viewDB = imgsimple("mysql-browse-database-32.png", null, "javascript:Loadjs('squid.categories.php?category={$categoryname}',true)"); $text_category = utf8_encode($text_category); $categoryname_text = utf8_encode($categoryname); $categoryText = $tpl->_ENGINE_parse_body("<span style='font-size:18px';font-weight:bold'>{$linkcat}{$categoryname_text}</span>\n\t\t\t\t\t</a><br><span style='font-size:16px;width:100%;font-weight:normal'><i>{$text_category}</i></span>"); $itemsEncTxt = "<span style='font-size:18px;font-weight:bold'>" . numberFormat($items, 0, "", " "); "</span>"; $compile = imgsimple("compile-distri-48.png", null, "DansGuardianCompileDB('{$categoryname}')"); $delete = imgsimple("dustbin-48.png", null, "TableCategoryPurge('{$table}')"); if ($categoryname == "UnkNown") { $linkcat = null; $delete = imgsimple("delete-48.png", null, "TableCategoryPurge('')"); } $cell = array(); $cell[] = $categoryText; $cell[] = "<span style='font-size:18px;padding-top:15px;font-weight:bold'>{$sizedb}</div>"; $cell[] = $itemsEncTxt; $cell[] = $compile; $cell[] = $delete; $data['rows'][] = array('id' => $ligne['ID'], 'cell' => $cell); } echo json_encode($data); }
function getUserData($uid) { $CI =& get_instance(); $CI->load->model('user_account_count_model', 'user_account_count'); $CI->load->model('repay_log_model', 'repay_log'); if (empty($uid)) { return false; } $userAcc = array(); //用户统计表 $uacount = $CI->user_account_count->get($uid); $params = array('income_today_count'); foreach ($params as $value) { if (isset($uacount[$value])) { $userAcc[$value] = $uacount[$value]; } else { $userAcc[$value] = 0; } } //即将还本 [取明日还本金额] $where = array('sum' => 'recover_capital', 'uid' => $uid, 'status' => 'wait', 'scope' => array('ltt' => array('recover_time' => strtotime(date('Y-m-d') + 86400)), 'mt' => array('recover_time' => strtotime(date('Y-m-d') + 86400 * 2)))); $watiCapital = $CI->repay_log->getWidgetRow($where); $userAcc['recover_capital'] = !empty($watiCapital['recover_capital']) ? $watiCapital['recover_capital'] : 0; //数字格式 foreach ($userAcc as &$value) { $value = numberFormat($value); } unset($value); return array('income_today_count' => $userAcc['income_today_count'], 'recover_capital' => $userAcc['recover_capital']); }
function subtitle_categories(){ if(CACHE_SESSION_GET(__FUNCTION__, __FILE__,15)){return;} $tpl=new templates(); $q=new mysql_squid_builder(); $categories=$q->COUNT_CATEGORIES(); $categories=numberFormat($categories,0,""," "); $tablescat=$q->LIST_TABLES_CATEGORIES(); $tablescatNUM=numberFormat(count($tablescat),0,""," "); $html="<div style='font-size:16px'><b>$categories</b> {websites_categorized} | <b>$tablescatNUM</b> {categories}</div>"; CACHE_SESSION_SET(__FUNCTION__, __FILE__, $tpl->_ENGINE_parse_body($html)); }
function categories_search() { $tpl = new templates(); $catz = new mysql_catz(); $tables = $catz->LIST_TABLES_CATEGORIES(); $dans = new dansguardian_rules(); $dans->LoadBlackListes(); $search = string_to_flexregex("categories-search"); $TransArray = $catz->TransArray(); while (list($key, $value) = each($tables)) { $categoryname = $TransArray[$key]; $text_category = $tpl->_ENGINE_parse_body($dans->array_blacksites[$categoryname]); if (!isset($dans->array_blacksites[$categoryname])) { continue; } if ($dans->array_pics[$categoryname] != null) { $pic = "<img src='img/{$dans->array_pics[$categoryname]}'>"; } else { $pic = " "; } $CTCOUNT = $catz->COUNT_ROWS($key); if ($CTCOUNT == 0) { continue; } $items = numberFormat($CTCOUNT, 0); if ($search != null) { if (!preg_match("#{$search}#", $categoryname)) { if (!preg_match("#{$search}#", $text_category)) { continue; } } } $tr[] = "\n\t\t<tr id='{$id}'>\n\t\t<td width=1% nowrap>{$pic}</td>\n\t\t<td><i class='icon-globe'></i> <strong>{$categoryname}</strong><div>{$text_category}</div></td>\n\t\t<td nowrap><i class='icon-info-sign'></i> <span style='font-size:18px'>{$items}</span></td>\n\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t\n\t\t<table class='table table-bordered'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan=2>{category}</th>\n\t\t\t\t\t<th>{websites}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("", $tr) . "</tbody></table>"; }
function items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $ID = $_GET["ID"]; $tablename = "WebTrackMem{$ID}"; $search = '%'; $table = "(SELECT SUM(hits) as hits, SUM(size) as size,sitename,zDate FROM {$tablename} GROUP BY sitename,zDate HAVING sitename='{$_GET["sitename"]}') as t "; $page = 1; $FORCE_FILTER = null; if (!$q->TABLE_EXISTS($tablename, $database)) { json_error_show("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($tablename, $database) == 0) { json_error_show("No rules"); } 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, $database)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $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}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } $rp = new squid_report($ID); while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5(serialize($ligne)); $color = "black"; //familysite size hits $urljsSIT = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.traffic.statistics.hours.php?filterby={$rp->userfield}&filterdata=" . urlencode($rp->userdata) . "&day={$ligne["zDate"]}&familysite={$ligne["sitename"]}');\"\n\tstyle='font-size:14px;text-decoration:underline;color:{$color}'>"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $data['rows'][] = array('id' => "{$zmd5}", 'cell' => array("<span style='font-size:14px;color:{$color}'>{$urljsSIT}{$ligne["zDate"]}</a></span>", "<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["size"]}</span>", "<span style='font-size:14px;color:{$color}'>{$ligne["hits"]}</span>")); } echo json_encode($data); }
<h1> <?php if ($wind['sug_money'] == $wind['max_money']) { ?> ¥<?php echo numberFormat($wind['max_money'], 2); ?> 万 <?php } else { ?> ¥<?php echo numberFormat($wind['sug_money'], 2); ?> ~¥<?php echo numberFormat($wind['max_money'], 2); ?> 万 <?php } ?> </h1> <p>风控最终审核价格</p> </div> <div class="hei101"></div> <div class="list mb15"> <!--车辆信息--> <?php if (!empty($car)) { ?> <?php
function showlist() { $q = new mysql_squid_builder(); $table = "mgr_client_list"; if (!$q->TABLE_EXISTS($table)) { $q->CheckReportTable(); } $tpl = new templates(); $page = 1; $FORCE_FILTER = null; $total = 0; 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)); writelogs($sql, __FUNCTION__, __FILE__, __LINE__); if (!$q->ok) { json_error_show("{$q->mysql_error}"); } $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if (!$q->ok) { json_error_show("{$q->mysql_error}"); } $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); if (!$q->ok) { json_error_show("{$q->mysql_error}"); } if (mysql_num_rows($results) == 0) { json_error_show("No data, {$sql}"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); while ($ligne = mysql_fetch_assoc($results)) { $md5 = md5(serialize($line)); $CUR_CNX = numberFormat($ligne["CUR_CNX"], 0, "", " "); $RQS = numberFormat($ligne["RQS"], 0, "", " "); $TCP_HIT = numberFormat($ligne["TCP_HIT"], 0, "", " "); $TCP_MISS = numberFormat($ligne["TCP_MISS"], 0, "", " "); $TCP_REDIRECT = numberFormat($ligne["TCP_REDIRECT"], 0, "", " "); $TCP_TUNNEL = numberFormat($ligne["TCP_TUNNEL"], 0, "", " "); $TAG_NONE = numberFormat($ligne["TAG_NONE"], 0, "", " "); $data['rows'][] = array('id' => $md5, 'cell' => array("<span style='font-size:16px'>{$ligne["uid"]}</a></span>", "<span style='font-size:16px'>{$ligne["ipaddr"]}</a></span>", "<span style='font-size:16px'>{$CUR_CNX}</span>", "<span style='font-size:16px'>{$RQS}</span>", "<span style='font-size:16px'>{$TCP_HIT}</span>", "<span style='font-size:16px'>{$TCP_MISS}</span>", "<span style='font-size:16px'>{$TCP_REDIRECT}</span>", "<span style='font-size:16px'>{$TCP_TUNNEL}</span>", "<span style='font-size:16px'>{$TAG_NONE}</span>")); } echo json_encode($data); }
function items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $search = '%'; $table = $_GET["table"]; $page = 1; $FORCE_FILTER = null; if ($_GET["field"] != null) { $FORCE_FILTER = " AND `{$_GET["field"]}`='{$_GET["value"]}'"; } if ($_GET["sitename"] != null) { $FORCE_FILTER = $FORCE_FILTER . " AND `sitename`='{$_GET["sitename"]}'"; } if (!$q->TABLE_EXISTS($table, $database)) { json_error_show("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($table, $database) == 0) { json_error_show("No data"); } 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, $database)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $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, $database); if (mysql_num_rows($results) == 0) { json_error_show("{$sql}<hr>No row", 1); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5(serialize($ligne)); $color = "black"; $date = strtotime($ligne["zDate"]); $Hour = date("H:i"); //familysite size hits $urljsSIT = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.website-zoom.php?js=yes&sitename={$ligne["sitename"]}&xtime={$_GET["xtime"]}');\"\n\tstyle='font-size:14px;text-decoration:underline;color:{$color}'>"; $urijs = "s_PopUpFull('{$ligne["uri"]}','1024','900');"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $ligne["familysite"] = $q->GetFamilySites($ligne["sitename"]); $data['rows'][] = array('id' => "{$zmd5}", 'cell' => array("<span style='font-size:12px;color:{$color}'>{$Hour}</a></span>", "<span style='font-size:12px;color:{$color}'><a href=\"javascript:blur();\" OnClick=\"javascript:{$urijs}\" style='text-decoration:underline'>{$ligne["uri"]}</a></span>", "<span style='font-size:12px;color:{$color}'>{$ligne["size"]}</span>", "<span style='font-size:12px;color:{$color}'>{$ligne["hits"]}</span>")); } echo json_encode($data); }
function who_items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $youtubeid = $_GET["youtubeid"]; $searchstring = string_to_flexregex("who-items"); $table = "youtube_all"; $page = 1; $FORCE_FILTER = " AND "; if ($searchstring != null) { $searchstring = "{$searchstring}"; } $sql = "SELECT zDate,uid,MAC,youtubeid,SUM(hits) as hits FROM {$table} GROUP BY youtubeid,zDate,uid,MAC HAVING youtubeid='{$youtubeid}' {$searchstring} ORDER BY zDate DESC LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { throw new Exception("ERROR {$q->mysql_error} `{$sql}`", 500); } $boot = new boostrap_form(); while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5(serialize($ligne)); $color = "black"; $urljsSIT = "Loadjs('miniadm.webstats.youtubeid.php?youtubeid={$youtubeid}')"; $link = $boot->trswitch($urljsSIT); $jsvideo = $boot->trswitch("Loadjs('miniadm.webstats.youtubeid.php?youtubeid={$youtubeid}');"); $urljsSIT = "Loadjs('miniadm.webstats.youtubeid.php?youtubeid={$youtubeid}&xtime={$_GET["xtime"]}');"; $link = $boot->trswitch($urljsSIT); $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $urljsSIT = null; $link = null; $xtime = strtotime($ligne["zDate"] . " 00:00:00"); $linkuid = $boot->trswitch("Loadjs('miniadm.webstats.ByMember.ByYoutubeByHour.php?filterBy=uid&xtime={$xtime}&value={$ligne["uid"]}&youtubeid={$youtubeid}')"); $linkMAC = $boot->trswitch("Loadjs('miniadm.webstats.ByMember.ByYoutubeByHour.php?filterBy=MAC&xtime={$xtime}&value={$ligne["MAC"]}&youtubeid={$youtubeid}')"); $tr[] = "\n\t\t<tr id='{$id}'>\n\t\t<td {$link} nowrap><i class='icon-time'></i> {$ligne["zDate"]}</td>\n\t\t<td {$linkuid}><i class='icon-info-sign'></i> {$ligne["uid"]}</td>\n\t\t<td {$linkMAC}><i class='icon-info-sign'></i> {$ligne["MAC"]}</td>\n\t\t<td {$link}><i class='icon-info-sign'></i> {$ligne["hits"]}</td>\n\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t<table class='table table-bordered table-hover'>\n\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th>{zDate}</th>\n\t\t\t\t<th>{member}</th>\n\t\t\t\t<th>{MAC}</th>\n\t\t\t\t<th>{hits}</th>\n\t\t\t</tr>\n\t\t</thead>\n\t<tbody>\n\t") . @implode("", $tr) . "</tbody></table>"; }
function myhome3(){ $page=CurrentPageName(); $q=new mysql_squid_builder(); $tpl=new templates(); if(!is_numeric($_SESSION["uid"])){ $error="Session:{$_SESSION["uid"]} invalid"; } if($_SESSION["uid"]==0){$error="Session:«{$_SESSION["uid"]}» invalid";} if($_SESSION["uid"]>0){ $currenttable="dansguardian_events_".date('Ymd'); $sql="SELECT SUM(hits) as thits,SUM(QuerySize) as tsize FROM $currenttable WHERE account={$_SESSION["uid"]}"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); if(!$q->ok){$error=$q->mysql_error."<br><code>$sql</code>";} } if(!is_numeric($ligne["thits"])){$ligne["thits"]=0;} if(!is_numeric($ligne["tsize"])){$ligne["tsize"]=0;} $SumHits=numberFormat($ligne["thits"],0,""," "); $SumSize=FormatBytes($ligne["tsize"]/1024); $html="<table style='width:99%' class=form> <tbody> <tr> <td width=1% valign='top'><img src='img/windows-internet-64.png'></td> <td width=99% valign='top'> <table style='width:100%'> <tbody> <tr> <td colspan=2><div style='font-size:16px'>{internet_browsing}</div></td> </tr> <tr> <td valign='top' $mouse style='font-size:14px;text-decoration:underline' OnClick=\"blur()\">{today}:<b>$SumHits</b> {hits}</td> </tr> <tr> <td valign='top' $mouse style='font-size:14px;text-decoration:underline' OnClick=\"blur()\">{today}:<b>$SumSize</b> {downloaded_flow}</td> </tr> </tbody> </table> <span style='font-size:11px;color:red'>$error</span> </td> </tr> </tbody> </table>"; echo $tpl->_ENGINE_parse_body($html); }
function status_squid_left($asroot=false){ if(GET_CACHED(__FILE__, __FUNCTION__,__FUNCTION__)){return;} $page=CurrentPageName(); $tpl=new templates(); $users=new usersMenus(); include_once(dirname(__FILE__)."/ressources/class.status.inc"); $sock=new sockets(); $SquidBinIpaddr=$sock->GET_INFO("SquidBinIpaddr"); if($SquidBinIpaddr==null){$SquidBinIpaddr="0.0.0.0";} $urgency_mode_img="20-check-grey.png"; if($SquidBinIpaddr=="0.0.0.0"){$SquidBinIpaddr="{all}";} $CacheManagement2=$sock->GET_INFO("CacheManagement2"); if(!is_numeric($CacheManagement2)){$CacheManagement2=0;} $squid=new squidbee(); $q=new mysql(); $master_version=$squid->SQUID_VERSION; $text_kavicap_error=null; $text_script=null; $cache_mem=$squid->global_conf_array["cache_mem"]; $users=new usersMenus(); $As32=false; if(!isset($_GET["uuid"])){$_GET["uuid"]=$sock->getframework("cmd.php?system-unique-id=yes");} $EnableKavICAPRemote=$sock->GET_INFO("EnableKavICAPRemote"); $KavICAPRemoteAddr=$sock->GET_INFO("KavICAPRemoteAddr"); $KavICAPRemotePort=$sock->GET_INFO("KavICAPRemotePort"); if(!is_numeric($EnableKavICAPRemote)){$EnableKavICAPRemote=0;} $CPU_NUMBER=$sock->getFrameWork("services.php?CPU-NUMBER=yes"); if($EnableKavICAPRemote==1){ $fp=@fsockopen($KavICAPRemoteAddr, $KavICAPRemotePort, $errno, $errstr, 1); if(!$fp){ $text_kavicap_error="<div>{kavicap_unavailable_text}<br><strong> <a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.kavicap.php');\" style='font-size:12px;color:#D70707;text-decoration:underline'>$KavICAPRemoteAddr:$KavICAPRemotePort</a><br>$errstr</div>"; } @fclose($fp); } $q=new mysql_squid_builder(); $text_error_sql="<div id='db-status-infos'></div> <script>LoadAjax('db-status-infos','$page?db-status-infos=yes',true);</script> "; $q=new mysql_squid_builder(); $requests=$q->EVENTS_SUM(); $requests=numberFormat($requests,0,""," "); $tableblock=date('Ymd')."_blocked"; $ligneW=$q->COUNT_ROWS($tableblock); $blocked_today=numberFormat($ligneW,0,""," ")." {blocked_websites} {this_day}"; $q=new mysql_squid_builder(); $websitesnums=$q->COUNT_ROWS("dansguardian_sitesinfos","artica_backup"); $websitesnums=numberFormat($websitesnums,0,""," "); $q=new mysql_squid_builder(); $categories=$q->COUNT_ROWS("dansguardian_community_categories"); $categories=numberFormat($categories,0,""," "); $sock=new sockets(); $sock->SET_INFO("squidStatsCategoriesNum",$categories); $sock->SET_INFO("squidStatsWebSitesNum",$websitesnums); $sock->SET_INFO("squidStatsBlockedToday",$blocked_today); $sock->SET_INFO("squidStatsRequestNumber",$requests); $styleText="font-size:12px;font-weight:bold"; $migration_pid=unserialize(base64_decode($sock->getFrameWork("squid.php?migration-stats=yes"))); if(is_array($migration_pid)){ $text_script="<span style='color:#B80000;font-size:13px'>{migration_script_run_text} PID:{$migration_pid[0]} {since}:{$migration_pid[1]}Mn</span>"; } $DisableSquidSNMPModeText="{disabled}"; $DisableSquidSNMPModeCK="20-check-grey.png"; $SquidEnableRockStoreCK="20-check-grey.png"; if(preg_match("#^([0-9]+)\.([0-9]+)#", $master_version,$re)){ $MAJOR=$re[1]; $MINOR=$re[2]; if($MAJOR>2){if($MINOR>1){$As32=true;}} $master_version_text="$MAJOR.$MINOR"; } if(preg_match("#^([0-9]+)\.([0-9]+)\.([0-9]+)#", $master_version,$re)){ $MAJOR=$re[1]; $MINOR=$re[2]; $REV=$re[3]; $master_version_text="$MAJOR.$MINOR.$REV"; } if($master_version_text==null){$master_version_text="Unknown";} if($As32){ if($CPU_NUMBER>1){ $SquidEnableRockStore=$sock->GET_INFO("SquidEnableRockStore"); $SquidRockStoreSize=$sock->GET_INFO("SquidRockStoreSize"); if(!is_numeric($SquidEnableRockStore)){$SquidEnableRockStore=0;} if(!is_numeric($SquidRockStoreSize)){$SquidRockStoreSize=2000;} $DisableSquidSNMPModeText=$CPU_NUMBER." cpu(s)"; $DisableSquidSNMPModeCK="20-check.png"; if($SquidEnableRockStore==1){ $SquidRockStoreSize=FormatBytes($SquidRockStoreSize*1024); $SquidEnableRockStoreCK="20-check.png"; }else{ $SquidRockStoreSize="{disabled}"; } $smptr=" <tr> <td width=1%><img src='img/$DisableSquidSNMPModeCK'></td> <td class=legend nowrap style='font-size:12px'>SMP:</td> <td style='font-size:14px'> <a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.caches32.php?smp-js=yes&uuid={$_GET["uuid"]}');\" style='$styleText;text-decoration:underline'>$DisableSquidSNMPModeText</a></span></td> </tr> <tr> <td width=1%><img src='img/$SquidEnableRockStoreCK'></td> <td class=legend nowrap style='font-size:12px'>Rock store:</td> <td style='font-size:14px'> <a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.rockstore.php');\" style='$styleText;text-decoration:underline'>$SquidRockStoreSize</a></td> </tr>"; } } $qs=new mysql(); if(!$qs->FIELD_EXISTS("nics","ucarp-enable","artica_backup")){$qs->QUERY_SQL("ALTER TABLE `nics` ADD `ucarp-enable` smallint( 1 ) NULL DEFAULT '0'",'artica_backup'); } $sql="SELECT COUNT(*) as tcount FROM nics WHERE `ucarp-enable`=1"; $ligne2=mysql_fetch_array($qs->QUERY_SQL($sql,"artica_backup")); $failover_icon="20-check-grey.png"; if($ligne2["tcount"]==0){ $failover_text="{disabled}"; }else{ $failover_text="{enabled}"; $failover_icon="20-check.png"; } if(!$users->UCARP_INSTALLED){ $failover_text="-"; $failover_icon="20-check-grey.png"; } if($CacheManagement2==1){$smptr=null;} $DisableAnyCache=$sock->GET_INFO("DisableAnyCache"); if(!is_numeric($DisableAnyCache)){$DisableAnyCache=0;} $SquidCacheLevel=$sock->GET_INFO("SquidCacheLevel"); if(!is_numeric($SquidCacheLevel)){$SquidCacheLevel=4;} if($SquidCacheLevel==0){$DisableAnyCache=1;} $hasProxyTransparent=$sock->GET_INFO("hasProxyTransparent"); if(!is_numeric($hasProxyTransparent)){$hasProxyTransparent=0;} $hasProxyTransparentText="{disabled}"; $hasProxyTransparentCheck="20-check-grey.png"; $DisableAnyCacheText="{enabled}"; $DisableAnyCacheCheck="20-check.png"; if($hasProxyTransparent==1){ $hasProxyTransparentText="{enabled}"; $hasProxyTransparentCheck="20-check.png"; } if($DisableAnyCache==1){ $DisableAnyCacheText="{disabled}"; $DisableAnyCacheCheck="20-check-grey.png"; }else{ $qN=new mysql(); $ligne=mysql_fetch_array($qN->QUERY_SQL("SELECT SUM(cache_size) as size FROM squid_caches_center WHERE enabled=1","artica_backup")); $size=$ligne["size"]; $DisableAnyCacheText=FormatBytes($size*1024); } if(preg_match("#^([0-9]+)\s+#", $cache_mem)){ $cache_mem2=$re[1]; $cache_mem2=($cache_mem*1024); $cache_mem2=FormatBytes($cache_mem2); } $EnableCNTLM=$sock->GET_INFO("EnableCNTLM"); $CNTLMPort=$sock->GET_INFO("CnTLMPORT"); $EnableRDPProxy=$sock->GET_INFO("EnableRDPProxy"); $SquidUrgency=$sock->GET_INFO("SquidUrgency"); if(!is_numeric($SquidUrgency)){$SquidUrgency=0;} $urgency_mode_color=null; $urgency_text="{disabled}"; if($SquidUrgency==1){ $urgency_mode_color=";color:#BE0303"; $urgency_mode_img="20-check-red.png"; $urgency_text="{enabled}"; } if(!is_numeric($EnableRDPProxy)){$EnableRDPProxy=0;} if(!is_numeric($EnableCNTLM)){$EnableCNTLM=0;} if(!is_numeric($CNTLMPort)){$CNTLMPort=3155;} $PP[]=$squid->listen_port; if(!is_numeric($squid->second_listen_port)){$squid->second_listen_port=0;} if($squid->second_listen_port>0){ $PP[]=$squid->second_listen_port; } if($EnableCNTLM==0){ if($CNTLMPort>0){ $PP[]=$CNTLMPort; } } $transparent_mode=" <tr> <td width=1%><img src='img/$hasProxyTransparentCheck'></td> <td class=legend nowrap style='font-size:12px'>{transparent}:</td> <td style='font-size:14px'> <a href=\"javascript:blur();\" OnClick=\"Loadjs('squid.newbee.php?squid-transparent-js=yes');\" style='$styleText;text-decoration:underline'>$hasProxyTransparentText</a></td> </tr>"; $DisableAnyCache=" <tr> <td width=1%><img src='img/$DisableAnyCacheCheck'></td> <td class=legend nowrap style='font-size:12px'>{caches} {disk}:</td> <td style='font-size:14px'> <a href=\"javascript:blur();\" style='$styleText'>$DisableAnyCacheText</a></td> </tr>"; $CacheMemory="<tr> <td width=1%><img src='img/20-check.png'></td> <td class=legend nowrap style='font-size:12px'>{cache_memory}:</td> <td style='font-size:14px'><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.cache_mem.php');\" style='$styleText;text-decoration:underline'>{$cache_mem2}</a></td> </tr>"; if($CacheManagement2==1){$CacheMemory=null;} $squidversion=" <center> <div class=form style='width:93%'> <table style='width:250px;margin-top:10px;' class='TableRemove TableMarged'> <tbody> <tr> <td colspan=3 style='font-size:14px;text-align:center;padding-bottom:10px'><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.popups.php?script=visible_hostname');\" style='font-size:14px;text-decoration:underline;'>$squid->visible_hostname</a> </td> </tr> <tr> <td width=1%><img src='img/20-check.png'></td> <td class=legend nowrap style='font-size:12px'>Proxy {version}:</td> <td style='$styleText'><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.compilation.status.php');\" style='$styleText;text-decoration:underline'>$master_version_text</a></td> </tr> <tr> <td width=1%><img src='img/20-check.png'></td> <td class=legend nowrap style='font-size:12px'>{listen_addr}:</td> <td style='font-size:14px'><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.nic.php');\" style='$styleText;text-decoration:underline'>$SquidBinIpaddr</a></td> </tr> <tr> <td width=1%><img src='img/$urgency_mode_img'></td> <td class=legend nowrap style='font-size:12px$urgency_mode_color'>{urgency_mode}:</td> <td style='$styleText'><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.urgency.php');\" style='$styleText;text-decoration:underline$urgency_mode_color'>$urgency_text</a></td> </tr> $smptr $transparent_mode $DisableAnyCache $CacheMemory <tr> <td width=1%><img src='img/$failover_icon'></td> <td class=legend nowrap style='font-size:12px'>{failover2}:</td> <td style='font-size:14px'><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.failover.php');\" style='$styleText;text-decoration:underline'>{$failover_text}</a></td> </tr> </tbody> </table> </div> </center> "; if($users->WEBSTATS_APPLIANCE){$squidversion=null;} $design=" $text_error_sql $text_script $text_kavicap_error $squidversion <div id='squid-plugins-activated'></div> <div style='width:100%;text-align:right'>". imgtootltip("refresh-24.png","{refresh}", "LoadAjax('squid-status','squid.main.quicklinks.php?status=yes');")." </div> "; $classform="class=form"; $sock=new sockets(); $EnableRemoteStatisticsAppliance=$sock->GET_INFO("EnableRemoteStatisticsAppliance"); if(!is_numeric($EnableRemoteStatisticsAppliance)){$EnableRemoteStatisticsAppliance=0;} $UnlockWebStats=$sock->GET_INFO("UnlockWebStats"); if(!is_numeric($UnlockWebStats)){$UnlockWebStats=0;} if($UnlockWebStats==1){$EnableRemoteStatisticsAppliance=0;} if($EnableRemoteStatisticsAppliance==1){$classform=null;} $html=" $design <center> <div id='squid-status-stats' $classform style='width:90%'></div> </center> <script> LoadAjax('squid-status-stats','squid.traffic.statistics.php?squid-status-stats=yes'); LoadAjax('squid-services','$page?squid-services=yes'); LoadAjax('squid-plugins-activated','dansguardian2.php?dansguardian-status=yes'); </script> "; if($asroot){ SET_CACHED(__FILE__, __FUNCTION__, __FUNCTION__, $html); return; } $html=$tpl->_ENGINE_parse_body($html); SET_CACHED(__FILE__, __FUNCTION__, __FUNCTION__, $html); echo $html; }
function squid_status_stats(){ $page=CurrentPageName(); $tpl=new templates(); $q=new mysql_squid_builder(); $websitesnums=$q->COUNT_ROWS("visited_sites"); $websitesnums=numberFormat($websitesnums,0,""," "); $categories=$q->COUNT_CATEGORIES(); $categories=numberFormat($categories,0,""," "); $q=new mysql_squid_builder(); $requests=$q->EVENTS_SUM(); $requests=numberFormat($requests,0,""," "); $DAYSNumbers=$q->COUNT_ROWS("tables_day"); $ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(totalsize) as tsize FROM tables_day")); $totalsize=FormatBytes($ligne["tsize"]/1024); $ligne=mysql_fetch_array($q->QUERY_SQL("SELECT AVG(cache_perfs) as pourc FROM tables_day")); $pref=round($ligne["pourc"]); $html=" <table style='width:100%'> <tbody> <tr> <td valign='top' style='font-size:14px'><b>$DAYSNumbers</b> {daysOfStatistics}</td> </tr> <tr> <td valign='top' style='font-size:14px'><b>$requests</b> {requests}</td> </tr> <tr> <td valign='top' style='font-size:14px'><b>$websitesnums</b> {visited_websites}</td> </tr> <tr> <td valign='top' style='font-size:14px'><b>$categories</b> {websites_categorized}</td> </tr> <tr> <td valign='top' style='font-size:14px'><b>$totalsize</b> {downloaded_flow}</td> </tr> <tr> <td valign='top' style='font-size:14px'><b>$pref%</b> {cache_performance}</td> </tr> </tbody> </table>"; echo $tpl->_ENGINE_parse_body($html); }
function inject($category, $table = null, $file = null) { include_once dirname(__FILE__) . "/ressources/class.dansguardian.inc"; $unix = new unix(); $q = new mysql_squid_builder(); if (is_file($category)) { $file = $category; $category_name = basename($file); echo "{$file} -> {$category_name}\n"; if (preg_match("#(.+?)\\.gz\$#", $category_name)) { echo "{$category_name} -> gunzip\n"; $new_category_name = str_replace(".gz", "", $category_name); $gunzip = $unix->find_program("gunzip"); $target_file = dirname($file) . "/{$new_category_name}"; $cmd = "/bin/gunzip -d -c \"{$file}\" >{$target_file} 2>&1"; echo "{$cmd}\n"; shell_exec($cmd); if (!is_file($target_file)) { echo "Uncompress failed\n"; return; } $file = $target_file; $table = $new_category_name; $category = $q->tablename_tocat($table); echo "{$new_category_name} -> {$table}\n"; } else { $table = $category_name; echo "{$new_category_name} -> {$table}\n"; $category = $q->tablename_tocat($table); } echo "Table: {$table}\nSource File:{$file}\nCategory: {$category}\n"; } if (!is_file($file)) { if (!is_file($table)) { echo "`{$table}` No such file\n"; } if (is_file($table)) { $file = $table; $table = null; } } if ($table == null) { $table = "category_" . $q->category_transform_name($category); echo "Table will be {$table}\n"; } if (!$q->TABLE_EXISTS($table)) { echo "{$table} does not exists, check if it is an official one\n"; $dans = new dansguardian_rules(); if (isset($dans->array_blacksites[$category])) { $q->CreateCategoryTable($category); } } if (!$q->TABLE_EXISTS($table)) { echo "`{$category}` -> no such table \"{$table}\"\n"; return; } $sql = "SELECT COUNT(*) AS TCOUNT FROM {$table}"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n"; if (preg_match("#is marked as crashed and last#", $q->mysql_error)) { echo "`{$table}` -> crashed, remove \"{$table}\"\n"; $q->QUERY_SQL("DROP TABLE {$table}"); $q->QUERY_SQL("flush tables"); $q = new mysql_squid_builder(); echo "`{$table}` -> Create category \"{$category}\"\n"; $q->CreateCategoryTable($category); $q->CreateCategoryTable($category); $q = new mysql_squid_builder(); } if (!$q->TABLE_EXISTS($table)) { echo "`{$category}` -> no such table \"{$table}\"\n"; return; } } if ($file == null) { $dir = "/var/lib/squidguard"; if ($GLOBALS["SHALLA"]) { $dir = "/root/shalla/BL"; } if (!is_file("{$dir}/{$category}/domains")) { echo "{$dir}/{$category}/domains no such file"; return; } $file = "{$dir}/{$category}/domains"; } if (!is_file($file)) { echo "{$file} no such file"; return; } $sock = new sockets(); $unix = new unix(); $uuid = $unix->GetUniqueID(); if ($uuid == null) { echo "No uuid\n"; return; } echo "open {$file}\n"; $handle = @fopen($file, "r"); if (!$handle) { echo "Failed to open file\n"; return; } $q = new mysql_squid_builder(); if ($GLOBALS["CATTO"] != null) { $category = $GLOBALS["CATTO"]; } $countstart = $q->COUNT_ROWS($table); $prefix = "INSERT IGNORE INTO {$table} (zmd5,zDate,category,pattern,uuid) VALUES "; echo "{$prefix}\n"; $catz = new mysql_catz(); $c = 0; $CBAD = 0; $CBADIP = 0; $CBADNULL = 0; while (!feof($handle)) { $c++; $www = trim(fgets($handle, 4096)); if ($www == null) { $CBADNULL++; continue; } $www = str_replace('"', "", $www); if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $www)) { $CBADIP++; continue; } $www = trim(strtolower($www)); if ($www == "thisisarandomentrythatdoesnotexist.com") { $CBAD++; continue; } if ($www == null) { $CBADNULL++; continue; } if (preg_match("#(.+?)\\s+(.+)#", $www, $re)) { $www = $re[1]; } if (preg_match("#^\\.(.*)\$#", $www, $re)) { $www = $re[1]; } if (strpos($www, "#") > 0) { echo "FALSE: {$www}\n"; continue; } if (strpos($www, "'") > 0) { echo "FALSE: {$www}\n"; continue; } if (strpos($www, "{") > 0) { echo "FALSE: {$www}\n"; continue; } if (strpos($www, "(") > 0) { echo "FALSE: {$www}\n"; continue; } if (strpos($www, ")") > 0) { echo "FALSE: {$www}\n"; continue; } if (strpos($www, "%") > 0) { echo "FALSE: {$www}\n"; continue; } $category2 = $catz->GET_CATEGORIES($www); if ($category2 != null) { if ($category2 == $category) { continue; } $md5 = md5($category . $www); if ($category == "p**n") { if ($category2 == "shopping") { echo date("H:i:s") . " Remove {$www} from shopping and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_shopping WHERE `pattern`='{$www}'"); $q->categorize($www, $category, true); continue; } if ($category2 == "hobby/arts") { echo date("H:i:s") . " Remove {$www} from hobby/arts and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_hobby_arts WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "society") { echo date("H:i:s") . " Remove {$www} from society and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_society WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "finance/realestate") { echo date("H:i:s") . " Remove {$www} from finance/realestate and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_finance_realestate WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "science/computing") { echo date("H:i:s") . " Remove {$www} from science/computing and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_science_computing WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "industry") { echo date("H:i:s") . " Remove {$www} from industry and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_industry WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "proxy") { echo date("H:i:s") . " Remove {$www} from proxy and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_proxy WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "searchengines") { echo date("H:i:s") . " Remove {$www} from searchengines and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_searchengines WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "blog") { echo date("H:i:s") . " Remove {$www} from blog and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_blog WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "forums") { echo date("H:i:s") . " Remove {$www} from blog and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_blog WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "recreation/sports") { echo date("H:i:s") . " Remove {$www} from recreation/sports and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_recreation_sports WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "hacking") { echo date("H:i:s") . " Remove {$www} from hacking and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_hacking WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "malware") { echo date("H:i:s") . " Remove {$www} from malware and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_malware WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "drugs") { echo date("H:i:s") . " Remove {$www} from drugs and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_drugs WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "health") { echo date("H:i:s") . " Remove {$www} from health and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_health WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "news") { echo date("H:i:s") . " Remove {$www} from news and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_news WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "audio-video") { echo date("H:i:s") . " Remove {$www} from audio-video and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_audio_video WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "recreation/schools") { echo date("H:i:s") . " Remove {$www} from recreation/schools and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_recreation_schools WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "reaffected") { echo date("H:i:s") . " Remove {$www} from reaffected and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_reaffected WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "warez") { echo date("H:i:s") . " Remove {$www} from warez and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_warez WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "suspicious") { echo date("H:i:s") . " Remove {$www} from suspicious and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_suspicious WHERE `pattern`='{$www}'"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } $q->QUERY_SQL("INSERT IGNORE INTO category_porn (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } } if ($category == "gamble") { if ($category2 == "shopping") { echo date("H:i:s") . " Remove {$www} from shopping and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_shopping WHERE `pattern`='{$www}'"); $q->categorize($www, $category, true); continue; } } if ($category == "proxy") { if ($category2 == "society") { echo date("H:i:s") . " Remove {$www} from society and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_society WHERE `pattern`='{$www}'"); $q->categorize($www, $category, true); continue; } if ($category2 == "p**n") { echo date("H:i:s") . " Remove {$www} from p**n and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_porn WHERE `pattern`='{$www}'"); $q->categorize($www, $category, true); continue; } if ($category2 == "shopping") { echo date("H:i:s") . " Remove {$www} from shopping and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_shopping WHERE `pattern`='{$www}'"); $q->categorize($www, $category, true); continue; } if ($category2 == "science/computing") { echo date("H:i:s") . " Remove {$www} from science/computing and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_science_computing WHERE `pattern`='{$www}'"); $q->categorize($www, $category, true); continue; } if ($category2 == "industry") { echo date("H:i:s") . " Remove {$www} from industry and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_industry WHERE `pattern`='{$www}'"); $q->categorize($www, $category, true); continue; } if ($category2 == "filehosting") { echo date("H:i:s") . " Remove {$www} from filehosting and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_filehosting WHERE `pattern`='{$www}'"); $q->categorize($www, $category, true); continue; } if ($category2 == "hacking") { echo date("H:i:s") . " Remove {$www} from hacking and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_hacking WHERE `pattern`='{$www}'"); $q->categorize($www, $category, true); continue; } if ($category2 == "governments") { echo date("H:i:s") . " Remove {$www} from governments and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_governments WHERE `pattern`='{$www}'"); $q->categorize($www, $category, true); continue; } } if ($category == "spyware") { if ($category2 == "society") { echo date("H:i:s") . " Remove {$www} from society and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_society WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "industry") { echo date("H:i:s") . " Remove {$www} from industry and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_industry WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "recreation/sports") { echo date("H:i:s") . " Remove {$www} from recreation/sports and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_recreation_sports WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "recreation/schools") { echo date("H:i:s") . " Remove {$www} from recreation/schools and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_recreation_schools WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "searchengines") { echo date("H:i:s") . " Remove {$www} from searchengines and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_searchengines WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "shopping") { echo date("H:i:s") . " Remove {$www} from shopping and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_shopping WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "audio-video") { echo date("H:i:s") . " Remove {$www} from audio-video and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_audio_video WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "suspicious") { $q->QUERY_SQL("DELETE FROM category_suspicious WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "health") { echo date("H:i:s") . " Remove {$www} from health and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_health WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "jobsearch") { echo date("H:i:s") . " Remove {$www} from jobsearch and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_jobsearch WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "hobby/arts") { $q->QUERY_SQL("DELETE FROM category_hobby_arts WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "science/computing") { echo date("H:i:s") . " Remove {$www} from science_computing and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_science_computing WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "recreation/travel") { echo date("H:i:s") . " Remove {$www} from recreation_travel and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_recreation_travel WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "dynamic") { echo date("H:i:s") . " Remove {$www} from dynamic and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_dynamic WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "finance/realestate") { echo date("H:i:s") . " Remove {$www} from finance_realestate and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_finance_realestate WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "isp") { echo date("H:i:s") . " Remove {$www} from isp and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_isp WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "housing/accessories") { echo date("H:i:s") . " Remove {$www} from housing/accessories and add it to {$category}\n"; $q->QUERY_SQL("DELETE FROM category_housing_accessories WHERE `pattern`='{$www}'"); $q->QUERY_SQL("INSERT IGNORE INTO category_spyware (zmd5,zDate,category,pattern,uuid,enabled) VALUES('{$md5}',NOW(),'p**n','{$www}','{$uuid}',1)"); if (!$q->ok) { echo "{$q->mysql_error}\n"; die; } continue; } if ($category2 == "malware") { continue; } if ($category2 == "phishing") { continue; } } echo date("H:i:s") . " {$www} {$category2} SKIP\n"; continue; } $md5 = md5($www . $category); $n[] = "('{$md5}',NOW(),'{$category}','{$www}','{$uuid}')"; if (count($n) > 6000) { $sql = $prefix . @implode(",", $n); $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error . "\n"; $n = array(); continue; } $countend = $q->COUNT_ROWS($table); $final = $countend - $countstart; echo "" . numberFormat($c, 0, "", " ") . " items, " . numberFormat($final, 0, "", " ") . " new entries added - {$CBADNULL} bad entries for null value,{$CBADIP} entries for IP addresses\n"; $n = array(); } } fclose($handle); if (count($f) > 0) { if ($c > 0) { $countend = $q->COUNT_ROWS($table); $final = $countend - $countstart; echo "{$c} items, {$final} new entries added - {$CBAD} bad entries\n"; $sql = $prefix . @implode(",", $n); $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error . "\n{$sql}"; continue; } $n = array(); } } $countend = $q->COUNT_ROWS($table); $final = $countend - $countstart; echo "" . numberFormat($final, 0, "", " ") . " new entries added\n"; @unlink($file); }
function webstats_middle_table_items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $search = '%'; $tablemain = "youtubeday_" . date("Ymd", $_GET["xtime"]); $table = "(SELECT SUM( hits ) AS hits, ipaddr, hostname, uid, MAC, youtubeid, title\nFROM (\n\tSELECT {$tablemain}.hits AS hits, {$tablemain}.ipaddr, {$tablemain}.hostname,\n\t{$tablemain}.uid, {$tablemain}.MAC, {$tablemain}.youtubeid, youtube_objects.title\n\tFROM `{$tablemain}` , `youtube_objects`\n\tWHERE youtube_objects.youtubeid = {$tablemain}.youtubeid\n\t) AS t1\nGROUP BY ipaddr, hostname, uid, MAC, youtubeid, title) as t"; $page = 1; $FORCE_FILTER = null; if (!$q->TABLE_EXISTS($tablemain, $database)) { json_error_show("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($tablemain, $database) == 0) { json_error_show("No rules"); } 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, $database)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $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}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5(serialize($ligne)); $color = "black"; //familysite size hits $urljsSIT = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('miniadm.webstats.youtubeid.php?youtubeid={$ligne["youtubeid"]}&xtime={$_GET["xtime"]}');\"\n\tstyle='font-size:12px;text-decoration:underline;color:{$color}'>"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $ligne["familysite"] = $q->GetFamilySites($ligne["sitename"]); $data['rows'][] = array('id' => "{$zmd5}", 'cell' => array("<span style='font-size:12px;color:{$color}'>{$urljsSIT}{$ligne["title"]}</a></span>", "<span style='font-size:12px;color:{$color}'>{$urljsFAM}{$ligne["uid"]}</a></span>", "<span style='font-size:12px;color:{$color}'>{$urljs}{$ligne["ipaddr"]}</span>", "<span style='font-size:12px;color:{$color}'>{$ligne["hostname"]}</span>", "<span style='font-size:12px;color:{$color}'>{$ligne["MAC"]}</span>", "<span style='font-size:12px;color:{$color}'>{$ligne["hits"]}</span>")); } echo json_encode($data); }
break; default: break; } if ($debug) { echo "{$payment_method} - {$crc}<br />"; } //save to database if (isset($needInsert)) { $query_result = $modx->db->query("INSERT INTO {$mod_tab_payments} SET id='{$payment_no}', orderid='{$payment_orderid}', state='I', date=NOW(), userid='{$payment_userid}', email='{$email}', signature='{$crc}'"); $query_result = $modx->db->query("INSERT INTO {$mod_tab_items} SET payid='{$payment_no}', description='{$paymentDesc}', content='{$payment_orderid}', price='{$payment_value}', unit='{$pay_purse_type}', state='Y', paid='N'"); } else { $modx->db->query("UPDATE {$mod_tab_payments} SET date=NOW() WHERE id='{$payment_no}'"); } //parse chunk $chunkArr = array("email_string" => $email_string, "pay_summ" => numberFormat($payment_value), "pay_currency" => $payment_currency, "pay_desc" => $paymentDesc, "action" => $pay_action, "pay_purse_type" => $pay_purse_type, "h_inputs" => $h_inputs); foreach ($chunkArr as $key => $value) { $chunk = str_replace('[+' . $key . '+]', $value, $chunk); } unset($key, $value); $output = $chunk; break; #################################################### # null #################################################### #################################################### # null #################################################### default: break; }
function webstats_middle_table_items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $year = $_GET["year"]; $week = $_GET["week"]; $tablename_prod = "{$year}{$week}_blocked_week"; $subtable = "( SELECT SUM(hits) as hits,client,hostname,website,category,rulename FROM `{$tablename_prod}` \n\tGROUP BY client,hostname,website,category,rulename) as t"; $search = '%'; $table = $subtable; $page = 1; $FORCE_FILTER = null; if (!$q->TABLE_EXISTS($tablename_prod, $database)) { json_error_show("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($tablename_prod, $database) == 0) { json_error_show("No data"); } 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, $database)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $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}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5(serialize($ligne)); $color = "black"; //familysite size hits $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); if ($ligne["uid"] == "-") { $ligne["uid"] = null; } // https://192.168.1.106:9000/ $urljs = null; if ($ligne["uid"] != null) { $urljs = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.members.zoom.php?table={$tablename}&field=uid&value={$ligne["uid"]}')\"\n\tstyle='font-size:14px;text-decoration:underline;color:{$color}'>"; } if ($urljs == null) { if ($ligne["MAC"] != null) { $urljs = "<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('squid.members.zoom.php?table={$tablename}&field=MAC&value={$ligne["MAC"]}')\"\n\t\t\tstyle='font-size:14px;text-decoration:underline;color:{$color}'>"; } } if ($urljs == null) { if ($ligne["hostname"] != null) { $urljs = "<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('squid.members.zoom.php?table={$tablename}&field=hostname&value={$ligne["hostname"]}')\"\n\t\t\tstyle='font-size:14px;text-decoration:underline;color:{$color}'>"; } } if ($urljs == null) { if ($ligne["client"] != null) { $urljs = "<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('squid.members.zoom.php?table={$tablename}&field=client&value={$ligne["client"]}')\"\n\t\t\tstyle='font-size:14px;text-decoration:underline;color:{$color}'>"; } } $data['rows'][] = array('id' => "{$zmd5}", 'cell' => array("<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["client"]}</a></span>", "<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["hostname"]}</span>", "<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["website"]}</span>", "<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["category"]}</span>", "<span style='font-size:14px;color:{$color}'>{$ligne["rulename"]}</span>", "<span style='font-size:14px;color:{$color}'>{$ligne["hits"]}</span>")); } echo json_encode($data); }
function categories_search() { $search = $_GET["category-search"]; $search = "*{$search}*"; $search = str_replace("**", "*", $search); $search = str_replace("**", "*", $search); $search = str_replace("*", "%", $search); if (CACHE_SESSION_GET(__FUNCTION__ . $search, __FILE__, 15)) { return; } $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql_squid_builder(); $dans = new dansguardian_rules(); $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance"); if (!is_numeric($EnableWebProxyStatsAppliance)) { $EnableWebProxyStatsAppliance = 0; } $sql = "SELECT * FROM personal_categories"; $results = $q->QUERY_SQL($sql); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { //$q->CreateCategoryTable($ligne["category"]); $PERSONALSCATS[$ligne["category"]] = $ligne["category_description"]; } $sql = "SELECT table_name as c FROM information_schema.tables WHERE table_schema = 'squidlogs' AND table_name LIKE 'category_{$search}'"; $results = $q->QUERY_SQL($sql); $add = imgtootltip("plus-24.png", "{add} {category}", "Loadjs('{$page}?add-perso-cat-js=yes')"); $compile_all = imgtootltip("compile-distri-32.png", "{saveToDisk} {all}", "Loadjs('{$page}?compile-all-dbs-js=yes')"); if (!$q->ok) { echo " <H2>Fatal Error: {$q->mysql_error}</H2>"; } $sock = new sockets(); $sock->getFrameWork("ufdbguard.php?db-status=yes"); $ArraySIZES = unserialize(@file_get_contents("ressources/logs/web/ufdbguard_db_status")); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $CountDeMembers = 0; $table = $ligne["c"]; $sizedb = $ArraySIZES[$table]["DBSIZE"]; $sizeTXT = $ArraySIZES[$table]["TXTSIZE"]; if (!preg_match("#^category_(.+)#", $table, $re)) { continue; } $categoryname = $re[1]; if ($classtr == "oddRow") { $classtr = null; } else { $classtr = "oddRow"; } $select = imgtootltip("32-parameters.png", "{edit}", "DansGuardianEditMember('{$ligne["ID"]}','{$ligne["pattern"]}')"); $delete = imgtootltip("delete-32.png", "{delete}", "DansGuardianDeleteMember('{$ligne["ID"]}')"); $compile = imgtootltip("compile-distri-32.png", "{saveToDisk}", "DansGuardianCompileDB('{$categoryname}')"); $color = "black"; $items = $q->COUNT_ROWS($ligne["c"]); $TOTAL_ITEMS = $TOTAL_ITEMS + $items; if (!isset($dans->array_blacksites[$categoryname])) { if (isset($dans->array_blacksites[str_replace("_", "-", $categoryname)])) { $categoryname = str_replace("_", "-", $categoryname); } if (isset($dans->array_blacksites[str_replace("_", "/", $categoryname)])) { $categoryname = str_replace("_", "/", $categoryname); } } if ($dans->array_pics[$categoryname] != null) { $pic = "<img src='img/{$dans->array_pics[$categoryname]}'>"; } else { $pic = " "; } if ($EnableWebProxyStatsAppliance == 0) { if ($sizedb == 0) { $pic = "<img src='img/warning-panneau-32.png'>"; } $sizedb_org = $sizedb; $sizedb = FormatBytes($sizedb / 1024); } else { $sizedb_org = $q->TABLE_SIZE($table); $sizedb = FormatBytes($sizedb_org / 1024); } $sizedb = texttooltip($sizedb, "{$sizedb_org} bytes", null, null, 1, "font-size:14px;font-weight:bold;color:{$color}"); $linkcat = null; $text_category = $dans->array_blacksites[$categoryname]; if (isset($PERSONALSCATS[$categoryname])) { $text_category = $PERSONALSCATS[$categoryname]; if ($pic == " ") { $pic = "<img src='img/20-categories-personnal.png'>"; } $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$page}?add-perso-cat-js=yes&cat={$categoryname}')\"\n\t\t\tstyle='font-size:14px;font-weight:bold;color:{$color};text-decoration:underline'>"; } if ($EnableWebProxyStatsAppliance == 0) { if ($sizedb_org < 35) { $pic = "<img src='img/warning-panneau-32.png'>"; } } $viewDB = imgtootltip("mysql-browse-database-32.png", "{view}", "javascript:Loadjs('squid.categories.php?category={$categoryname}')"); $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td width=1%>{$pic}</td>\n\t\t\t<td style='font-size:14px;font-weight:bold;color:{$color}' width=99%>\n\t\t\t{$linkcat}{$categoryname}</a><div style='font-size:11px;width:100%;font-weight:normal'>{$text_category}</div></td>\n\t\t\t<td style='font-size:14px;font-weight:bold;color:{$color}' width=1% nowrap align='right'>{$sizedb}</td>\n\t\t\t<td width=1%>{$viewDB}</td>\n\t\t\t<td style='font-size:14px;font-weight:bold;color:{$color}' width=1% nowrap align='right'>" . numberFormat($items, 0, "", " ") . "</td>\n\t\t\t<td width=1%>{$compile}</td>\n\t\t\t<td width=1%>{$delete}</td>\n\t\t</tr>\n\t\t"; } $TOTAL_ITEMS = numberFormat($TOTAL_ITEMS, 0, "", " "); $header = "<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%>{$add}</th>\n\t\t<th width=99%>{category}</th>\n\t\t<th width=1%>{size}</th>\n\t\t<th width=1% colspan=2>{$TOTAL_ITEMS} {items}</th>\n\t\t<th width=1%>{$compile_all}</th>\n\t\t<th width=1%> </th>\n\t</tr>\n</thead>\n<tbody class='tbody'>"; $html = $header . $html . "</table>\n\t</center>\n\t\n\t<script>\n\t\tfunction DansGuardianCompileDB(category){\n\t\t\tLoadjs('{$page}?compile-db-js='+category);\n\t\t}\n\t</script>\n\t"; CACHE_SESSION_SET(__FUNCTION__ . $search, __FILE__, $tpl->_ENGINE_parse_body($html)); }
function js() { header("content-type: application/x-javascript"); $page = CurrentPageName(); $tpl = new templates(); if (!$_SESSION["CORP"]) { $onlycorpavailable = $tpl->javascript_parse_text("{onlycorpavailable}"); echo "alert('{$onlycorpavailable}');"; return; } $q = new mysql_squid_builder(); $youtube_objects = $q->COUNT_ROWS("youtube_objects"); $youtube_objects = numberFormat($youtube_objects, 0, "", " "); $title = $tpl->_ENGINE_parse_body("{$youtube_objects} Youtube {objects}"); echo "YahooWin3('926','{$page}?master-content=yes','{$title}')"; }
function webstats_middle_table_items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $xtime = $_GET["xtime"]; $database = "squidlogs"; $tablename_members = date("Ymd", $_GET["xtime"]) . "_members"; if ($_GET["FILTER"] == null) { $_GET["FILTER"] = which_filter($tablename_members); } $subtable = "( SELECT {$_GET["FILTER"]},SUM(size) as size, SUM(hits) as hits FROM `{$tablename_members}` \n\tGROUP BY {$_GET["FILTER"]} HAVING LENGTH({$_GET["FILTER"]})>0) as t"; $search = '%'; $table = $subtable; $page = 1; $FORCE_FILTER = null; $dansguardian_events = date("Ymd", $xtime) . "_hour"; if (!$q->TABLE_EXISTS($tablename_members, $database)) { json_error_show("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($tablename_members, $database) == 0) { json_error_show("No data"); } 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("items"); if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $boot = new boostrap_form(); $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} ORDER BY size DESC LIMIT 0,150"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5(serialize($ligne)); $color = "black"; //familysite size hits $colorsize = "black"; $sizeorg = $ligne["size"]; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); if ($sizeorg > 102400000) { $colorsize = "#4E0000"; } if ($sizeorg > 512000000) { $colorsize = "#9A0000"; } // https://192.168.1.106:9000/ $urljs = "Loadjs('squid.members.zoom.php?table={$dansguardian_events}&field={$_GET["FILTER"]}&value={$ligne["{$_GET["FILTER"]}"]}')"; $link = $boot->trswitch($urljs); $tr[] = "\n\t<tr id='{$id}'>\n\t<td {$link}><i class='icon-user'></i> {$ligne["name"]}</a>{$ligne["{$_GET["FILTER"]}"]}</td>\n\t<td {$link}><i class='icon-globe'></i> {$ligne["hits"]}</td>\n\t<td {$link}><i class='icon-globe'></i> {$ligne["size"]}</td>\n\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t\t\n\t\t<table class='table table-bordered table-hover'>\n\t\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{{$_GET["FILTER"]}}</th>\n\t\t\t\t\t<th>{hits}</th>\n\t\t\t\t\t<th>{size}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("\n", $tr) . " </tbody>\n\t\t</table>"; }
function inject($category, $table = null, $file = null) { include_once dirname(__FILE__) . "/ressources/class.dansguardian.inc"; $unix = new unix(); $q = new mysql_squid_builder(); if (is_file($category)) { $file = $category; $category_name = basename($file); echo "{$file} -> {$category_name}\n"; if (preg_match("#(.+?)\\.gz\$#", $category_name)) { echo "{$category_name} -> gunzip\n"; $new_category_name = str_replace(".gz", "", $category_name); $gunzip = $unix->find_program("gunzip"); $target_file = dirname($file) . "/{$new_category_name}"; $cmd = "/bin/gunzip -d -c \"{$file}\" >{$target_file} 2>&1"; echo "{$cmd}\n"; shell_exec($cmd); if (!is_file($target_file)) { echo "Uncompress failed\n"; return; } $file = $target_file; $table = $new_category_name; $category = $q->tablename_tocat($table); echo "{$new_category_name} -> {$table}\n"; } else { $table = $category_name; echo "{$new_category_name} -> {$table}\n"; $category = $q->tablename_tocat($table); } echo "Table: {$table}\nSource File:{$file}\nCategory: {$category}\n"; } if (!is_file($file)) { if (!is_file($table)) { echo "`{$table}` No such file\n"; } if (is_file($table)) { $file = $table; $table = null; } } if ($table == null) { $table = "category_" . $q->category_transform_name($category); echo "Table will be {$table}\n"; } if (!$q->TABLE_EXISTS($table)) { echo "{$table} does not exists, check if it is an official one\n"; $dans = new dansguardian_rules(); if (isset($dans->array_blacksites[$category])) { $q->CreateCategoryTable($category); } } if (!$q->TABLE_EXISTS($table)) { echo "`{$category}` -> no such table \"{$table}\"\n"; return; } $sql = "SELECT COUNT(*) AS TCOUNT FROM {$table}"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n"; if (preg_match("#is marked as crashed and last#", $q->mysql_error)) { echo "`{$table}` -> crashed, remove \"{$table}\"\n"; $q->QUERY_SQL("DROP TABLE {$table}"); $q->QUERY_SQL("flush tables"); $q = new mysql_squid_builder(); echo "`{$table}` -> Create category \"{$category}\"\n"; $q->CreateCategoryTable($category); $q->CreateCategoryTable($category); $q = new mysql_squid_builder(); } if (!$q->TABLE_EXISTS($table)) { echo "`{$category}` -> no such table \"{$table}\"\n"; return; } } if ($file == null) { $dir = "/var/lib/squidguard"; if ($GLOBALS["SHALLA"]) { $dir = "/root/shalla/BL"; } if (!is_file("{$dir}/{$category}/domains")) { echo "{$dir}/{$category}/domains no such file"; return; } $file = "{$dir}/{$category}/domains"; } if (!is_file($file)) { echo "{$file} no such file"; return; } $sock = new sockets(); $unix = new unix(); $uuid = $unix->GetUniqueID(); if ($uuid == null) { echo "No uuid\n"; return; } echo "open {$file}\n"; $handle = @fopen($file, "r"); if (!$handle) { echo "Failed to open file\n"; return; } $q = new mysql_squid_builder(); if ($GLOBALS["CATTO"] != null) { $category = $GLOBALS["CATTO"]; } $countstart = $q->COUNT_ROWS($table); $prefix = "INSERT IGNORE INTO {$table} (zmd5,zDate,category,pattern,uuid) VALUES "; echo "{$prefix}\n"; $c = 0; $CBAD = 0; $CBADIP = 0; $CBADNULL = 0; while (!feof($handle)) { $c++; $www = trim(fgets($handle, 4096)); if ($www == null) { $CBADNULL++; continue; } $www = str_replace('"', "", $www); if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $www)) { $CBADIP++; continue; } $www = trim(strtolower($www)); if ($www == "thisisarandomentrythatdoesnotexist.com") { $CBAD++; continue; } if ($www == null) { $CBADNULL++; continue; } if (preg_match("#(.+?)\\s+(.+)#", $www, $re)) { $www = $re[1]; } if (preg_match("#^\\.(.*)\$#", $www, $re)) { $www = $re[1]; } if (strpos($www, "#") > 0) { echo "FALSE: {$www}\n"; continue; } if (strpos($www, "'") > 0) { echo "FALSE: {$www}\n"; continue; } if (strpos($www, "{") > 0) { echo "FALSE: {$www}\n"; continue; } if (strpos($www, "(") > 0) { echo "FALSE: {$www}\n"; continue; } if (strpos($www, ")") > 0) { echo "FALSE: {$www}\n"; continue; } if (strpos($www, "%") > 0) { echo "FALSE: {$www}\n"; continue; } $md5 = md5($www . $category); $n[] = "('{$md5}',NOW(),'{$category}','{$www}','{$uuid}')"; if (count($n) > 6000) { $sql = $prefix . @implode(",", $n); $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error . "\n"; $n = array(); continue; } $countend = $q->COUNT_ROWS($table); $final = $countend - $countstart; echo "" . numberFormat($c, 0, "", " ") . " items, " . numberFormat($final, 0, "", " ") . " new entries added - {$CBADNULL} bad entries for null value,{$CBADIP} entries for IP addresses\n"; $n = array(); } } fclose($handle); if (count($f) > 0) { if ($c > 0) { $countend = $q->COUNT_ROWS($table); $final = $countend - $countstart; echo "{$c} items, {$final} new entries added - {$CBAD} bad entries\n"; $sql = $prefix . @implode(",", $n); $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error . "\n{$sql}"; continue; } $n = array(); } } $countend = $q->COUNT_ROWS($table); $final = $countend - $countstart; echo "" . numberFormat($final, 0, "", " ") . " new entries added\n"; @unlink($file); }
function table_sites_search() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $boot = new boostrap_form(); $database = "squidlogs"; $search = '%'; $table = "generic_categories"; $rp = 250; $page = 1; $FORCE_FILTER = null; $ORDER = "ORDER BY size DESC"; if (!$q->TABLE_EXISTS($table, $database)) { senderror("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($table, $database) == 0) { senderror("No data"); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $search = string_to_flexquery("category-search"); if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $category = mysql_escape_string2($_GET["category"]); $sql = "SELECT SUM( size ) AS size,SUM(hits) as hits, zDate, category FROM generic_categories GROUP BY category,zDate\n\tHAVING category='{$_GET["category"]}' ORDER BY zDate"; $results = $q->QUERY_SQL($sql); $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { senderror($q->mysql_error . "<br>{$sql}"); } while ($ligne = mysql_fetch_assoc($results)) { $color = "black"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $xtime = strtotime($ligne["zDate"] . " 00:00:00"); $dateText = time_to_date($xtime); $catz = urlencode($_GET["category"]); $jsSitename = $boot->trswitch("Loadjs('miniadm.webstats.websites.ByDayByCategory.php?category={$catz}&xtime={$xtime}')"); $tr[] = "\n\t\t\t\t<tr {$jsSitename}>\n\t\t\t\t\t<td><i class='icon-time'></i> {$dateText}</a></td>\n\t\t\t\t\t<td><i class='icon-info-sign'></i> {$ligne["size"]}</td>\n\t\t\t\t\t<td><i class='icon-info-sign'></i> {$ligne["hits"]}</td>\n\t\t\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t\n\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{day}</th>\n\t\t\t\t\t<th>{size}</th>\n\t\t\t\t\t<th>{hits}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t\t") . @implode("", $tr) . "</tbody></table>"; }
function squid_status_stats() { $off = "<script>UnlockPage();</script>"; if (!$GLOBALS["AS_ROOT"]) { $cachefile = "/usr/share/artica-postfix/ressources/logs/web/traffic.statistics.html"; if (is_file($cachefile)) { $tpl = new templates(); $cacheContent = @file_get_contents($cachefile); if (strlen($cacheContent) > 20) { echo $tpl->_ENGINE_parse_body(@file_get_contents($cachefile)) . $off; return; } } } if (CACHE_SESSION_GET(__FUNCTION__, __FILE__)) { return; } if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " Loading classes<br>\n"; } $sock = new sockets(); $users = new usersMenus(); $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance"); $SquidActHasReverse = $sock->GET_INFO("SquidActHasReverse"); if (!is_numeric($SquidActHasReverse)) { $SquidActHasReverse = 0; } if ($EnableRemoteStatisticsAppliance == 1) { return; } $DisableArticaProxyStatistics = $sock->GET_INFO("DisableArticaProxyStatistics"); if (!is_numeric($DisableArticaProxyStatistics)) { $DisableArticaProxyStatistics = 0; } $MalwarePatrolDatabasesCount = $sock->getFrameWork("cmd.php?MalwarePatrolDatabasesCount=yes"); $mouse = "OnMouseOver=\";this.style.cursor='pointer';\" OnMouseOut=\";this.style.cursor='default';\""; $EnableMacAddressFilter = $sock->GET_INFO("EnableMacAddressFilter"); if (!is_numeric($EnableMacAddressFilter)) { $EnableMacAddressFilter = 1; } if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " Loading mysql_storelogs()<br>\n"; } $syslogs = new mysql_storelogs(); if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " Count accesslogs<br>\n"; } $SyslogsFiles = $syslogs->COUNT_ROWS("accesslogs"); $TR_ACCESSLOG = "\n\t<tr>\n\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' \n\t\tOnClick=\"javascript:Loadjs('squid.accesses.rotate.php')\"><b><span style='font-size:12px'>{$SyslogsFiles}</span></b><span style='font-size:12px'> {access_logs}</td>\n\t</tr>"; $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); if ($users->PROXYTINY_APPLIANCE) { $DisableArticaProxyStatistics = 1; } if ($DisableArticaProxyStatistics == 0) { $websitesnums = $q->COUNT_ROWS("visited_sites"); $websitesnums = numberFormat($websitesnums, 0, "", " "); $sql = "DELETE FROM categorize WHERE LENGTH(pattern)=0"; $q->QUERY_SQL($sql); $export = $q->COUNT_ROWS("categorize"); $export = numberFormat($export, 0, "", " "); } $catz = new mysql_catz(); $categories = $catz->COUNT_CATEGORIES(); $categories = numberFormat($categories, 0, "", " "); if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " categories= {$categories}<br>\n"; } $YourItems = $q->COUNT_CATEGORIES(); $YourItems = numberFormat($YourItems, 0, "", " "); if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " LIST_TABLES_CATEGORIES()<br>\n"; } $tablescat = $q->LIST_TABLES_CATEGORIES(); if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " tablescat={$tablescat}<br>\n"; } $tablescatNUM = numberFormat(count($tablescat), 0, "", " "); if ($DisableArticaProxyStatistics == 0) { if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " EVENTS_SUM()<br>\n"; } $requests = $q->EVENTS_SUM(); $requests = numberFormat($requests, 0, "", " "); if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " requests = {$requests}<br>\n"; } } if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " no_license -> translate<br>\n"; } $nolicense = $tpl->_ENGINE_parse_body("{no_license}"); $PhishingURIS = $q->COUNT_ROWS("categoryuris_phishing"); $PhishingURIS = numberFormat($PhishingURIS, 0, "", " "); if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " >COUNT_ROWS('categoryuris_malware')<br>\n"; } $MalwaresURIS = $q->COUNT_ROWS("categoryuris_malware"); $MalwaresURIS = numberFormat($MalwaresURIS, 0, "", " "); if (!$users->CORP_LICENSE) { $PhishingURIS = $nolicense; $MalwaresURIS = $nolicense; } if ($DisableArticaProxyStatistics == 0) { if ($EnableMacAddressFilter == 1) { $Computers = $q->COUNT_ROWS("webfilters_nodes"); $Computers = numberFormat($Computers, 0, "", " "); $nodes = "\n\t\t\t<tr>\n\t\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.nodes.php',true)\"><b><span style='font-size:12px'>{$Computers}</span></b><span style='font-size:12px'> {computers}</td>\n\t\t\t</tr>"; } else { $Computers = $q->COUNT_ROWS("UserAutDB"); $Computers = numberFormat($Computers, 0, "", " "); $nodes = "\n\t\t\t<tr>\n\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.UserAutDB.php')\"><b><span style='font-size:12px'>{$Computers}</span></b><span style='font-size:12px'> {clients}</td>\n\t\t\t</tr>"; } if (!$users->CORP_LICENSE) { $license_inactive = "<br><strong style='font-size:11px;font-weight:bolder;color:#BA1010'>{license_inactive}</strong>"; } if (!$q->TABLE_EXISTS("tables_day")) { $q->CheckTables(); } $DAYSNumbers = $q->COUNT_ROWS("tables_day"); if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " DAYSNumbers = {$DAYSNumbers}<br>\n"; } //$GLOBALS["FULL_DEBUG"] $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(totalsize) as tsize FROM tables_day")); $totalsize = FormatBytes($ligne["tsize"] / 1024); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT AVG(cache_perfs) as pourc FROM tables_day")); $pref = round($ligne["pourc"]); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(sitename) as tcount FROM visited_sites WHERE LENGTH(category)=0")); $websitesnumsNot = numberFormat($ligne["tcount"], 0, "", " "); if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " SELECT count(youtubeid),youtubeid FROM `youtube_dayz` GROUP BY youtubeid<br>\n"; } $results = $q->QUERY_SQL("SELECT count(youtubeid),youtubeid FROM `youtube_dayz` GROUP BY youtubeid"); $youtube_objects = mysql_num_rows($results); $youtube_objects = numberFormat($youtube_objects, 0, "", " "); $CachePermformance = $q->CachePerfHour(); if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " CachePermformance = {$CachePermformance}<br>\n"; } if ($CachePermformance > -1) { $color = "#E01313"; if ($CachePermformance > 20) { $color = "#6DBB6A"; } $cachePerfText = "\n\t\t\t<tr>\n\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t<td valign='top' style='font-size:12px;'><b style='color:{$color}'>{$CachePermformance}%</span></b><span style='font-size:12px'> {cache_performance} ({now})</td>\n\t\t\t</tr>\n\t\t\t"; } if ($SquidActHasReverse == 1) { $TR_CAT_NUMBER = null; } $TR_CAT_NUMBER = "\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.categories.php')\"><b><span style='font-size:12px'>{$categories}</span></b><span style='font-size:12px'> {websites_categorized}{$license_inactive}</td>\n\t</tr>\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.categories.php')\"><span style='font-size:12px'>{youritems}: <b>{$YourItems}</span></b><span style='font-size:12px'></td>\n\t</tr>"; $TR_CATZ = "\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td width=99% valign='top' style='font-size:12px;text-decoration:underline' \n\t\t{$mouse} OnClick=\"javascript:Loadjs('squid.traffic.statistics.days.php?js=yes&with-purge=yes')\"><b><span style='font-size:12px'>{$DAYSNumbers}</span></b><span style='font-size:12px'> {daysOfStatistics}</td>\n\t</tr>\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' style='font-size:12px'><b><span style='font-size:12px'>{$requests}</span></b><span style='font-size:12px'> {requests}</td>\n\t</tr>\n\t{$nodes}\n\t\t\n\t{$TR_CAT_NUMBER}\n"; $TR_YOUTUBE = "\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline'\n\t\t{$mouse} OnClick=\"javascript:Loadjs('squid.youtube.all.php')\"\n\t\t><b><span style='font-size:12px'>{$youtube_objects}</span></b><span style='font-size:12px'> Youtube {objects}</td>\n\t</tr>"; if ($DisableArticaProxyStatistics == 1) { $TR_YOUTUBE = null; $TR_CATZ = null; } if ($SquidActHasReverse == 1) { $TR_YOUTUBE = null; } $submenu = "\t\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' style='font-size:12px'><b><span style='font-size:12px'>{$totalsize}</span></b><span style='font-size:12px'> {downloaded_flow}</td>\n\t</tr>\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' style='font-size:12px'><b><span style='font-size:12px'>{$pref}%</span></b><span style='font-size:12px'> {cache_performance}</td>\n\t</tr>\n\t\n\t{$cachePerfText}"; $main_table = "\n\t\t\n\t\t{$TR_CATZ}\n\t\t{$TR_YOUTUBE}\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$PhishingURIS}</span></b><span style='font-size:12px'> {phishing_uris}</td>\n\t</tr>\t\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$MalwaresURIS}</span></b><span style='font-size:12px'> {viruses_uris}</td>\n\t</tr>\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$MalwarePatrolDatabasesCount}</span></b><span style='font-size:12px'> Malware Patrol</td>\n\t</tr>\t\n\t\t\t\t\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.visited.php?onlyNot=yes')\"><b><span style='font-size:12px'>{$websitesnumsNot}</span></b><span style='font-size:12px'> {not_categorized}</td>\n\t</tr>\t\n\t\t\t\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.categories.php')\"><b><span style='font-size:12px'>{$tablescatNUM}</span></b><span style='font-size:12px'> {categories}</td>\n\t</tr>\t\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.categories.toexport.php')\"><b><span style='font-size:12px'>{$export}</span></b><span style='font-size:12px'> {websites_to_export}</td>\n\t</tr>"; } if ($DisableArticaProxyStatistics == 1) { $main_table = "\t\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$PhishingURIS}</span></b><span style='font-size:12px'> {phishing_uris}</td>\n\t\t\t</tr>\t\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$MalwaresURIS}</span></b><span style='font-size:12px'> {viruses_uris}</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$MalwarePatrolDatabasesCount}</span></b><span style='font-size:12px'> Malware Patrol</td>\n\t\t\t</tr>"; } $addwebsites = "\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/plus-16.png'></td>\n\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' \n\t\t\tOnClick=\"javascript:Loadjs('squid.visited.php?add-www=yes')\"><b><span style='font-size:12px'>{categorize_websites}</span></b><span style='font-size:12px'></td>\n\t\t</tr>\t"; if ($users->PROXYTINY_APPLIANCE) { $addwebsites = null; $submenu = null; } $html = "\n<table style='width:100%'>\n\t<tbody>\n\t{$TR_ACCESSLOG}\n\t{$main_table}\t\n\t{$submenu}\n\t{$addwebsites}\n\t</tbody>\n\t</table>\n{$off}"; if ($GLOBALS["VERBOSE"]) { echo __LINE__ . " tpl->_ENGINE_parse_body<br>\n"; } $html = $tpl->_ENGINE_parse_body($html); if (!$GLOBALS["AS_ROOT"]) { CACHE_SESSION_SET(__FUNCTION__, __FILE__, $html); } }
function section_search() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $xtime = $_GET["xtime"]; $tablename_prod = date("Ymd", $xtime) . "_blocked"; $tablename = $_GET["tablename"]; $subtable = "( SELECT COUNT(ID) as hits,website,category FROM `{$tablename_prod}` \n\tGROUP BY website,category ORDER BY hits DESC) as t"; $search = '%'; $table = $subtable; $page = 1; $FORCE_FILTER = null; if (!$q->TABLE_EXISTS($tablename_prod)) { senderror("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($tablename_prod) == 0) { senderror("No data"); } $searchstring = string_to_flexquery($_GET["www-search"]); $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror($q->mysql_error); } while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5(serialize($ligne)); $color = "black"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); if ($ligne["uid"] == "-") { $ligne["uid"] = null; } $boot = new boostrap_form(); $urljs = null; $truri = $boot->trswitch($urljsSIT); $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $tr[] = "\n\t<tr {$truri}>\n\t<td ><i class='icon-globe'></i> {$ligne["website"]}</td>\n\t<td width=1% align=center nowrap>{$ligne["category"]}</td>\n\t<td width=1% align=center nowrap>{$ligne["hits"]}</td>\n\t</tr>\n\t"; } echo $tpl->_ENGINE_parse_body("\n\t\t\t<table class='table table-bordered table-hover'>\n\t\t\t<thead>\n\t\t\t<tr>\n\t\t\t<th>{websites}</th>\n\t\t\t<th>{category}</th>\n\t\t\t<th>{hits}</th>\n\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>\n\t\t\t") . @implode("\n", $tr) . "\n\t\t\t</tbody>\n\t\t\t</table>"; }
function table_sites_search() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $boot = new boostrap_form(); $database = "squidlogs"; $search = '%'; $table = date("Ymd", $_GET["xtime"]) . "_hour"; $rp = 250; $page = 1; $FORCE_FILTER = null; $ORDER = "ORDER BY size DESC"; if (!$q->TABLE_EXISTS($table, $database)) { senderror("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($table, $database) == 0) { senderror("No data"); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $search = string_to_flexquery("sitename-search"); if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $familysite = mysql_escape_string2($_GET["familysite"]); $sql = "SELECT SUM(size) as size, sum(hits) as hits,sitename,familysite FROM {$table}\n\tGROUP BY sitename,familysite HAVING `familysite`='{$familysite}' {$search} {$ORDER} LIMIT 0,500"; $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { senderror($q->mysql_error . "<br>{$sql}"); } while ($ligne = mysql_fetch_assoc($results)) { $color = "black"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $jsSitename = $boot->trswitch("Loadjs('miniadm.webstats.websites.ByDayBySiteName.php?sitename={$ligne["sitename"]}&xtime={$_GET["xtime"]}')"); $tr[] = "\n\t\t\t\t<tr id='{$id}'>\n\t\t\t\t\t<td {$jsSitename}><i class='icon-globe'></i> {$ligne["sitename"]}</a></td>\n\t\t\t\t\t<td {$link}><i class='icon-info-sign'></i> {$ligne["size"]}</td>\n\t\t\t\t\t<td {$link}><i class='icon-info-sign'></i> {$ligne["hits"]}</td>\n\t\t\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t\n\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{website}</th>\n\t\t\t\t\t<th>{size}</th>\n\t\t\t\t\t<th>{hits}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t\t") . @implode("", $tr) . "</tbody></table>"; }