include_once 'ressources/class.mysql.inc'; include_once 'ressources/class.groups.inc'; include_once 'ressources/class.dansguardian.inc'; $usersmenus = new usersMenus(); if (!$usersmenus->AsDansGuardianAdministrator) { $tpl = new templates(); $alert = $tpl->_ENGINE_parse_body('{ERROR_NO_PRIVS}'); echo "alert('{$alert}');"; die; } if (isset($_GET["categories"])) { categories(); exit; } if (isset($_GET["category-search"])) { categories_search(); exit; } if (isset($_GET["add-perso-cat-js"])) { add_category_js(); exit; } if (isset($_GET["add-perso-cat-popup"])) { add_category_popup(); exit; } if (isset($_POST["category_text"])) { add_category_save(); exit; } if (isset($_GET["events"])) {
header("Pragma: no-cache"); header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); $user=new usersMenus(); if(!$user->AsSquidAdministrator){ $tpl=new templates(); echo "alert('".$tpl->javascript_parse_text("{ERROR_NO_PRIVS}").");"; exit; } if(isset($_GET["popup"])){popup();exit;} if(isset($_GET["status"])){status();exit;} if(isset($_GET["categories"])){categories();exit;} if(isset($_GET["cat-search"])){categories_search();exit;} js(); function status(){ $q=new mysql(); $page=CurrentPageName(); $tpl=new templates(); $total=FormatNumber($q->COUNT_ROWS("dansguardian_community_categories","artica_backup"),0,'.',' ',3); $sql="SELECT count(*) as tcount FROM `dansguardian_sitesinfos` WHERE `dbpath` = ''"; $ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup'));
if(isset($_GET["popup"])){page();exit;} if(isset($_GET["tabs"])){tabs();exit;} if(isset($_GET["flow-day"])){flow_day();exit;} if(isset($_GET["flow-month-graph1"])){flow_month_graph1();exit;} if(isset($_GET["flow-month-graph2"])){flow_month_graph2();exit;} if(isset($_GET["websites"])){websites_table();exit;} if(isset($_GET["search-websites"])){websites_search();exit;} if(isset($_GET["members"])){members_table();exit;} if(isset($_GET["search-members"])){members_search();exit;} if(isset($_GET["categories"])){categories_table();exit;} if(isset($_GET["search-categories"])){categories_search();exit;} if(isset($_GET["days"])){days_table();exit;} if(isset($_GET["search-days"])){days_search();exit;} js(); function js(){ header("content-type: application/x-javascript"); $tpl=new templates(); $suffix=suffix();
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"]; $artica = $forceArtica; if (isset($_GET["artica"])) { $artica = true; } $tableSchema = "squidlogs"; if (!$q->BD_CONNECT()) { json_error_show("Testing connection to MySQL server failed...", 1); } if (!$q->TABLE_EXISTS("webfilters_categories_caches")) { $q->CheckTables(); } $dans = new dansguardian_rules(); $dans->LoadBlackListes(); $sql = "SELECT * FROM personal_categories"; if (!$q->TABLE_EXISTS("personal_categories")) { json_error_show("personal_categories no such table!", 1); } $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show("Mysql Error [" . __LINE__ . "]: {$q->mysql_error}", 1); } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $PERSONALSCATS[$ligne["category"]] = $ligne["category_description"]; } $search = '%'; $page = 1; $ORDER = "ORDER BY table_name"; $searchstring = "table_name LIKE 'category_%'"; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if ($artica) { $q = new mysql_catz(); writelogs("Artica mode -> {$q->database} " . $q->COUNT_CATEGORIES(), __FUNCTION__, __FILE__, __LINE__); $tableSchema = "catz"; } if (isset($_POST['page'])) { $page = $_POST['page']; } if ($_POST["query"] != null) { $_POST["query"] = "*{$_POST["query"]}*"; $_POST["query"] = str_replace("**", "*", $_POST["query"]); $_POST["query"] = str_replace("**", "*", $_POST["query"]); $_POST["query"] = str_replace("*", "%", $_POST["query"]); $search = $_POST["query"]; $searchstring = "table_name LIKE 'category_{$search}'"; $sql = "SELECT COUNT( table_name ) AS tcount FROM information_schema.tables WHERE table_schema = '{$tableSchema}' AND table_name LIKE 'category_{$search}'"; 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}", 1); } $total = $ligne["tcount"]; } else { $sql = "SELECT COUNT(table_name) as TCOUNT FROM information_schema.tables WHERE table_schema = '{$tableSchema}' AND table_name LIKE 'category_%'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if (!$q->ok) { json_error_show("Mysql Error [" . __LINE__ . "]: {$q->mysql_error}", 1); } $total = $ligne["TCOUNT"]; writelogs("{$sql} = {$total}", __FUNCTION__, __FILE__, __LINE__); } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT table_name as c,TABLE_ROWS FROM information_schema.tables WHERE table_schema = '{$tableSchema}' AND {$searchstring} {$ORDER} {$limitSql}"; writelogs("{$q->mysql_admin}:{$q->mysql_password}:{$sql}", __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show("Mysql Error [" . __LINE__ . "]: {$q->mysql_error}", 1); } if (mysql_num_rows($results) == 0) { if (!$artica) { categories_search(true); return; } } if (mysql_num_rows($results) == 0) { json_error_show("({$tableSchema}) No categories table found...", 1); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $enc = new mysql_catz(); while ($ligne = mysql_fetch_assoc($results)) { $table = $ligne["c"]; writelogs("Scanning table {$table}", __FUNCTION__, __FILE__, __LINE__); $select = imgtootltip("32-parameters.png", "{apply}", "DansGuardianEditMember('{$ligne["ID"]}','{$ligne["pattern"]}')"); $items = $q->COUNT_ROWS($ligne["c"]); $itemsEnc = $enc->COUNT_ROWS($ligne["c"]); if (!preg_match("#^category_(.+)#", $table, $re)) { continue; } $categoryname = $re[1]; $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_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\tstyle='font-size:14px;font-weight:bold;color:{$color};text-decoration:underline'>"; $text_category = $dans->array_blacksites[$categoryname]; if (isset($PERSONALSCATS[$categoryname])) { $text_category = utf8_encode($PERSONALSCATS[$categoryname]); if ($pic == " ") { $pic = "<img src='img/20-categories-personnal.png'>"; } $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'>"; } if ($EnableWebProxyStatsAppliance == 0) { if ($sizedb_org < 35) { $pic = "<img src='img/warning-panneau-32.png'>"; } } $viewDB = imgsimple("mysql-browse-database-32.png", "{view}", "javascript:Loadjs('squid.categories.php?category={$categoryname}',true)"); $categoryText = $tpl->_ENGINE_parse_body("<div style='font-size:14px';font-weight:bold'>{$linkcat}{$categoryname}</div>\n\t\t</a><div style='font-size:11px;width:100%;font-weight:normal'>{$text_category}</div>"); $items = numberFormat($items, 0, "", " "); $itemsEnc = numberFormat($itemsEnc, 0, "", " "); $compile = imgsimple("compile-distri-32.png", "{saveToDisk} {$categoryname}", "DansGuardianCompileDB('{$categoryname}')"); $delete = imgsimple("delete-32.png", "{delete}", "TableCategoryPurge('{$table}')"); if ($_GET["minisize"] == "yes") { $delete = null; } $cell = array(); $cell[] = $pic; $cell[] = $categoryText; $cell[] = "<div style='font-size:13px;padding-top:15px;font-weight:bold'>{$sizedb}</div>"; if (!$artica) { $cell[] = "<div style='font-size:13px;padding-top:5px;font-weight:bold'>{$items}<br>{$itemsEnc}</strong>"; } else { $cell[] = "<div style='font-size:13px;padding-top:15px;font-weight:bold'>-</strong>"; $cell[] = "<div style='font-size:13px;padding-top:15px;font-weight:bold'>{$items}</strong>"; } $cell[] = $compile; $cell[] = $delete; $data['rows'][] = array('id' => $ligne['ID'], 'cell' => $cell); } echo json_encode($data); }