function search() { $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql(); if (isset($_POST['page'])) { $page = $_POST['page']; } $searchstring = string_to_flexregex(); if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $CATZ_ARRAY = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/UFDB_ARTICA_CATZ")); $CATZ_ITEMS = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/UFDB_ARTICA_COUNTZ")); unset($CATZ_ARRAY["TIME"]); $data = array(); $data['page'] = 1; $data['total'] = count($CATZ_ARRAY); $data['rows'] = array(); $catz = new mysql_catz(); $TransArray = $catz->TransArray(); $c = 0; while (list($tablename, $size) = each($CATZ_ARRAY)) { $items = intval($CATZ_ITEMS[$tablename]); $size = $size / 1024; $size = FormatBytes($size); if (isset($TransArray[$tablename])) { $tablename = $TransArray[$tablename]; } if ($searchstring != null) { if (!preg_match("#{$searchstring}#", $tablename)) { continue; } } $c++; $items = FormatNumber($items); $data['rows'][] = array('id' => md5($tablename), 'cell' => array("<strong style='font-size:18px;color:{$color}'>{$tablename}</strong>", "<div style='font-size:18px;font-weight:normal;color:{$color}'>{$size}</div>", "<div style='font-size:18px;font-weight:normal;color:{$color}'>{$items}</div>")); } $data['total'] = $c; echo json_encode($data); }
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 filaname_tocat($filename) { if (strpos($filename, "/domains.ufdb") > 0) { $filename = str_replace("/domains.ufdb", "", $filename); } $q = new mysql_catz(true); $trans = $q->TransArray(); $filename = basename($filename); $filename = str_replace(".ufdb", "", $filename); if (preg_match("#^category_(.*)#", $filename, $re)) { $filename = $re[1]; } if (isset($trans["category_{$filename}"])) { return $trans["category_{$filename}"]; } $array["audio-video"] = "audio-video"; $array["gambling"] = "gamble"; $array["cooking"] = "hobby/cooking"; $array["bank"] = "finance/banking"; $array["lingerie"] = "sex/lingerie"; $array["drogue"] = "drugs"; $array["child"] = "children"; $array["adult"] = "p**n"; $array["aggressive"] = "agressive"; $array["agressif"] = "agressive"; $array["radio"] = "webradio"; $array["remote-control"] = "remote-control"; $array["social_networks"] = "socialnet"; $array["mobile-phone"] = "mobile-phone"; $array["sports"] = "recreation/sports"; $array["verisign"] = "sslsites"; $array["associations"] = "associations"; $array["translation"] = "translators"; $array["arjel"] = "arjel"; if (isset($array["{$filename}"])) { return $array["{$filename}"]; } return "{$filename}"; }
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 categories_match($gpid, $sitname) { if (preg_match("#^www\\.(.+)#", $sitname, $re)) { $sitname = $re[1]; } if (preg_match("#^(.+):[0-9]+]#", $sitname, $re)) { $sitname = $re[1]; } if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("Analyze: Group: {$gpid} `{$sitname}`"); } $categories_get_memory = categories_get_memory($gpid, $sitname); if ($categories_get_memory != null) { if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("Group: {$gpid} `{$sitname}` -> MEMORY: `{$categories_get_memory}` "); } if ($categories_get_memory == "UNKNOWN") { return null; } return $categories_get_memory; } $q = new mysql_catz(); if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("Group: {$gpid} `{$sitname}` -> CATEGORY ?? [" . __LINE__ . "]"); } $categoriF = $q->GET_CATEGORIES($sitname); $trans = $q->TransArray(); if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("Group: {$gpid} `{$sitname}` -> category: `{$categoriF}` "); } if ($categoriF == null) { if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("squid_familysite()"); } if (!class_exists("squid_familysite")) { include_once dirname(__FILE__) . "/ressources/class.squid.familysites.inc"; } $qF = new squid_familysite(); $familysite = $qF->GetFamilySites($sitname); if ($familysite != $sitname) { $categoriF = $q->GET_CATEGORIES($familysite); if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("Group: {$gpid} `{$sitname}` -> {$familysite} -> category: `{$categoriF}` "); } } } if ($categoriF == null) { categories_set_memory($gpid, $sitname, "UNKNOWN"); return null; } if (strpos($categoriF, ",") > 0) { $categoriT = explode(",", $categoriF); } else { $categoriT[] = $categoriF; } while (list($a, $b) = each($categoriT)) { $MAIN[$b] = true; } $filename = "/etc/squid3/acls/catz_gpid{$gpid}.acl"; $categories = unserialize(@file_get_contents($filename)); while (list($category_table, $category_rule) = each($categories)) { $category_rule = urlencode($category_rule); $categoryname = $trans[$category_table]; if (isset($MAIN[$categoryname])) { if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("FOUND `{$categoryname}` -> `{$category_rule}` "); } categories_set_memory($gpid, $sitname, $category_rule); return $category_rule; } } categories_set_memory($gpid, $sitname, "UNKNOWN"); }
function categories_search($forceArtica = false) { $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); } $table = "webfilters_categories_caches"; $sql = "SELECT * FROM personal_categories"; if ($OnlyPersonal == 0) { if (!$q->TABLE_EXISTS($table)) { $q->create_webfilters_categories_caches(); } $dans = new dansguardian_rules(); if ($q->COUNT_ROWS($table) == 0) { $dans->CategoriesTableCache(); } $dans->LoadBlackListes(); } else { $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(); $AS_SELECT = false; if ($_GET["select"] == "yes") { $AS_SELECT = true; } $enc = new mysql_catz(); $field = "categorykey"; $field_description = "description"; if ($OnlyPersonal == 1) { $field = "category"; $field_description = "category_description"; } $ProductName = "Artica"; $ProductNamef = dirname(__FILE__) . "/ressources/templates/{$_COOKIE["artica-template"]}/ProducName.conf"; if (is_file($ProductNamef)) { $ProductName = trim(@file_get_contents($ProductNamef)); } $CATZ_ARRAY = unserialize(base64_decode(@file_get_contents(CATZ_ARRAY_FILE()))); $FULL_ARRAY = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/ARTICA_DBS_STATUS_FULL.db")); $TLSE_ARRAY = $FULL_ARRAY["TLSE_ARRAY"]; $ARTICA_ARRAY = $FULL_ARRAY["CAT_ARTICAT_ARRAY"]; //print_r($ARTICA_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)) { $sizedb = array(); $ZZCOUNT = 0; $categorykey = $ligne[$field]; 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; $ITEMS_COLONE = array(); $Time = array(); $text_category = null; $table = $q->cat_totablename($categorykey); if ($GLOBALS["VERBOSE"]) { echo "Scanning table {$table}<br>\n"; } $UnivToulouseItems = null; $ligne_databases = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM UPDATE_DBWF_INFOS WHERE category='{$categoryname}'")); $size_artica = $ligne_databases["size_artica"]; $date_artica = $ligne_databases["date_artica"]; $count_artica = $ligne_databases["count_artica"]; $size_tlse = $ligne_databases["size_tlse"]; $date_tlse = $ligne_databases["date_tlse"]; $count_tlse = $ligne_databases["count_tlse"]; $size_perso = $ligne_databases["size_perso"]; $date_perso = $ligne_databases["date_perso"]; $count_perso = $ligne_databases["count_perso"]; $items = $count_perso; $itemsEnc = $count_artica; $ZZCOUNT = $ZZCOUNT + $items; $ZZCOUNT = $ZZCOUNT + $itemsEnc; if ($date_perso > 0) { $Time[] = date("m-d H:i", $date_perso); } else { $Time[] = "-"; } $sizeArtica = $size_artica; if ($date_artica > 0) { $Time[] = date("m-d H:i", $date_artica); } else { $Time[] = "-"; } $ITEMS_COLONE[] = "Perso.: " . numberFormat($items, 0, "", " "); $ITEMS_COLONE[] = "{$ProductName}: " . numberFormat($itemsEnc, 0, "", " "); if (!preg_match("#^category_(.+)#", $table, $re)) { continue; } $compile = imgsimple("compile-distri-32.png", "{saveToDisk}", "DansGuardianCompileDB('{$categoryname}')"); 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 = " "; } $sizedb[] = FormatBytes($size_perso / 1024); $sizedb[] = FormatBytes($size_artica / 1024); $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.categories.php?category={$categoryname}&t={$t}',true)\"\n\t\tstyle='font-size:14px;font-weight:bold;color:{$color};text-decoration:underline'>"; $text_category = $tpl->_ENGINE_parse_body(utf8_decode($ligne[$field_description])); $text_category = trim($text_category); $pic = "<img src='img/20-categories-personnal.png'>"; if ($ligne["picture"] != null) { $pic = "<img src='img/{$ligne["picture"]}'>"; } if ($OnlyPersonal == 0) { if (!isset($dans->array_blacksites[$categoryname])) { $linkcat = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?add-perso-cat-js=yes&cat={$categoryname}&t={$t}',true)\"\n\t\t\t\tstyle='font-size:14px;font-weight:bold;color:{$color};text-decoration:underline'>"; } } else { $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:14px;font-weight:bold;color:{$color};text-decoration:underline'>"; } $viewDB = imgsimple("mysql-browse-database-32.png", "{view}", "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:14px';font-weight:bold'>{$linkcat}{$categoryname_text}</span>\n\t\t</a><br><span style='font-size:11px;width:100%;font-weight:normal'>{$text_category}</span>"); if ($OnlyPersonal == 1) { $itemsEncTxt = "<br><span style='font-size:11px'>" . numberFormat($itemsEnc, 0, "", " "); "</span>"; } $compile = imgsimple("compile-distri-32.png", null, "DansGuardianCompileDB('{$categoryname}')"); $delete = imgsimple("delete-32.png", "{delete}", "TableCategoryPurge('{$table}')"); if ($_GET["minisize"] == "yes") { $delete = null; } if ($OnlyPersonal == 0) { $UnivToulouse_websitesnum = $count_tlse; $ZZCOUNT = $ZZCOUNT + $UnivToulouse_websitesnum; $UnivToulouse_size = $size_tlse; $sizedb[] = FormatBytes($UnivToulouse_size / 1024); $ITEMS_COLONE[] = "University: " . numberFormat($UnivToulouse_websitesnum, 0, "", " "); if ($date_tlse > 0) { $Time[] = date("m-d H:i", $date_tlse); } else { $Time[] = "-"; } } if ($categoryname == "UnkNown") { $linkcat = null; $delete = imgsimple("delete-32.png", "{delete}", "TableCategoryPurge('')"); } if ($EnableWebProxyStatsAppliance == 0) { if ($ZZCOUNT == 0) { $pic = "<img src='img/warning-panneau-32.png'>"; } } $cell = array(); $cell[] = $pic; $cell[] = $categoryText; $cell[] = "<span style='font-size:11px;padding-top:15px;font-weight:bold'>" . @implode("<br>", $sizedb) . "</span>"; $cell[] = "<span style='font-size:11px;padding-top:5px;font-weight:bold'>" . @implode("<br>", $ITEMS_COLONE) . "</span>"; if (!$AS_SELECT) { $cell[] = "<span style='font-size:11px;padding-top:5px;font-weight:bold'>" . @implode("<br>", $Time) . "</span>"; $cell[] = $compile; $cell[] = $delete; } else { $select = imgsimple("arrow-right-32.png", null, "{$_GET["callback"]}('{$categorykey}')"); $cell[] = $select; } $data['rows'][] = array('id' => $ligne['ID'], 'cell' => $cell); } echo json_encode($data); }
function categories_match($gpid, $sitname) { $sitname = trim($sitname); if (preg_match("#^www\\.(.+)#", $sitname, $re)) { $sitname = $re[1]; } if (preg_match("#^(.+):[0-9]+]#", $sitname, $re)) { $sitname = $re[1]; } if ($GLOBALS["DEBUG"]) { WLOG("Analyze: Group: {$gpid} `{$sitname}`"); } $categories_get_memory = categories_get_memory($gpid, $sitname); if ($categories_get_memory != null) { if ($GLOBALS["DEBUG"]) { WLOG("Group: {$gpid} `{$sitname}` -> MEMORY: `{$categories_get_memory}` "); } if ($categories_get_memory == "UNKNOWN") { if ($GLOBALS["DEBUG"]) { WLOG("Analyze: Group: FROM MEMORY `{$sitname}` -> UNKNOWN"); } return null; } if ($GLOBALS["DEBUG"]) { WLOG("Analyze: Group: FROM MEMORY `{$sitname}` -> {$categories_get_memory}"); } return $categories_get_memory; } $q = new mysql_catz(); $categoriF = $q->GET_CATEGORIES($sitname); $trans = $q->TransArray(); if ($GLOBALS["DEBUG"]) { WLOG("Group: {$gpid} `{$sitname}` -> RESULTS: `{$categoriF}` "); } if ($categoriF == null) { if ($GLOBALS["DEBUG"]) { WLOG("Group: {$gpid} `{$sitname}` -> SET TO `UNKNOWN` "); } categories_set_memory($gpid, $sitname, "UNKNOWN"); return null; } if (strpos($categoriF, ",") > 0) { $categoriT = explode(",", $categoriF); } else { $categoriT[] = $categoriF; } while (list($a, $b) = each($categoriT)) { if ($GLOBALS["DEBUG"]) { WLOG("Group: {$gpid} `{$sitname}` -> category IS: [{$b}] [" . __LINE__ . "]"); } $MAIN[$b] = true; } $filename = "/etc/squid3/acls/catz_gpid{$gpid}.acl"; $categories = unserialize(@file_get_contents($filename)); while (list($category_table, $category_rule) = each($categories)) { $category_rule = urlencode($category_rule); $categoryname = $trans[$category_table]; if (isset($MAIN[$categoryname])) { if ($GLOBALS["DEBUG"]) { WLOG("FOUND `{$categoryname}` -> `{$category_rule}` "); } categories_set_memory($gpid, $sitname, $category_rule); return $category_rule; } else { if ($GLOBALS["DEBUG"]) { WLOG("Group: {$gpid} `{$sitname}` -> {$categoryname} = NO MATCH [" . __LINE__ . "]"); } } } categories_set_memory($gpid, $sitname, "UNKNOWN"); }
function categories_match($gpid, $sitname, $MD5KEY) { $sitname = trim($sitname); if (preg_match("#^www\\.(.+)#", $sitname, $re)) { $sitname = $re[1]; } if (preg_match("#^(.+):[0-9]+]#", $sitname, $re)) { $sitname = $re[1]; } if ($GLOBALS["DEBUG"]) { WLOG("Analyze: Group: {$gpid} `{$sitname}`"); } $categories_get_memory = categories_get_memory($gpid, $sitname, $MD5KEY); if ($categories_get_memory == 0) { if ($GLOBALS["DEBUG"]) { WLOG("Group: {$gpid} `{$sitname}` -> MEMORY: `{$categories_get_memory}` "); } categories_logs("{$gpid};MEMORY;UNKNOWN/NONE"); if ($GLOBALS["DEBUG"]) { WLOG("Analyze: Group: FROM MEMORY `{$sitname}` -> UNKNOWN"); } return false; } if ($categories_get_memory == 1) { categories_logs("{$gpid};MEMORY;TRUE/-"); if ($GLOBALS["DEBUG"]) { WLOG("Analyze: Group: FROM MEMORY `{$sitname}` -> TRUE"); } return true; } if ($categories_get_memory == 2) { categories_logs("{$gpid};MEMORY;FALSE/-"); if ($GLOBALS["DEBUG"]) { WLOG("Analyze: Group: FROM MEMORY `{$sitname}` -> FALSE"); } return false; } $q = new mysql_catz(); $categoriF = $q->GET_CATEGORIES($sitname); $trans = $q->TransArray(); if ($GLOBALS["DEBUG"]) { WLOG("Group: {$gpid} `{$sitname}` -> RESULTS: `{$categoriF}` "); } if ($categoriF == null) { if ($GLOBALS["DEBUG"]) { WLOG("Group: {$gpid} `{$sitname}` -> SET TO `UNKNOWN` "); } categories_logs("{$gpid};QUERY;UNKNOWN/NONE"); categories_set_memory($gpid, $sitname, 0, $MD5KEY); return false; } if (strpos($categoriF, ",") > 0) { $categoriT = explode(",", $categoriF); } else { $categoriT[] = $categoriF; } while (list($a, $b) = each($categoriT)) { if ($GLOBALS["DEBUG"]) { WLOG("Group: {$gpid} `{$sitname}` -> category IS: [{$b}] [" . __LINE__ . "]"); } $MAIN[$b] = true; } if (!isset($GLOBALS["CONFIG"][$gpid])) { $filename = "/etc/squid3/acls/catz_gpid{$gpid}.acl"; $GLOBALS["CONFIG"][$gpid] = unserialize(@file_get_contents($filename)); } $categories = $GLOBALS["CONFIG"][$gpid]; while (list($category_table, $category_rule) = each($categories)) { $category_rule = urlencode($category_rule); $categoryname = $trans[$category_table]; if ($categoryname == null) { $categoryname = $category_rule; } if (isset($MAIN[$categoryname])) { if ($GLOBALS["DEBUG"]) { WLOG("FOUND `{$categoryname}` -> `{$category_rule}` "); } categories_logs("{$gpid};QUERY;TRUE/{$categoryname}"); categories_set_memory($gpid, $sitname, 1, $MD5KEY); return true; } } categories_logs("{$gpid};QUERY;FALSE/" . @implode(",", $categoriT)); categories_set_memory($gpid, $sitname, 2, $MD5KEY); return false; }