function section_websites_search() { $boot = new boostrap_form(); $tpl = new templates(); $q = new mysql_squid_builder(); $page = CurrentPageName(); $table = "visited_sites_tot"; $searchstring = string_to_flexquery("sites-search"); $ORDER = $boot->TableOrder(array("size" => "ASC")); if ($q->COUNT_ROWS($table) == 0) { senderrors("no data"); } $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } while ($ligne = mysql_fetch_assoc($results)) { $md = md5(serialize($ligne)); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $sitenameenc = urlencode($ligne["familysite"]); $js = "Loadjs('miniadm.webstats.familysite.all.php?familysite={$sitenameenc}')"; $link = $boot->trswitch($js); $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t\t<td style='font-size:16px' width=10% nowrap {$link}>{$ligne["familysite"]}</td>\n\t\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["hits"]}</td>\n\t\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["size"]}</td>\n\t\t</tr>\n\t\t"; } echo $boot->TableCompile(array("familysite" => "{familysite}", "hits" => "{hits}", "size" => "{size}"), $tr); }
function tabs() { $tpl = new templates(); $page = CurrentPageName(); $users = new usersMenus(); if (!VerifyRights()) { senderrors("no rights"); } $array["Active Directory"] = "{$page}?activedirectory=yes"; $page = CurrentPageName(); $tpl = new templates(); $t = time(); $boot = new boostrap_form(); echo $boot->build_tab($array); }
function search_session() { $tpl = new templates(); $sock = new sockets(); $datas = unserialize(base64_decode($sock->getFrameWork("squid.php?squid-sessions=yes"))); if (count($datas) == 0) { senderrors("{this_request_contains_no_data}"); } while (list($num, $val) = each($datas)) { if ($val["USER"] == null) { $val["USER"] = $val["CLIENT"]; } else { $val["USER"] = $val["USER"] . "<br><i style='font-size:11px'>{$val["CLIENT"]}</i>"; } $tr[] = "\n\t<tr>\n\t\n\t<td width=33% {$jsedit} style='vertical-align:middle' nowrap>\n\t\t<span style='font-size:18px;font-weight:bold'>{$val["USER"]}</span>\n\t</td>\n\t<td width=33% {$jsedit} style='vertical-align:middle'>\n\t\t<span style='font-size:14px;font-weight:bold'>{$val["URI"]}</span>\n\t</td>\t\n\t<td width=33% {$jsedit} style='vertical-align:middle'nowrap>\n\t\t<span style='font-size:18px;font-weight:bold'>{$val["SINCE"]}</span>\n\t</td>\t\t\n\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t\n\t\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 >{member}</th>\n\t\t\t\t\t<th >{requests}</th>\n\t\t\t\t\t<th >{since}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>") . @implode("", $tr) . "</tbody></table>"; }
function popup() { $filename = "/usr/share/artica-postfix/ressources/logs/web/nginx.importbulk"; $tpl = new templates(); $page = CurrentPageName(); $t = time(); $q = new mysql_squid_builder(); $sql = " SELECT * FROM authenticator_rules WHERE enabled=1 ORDER BY rulename"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } $authrules[null] = "{none}"; while ($ligne = mysql_fetch_assoc($results)) { $authrules[$ligne["ID"]] = $ligne["rulename"]; } $CONF = unserialize(@file_get_contents($filename)); $html = "\n\n\t<div style='font-size:40px;margin-bottom:20px;margin-top:10px'>{bulk_import}</div>\n\t<p class=explain style='font-size:18px'>{nginx_bulk_import_explain}</p>\n\t<div style='width:98%' class=form>\n\t\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend style='font-size:18px'>{remove_old_imports}:</td>\n\t\t<td>" . Field_checkbox("RemoveOldImports", 1, $CONF["RemoveOldImports"]) . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:18px'>{websites}:</td>\n\t\t<td>" . Field_text("RandomText", $CONF["RandomText"], "explain={nginx_import_random_explain};font-size:18px") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:18px'>{authentication}:</td>\n\t\t<td>" . Field_array_Hash($authrules, "authentication", $CONF["authentication"], "style:font-size:18px") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:18px;text-align:left' colspan=2>{destinations}:</td>\n\t</tr>\n\t<tr>\n\t<td colspan=2>\n\t<textarea style='margin-top:5px;font-family:Courier New;\n\tfont-weight:bold;width:95%;height:450px;border:5px solid #8E8E8E;overflow:auto;font-size:14px !important'\n\tid='textToParseCats{$t}'>{$CONF["import"]}</textarea>\n\t</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=2 align='right'>\n\t<hr>\n\t<div style='text-align:right'>\n\t" . button("{submit}", "Save{$t}()", 26) . "</div>\n\t</td>\n\t</tr>\n\t</table>\n</div>\n<script>\n\tvar xSave{$t}=function (obj) {\n\tvar results=obj.responseText;\n\tUnlockPage();\n\tif (results.length>3){\n\t\tdocument.getElementById('textToParseCats{$t}').value=results;\n\t}\n\tExecuteByClassName('SearchFunction');\n}\n\n\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tLockPage();\n\tXHR.appendData('import',encodeURIComponent(document.getElementById('textToParseCats{$t}').value));\n\tif(document.getElementById('RemoveOldImports').checked){\n\t\tXHR.appendData('RemoveOldImports',1);\n\t}else{\n\t\tXHR.appendData('RemoveOldImports',0);\n\t\n\t}\n\tXHR.appendData('RandomText',document.getElementById('RandomText').value);\n\tXHR.appendData('authentication',document.getElementById('authentication').value);\n\tdocument.getElementById('textToParseCats{$t}').value='Please wait....'\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n}\n\n</script>\n"; echo $tpl->_ENGINE_parse_body($html); }
function sources_search() { $boot = new boostrap_form(); $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql_squid_builder(); $table = "authenticator_authlnk"; $ORDER = $boot->TableOrder(array("zorder" => "ASC")); $searchstring = string_to_flexquery("sources-search"); if (!$q->TABLE_EXISTS("authenticator_authlnk")) { $f = new squid_reverse(); } $table = "(\n\tSELECT\n\tauthenticator_authlnk.ID,\n\tauthenticator_authlnk.zorder,\n\tauthenticator_auth.groupname,\n\tauthenticator_auth.group_type,\n\tauthenticator_authlnk.groupid\n\tFROM authenticator_authlnk,authenticator_auth\n\tWHERE authenticator_authlnk.ruleid='{$_GET["mainrule"]}'\n\t\t\tAND authenticator_authlnk.groupid=authenticator_auth.ID\n\t\t\t) as t"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } $AdminPrivs = AdminPrivs(); $t = time(); while ($ligne = mysql_fetch_assoc($results)) { $edit = $boot->trswitch("Loadjs('{$page}?sources-group-js=yes&groupid={$ligne["groupid"]}');"); $md = md5(serialize($ligne)); if ($AdminPrivs) { $delete = imgsimple("delete-48.png", "{delete}", "Delete{$t}('{$ligne["ID"]}','{$md}')"); } $tr[] = "\n\t\t\t<tr id='{$md}'>\n\t\t\t<td style='font-size:18px' width=99% nowrap {$edit}>{$ligne["groupname"]} - " . $tpl->_ENGINE_parse_body($GLOBALS["TYPES"][$ligne["group_type"]]) . "</td>\n\t\t\t<td style='font-size:18px' width=1% nowrap>{$delete}</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t"; } $delete_text = $tpl->javascript_parse_text("{unlink}"); echo $boot->TableCompile(array("rulename" => " {groupname}", "delete" => null), $tr) . "\n\n<script>\nvar mem{$t}='';\n\tvar xDelete{$t}=function(obj){\n\t\tvar tempvalue=obj.responseText;\n\t\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\t\$('#'+mem{$t}).remove();\n\t}\nfunction Delete{$t}(ID,mem){\n\tmem{$t}=mem;\n\tif(confirm('{$delete_text} ID: '+ID+'?')){\n\t\tmem{$t}=mem;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('source-unlink',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n}\n</script>\n\t"; }
function search_caches() { $sock = new sockets(); $DisableAnyCache = $sock->GET_INFO("DisableAnyCache"); if (!is_numeric($DisableAnyCache)) { $DisableAnyCache = 0; } if ($DisableAnyCache == 1) { senderrors("{DisableAnyCache_error_explain}"); } $page = CurrentPageName(); $tpl = new templates(); $delete_cache = $tpl->javascript_parse_text("{delete_cache}"); $WARN_OPE_RESTART_SQUID_ASK = $tpl->javascript_parse_text("{WARN_OPE_RESTART_SQUID_ASK}"); $t = $_GET["t"]; $q = new mysql_squid_builder(); $searchstring = string_to_flexquery("search-caches"); $searchstringRGX = string_to_flexregex("search-caches"); $sql = "SELECT * FROM cachestatus WHERE uuid='{$_GET["uuid"]}' {$searchstring}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error); } if ($GLOBALS["VERBOSE"]) { echo __LINE__ . ":: -> new squidbee()<br>\n"; } $squid = new squidbee(); $boot = new boostrap_form(); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $linkCache = null; $delete = imgtootltip("delete-64.png", "{delete_cache}", "squid32DeleteCache('" . base64_encode($ligne["cachedir"]) . "')"); if (basename($ligne["cachedir"]) == "cache_booster") { $linkCache = $boot->trswitch("Loadjs('squid.booster.php')"); } $NICKEL[$ligne["cachedir"]] = true; if ($ligne["cachedir"] == $squid->CACHE_PATH) { $cache_type = $squid->CACHE_TYPE; $icon = "disk-64-config.png"; $linkCache = $boot->trswitch("Loadjs('squid.caches32.php?add-new-disk-js=yes&chdef=yes')"); $delete = " "; } else { $cache_type = $squid->cache_list[$ligne["cachedir"]]["cache_type"]; } if ($ligne["cachedir"] != $squid->CACHE_PATH) { if (!isset($squid->cache_list[$ligne["cachedir"]])) { $icon = "disk-64-hide.png"; $delete = " "; } } $tr[] = "\n\t\t\t<tr>\n\t\t\t\t<td width=1% nowrap {$linkCache}><img src='img/{$icon}'></td>\n\t\t\t\t<td style='font-size:16px' {$linkCache}>{$ligne["cachedir"]} ({$cache_type})</td>\n\t\t\t\t<td nowrap width=1% style='font-size:16px'>" . FormatBytes($ligne["currentsize"]) . "/" . FormatBytes($ligne["maxsize"]) . "</td>\n\t\t\t\t<td width=1% nowrap>" . pourcentage($ligne["pourc"]) . "</td>\n\t\t\t\t<td width=1% nowrap>{$delete}</td>\n\t\t\t</tr>\n\t\t\t"; } while (list($path, $array) = each($squid->cache_list)) { if (isset($NICKEL[$path])) { continue; } if ($searchstringRGX != null) { if (!preg_match("#{$searchstringRGX}#", $path)) { continue; } } $icon = "disk-64-hide.png"; $unit = " MB"; $maxcachesize = null; if ($array["cache_type"] == "rock") { $maxcachesize = " ({max_objects_size} {$array["cache_maxsize"]}{$unit})"; } if (is_numeric($array["cache_size"])) { if ($array["cache_size"] > 1000) { $array["cache_size"] = $array["cache_size"] / 1000; $unit = " GB"; } } if ($array["cache_type"] == "rock") { continue; } $delete = imgtootltip("delete-64.png", "{delete_cache}", "squid32DeleteCache('" . base64_encode($path) . "')"); $tr[] = "\n\t\t<tr>\n\t\t\t<td width=1% nowrap><img src='img/{$icon}'></td>\n\t\t\t<td style='font-size:16px'>{$path} ({$array["cache_type"]})</td>\n\t\t\t<td nowrap width=1% style='font-size:16px'>{$array["cache_size"]}{$unit}/{$maxcachesize}</td>\n\t\t\t<td width=1% nowrap> </td>\n\t\t\t<td width=1% nowrap>{$delete}</td>\n\t\t</tr>\n\t\t"; } echo $tpl->_ENGINE_parse_body("\n\t\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t<tr>\n\t\t\t\t<th colspan=2>{caches}</th>\n\t\t\t\t<th colspan=2>{used}</th>\n\t\t\t\t\n\t\t\t\t<th> </th>\n\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>\n\t\t\t") . @implode("", $tr) . "</tbody></table>\n\n\t<script>\n\t\n\t\tLoadAjaxTiny('{$t}-license','squid.caches32.php?license-explain=yes');\n\t\t\n\t\t\n\t\tfunction squid32DeleteCache(encoded){\n\t\t\tif(confirm('{$delete_cache} ?\\n{$WARN_OPE_RESTART_SQUID_ASK}')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tXHR.appendData('delete-cache',encoded);\n\t\t\t\tAnimateDiv('caches-32-div');\t\t\n\t\t\t\tXHR.sendAndLoad('squid.caches32.php', 'POST',x_SaveSquid32Caches);\t\t\t\n\t\t\t\n\t\t\t}\n\t\t}\n\n\tvar x_SaveSquid32Caches= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>3){alert(results);return;}\n\t\t\tExecuteByClassName('SearchFunction');\n\t\t}\t\n\n\t</script>"; }
function parents_search() { $sock = new sockets(); $page = CurrentPageName(); $haarp = new haarp(); $tpl = new templates(); $t = time(); $q = new mysql(); $cacheFile = "/usr/share/artica-postfix/ressources/logs/web/squid.peers.db"; $color = "black"; $timefile = filemtime($cacheFile); $lastdate = date("Y-m-d H:i:s", $timefile); $STATUS = unserialize(@file_get_contents($cacheFile)); $searchstring = string_to_flexquery("search-parents"); $users = new usersMenus(); $LIC = 0; if ($users->CORP_LICENSE) { $LIC = 1; } $delete_rule = $tpl->javascript_parse_text("{delete_cache}"); $license_error = $tpl->javascript_parse_text("{license_error}"); $sql = "SELECT * FROM squid_parents WHERE 1 {$searchstring} ORDER BY weight DESC"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { senderrors($q->mysql_error); } $boot = new boostrap_form(); $t = time(); $domains = $tpl->_ENGINE_parse_body("{domains}"); $all = $tpl->_ENGINE_parse_body("{all}"); $fetchesWord = $tpl->_ENGINE_parse_body("{fetches}"); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $status_icon = "42-green.png"; $fetches = null; $ID = $ligne["ID"]; $color = "black"; $delete = imgtootltip("delete-24.png", null, "Delete{$t}('{$ligne["ID"]}')"); $STATUS_KEY = $ligne["servername"]; if (!isset($STATUS[$STATUS_KEY]["STATUS"])) { if (isset($STATUS["Peer{$ligne["ID"]}"])) { $STATUS_KEY = "Peer{$ligne["ID"]}"; } } if ($ligne["icp_port"] > 0) { $ligne["server_port"] = $ligne["server_port"] . "/" . $ligne["icp_port"]; } $ligne3 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(md5) as tcount FROM cache_peer_domain WHERE `servername`='{$ligne["servername"]}'", "artica_backup")); $countDeDomains = $ligne3["tcount"]; if ($countDeDomains == 0) { $countDeDomains = $all; } $array = unserialize(base64_decode($ligne["options"])); if (!isset($STATUS[$STATUS_KEY]["STATUS"])) { $status_icon = "42-green-grey.png"; } else { if ($STATUS[$STATUS_KEY]["STATUS"] == "Down") { $status_icon = "42-red.png"; } } $search = string_to_flexregex("search-options"); if (!is_array($array)) { $array = array(); } $tty = array(); while (list($num, $val) = each($array)) { if ($val != null) { $val = "={$val}"; } $tty[] = "{$num}{$val}"; } $options = @implode(", ", $tty); $js = $boot->trswitch("Loadjs('{$page}?parent-js={$ligne["ID"]}')"); $jsdomains = $boot->trswitch("Loadjs('squid.cache_peer_domain.php?servername={$ligne["servername"]}&t={$t}')"); if (is_numeric($STATUS[$STATUS_KEY]["FETCHES"])) { $fetches = "<span style='font-size:12px'>({$fetchesWord}: " . FormatNumber($STATUS[$STATUS_KEY]["FETCHES"]) . ")</span>"; } if ($ligne["enabled"] == 0) { $status_icon = "42-green-grey.png"; $fetches = "<span style='font-size:12px'>({$fetchesWord}: -)</span>"; $color = "#A7A7A7"; } $tr[] = "\n\t\t<tr id='serv-{$ID}'>\n\t\t<td style='font-size:18px;color:{$color}' {$js} width=1% nowrap><img src='img/{$status_icon}'></td>\n\t\t<td style='font-size:18px;color:{$color}' {$js}>{$ligne["servername"]} {$fetches}<div style='font-size:12px'>{$options}</div></td>\n\t\t<td style='font-size:18px;color:{$color}' {$js}>{$ligne["server_port"]}</code></td>\n\t\t<td style='font-size:18px;color:{$color}' {$js}>{$ligne["server_type"]}</code></td>\n\t\t<td style='font-size:18px;color:{$color}' {$jsdomains}>{$countDeDomains} {$domains}</code></td>\n\t\t<td width=1% nowrap>{$delete}</td>\n\t\t</tr>\n\t\n\t\t"; } $servername = $tpl->_ENGINE_parse_body("{hostname}"); $listen_port = $tpl->_ENGINE_parse_body("{listen_port}"); $server_type = $tpl->_ENGINE_parse_body("{server_type}"); $delete = $tpl->_ENGINE_parse_body("{delete}"); 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 >{status}</th>\n\t\t\t<th >{$servername} ({$lastdate})</th>\n\t\t\t<th >{$listen_port}</th>\n\t\t\t<th>{$server_type}</th>\n\t\t\t<th>{$domains}</th>\n\t\t\t<th> </th>\n\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>") . @implode("", $tr) . "</tbody></table>\n<script>\nvar mem{$t}='';\n\tvar x_Delete{$t}=function(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\$('#serv-'+mem{$t}).remove();\n}\nfunction Delete{$t}(ID){\n\tvar LIC={$LIC};\n\t\n\tif(confirm('{$delete} '+ID+'?')){\n\t\tmem{$t}=ID;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('parent-delete',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_Delete{$t});\n\t\t}\n\t}\n\t</script>"; }
ini_set('error_prepend_string', null); ini_set('error_append_string', null); } if (!isset($_SESSION["uid"])) { writelogs("Redirecto to miniadm.logon.php...", "NULL", __FILE__, __LINE__); header("location:miniadm.logon.php"); } BuildSessionAuth(); if ($_SESSION["uid"] == "-100") { writelogs("Redirecto to location:admin.index.php...", "NULL", __FILE__, __LINE__); header("location:admin.index.php"); die; } $users = new usersMenus(); if (!$users->AsProxyMonitor) { senderrors("Access denied"); } if (isset($_GET["maintenant"])) { maintenant(); exit; } if (isset($_GET["today"])) { today(); exit; } if (isset($_GET["search-today"])) { today_search(); exit; } if (isset($_GET["search"])) { search();
function database_search() { $boot = new boostrap_form(); $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_mailarchive_builder(); $search = string_to_flexquery("search-indextables"); $sql = "SELECT * FROM indextables WHERE 1 {$search} ORDER BY xday DESC"; $results = $q->QUERY_SQL($sql, "mailarchive"); if (!$q->ok) { senderror($q->mysql_error); } if (mysql_num_rows($results) == 0) { senderrors("{this_request_contains_no_data}"); } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $id = md5(serialize($ligne)); $ligne["rowsnum"] = FormatNumber($ligne["rowsnum"]); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $tr[] = "\n\t\t<tr id='{$id}'>\n\t\t<td width=1% nowrap><img src='img/table-show-48.png'></td>\n\t\t<td width=90% nowrap><div style='font-size:18px'>{$ligne["xday"]}</div></td>\n\t\t<td width=90% nowrap><div style='font-size:18px'><div style='font-size:18px'>{$ligne["rowsnum"]}</div></td>\n\t\t<td width=90% nowrap><div style='font-size:18px'><div style='font-size:18px'>{$ligne["size"]}</div></td>\n\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t\n\t\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>{day}</th>\n\t\t\t\t\t<th >{rows}</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("", $tr) . "</tbody></table>"; }
function section_categories_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"; $familysite = $_GET["familysite"]; $search = '%'; $table = date("Ymd", $_GET["xtime"]) . "_hour"; $rp = 250; $page = 1; $boot = new boostrap_form(); $FAMS = $boot->SQUID_CATEGORIES_FAM; $searchstring = string_to_flexquery("categories-search"); $ORDER = $boot->TableOrder(array("size" => "DESC")); if (!$q->TABLE_EXISTS($table)) { senderrors("no such table"); } if ($q->COUNT_ROWS($table) == 0) { senderrors("no data"); } //zDate | client | uid | hostname | MAC | familysite | catfam | hits | size $table = "( SELECT sitename,familysite,category,catfam,SUM(size) as size,SUM(hits) as hits FROM `{$table}` GROUP BY\n\tsitename HAVING familysite='{$familysite}' AND catfam={$_GET["fam"]}) as t"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } while ($ligne = mysql_fetch_assoc($results)) { $md = md5(serialize($ligne)); $fam = $tpl->_ENGINE_parse_body("{$FAMS[$ligne["catfam"]]["TITLE"]}"); $link = null; $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t<td style='font-size:14px' width=50% nowrap {$link}>{$ligne["sitename"]}</td>\n\t\t<td style='font-size:14px' width=1% nowrap {$link}>{$ligne["hits"]}</td>\n\t\t<td style='font-size:14px' width=1% nowrap {$link}>{$ligne["size"]}</td>\n\t\t<td style='font-size:14px' width=1% nowrap {$link}>{$ligne["category"]}</td>\n\t\t<td style='font-size:14px' width=50% {$link}>{$fam}</td>\n\t\t</tr>\n\t\t"; } echo $boot->TableCompile(array("zDate" => "{this_month}", "hits" => "{hits}", "size" => "{size}", "category" => "{category}", "catfam" => "{behavior}"), $tr); }
function pages_search() { $boot = new boostrap_form(); $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql_squid_builder(); $table = "nginx_error_pages"; $ORDER = $boot->TableOrder(array("pagename" => "ASC")); $searchstring = string_to_flexquery("pages-search"); if (!$q->TABLE_EXISTS("nginx_error_pages")) { $f = new squid_reverse(); } $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } $AdminPrivs = AdminPrivs(); $t = time(); while ($ligne = mysql_fetch_assoc($results)) { $edit = $boot->trswitch("Loadjs('{$page}?error-add-js=yes&ID={$ligne["ID"]}');"); $md = md5(serialize($ligne)); if ($AdminPrivs) { $delete = imgsimple("delete-48.png", "{delete}", "Delete{$t}('{$ligne["ID"]}','{$md}')"); } $tr[] = "\n\t\t\t<tr id='{$md}'>\n\t\t\t\t<td style='font-size:18px' width=50% nowrap {$edit}>{$ligne["pagename"]}</td>\n\t\t\t\t<td style='font-size:18px' width=50% nowrap {$edit}>{$ligne["title"]}</td>\n\t\t\t\t<td style='font-size:18px' width=1% nowrap {$edit}>{$ligne["error_code"]}</td>\n\t\t\t\t<td style='font-size:18px' width=1% nowrap>{$delete}</td>\n\t\t\t</tr>\n\t\t\t"; } $delete_text = $tpl->javascript_parse_text("{delete}"); echo $boot->TableCompile(array("pagename" => " {pagename}", "title" => " {page_title}", "error_code" => " {error_code}", "delete" => null), $tr) . "\n\n<script>\nvar mem{$t}='';\n\tvar xDelete{$t}=function(obj){\n\t\tvar tempvalue=obj.responseText;\n\t\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\t\$('#'+mem{$t}).remove();\n\t}\nfunction Delete{$t}(ID,mem){\n\tmem{$t}=mem;\n\tif(confirm('{$delete_text} ID: '+ID+'?')){\n\t\tmem{$t}=mem;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('delete-page',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n}\n</script>\n\t"; }
function www_requests_search() { $page = CurrentPageName(); $tpl = new templates(); $t = time(); $boot = new boostrap_form(); $search = string_to_flexquery("requests-search"); $xtime = $_GET["xtime"]; $dansguardian_table = "dansguardian_events_" . date("Ymd", $xtime); $q = new mysql_squid_builder(); $sql = "SELECT uri,uid,QuerySize as size,hits FROM {$dansguardian_table}\n\tWHERE `sitename`='{$_GET["sitename"]}'\n\tAND HOUR(zDate)={$_GET["hour"]}\n\tAND uid='{$_GET["uid"]}' {$search}"; $results = $q->QUERY_SQL($sql); $results = $q->QUERY_SQL($sql); if (mysql_num_rows($results) == 0) { senderrors("No data"); } $_GET["uid"] = urlencode($_GET["uid"]); if (!$q->ok) { senderrors($q->mysql_error); } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $size = FormatBytes($ligne["size"] / 1024); $hits = FormatNumber($ligne["hits"]); $link = $boot->trswitch("blur()"); $uri = $ligne["uri"]; $tr[] = "\n\t\t<tr>\n\t\t<td><i class='icon-globe'></i>{$uri}</td>\n\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\n\t\t\t<table class='table table-bordered table-hover'>\n\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{requests}</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 webstats_middle_table_items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $sitename = $tpl->javascript_parse_text("{sitename}"); $imapserv = $tpl->_ENGINE_parse_body("{imap_server}"); $account = $tpl->_ENGINE_parse_body("{account}"); // $title=$tpl->_ENGINE_parse_body("$attachments_storage {items}: «$size»"); $filessize = $tpl->_ENGINE_parse_body("{filesize}"); $action_delete_rule = $tpl->javascript_parse_text("{action_delete_rule}"); $enable = $tpl->_ENGINE_parse_body("{enable}"); $compile_rules = $tpl->_ENGINE_parse_body("{compile_rules}"); $online_help = $tpl->_ENGINE_parse_body("{online_help}"); $enabled = $tpl->_ENGINE_parse_body("{enabled}"); $items = $tpl->_ENGINE_parse_body("{items}"); $error_want_operation = $tpl->javascript_parse_text("{error_want_operation}"); $events = $tpl->javascript_parse_text("{events}"); $category = $tpl->javascript_parse_text("{category}"); $title = $tpl->javascript_parse_text("{video_title}"); $size = $tpl->javascript_parse_text("{size}"); $duration = $tpl->javascript_parse_text("{duration}"); $hits = $tpl->javascript_parse_text("{hits}"); $familysite = $tpl->javascript_parse_text("{familysite}"); $video = $tpl->_ENGINE_parse_body("{video}"); $uid = $tpl->_ENGINE_parse_body("{account}"); $ipaddr = $tpl->_ENGINE_parse_body("{ipaddr}"); $hostname = $tpl->_ENGINE_parse_body("{hostname}"); $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 (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']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} ORDER BY hits DESC LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error); } $boot = new boostrap_form(); while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5(serialize($ligne)); $color = "black"; //familysite size hits $urljsSIT = "Loadjs('miniadm.webstats.youtubeid.php?youtubeid={$ligne["youtubeid"]}&xtime={$_GET["xtime"]}');"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $ligne["familysite"] = $q->GetFamilySites($ligne["sitename"]); $truri = $boot->trswitch($urljsSIT); $jsuid = null; if ($ligne["uid"] != null) { $jsuid = $boot->trswitch("Loadjs('miniadm.webstats.ByMember.youtube.Byday.php?uid={$ligne["uid"]}&by=uid&xtime={$_GET["xtime"]}')"); $ligne["uid"] = "<i class='icon-user'></i> {$ligne["uid"]}"; } $tr[] = "\n\t<tr>\n\t\t<td {$truri}><img src='miniadm.webstats.youtube.php?thumbnail={$ligne["youtubeid"]}'></td>\n\t\t<td {$truri}><i class='icon-facetime-video'></i> {$ligne["title"]}</td>\n\t\t<td nowrap {$jsuid}>{$ligne["uid"]}</td>\n\t\t<td nowrap {$jsuid}><i class='icon-user'></i> {$ligne["ipaddr"]}</td>\n\t\t<td nowrap {$jsuid}><i class='icon-user'></i> {$ligne["hostname"]}</td>\n\t\t<td nowrap {$jsuid}><i class='icon-user'></i> {$ligne["MAC"]}</td>\n\t\t<td width=1% align=center>{$ligne["hits"]}</td>\n\t</tr>\n\t"; } 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<th colspan=2>{$video}</th>\n\t\t\t<th>{member}</th>\n\t\t\t<th>{ipaddr}</th>\n\t\t\t<th>{hostname}</th>\n\t\t\t<th>{MAC}</th>\n\t\t\t<th>{hits}</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t\t ") . @implode("\n", $tr) . " \n\t\t</tbody>\n\t</table>"; }
function search_certificates() { $boot = new boostrap_form(); $page = CurrentPageName(); $tpl = new templates(); $q = new mysql(); $search = string_to_flexquery("search-certificates"); $sql = "SELECT * FROM sslcertificates WHERE 1 {$search} ORDER BY CommonName"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { senderror($q->mysql_error); } if (mysql_num_rows($results) == 0) { senderrors("{this_request_contains_no_data}"); } $db = file_get_contents(dirname(__FILE__) . '/ressources/databases/ISO-3166-Codes-Countries.txt'); $tbl = explode("\n", $db); while (list($num, $ligne) = each($tbl)) { if (preg_match('#(.+?);\\s+([A-Z]{1,2})#', $ligne, $regs)) { $regs[2] = trim($regs[2]); $regs[1] = trim($regs[1]); $array_country_codes["{$regs[1]}_{$regs[2]}"] = $regs[1]; } } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $id = md5(serialize($ligne)); if ($ligne["CountryName"] == null) { $ligne["CountryName"] = "UNITED STATES_US"; } if ($ligne["stateOrProvinceName"] == null) { $ligne["stateOrProvinceName"] = "New York"; } if ($ligne["localityName"] == null) { $ligne["localityName"] = "Brooklyn"; } if ($ligne["emailAddress"] == null) { $ligne["emailAddress"] = "*****@*****.**"; } if ($ligne["OrganizationName"] == null) { $ligne["OrganizationName"] = "MyCompany Ltd"; } if ($ligne["OrganizationalUnit"] == null) { $ligne["OrganizationalUnit"] = "IT service"; } $CountryName = $array_country_codes[$ligne["CountryName"]]; $CommonName = urlencode($ligne["CommonName"]); $link = $boot->trswitch("Loadjs('{$page}?certificate-edit-js=yes&CommonName={$CommonName}')"); $delete = imgsimple("delete-64.png", null, "Loadjs('{$page}?delete-certificate-js={$CommonName}&id={$id}')"); $tr[] = "\n\t\t<tr id='{$id}'>\n\t\t<td width=1% nowrap {$link}><img src='img/certificate-download-64.png'></td>\n\t\t<td width=90% nowrap {$link}><div style='font-size:18px'>{$ligne["CommonName"]}</div>\n\t\t\t<div style='font-size:16px'>{$CountryName},{$ligne["stateOrProvinceName"]},{$ligne["localityName"]}</div>\n\t\t\t<div style='font-size:12px'>{$ligne["OrganizationName"]} {$ligne["OrganizationalUnit"]}</div>\n\t\t\n\t\t</td>\n\t\t<td width=5% nowrap {$link}>{$ligne["emailAddress"]}</td>\n\t\t<td width=1% nowrap>{$delete}</td>\n\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t\n\t\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 colspan=2>{certificate}</th>\n\t\t\t\t\t<th >{email}</th>\n\t\t\t\t\t<th > </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 tasks_search() { $boot = new boostrap_form(); $tpl = new templates(); $q = new mysql(); $t = time(); if (isset($_GET["t"])) { $t = $_GET["t"]; } $page = CurrentPageName(); $table = "system_schedules"; $searchstring = string_to_flexquery("search-tasks"); $ORDER = $boot->TableOrder(array("ID" => "DESC")); if ($q->COUNT_ROWS($table, "artica_backup") == 0) { senderrors("{no_task}"); } if ($_GET["task-section"] > 0) { $table = "( SELECT * FROM {$table} WHERE `TaskType`={$_GET["task-section"]} ) as T"; } $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } $schedules = new system_tasks(); while ($ligne = mysql_fetch_assoc($results)) { $color = "black"; $events = " "; $md = md5(serialize($ligne)); $TaskType = $ligne["TaskType"]; $jstaskexplain = $tpl->javascript_parse_text($schedules->tasks_array[$ligne["TaskType"]]); $ligne["TaskType"] = $tpl->_ENGINE_parse_body($schedules->tasks_array[$ligne["TaskType"]]); $TimeDescription = $ligne["TimeDescription"]; $delete = imgtootltip("delete-32.png", "{delete} {$ligne['ID']}", "Delete{$t}('{$ligne['ID']}','{$md}')"); $run = $tpl->_ENGINE_parse_body(imgtootltip("24-run.png", "{run} {$ligne['ID']}", "SystemTaskRun('{$ligne['ID']}','{$jstaskexplain}')")); if ($ligne["enabled"] == 0) { $color = "#A0A0A0"; } $tablename = "Taskev{$ligne['ID']}"; if (!$q->TABLE_EXISTS($tablename, "artica_events")) { $events = null; } else { $evs = $q->COUNT_ROWS($tablename, "artica_events"); if ($evs > 0) { $events = imgsimple("events-32.png"); } } $explainTXT = $tpl->_ENGINE_parse_body($schedules->tasks_explain_array[$TaskType]); $TimeText = $tpl->_ENGINE_parse_body($schedules->PatternToHuman($ligne["TimeText"])); $TimeText = str_replace("<br>", "", $TimeText); if (preg_match("#(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)#", $TimeDescription, $re)) { $TimeDescription = $TimeText; $TimeText = null; } $js = "Loadjs('{$page}?schedule-js=yes&ID={$ligne['ID']}')"; $link = $boot->trswitch($js); $ligne["TimeDescription"] = utf8_encode($ligne["TimeDescription"]); $ligne["TaskType"] = utf8_encode($ligne["TaskType"]); $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne['ID']}</td>\n\t\t<td style='font-size:16px' width=25% nowrap {$link}>{$ligne["TaskType"]}</td>\n\t\t<td style='font-size:16px' width=70% {$link}>{$TimeDescription}<br>{$explainTXT}</td>\n\t\t<td style='font-size:16px' width=1% nowrap >{$run}</td>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$events}</td>\n\t\t<td style='font-size:12px' width=1%>{$delete}</td>\n\t\t</tr>\n\t\t"; } $run_this_task_now = $tpl->javascript_parse_text("{run_this_task_now}"); $delete_text = $tpl->javascript_parse_text("{delete_this_task}"); echo $boot->TableCompile(array("ID" => "ID", "TaskType" => "{type}", "TimeText" => "{explain}", "run:no" => "{run}", "event:no" => "{events}", "delete:no" => null), $tr) . "\n<script>\nvar mem{$t}='';\nvar xDelete{$t}=function(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\$('#'+mem{$t}).remove();\n}\nfunction Delete{$t}(ID,mem){\n\tmem{$t}=mem;\n\tif(confirm('{$delete_text} ID: '+ID+'?')){\n\t\tmem{$t}=mem;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('task-delete',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n}\nvar xSystemTaskEnable{$t}=function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>0){alert(results);}\n\tExecuteByClassName('SearchFunction');\t\t\n}\n\nfunction SystemTaskRun{$t}(ID){\n\tif(confirm('{$run_this_task_now} :`'+ID+'`')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('task-run',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xSystemTaskEnable{$t});\t\t\n\t}\n}\n\t\t\t\n</script>\n\t\t\t\n"; }
function events_search() { $boot = new boostrap_form(); $tpl = new templates(); $q = new mysql(); $page = CurrentPageName(); $table = "mirror_logs"; $searchstring = string_to_flexquery("search-events"); $ORDER = $boot->TableOrder(array("zDate" => "DESC")); if ($q->COUNT_ROWS($table, "artica_events") == 0) { senderrors("no data"); } $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } while ($ligne = mysql_fetch_assoc($results)) { $md = md5(serialize($ligne)); if ($ligne["totalsize"] > 0) { $ligne["totalsize"] = FormatBytes($ligne["totalsize"] / 1024); } $distance = $tpl->_ENGINE_parse_body(distanceOfTimeInWords($ligne["starton"], $ligne["endon"])); $link = null; $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["zDate"]}</td>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["pid"]}</td>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$distance}</td>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["filesnumber"]}</td>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["totalsize"]}</td>\n\t\t<td style='font-size:12px' width=99% {$link}>{$ligne["error"]}</td>\n\t\t</tr>\n\t\t"; } echo $boot->TableCompile(array("zDate" => "{date}", "pid" => "pid", "endon" => "{duration}", "filesnumber" => "{files}", "size" => "{size}", "error" => "{error}"), $tr); }
function sessions_search() { $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $t = time(); $searchstring = string_to_flexregex("sessions-search"); $arrayS = unserialize(base64_decode($sock->getFrameWork("chilli.php?query=yes"))); if (!is_array($arrayS)) { senderrors("no data"); } while (list($ID, $array) = each($arrayS)) { $md = md5(serialize($array)); if ($searchstring != null) { if (!preg_match("#{$searchstring}#", serialize($array))) { continue; } } $MAC = $array["MAC"]; $IP = $array["IP"]; $STATUS = $array["STATUS"]; $UID = $array["UID"]; $URI = $array["URI"]; $delete = " "; $img = "ok32-grey.png"; $color = "#A2A2A2"; $delete = null; if ($STATUS == "pass") { $img = "ok32.png"; $color = "black"; $delete = imgtootltip("delete-32.png", null, "Delete{$t}('{$ID}')"); } else { $delete = imgtootltip("check-32.png", null, "Connect{$t}('{$ID}')"); if ($UID != null) { $color = "black"; } } $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t<td width=1% nowrap style='vertical-align:middle;text-align:center'><img src='img/{$img}'></td>\n\t\t<td width=5% style='vertical-align:middle' nowrap><span style='font-size:18px;font-weight:bold;color:{$color}'>{$UID}</span></td>\n\t\t<td width=5% style='vertical-align:middle' nowrap><span style='font-size:18px;font-weight:bold;color:{$color}'>{$IP}</span></td>\n\t\t<td width=5% style='vertical-align:middle' nowrap><span style='font-size:18px;font-weight:bold;color:{$color}'>{$MAC}</span></td>\n\t\t<td width=1% nowrap style='vertical-align:middle;text-align:center'>{$delete}</td>\n\t\t</tr>\n\t\t"; } $deleteTXT = $tpl->javascript_parse_text("{disconnect_session}"); echo $tpl->_ENGINE_parse_body("\n<table class='table table-bordered table-hover'>\n<thead>\n\t<tr>\n\t\t<th colspan=2>{members} {$searchstring}</th>\n\t\t<th>{ipaddr}</th>\n\t\t<th>{MAC}</th>\n\t\t<th> </th>\n\t</tr>\n</thead>\n<tbody>") . @implode("", $tr) . "</tbody></table>\n\t<script>\nvar FreeWebIDMEM{$t}='';\n\tvar xDelete{$t}=function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>10){alert(results);return;}\n\tExecuteByClassName('SearchFunction');\n\t}\n\t\nfunction Delete{$t}(id){\n\tif(confirm('{$deleteTXT} \"'+id+'\" ?')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('session-delete',id);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n}\nfunction Connect{$t}(id){\n\tif(confirm('Allow \"'+id+'\" ?')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('session-connect',id);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n}\t</script>"; }
function EXPLAIN_RULE($ID) { $page = CurrentPageName(); $q = new mysql_squid_builder(); $table = "(\n\tSELECT\n\tauthenticator_sourceslnk.ID,\n\tauthenticator_sourceslnk.zorder,\n\tauthenticator_sourceslnk.groupid,\n\tauthenticator_groups.groupname,\n\tauthenticator_groups.enabled,\n\tauthenticator_groups.group_type\n\tFROM authenticator_sourceslnk,authenticator_groups\n\tWHERE authenticator_sourceslnk.ruleid='{$ID}'\n\tAND authenticator_sourceslnk.groupid=authenticator_groups.ID\n\t) as t"; $sql = "SELECT * FROM {$table} WHERE 1 ORDER BY zorder"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } $t = time(); $Mainedit = "Loadjs('{$page}?rules-js={$ID}');"; while ($ligne = mysql_fetch_assoc($results)) { $enabled = null; if ($ligne["enabled"] == 0) { $enabled = " ({disabled}) "; } $edit = "Loadjs('{$page}?rules-sources-group-js=yes&groupid={$ligne["groupid"]}');"; $a = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$edit}\">"; $IF[] = " {$a}" . $GLOBALS["SOURCE_TYPE"][$ligne["group_type"]] . "</a>{$enabled}"; } $table = "(\n\tSELECT\n\tauthenticator_authlnk.ID,\n\tauthenticator_authlnk.zorder,\n\tauthenticator_auth.groupname,\n\tauthenticator_auth.group_type,\n\tauthenticator_auth.enabled,\n\tauthenticator_authlnk.groupid\n\tFROM authenticator_authlnk,authenticator_auth\n\tWHERE authenticator_authlnk.ruleid='{$ID}'\n\t\t\tAND authenticator_authlnk.groupid=authenticator_auth.ID\n\t\t\t\t) as t"; $sql = "SELECT * FROM {$table} WHERE 1 ORDER BY zorder"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } $t = time(); while ($ligne = mysql_fetch_assoc($results)) { $enabled = null; if ($ligne["enabled"] == 0) { $enabled = " ({disabled}) "; } $js = "Loadjs('miniadmin.nginx.authenticator.sources.php?sources-group-js=yes&groupid={$ligne["groupid"]}');"; $THEN[] = $GLOBALS["DEST_TYPES"][$ligne["group_type"]] . " {with_group} \n\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\">{$ligne["groupname"]}</a>{$enabled}"; } $tpl = new templates(); $a = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$Mainedit}\">"; $line = "{$a}{rule}</a>: {if} " . @implode(" {and} ", $IF) . " {then} " . @implode(" {or} ", $THEN); return $tpl->_ENGINE_parse_body($line); }
function bridge_search() { $boot = new boostrap_form(); $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql(); $table = "iptables_bridge"; $database = "artica_backup"; $t = time(); $ORDER = $boot->TableOrder(array("ID" => "DESC")); $sock = new sockets(); $net = new networking(); $ip = new IP(); $interfaces = unserialize(base64_decode($sock->getFrameWork("cmd.php?ifconfig-interfaces=yes"))); $searchstring = string_to_flexquery("search-bridge"); $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } $net = new networking(); while ($ligne = mysql_fetch_assoc($results)) { $md = md5(serialize($ligne)); $ip = new IP(); $img = "folder-network-48.png"; $cdir = $ligne["cdir"]; $eth = "br{$ligne["ID"]}"; $eth_text = "br{$ligne["ID"]}"; $array = $net->GetNicInfos($ligne["nic_inbound"]); $nic_inbound_ip = $array["IPADDR"]; $array = $net->GetNicInfos($ligne["nic_linked"]); $nic_linked_ip = $array["IPADDR"]; $delete = imgsimple("delete-48.png", "{delete}", "Delete{$t}('{$ligne["ID"]}','{$md}')"); $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t\t<td style='font-size:18px' width=1% nowrap><img src='img/{$img}'></td>\n\t\t\t<td style='font-size:18px' width=1% nowrap>{$ligne["nic_inbound"]} - {$nic_inbound_ip}</td>\n\t\t\t<td style='font-size:18px' width=10% nowrap>{$ligne["nic_linked"]} - {$nic_linked_ip}</td>\n\t\t\t<td style='font-size:18px' width=1% nowrap>{$delete}</td>\n\t\t</tr>\n\t\t"; } $delete_text = $tpl->javascript_parse_text("{delete_nic_bridge}"); echo $boot->TableCompile(array("ID" => "ID", "nic_inbound" => "{from}", "nic_linked" => "{to}", "delete" => null), $tr) . "\n\t\t\t\t\t\n<script>\nvar mem{$t}='';\nvar xDelete{$t}=function(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\$('#'+mem{$t}).remove();\n}\nfunction Delete{$t}(ID,mem){\n\tmem{$t}=mem;\n\tif(confirm('{$delete_text} ID: '+ID+'?')){\n\t\tmem{$t}=mem;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('bridge-delete',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t\t}\n\t}\n</script>\t\t\t\t\t\n"; }
function etchosts_search() { $boot = new boostrap_form(); $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql(); $table = "net_hosts"; $database = "artica_backup"; $t = time(); if ($q->COUNT_ROWS($table, $database) == 0) { $sock->getFrameWork("system.php?etchosts-default=yes"); } $ORDER = $boot->TableOrder(array("hostname" => "ASC")); $sock = new sockets(); $net = new networking(); $ip = new IP(); $interfaces = unserialize(base64_decode($sock->getFrameWork("cmd.php?ifconfig-interfaces=yes"))); $searchstring = string_to_flexquery("search-etchosts"); $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } $net = new networking(); while ($ligne = mysql_fetch_assoc($results)) { $md = md5(serialize($ligne)); $delete = imgsimple("delete-48.png", "{delete}", "Delete{$t}('{$ligne["zmd5"]}','{$md}','{$ligne["hostname"]}@{$ligne["ipaddr"]}')"); $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t\t<td style='font-size:20px' width=90% nowrap >{$ligne["hostname"]}</td>\n\t\t\t<td style='font-size:20px' width=5% nowrap >{$ligne["ipaddr"]}</td>\n\t\t\t<td style='font-size:20px' width=5% nowrap >{$ligne["alias"]}</td>\n\t\t\t<td style='font-size:20px' width=1% nowrap>{$delete}</td>\n\t\t</tr>\n\t\t"; } $delete_text = $tpl->javascript_parse_text("{delete_nic_etchosts}"); echo $boot->TableCompile(array("hostname" => "{hostname}", "ipaddr" => "{ipaddr}", "alias" => "{alias}", "delete" => null), $tr) . "\n\t\t\t\t\t\n<script>\nvar mem{$t}='';\nvar xDelete{$t}=function(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\$('#'+mem{$t}).remove();\n}\nfunction Delete{$t}(md5,mem,ipaddr){\n\tmem{$t}=mem;\n\tif(confirm('{$delete_text}: '+ipaddr+'?')){\n\t\tmem{$t}=mem;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('etchosts-delete',md5);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t\t}\n\t}\n</script>\t\t\t\t\t\n"; }
function events_rotate_table() { $q = new mysql_storelogs(); $boot = new boostrap_form(); $table = "evnts"; $rows = $q->COUNT_ROWS($table); if ($rows == 0) { senderror("{$table} is empty"); } $ORDER = $boot->TableOrder(array("zDate" => "DESC")); $searchstring = string_to_flexquery("search-rotate-events"); $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } $tpl = new templates(); while ($ligne = mysql_fetch_assoc($results)) { $md = md5(serialize($ligne)); $ligne["content"] = $tpl->_ENGINE_parse_body($ligne["content"]); $ligne["content"] = str_replace("\n", "<br>", $ligne["content"]); $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t<td style='font-size:12px' width=1% nowrap>{$ligne["zDate"]}</td>\n\t\t<td style='font-size:12px' width=1% nowrap>{$ligne["hostname"]}</td>\n\t\t<td style='font-size:12px' width=30% nowrap>{$ligne["subject"]}</td>\n\t\t<td style='font-size:12px' width=70% nowrap>{$ligne["content"]}</td>\n\t\t</tr>\n\t\t"; } echo $boot->TableCompile(array("zDate" => " {zDate} {$rows} {rows}", "hostname" => "{hostname}", "subject" => "{subject}", "content" => null), $tr); }
function save_network_results() { 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"); if (!is_file("/usr/share/artica-postfix/ressources/logs/web/exec.virtuals-ip.php.html")) { senderrors("exec.virtuals-ip.php.html no such file, please wait..;"); } $f = explode("\n", file_get_contents("/usr/share/artica-postfix/ressources/logs/web/exec.virtuals-ip.php.html")); $tpl = new templates(); $page = CurrentPageName(); $t = time(); $title = $tpl->_ENGINE_parse_body("{close}"); krsort($f); $html = "\n\t<div><code style='font-size:12px;white-space:normal;background-color:transparent;border:0px'>"; while (list($index, $val) = each($f)) { $html = $html . "{$val}<br>"; } echo $html . "</code></div>"; }
function virtip_search() { $boot = new boostrap_form(); $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $q = new mysql(); $table = "nics_virtuals"; $database = "artica_backup"; $t = time(); $ORDER = $boot->TableOrder(array("ID" => "DESC")); $sock = new sockets(); $net = new networking(); $ip = new IP(); $interfaces = unserialize(base64_decode($sock->getFrameWork("cmd.php?ifconfig-interfaces=yes"))); $searchstring = string_to_flexquery("search-virtip"); $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } $net = new networking(); while ($ligne = mysql_fetch_assoc($results)) { $md = md5(serialize($ligne)); $ip = new IP(); $cdir = $ligne["cdir"]; $eth = "{$ligne["nic"]}:{$ligne["ID"]}"; $eth_text = "{$ligne["nic"]}:{$ligne["ID"]}"; if ($ligne["cdir"] == null) { $ligne["cdir"] = $net->array_TCP[$ligne["nic"]]; $eth = $ligne["nic"]; } if ($ligne["cdir"] == null) { $ligne["cdir"] = $net->array_TCP[$ligne["nic"]]; $eth = $ligne["nic"]; } $img = "folder-network-48.png"; if ($interfaces["{$ligne["nic"]}.{$ligne["ID"]}"] != null) { $img = "folder-network-48-grey.png"; } if (trim($ligne["org"]) == null) { $ligne["org"] = $tpl->_ENGINE_parse_body("<strong style='color:red'>{no_organization}</strong>"); } $edit = $boot->trswitch("Loadjs('{$page}?virtid-js={$ligne["ID"]}')"); $delete = imgsimple("delete-48.png", "{delete}", "Delete{$t}('{$ligne["ID"]}','{$md}')"); $a = $ip->parseCIDR($cdir); if ($a[0] == 0) { $img = "warning-panneau-24.png"; $cdir = "<span style='color:red'>{$cdir}</span>"; } $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t\t<td style='font-size:18px' width=48px nowrap {$edit}><img src='img/{$img}'></td>\n\t\t\t<td style='font-size:18px' width=1% nowrap {$edit}>{$eth_text}</td>\n\t\t\t<td style='font-size:18px' width=90% nowrap {$edit}>{$ligne["org"]}</td>\n\t\t\t<td style='font-size:18px' width=10% nowrap {$edit}>{$ligne["nic"]}</td>\n\t\t\t<td style='font-size:18px' width=5% nowrap {$edit}>{$ligne["ipaddr"]}</td>\n\t\t\t<td style='font-size:18px' width=5% nowrap {$edit}>{$ligne["netmask"]}</td>\n\t\t\t<td style='font-size:18px' width=1% nowrap>{$delete}</td>\n\t\t</tr>\n\t\t"; } $delete_text = $tpl->javascript_parse_text("{delete}"); echo $boot->TableCompile(array("ID" => "ID:colspan=2", "org" => " {organization}", "nic" => "{nic}", "ipaddr" => "{ipaddr}", "netmask" => "{netmask}", "delete" => null), $tr) . "\n\t\t\t\t\t\n<script>\nvar mem{$t}='';\nvar xDelete{$t}=function(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\$('#'+mem{$t}).remove();\n}\nfunction Delete{$t}(ID,mem){\n\tmem{$t}=mem;\n\tif(confirm('{$delete_text} ID: '+ID+'?')){\n\t\tmem{$t}=mem;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('virtip-delete',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t\t}\n\t}\n</script>\t\t\t\t\t\n"; }
function service() { $page = CurrentPageName(); $t = time(); $tpl = new templates(); $sock = new sockets(); $datas = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig"))); $squid = new squidbee(); $users = new usersMenus(); $url_rewrite_bypass = $squid->url_rewrite_bypass; $ufdbguardReloadTTL = $sock->GET_INFO("ufdbguardReloadTTL"); $EnableGoogleSafeSearch = $sock->GET_INFO("EnableGoogleSafeSearch"); $UfdbDatabasesInMemory = $sock->GET_INFO("UfdbDatabasesInMemory"); $EnableUfdbGuard = $sock->EnableUfdbGuard(); if ($datas["enforce-https-with-hostname"] == null) { $datas["enforce-https-with-hostname"] = 0; } if ($datas["enforce-https-official-certificate"] == null) { $datas["enforce-https-official-certificate"] = 0; } if ($datas["https-prohibit-insecure-sslv2"] == null) { $datas["https-prohibit-insecure-sslv2"] = 0; } if (!is_numeric($datas["url-lookup-result-during-database-reload"])) { $datas["url-lookup-result-during-database-reload"] = 1; } if (!is_numeric($datas["url-lookup-result-when-fatal-error"])) { $datas["url-lookup-result-when-fatal-error"] = 1; } if (!is_numeric($datas["check-proxy-tunnel"])) { $datas["check-proxy-tunnel"] = 1; } if (!is_numeric($datas["strip-domain-from-username"])) { $datas["strip-domain-from-username"] = 0; } if (!is_numeric($datas["refreshuserlist"])) { $datas["refreshuserlist"] = 15; } if (!is_numeric($datas["refreshdomainlist"])) { $datas["refreshdomainlist"] = 15; } if (!is_numeric($EnableUfdbGuard)) { $EnableUfdbGuard = 0; } if (!is_numeric($UfdbDatabasesInMemory)) { $UfdbDatabasesInMemory = 0; } if (!is_numeric($datas["allow-unknown-protocol-over-https"])) { $datas["allow-unknown-protocol-over-https"] = 1; } if (!isset($datas["tcpsockets"])) { $datas["tcpsockets"] = 0; } if (!isset($datas["listen_addr"])) { $datas["listen_addr"] = "all"; } if (!isset($datas["listen_port"])) { $datas["listen_port"] = "3977"; } if ($datas["listen_addr"] == null) { $datas["listen_addr"] = "all"; } if (!is_numeric($datas["listen_port"])) { $datas["listen_port"] = "3977"; } if (!is_numeric($datas["tcpsockets"])) { $datas["tcpsockets"] = 0; } if (!is_numeric($datas["DebugAll"])) { $datas["DebugAll"] = 0; } if (!is_numeric($ufdbguardReloadTTL)) { $ufdbguardReloadTTL = 10; } if (!is_numeric($EnableGoogleSafeSearch)) { $EnableGoogleSafeSearch = 1; } $WEBSTATS_APPLIANCE = 0; if ($users->WEBSTATS_APPLIANCE) { $WEBSTATS_APPLIANCE = 1; $datas["tcpsockets"] = 1; } $sys = new networking(); $ips = $sys->ALL_IPS_GET_ARRAY(); if ($users->WEBSTATS_APPLIANCE) { unset($ips["127.0.0.1"]); } $as27 = 0; if ($squid->IS_27) { senderrors("{not_supported} SQUID v2.7"); } $ips["all"] = "{all}"; $boot = new boostrap_form(); $boot->set_spacertitle("{feature}"); $boot->set_checkbox("EnableUfdbGuard", "{EnableUfdbGuard}", "{$EnableUfdbGuard}", array("DISABLEALL" => true)); $boot->set_spacertitle("SSL"); $boot->set_checkbox("enforce-https-with-hostname", "{enforce-https-with-hostname}", $datas["enforce-https-with-hostname"], array("TOOLTIP" => "{UFDBGUARD_SSL_OPTS}")); $boot->set_checkbox("enforce-https-official-certificate", "{enforce-https-official-certificate}", $datas["enforce-https-official-certificate"]); $boot->set_checkbox("https-prohibit-insecure-sslv2", "{https-prohibit-insecure-sslv2}", $datas["https-prohibit-insecure-sslv2"]); $boot->set_checkbox("allow-unknown-protocol-over-https", "{allow-unknown-protocol-over-https}", $datas["allow-unknown-protocol-over-https"]); $boot->set_checkbox("check-proxy-tunnel", "{check-proxy-tunnel}", $datas["check-proxy-tunnel"]); $boot->set_spacertitle("{UFDBGUARD_SERVICE_OPTS}"); $boot->set_checkbox("DebugAll", "{verbose_mode}", $datas["DebugAll"]); $boot->set_checkbox("UfdbDatabasesInMemory", "{UfdbDatabasesInMemory}", $UfdbDatabasesInMemory, array("TOOLTIP" => "{UfdbDatabasesInMemory_explain}")); $boot->set_field("ufdbguardReloadTTL", "{minimum_reload_interval} {minutes}", $ufdbguardReloadTTL); $boot->set_checkbox("tcpsockets", "{enable_tcpsockets}", $datas["tcpsockets"], array("LINK" => "listen_addr,listen_port")); $boot->set_list("listen_addr", "{listen_address}", $ips, $datas["listen_addr"]); $boot->set_field("listen_port", "{listen_port}", $datas["listen_port"]); $boot->set_checkbox("EnableGoogleSafeSearch", "{EnableGoogleSafeSearch}", $EnableGoogleSafeSearch); $boot->set_checkbox("strip-domain-from-username", "{strip-domain-from-username}", $datas["strip-domain-from-username"]); $boot->set_checkbox("refreshuserlist", "{refreshuserlist} ({minutes})", $datas["refreshuserlist"]); $boot->set_checkbox("refreshdomainlist", "{refreshdomainlist} ({minutes})", $datas["refreshdomainlist"]); $boot->set_spacertitle("{ON_ERRORS}"); $boot->set_checkbox("url_rewrite_bypass", "{bypass_iffailed}", $url_rewrite_bypass, array("TOOLTIP" => "{url_rewrite_bypass_explain}")); $boot->set_checkbox("url-lookup-result-during-database-reload", "{url-lookup-result-during-database-reload}", $datas["url-lookup-result-during-database-reload"]); $boot->set_checkbox("url-lookup-result-when-fatal-error", "{url-lookup-result-when-fatal-error}", $datas["url-lookup-result-when-fatal-error"]); $boot->set_button("{apply}"); $users = new usersMenus(); if (!$users->AsDansGuardianAdministrator) { $boot->set_form_locked(); } $form = $boot->Compile(); $html = "<table style='width:100%'>\n\t<tr>\n\t\t<td style='vertical-align:top;width:400px'>\n\t\t\t<div id='{$t}'></div>\n\t\t\t<div style='text-aling:right'>" . imgtootltip("refresh-32.png", null, "LoadAjax('{$t}','{$page}?ufdbguard-status=yes');") . "</div>\n\t\t\t</td>\n\t\t<td style='vertical-align:top;padding-left:20px'>{$form}</td>\n\t</tr>\n\t</table>\n\t<script>\n\t\tLoadAjax('{$t}','{$page}?ufdbguard-status=yes');\n\t</script>\n\t\t\t\n\t"; echo $html; }
function table_blocked() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $dt = strtotime("{$_GET["zday"]} 00:00:00"); if (isset($_SESSION["QUERY_BLOCKED_DATE"])) { $dt = $_SESSION["QUERY_BLOCKED_DATE"]; } $zday = date('Ymd', $dt); $title_date = time_to_date($dt); $MAIN_QUERY = $_GET["query-blocked"]; $search = '%'; $table = $zday . "_blocked"; if (!$q->TABLE_EXISTS($table)) { senderrors("{no_such_table}:{$table}"); } $main_query = $_GET["query-blocked"]; $QUERY_BLOCKED_UID = $_SESSION["QUERY_BLOCKED_UID"]; $QUERY_BLOCKED_CATEGORY = $_SESSION["QUERY_BLOCKED_CATEGORY"]; $BLOCKED_CATEGORY_LIMIT = $_SESSION["BLOCKED_CATEGORY_LIMIT"]; if (!is_numeric($BLOCKED_CATEGORY_LIMIT)) { $BLOCKED_CATEGORY_LIMIT = 250; } if ($QUERY_BLOCKED_UID != null) { $title_members = " {and} {member}:{$QUERY_BLOCKED_UID}"; $QUERY_BLOCKED_UID_OP = " = "; if (preg_match("#not.*?:(.+)#i", $QUERY_BLOCKED_UID, $re)) { $neg = true; $QUERY_BLOCKED_UID = trim($re[1]); } if ($neg) { $QUERY_BLOCKED_UID_OP = " != "; } $QUERY_BLOCKED_UID = str_replace("*", "%", $QUERY_BLOCKED_UID); if (strpos(" {$QUERY_BLOCKED_UID}", "%") > 0) { $QUERY_BLOCKED_UID_OP = " LIKE "; if ($neg) { $QUERY_BLOCKED_UID_OP = " NOT LIKE "; } } $QUERY_BLOCKED_UID_SQL = " AND (\n\t\t\t(`client` {$QUERY_BLOCKED_UID_OP}'{$QUERY_BLOCKED_UID}') \n\t\t\tOR (`hostname` {$QUERY_BLOCKED_UID_OP}'{$QUERY_BLOCKED_UID}')\n\t\t\tOR (`uid` {$QUERY_BLOCKED_UID_OP}'{$QUERY_BLOCKED_UID}')\n\t\t\t)\n\t\t"; } $neg = false; if ($QUERY_BLOCKED_CATEGORY != null) { $title_cat = " {and} {category}:{$QUERY_BLOCKED_CATEGORY}"; if (preg_match("#not.*?:(.+)#i", $QUERY_BLOCKED_CATEGORY, $re)) { $neg = true; $QUERY_BLOCKED_CATEGORY = trim($re[1]); } $QUERY_BLOCKED_CATEGORY = str_replace("*", "%", $QUERY_BLOCKED_CATEGORY); $QUERY_BLOCKED_CATEGORY_OP = " = "; if ($neg) { $QUERY_BLOCKED_CATEGORY_OP = " != "; } if (strpos(" {$QUERY_BLOCKED_CATEGORY}", "%") > 0) { $QUERY_BLOCKED_CATEGORY_OP = " LIKE "; if ($neg) { $QUERY_BLOCKED_CATEGORY_OP = " NOT LIKE "; } } $QUERY_BLOCKED_CATEGORY_SQL = " AND `category`{$QUERY_BLOCKED_CATEGORY_OP}'{$QUERY_BLOCKED_CATEGORY}'"; } $neg = false; if ($MAIN_QUERY != null) { $title_cat = " {and} {website}:{$MAIN_QUERY}"; if (preg_match("#not.*?:(.+)#i", $MAIN_QUERY, $re)) { $neg = true; $MAIN_QUERY = trim($re[1]); } $MAIN_QUERY = str_replace("*", "%", $MAIN_QUERY); $MAIN_QUERY_OP = " = "; if ($neg) { $MAIN_QUERY_OP = " != "; } if (strpos(" {$MAIN_QUERY}", "%") > 0) { $MAIN_QUERY_OP = " LIKE "; if ($neg) { $MAIN_QUERY_OP = " NOT LIKE "; } } $MAIN_QUERY_SQL = " AND `website`{$MAIN_QUERY_OP}'{$MAIN_QUERY}'"; } $sql = "SELECT * FROM `{$table}` WHERE 1 {$MAIN_QUERY_SQL}{$QUERY_BLOCKED_UID_SQL}{$QUERY_BLOCKED_CATEGORY_SQL} ORDER BY zDate LIMIT 0,{$BLOCKED_CATEGORY_LIMIT}"; $results = $q->QUERY_SQL($sql, 'artica_events'); $boot = new boostrap_form(); $UnBlockWebSiteExplain = $tpl->javascript_parse_text("{UnBlockWebSiteExplain}"); $today = date('Y-m-d'); if (!$q->ok) { sendserrors($q->mysql_error . "<br>{$sql}"); } $t = time(); $q2 = new mysql(); while ($ligne = mysql_fetch_assoc($results)) { $member = $ligne["client"]; if ($ligne["hostname"] != null) { $member = $ligne["hostname"]; } if ($ligne["uid"] != null) { $member = $ligne["uid"]; } $js = "Loadjs('squid.categories.php?category={$ligne["category"]}&website={$ligne["website"]}',true)"; $link = $boot->trswitch($js); $unblock = imgsimple("whitelist-24.png", null, "UnBlockWebSite{$t}('{$ligne["website"]}')"); $ligne3 = mysql_fetch_array($q2->QUERY_SQL("SELECT items FROM urlrewriteaccessdeny WHERE items='{$ligne["website"]}'", "artica_backup")); if (!$q->ok) { $unblock = "<img src='img/icon_err.gif'><br>{$q->mysql_error}"; } else { if ($ligne3["items"] != null) { $unblock = imgsimple("20-check.png", null, null); } } if ($ligne["blocktype"] != null) { $blocktype = "<div><i style='font-size:10px'>{$ligne["blocktype"]}</i></div>"; } $tr[] = "\n\t\t<tr>\n\t\t<td nowrap><i class='icon-time'></i> {$ligne["zDate"]}</td>\n\t\t<td {$link}><i class='icon-user'></i> {$member}</td>\n\t\t<td {$link}><i class='icon-globe'></i> {$ligne["website"]}{$blocktype}</td>\n\t\t<td {$link}><i class='icon-info'></i> {$ligne["category"]}</td>\n\t\t<td {$link}><i class='icon-info'></i> {$ligne["rulename"]}</td>\n\t\t<td>{$unblock}</td>\n\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t\t\t\n\t\t<p>{search}:{$title_date}{$title_members}{$title_cat}</p>\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>{zDate} </th>\n\t\t\t\t\t<th>{member}</th>\n\t\t\t\t\t<th>{website}</th>\n\t\t\t\t\t<th>{category}</th>\n\t\t\t\t\t<th>{rule}</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>\n\t\t<script>\n\tvar x_UnBlockWebSite{$t}=function(obj){\n\t var tempvalue=obj.responseText;\n\t if(tempvalue.length>3){alert(tempvalue);}\n\t \n\t}\t\n\nfunction UnBlockWebSite{$t}(domain){\n\tif(confirm('{$UnBlockWebSiteExplain}:'+domain+' ?')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('unlock',domain);\n\t\tXHR.sendAndLoad('squid.blocked.events.php', 'POST',x_UnBlockWebSite{$t});\n\t}\n\n}\n</script>\t\t\t\t\t\n"; }
function replace_search() { $searchstring = string_to_flexquery("replace-search"); $q = new mysql_squid_builder(); $folderid = $_GET["folderid"]; $servername = $_GET["servername"]; $sql = "SELECT * FROM nginx_replace_folder WHERE folderid='{$folderid}' {$searchstring} ORDER BY zorder LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { if (strpos($q->mysql_error, "doesn't exist") > 0) { $f = new squid_reverse(); $results = $q->QUERY_SQL($sql); } } if (!$q->ok) { senderrors($q->mysql_error); } $tpl = new templates(); $GLOBALS["CLASS_TPL"] = $tpl; $boot = new boostrap_form(); $page = CurrentPageName(); $t = time(); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $icon = "www-web-search-64.png"; $md = md5(serialize($ligne)); $delete = imgsimple("delete-48.png", null, "Delete{$t}({$ligne["ID"]},'{$md}')"); $jsEdit = $boot->trswitch("Loadjs('{$page}?replace-js=yes&servername={$servername}&replaceid={$ligne["ID"]}&folderid={$folderid}')"); $stringtosearch = substr($ligne["stringtosearch"], 0, 200) . "..."; $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t<td width=1% nowrap {$jsEdit}><img src='img/{$icon}'></td>\n\t\t<td width=80% {$jsEdit}><span style='font-size:16px;font-weight:bold'>{$ligne["rulename"]}</span><div style='margin-top:10px'><code style='font-size:13px !important'>{$stringtosearch}</code></div></td>\n\t\t<td width=1% nowrap style='vertical-align:middle'>{$delete}</td>\n\t\t</tr>\n\t\t"; } $delete_freeweb_text = $tpl->javascript_parse_text("{delete_rule}"); echo $tpl->_ENGINE_parse_body("\n\t\t\t\t<table class='table table-bordered table-hover'>\n\t<thead>\n\t\t<tr>\n\t\t\t<th colspan=2>{rules}</th>\n\t\t\t<th> </th>\n\t\t</tr>\n\t\t</thead>\n<tbody>") . @implode("", $tr) . "</tbody></table>\n<script>\nvar FreeWebIDMEM{$t}='';\nvar xDelete{$t}=function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>10){alert(results);return;}\n\t\$('#'+FreeWebIDMEM{$t}).remove();\n\t}\n\nfunction Delete{$t}(server,md){\n\tFreeWebIDMEM{$t}=md;\n\t\tif(confirm('{$delete_freeweb_text}')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('replace-delete',server);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t\t}\n\t}\n</script>\n"; }
function websites_privs_search() { $searchstring = string_to_flexquery("directories-search"); $q = new mysql_squid_builder(); $servername = $_GET["servername"]; $WHERE = "servername='{$servername}'"; if (is_numeric($servername)) { $WHERE = "sourceid='{$servername}'"; } $sql = "SELECT * FROM reverse_privs WHERE {$WHERE} {$searchstring} ORDER BY uid LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { if (strpos($q->mysql_error, "doesn't exist")) { $pp = new squid_reverse(); } $results = $q->QUERY_SQL($sql); } if (!$q->ok) { senderrors($q->mysql_error); } $tpl = new templates(); $GLOBALS["CLASS_TPL"] = $tpl; $boot = new boostrap_form(); $page = CurrentPageName(); $t = time(); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $md = md5(serialize($ligne)); $delete = imgsimple("delete-24.png", null, "Delete{$t}('{$ligne["uid"]}','{$md}')"); $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t<td width=80%><span style='font-size:18px;font-weight:bold'><i class='icon-user'></i> {$ligne["uid"]}</span></td>\n\t\t<td width=1% nowrap style='vertical-align:middle'>{$delete}</td>\n\t\t</tr>\n\t\t"; } $reset_admin_password = $tpl->javascript_parse_text("{reset_admin_password}"); $delete_freeweb_text = $tpl->javascript_parse_text("{delete}"); echo $tpl->_ENGINE_parse_body("\n<table class='table table-bordered table-hover'>\n\t<thead>\n\t\t<tr>\n\t\t\t<th>{member}</th>\n\t\t\t<th> </th>\n\t\t</tr>\n\t\t</thead>\n<tbody>") . @implode("", $tr) . "</tbody></table>\n<script>\n var FreeWebIDMEM{$t}='';\nvar xDelete{$t}=function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>10){alert(results);return;}\n\t\$('#'+FreeWebIDMEM{$t}).remove();\n}\n\t\nfunction Delete{$t}(uid,md){\n\tFreeWebIDMEM{$t}=md;\n\tif(confirm('{$delete_freeweb_text} '+ uid)){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('uid-delete',uid);\n\t\tXHR.appendData('uid-srv','{$servername}');\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n}\n</script>\n"; }
function www_beahvior_search() { $page = CurrentPageName(); $tpl = new templates(); $boot = new boostrap_form(); $familysite = $_GET["familysite"]; $FAMS = $boot->SQUID_CATEGORIES_FAM; $current_month = date("Ym"); $table = "{$current_month}_catfam"; $q = new mysql_squid_builder(); $searchstring = string_to_flexquery("www-behavior-search"); $ORDER = $boot->TableOrder(array("zDate" => "DESC")); if (!$q->TABLE_EXISTS($table)) { senderrors("no such table"); } if ($q->COUNT_ROWS($table) == 0) { senderrors("no data"); } //zDate | client | uid | hostname | MAC | familysite | catfam | hits | size $table = "( SELECT familysite,zDate,catfam,SUM(size) as size,SUM(hits) as hits FROM `{$table}` GROUP BY \n\tzDate,familysite HAVING familysite='{$familysite}') as t"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } while ($ligne = mysql_fetch_assoc($results)) { $md = md5(serialize($ligne)); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $sitenameenc = urlencode($ligne["familysite"]); $xtime = strtotime("{$ligne["zDate"]} 00:00:00"); $js = "Loadjs('miniadm.webstats.fam.ByDay.php?familysite={$sitenameenc}&xtime={$xtime}&fam={$ligne["catfam"]}')"; $link = $boot->trswitch($js); $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["zDate"]}</td>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["hits"]}</td>\n\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["size"]}</td>\n\t\t<td style='font-size:16px' width=99% {$link}>" . $tpl->_ENGINE_parse_body($FAMS[$ligne["catfam"]]["TITLE"]) . "</td>\n\t\t</tr>\n\t\t"; } echo $boot->TableCompile(array("zDate" => "{this_month}", "hits" => "{hits}", "size" => "{size}", "catfam" => "{behavior}"), $tr); }
session_start(); ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); ini_set('error_prepend_string', null); ini_set('error_append_string', null); if (!isset($_SESSION["uid"])) { header("location:miniadm.logon.php"); } include_once dirname(__FILE__) . "/ressources/class.templates.inc"; include_once dirname(__FILE__) . "/ressources/class.users.menus.inc"; include_once dirname(__FILE__) . "/ressources/class.miniadm.inc"; include_once dirname(__FILE__) . "/ressources/class.mysql.postfix.builder.inc"; include_once dirname(__FILE__) . "/ressources/class.squid.inc"; $users = new usersMenus(); if (!$users->AsSquidAdministrator) { senderrors("{ERROR_NO_PRIVS}"); } if (isset($_GET["tab-rules"])) { tabs_rules(); exit; } if (isset($_GET["rules"])) { section_rules(); exit; } if (isset($_GET["rules_add_default_js"])) { rules_add_default_js(); exit; } if (isset($_GET["delete_all_js"])) { delete_all_js();
function performances() { $q = new mysql(); $sql = "select domain,COUNT(*) as files,sum(filesize) as size,sum(filesize*requested) as eco, sum(requested) as hits from haarp where deleted=0 and static=0 group by domain order by 1 DESC"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { senderrors($q->mysql_error); } $boot = new boostrap_form(); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $domain = $ligne["domain"]; //0 $files = $ligne["files"]; //1 $size = $ligne["size"]; // 2 $eco = $ligne["eco"]; //3 $hits = $ligne["hits"]; //4 if ($size > 0) { $percent = $eco * 100 / $size; } $percent = round($percent, 2); $totaleconomy = $totaleconomy + $eco; $totalhits = $totalhits + $hits; $totalcount = $totalcount + $files; $totalsize = $totalsize + $size; $files = FormatNumber($files); $hits = FormatNumber($hits); $eco = FormatBytes($eco / 1024); $size = FormatBytes($size / 1024); $tr[] = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px'>{$domain} ({$percent}%)</td>\n\t\t\t<td style='font-size:18px' width=1% nowrap>{$files}</td>\t\n\t\t\t<td style='font-size:18px' width=1% nowrap>{$size}</td>\n\t\t\t<td style='font-size:18px' width=1% nowrap>{$eco}</td>\n\t\t\t<td style='font-size:18px' width=1% nowrap>{$hits}</td>\n\t\t</tr>\n\t\t\t\t\n\t\t"; } $totalcount = FormatNumber($totalcount); $totalhits = FormatNumber($totalhits); $totaleconomy = FormatBytes($totaleconomy / 1024); $totalsize = FormatBytes($totalsize / 1024); $tr[] = "\n\t<tr style='background-color:#A5A5A5'>\n\t<td style='font-size:22px;font-weight:bold'> </td>\n\t<td style='font-size:22px;font-weight:bold'>{$totalcount}</td>\n\t<td style='font-size:22px;font-weight:bold'>{$totalsize}</td>\n\t<td style='font-size:22px;font-weight:bold'>{$totaleconomy}</td>\n\t<td style='font-size:22px;font-weight:bold'>{$totalhits}</td>\n\t</tr>\n\t\n\t"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body("\n\t\n\t\t\t<table class='table table-bordered'>\n\t\n\t\t\t<thead>\n\t\t\t<tr>\n\t\t\t<th>{domains}</th>\n\t\t\t<th>{files}</th>\n\t\t\t<th>{size}</th>\n\t\t\t<th>{economy}</th>\n\t\t\t<th>{hits}</th>\n\t\t\t</tr>\n\t\t\t</thead>" . @implode("", $tr) . "</table>"); }