function status() { $tpl = new templates(); $page = CurrentPageName(); $users = new usersMenus(); $sock = new sockets(); if (!$users->ARTICADB_INSTALLED) { $html = FATAL_ERROR_SHOW_128("{ARTICADB_NOT_INSTALLED_EXPLAIN}") . "<center style='margin:80px'>\n\t\t<hr>" . button("{install_now}", "Loadjs('squid.blacklist.upd.php')", 16) . "</center>"; echo $tpl->_ENGINE_parse_body($html); return; } $date = $sock->getFrameWork("squid.php?articadb-version=yes"); $q = new mysql_catz(); $sock = new sockets(); $ini = new Bs_IniHandler(); $catz = $q->LIST_TABLES_CATEGORIES(); $ini->loadString(base64_decode($sock->getFrameWork('cmd.php?squid-ini-status=yes'))); $APP_ARTICADB = DAEMON_STATUS_ROUND("APP_ARTICADB", $ini, null, 1); $APP_SQUID_DB = DAEMON_STATUS_ROUND("APP_SQUID_DB", $ini, null, 1); $sql = "SHOW VARIABLES LIKE '%version%';"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "<p class=text-error>{$q->mysql_error}</p>"; } else { while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { if ($ligne["Variable_name"] == "slave_type_conversions") { continue; } $tt[] = "\t<tr>\n\t\t\t<td colspan=2><div style='font-size:14px'>{{$ligne["Variable_name"]}}: {$ligne["Value"]}</a></div></td>\n\t\t\t</tr>"; } } $arrayV = unserialize(base64_decode($sock->getFrameWork("squid.php?articadb-nextversion=yes"))); $REMOTE_VERSION = $arrayV["TIME"]; if ($REMOTE_VERSION > $date) { $updaebutton = "<div style='text-align:right'><hr>" . button("{update}:{version} {$REMOTE_VERSION} ", "Loadjs('squid.blacklist.upd.php')", 16) . "</div>"; } $nextcheck = $sock->getFrameWork("squid.php?articadb-nextcheck=yes"); $nextcheck = intval($nextcheck); if ($nextcheck > 0) { $nextcheck_text = "\n\t\t\t<tr>\n\t\t\t<td colspan=2><div style='font-size:16px'>{next_check_in}: {$nextcheck}Mn</div></td>\n\t\t\t</tr>"; } if ($nextcheck < 0) { $nextcheck = str_replace("-", "", $nextcheck); $nextcheckTime = time() - intval($nextcheck) * 60; $nextcheckTimeText = distanceOfTimeInWords($nextcheckTime, time()); $nextcheck_text = "\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=2><div style='font-size:16px'>{last_check}: {$nextcheckTimeText}</div></td>\n\t\t\t\t\t</tr>"; } $dbsize = $sock->getFrameWork("squid.php?articadbsize=yes"); $items = numberFormat($q->COUNT_CATEGORIES(), 0, "", " "); $html = "\n\t\t\t\t<table style='width:100%' class=TableRemove>\n\t\t\t\t<tr>\n\t\t\t\t\t<td width=130px' ><img src='img/spider-database-128.png'></td>\n\t\t\t\t\t<td valign='top'>\n\t\t\t\t<table style='width:99%'>\n\t\t\t\t<tr>\n\t\t\t\t<td valign='top' style='width:320px'>{$APP_ARTICADB}{$APP_SQUID_DB}</td>\n\t\t\t\t<td valign='top' style='padding-left:10px'>\n\t\t\t\t<table style='width:100%'>\n\t\t\t\t<tbody>\n\t\t\t\t<tr>\n\t\t\t\t<td colspan=2><div style='font-size:16px'>{pattern_database_version}: {$date} ({$dbsize})</div></td>\n\t\t\t\t</tr>\n\t\t\t\t{$nextcheck_text}\n\t\t\t\t<tr>\n\t\t\t\t<td colspan=2><div style='font-size:16px'>{categories}: <strong>" . count($catz) . "</strong></a></div></td>\n\t\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan=2><div style='font-size:16px'>{categorized_websites}: <strong>{$items}</strong> </div></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan=2><div style='font-size:16px;font-weight:bold;margin-top:10px'>{mysql_engine}:</div></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t" . @implode("", $tt) . "\n\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t{$updaebutton}\n\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t\t"; echo $tpl->_ENGINE_parse_body($html); }
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); }