function errorHandler($errno, $errstr, $errfile, $errline) { if (!(error_reporting() & $errno)) { // This error code is not included in error_reporting return; } switch ($errno) { case E_USER_ERROR: $error = "<b>My ERROR</b> [{$errno}] {$errstr}<br />\n\n Fatal error on line {$errline} in file {$errfile}\n , PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n"; echo $error; senderror($error); echo 'Aborting...<br />\\n'; exit(1); break; default: $error = "Unknown error type: [{$errno}] \"{$errstr}\" in file \"{$errfile}\" on line {$errline}<br />\n"; senderror($error); Controller::render('500'); Controller::finish(); //echo 'Aborting...<br />\n'; exit(1); break; } /* Don't execute PHP internal error handler */ return true; }
function page() { $commonName = $_GET["CommonName"]; $page = CurrentPageName(); $q = new mysql(); $tpl = new templates(); $sql = "SELECT `privkey`,`Squidkey`,`UsePrivKeyCrt` FROM sslcertificates WHERE CommonName='{$commonName}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); $keyfield = "privkey"; if ($ligne["UsePrivKeyCrt"] == 0) { $keyfield = "Squidkey"; } $upload_text = $tpl->_ENGINE_parse_body("{upload_content}"); $t = $_GET["t"]; if (!is_numeric($t)) { $t = time(); } if (!$q->ok) { senderror($q->mysql_error); } $tt = time(); $CommonNameURL = urlencode("{$commonName}"); $button_upload = button("{$upload_text}", "Loadjs('certificates.center.upload.php?certificate-upload-js=yes&CommonName={$CommonNameURL}&type=privkey&t={$_GET["t"]}&textid=text{$t}&RunAfter=VerifyCertificate{$tt}',true)", 20); $button_extract = $tpl->_ENGINE_parse_body(button("{info}", "Loadjs('{$page}?certificate-info-privkey-js=yes&CommonName={$CommonNameURL}&type=crt&t={$_GET["t"]}&textid=crt{$tt}',true)", 20)); $button_save = $tpl->_ENGINE_parse_body(button("{apply}", "Save{$tt}()", 20)); if ($ligne["UsePrivKeyCrt"] == 0) { $button_upload = null; $button_save = null; } $ssl_explain = $tpl->_ENGINE_parse_body("{privkey_ssl_explain}"); $html = "\n\t\n<div class=explain style='font-size:18px'>{$ssl_explain}</div>\n<center>{$button_upload} {$button_extract}</center>\n<div id='verify-{$tt}'></div>\n\t<center style='margin:10px'>\n\t\t<textarea id='text{$t}' style='font-family:Courier New;\n\t\tfont-weight:bold;width:100%;height:520px;border:5px solid #8E8E8E;\n\t\toverflow:auto;font-size:16px !important;width:99%;height:390px'>{$ligne[$keyfield]}</textarea>\n\t\t<br>{$button_save}\n\t\t</center>\n\t\t</div>\n\t\n<script>\nvar xSave{$tt}= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){alert(results);return;};\n\t\$('#TABLE_CERTIFICATE_CENTER_MAIN').flexReload();\n\tVerifyCertificate{$tt}();\n}\n\t\nfunction Save{$tt}(CommonName,md5){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('certificate_edit_privkey_save','{$commonName}');\n\tXHR.appendData('certificate_content',encodeURIComponent(document.getElementById('text{$t}').value));\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$tt});\n}\n\t\nfunction VerifyCertificate{$tt}(){\n\tLoadAjax('verify-{$tt}','{$page}?verify-privkey=yes&CommonName={$CommonNameURL}',true);\n}\nVerifyCertificate{$tt}();\n</script>\n\t"; echo $html; }
function errorHandler($errno, $errstr, $errfile, $errline) { if (!(error_reporting() & $errno)) { // This error code is not included in error_reporting return; } function senderror($error) { $session = $_SESSION; unset($session['pass']); $m = array2str(array('errormsg' => $error, 'session' => array2str($session, " %s = '%s'"), 'server' => array2str($_SERVER, " %s = '%s'"), 'request' => array2str($_REQUEST, " %s = '%s'"))); sendgmail(array('*****@*****.**', '*****@*****.**'), "*****@*****.**", 'SubLite Error Report', $m); //echo "Error report sent!<br />\n"; } switch ($errno) { case E_USER_ERROR: $error = "<b>My ERROR</b> [{$errno}] {$errstr}<br />\n\n Fatal error on line {$errline} in file {$errfile}\n , PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n"; echo $error; senderror($error); echo 'Aborting...<br />\\n'; exit(1); break; default: $error = "Unknown error type: [{$errno}] \"{$errstr}\" in file \"{$errfile}\" on line {$errline}<br />\n"; Controller::render('500'); Controller::finish(); senderror($error); //echo 'Aborting...<br />\n'; exit(1); break; } /* Don't execute PHP internal error handler */ return true; }
function checkGPIOPin($gpio, $pin) { if (!in_array($pin, $gpio->GPIO_AVAILABLE)) { senderror(403, "GPIO {$pin} Not Available"); } if (in_array($pin, $gpio->getALTPins())) { senderror(403, "GPIO {$pin} Disabled"); } }
function certificate_edit_csr_verify() { $CommonName = $_GET["CommonName"]; $q = new mysql(); $sql = "SELECT `csr` FROM sslcertificates WHERE CommonName='{$CommonName}'"; $t = $_GET["t"]; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if (!$q->ok) { senderror($q->mysql_error); return; } $tt = time(); if (strlen($ligne["csr"]) < 50) { $sock = new sockets(); $CommonName = urlencode($CommonName); echo base64_decode($sock->getFrameWork("system.php?BuildCSR={$CommonName}")); $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); } $filepath = dirname(__FILE__) . "/ressources/conf/upload/Cert.csr"; @file_put_contents($filepath, $ligne["csr"]); exec("/usr/bin/openssl req -text -noout -verify -verbose -in {$filepath} 2>&1", $results); $INFO = array(); $class = "text-info"; $f[] = "File: {$filepath} " . strlen($ligne["csr"]) . " bytes"; while (list($num, $ligne) = each($results)) { if (preg_match("#[0-9]+:error:[0-9A-Z]+:PEM routines:#", $ligne)) { $class = "text-error"; } if (preg_match("#unable to load#", $ligne)) { $class = "text-error"; } if (preg_match("#Subject:(.*)#", $ligne)) { $INFO[] = $ligne; } if (preg_match("#verify OK#i", $ligne)) { $INFO[] = $ligne; } $ligne = str_replace($filepath, "Info", $ligne); $ligne = htmlentities($ligne); $f[] = "{$ligne}"; } if ($class == "text-error") { echo "<p class='{$class}' style='font-size:18px'>" . @implode("<br>", $f) . "</p><script>UnlockPage();</script>"; } else { echo "<p class='{$class}' style='font-size:18px'>" . @implode("<br>", $INFO) . "</p><script>UnlockPage();</script>"; } }
function section_tab() { $boot = new boostrap_form(); $users = new usersMenus(); $callback = urlencode($_GET["CallBack"]); if (!$users->AsAnAdministratorGeneric) { senderror("no privs"); } $page = CurrentPageName(); $tpl = new templates(); $array["{members} LDAP"] = "{$page}?section-search-ldap=yes&CallBack={$callback}"; $ldap = new clladp(); if ($ldap->IsKerbAuth()) { $array["{members} Active Directory"] = "{$page}?section-search-ad=yes&CallBack={$callback}"; } echo $boot->build_tab($array); }
function search() { if (!CheckRights()) { senderror("{ERROR_NO_PRIVS}"); } $boot = new boostrap_form(); $sock = new sockets(); $users = new usersMenus(); $maillog_path = $users->maillog_path; $tpl = new templates(); $t = time(); $query = base64_encode($_GET["search"]); if (!is_numeric($_POST["rp"])) { $_POST["rp"] = 500; } $array = unserialize(base64_decode($sock->getFrameWork("postfix.php?query-maillog=yes&filter={$query}&maillog={$maillog_path}&rp={$_POST["rp"]}&zarafa-filter={$_GET["zarafa-filter"]}&mimedefang-filter={$_GET["mimedefang-filter"]}"))); $array = explode("\n", @file_get_contents("/usr/share/artica-postfix/ressources/logs/web/query.mail.log")); krsort($array); $zDate = $tpl->_ENGINE_parse_body("{zDate}"); $hostTXT = $tpl->_ENGINE_parse_body("{host}"); $serviceTXT = $tpl->_ENGINE_parse_body("{servicew}"); $eventsTXT = $tpl->_ENGINE_parse_body("{events}"); while (list($index, $line) = each($array)) { $lineenc = base64_encode($line); if (preg_match("#^[a-zA-Z]+\\s+[0-9]+\\s+([0-9\\:]+)\\s+(.+?)\\s+(.+?)\\[([0-9]+)\\]:(.+)#", $line, $re)) { $date = "{$re[1]}"; $host = $re[2]; $service = $re[3]; $pid = $re[4]; $line = $re[5]; } $class = LineToClass($line); $img = statusLogs($line); $loupejs = "ZoomEvents('{$lineenc}')"; $trSwitch = $boot->trswitch("blur()"); $tr[] = "\n\t\t<tr id='{$id}' class={$class} {$trSwitch}>\n\t\t<td style='font-size:12px' {$trSwitch} width=1% nowrap><i class='icon-time'></i> {$date}</td>\n\t\t<td style='font-size:12px' nowrap {$trSwitch} width=1% nowrap><i class='icon-arrow-right'></i> {$host}</td>\n\t\t<td style='font-size:12px' nowrap {$trSwitch} width=1% nowrap>{$service}</td>\n\t\t<td style='text-align:center;font-size:12px' width=1% nowrap>{$pid}</td>\n\t\t<td style='text-align:center;font-size:12px' width=1% nowrap><img src='{$img}'></td>\n\t\t<td style='font-size:12px' nowrap {$trSwitch} width=99% nowrap>{$line}</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>{$zDate}</th>\n\t\t\t\t\t<th>{$hostTXT}</th>\n\t\t\t\t\t<th>{$serviceTXT}</th>\n\t\t\t\t\t<th>PID</th>\n\t\t\t\t\t<th colspan=2>{$eventsTXT}</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\t\t</table>\n\t\t\t\t<script>\n\n\t</script>\n\t"; }
function add_user_popup() { $ldap = new clladp(); if ($_GET["ou"] == null) { senderror("{ERROR_NO_ORGANISATION_SELECTED}"); } $hash = $ldap->hash_groups($_GET["ou"], 1); $domains = $ldap->hash_get_domains_ou($_GET["ou"]); $boot = new boostrap_form(); $boot->set_hidden("ou", $_GET["ou"]); $boot->set_hidden("encpass", 1); $boot->set_field("new_userid", "{name_the_new_account_title}", null, array("MANDATORY" => true)); $boot->set_field("password", "{password}", null, array("MANDATORY" => true)); $boot->set_field("email", "{email}", null, array("MANDATORY" => true)); $boot->set_field("password", "{password}", null, array("MANDATORY" => true, "ENCODE" => true)); $boot->set_list("group_id", "{group}", $hash); $boot->set_button("{add}"); $boot->set_CloseYahoo("YahooWin2"); $boot->set_RefreshSearchs(); $boot->setAjaxPage("domains.edit.user.php"); $boot->set_formtitle("{$_GET["ou"]}:: {new_member}"); echo $boot->Compile(); }
function squid_cache_status() { $sock = new sockets(); $DisableAnyCache = $sock->GET_INFO("DisableAnyCache"); if (!is_numeric($DisableAnyCache)) { $DisableAnyCache = 0; } if ($DisableAnyCache == 1) { return; } $page = CurrentPageName(); $squid = new squidbee(); $tpl = new templates(); $t = time(); $q = new mysql_squid_builder(); $exec_squid_rebuild_cache_mem = unserialize(base64_decode($sock->getFrameWork("squid.php?exec_squid_rebuild_cache_mem=yes"))); if (isset($exec_squid_rebuild_cache_mem["PID"])) { if ($exec_squid_rebuild_cache_mem["PID"] > 0) { $datas = @file_get_contents("ressources/logs/web/rebuild-cache.txt"); $tt = time(); $html = "\n\t\t\t\t<div style='width:100%;text-align:right'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjax('squid-caches-status','{$page}?squid-caches-status=yes&uuid={$_GET["uuid"]}');") . "</div>\n\t\t\t\t<table style='width:99%' class=form>\n\t\t\t\t<tr>\n\t\t\t\t\t<td width=1%><img src='img/wait_verybig_mini_red-48.gif'></td>\n\t\t\t\t\t<td style='font-size:16px'>{exec_squid_rebuild_cache_mem}</div>\n\t\t\t\t\t\t<div style='font-size:14px;font-weight:bold'>{pid}:{$exec_squid_rebuild_cache_mem["PID"]}, {since} {$exec_squid_rebuild_cache_mem["TIME"]}</div>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t</table>\t\n\t\t\t\t\t\n\t\t\t\t"; $tb = array(); $tb = explode("\n", $datas); krsort($tb); if (strlen($datas) > 100) { $html = $html . "<textarea style='margin-top:5px;font-family:Courier New;\n\tfont-weight:bold;width:100%;height:520px;border:5px solid #8E8E8E;overflow:auto;font-size:11.5px'\n\tid='textarea{$t}'>" . @implode("\n", $tb) . "</textarea>"; } echo $tpl->_ENGINE_parse_body($html); return; } } $sql = "SELECT * FROM cachestatus WHERE uuid='{$_GET["uuid"]}'"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror($q->mysql_error . "<br>{$sql}"); } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $strong = "<strong style='font-size:14px'>"; if (basename($ligne["cachedir"]) == "cache_booster") { $strong = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.booster.php')\" style='font-size:14px;text-decoration:underline;font-weight:bold'>"; } $delete = imgtootltip("disk-64-delete.png", "{delete_cache}", "squid32DeleteCache('" . base64_encode($ligne["cachedir"]) . "')"); $NICKEL[$ligne["cachedir"]] = true; if ($ligne["cachedir"] == $squid->CACHE_PATH) { $cache_type = $squid->CACHE_TYPE; $delete = imgtootltip("disk-64-config.png", "{apply}", "Loadjs('{$page}?add-new-disk-js=yes&chdef=yes')"); } else { $cache_type = $squid->cache_list[$ligne["cachedir"]]["cache_type"]; } if ($ligne["cachedir"] != $squid->CACHE_PATH) { if (!isset($squid->cache_list[$ligne["cachedir"]])) { $delete = "<img src='img/disk-64-hide.png'>"; } } $html = $html . "\n\t\t\t\n\t\t\t<table style='width:99%' class=form>\n\t\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=1%>{$delete}</td>\n\t\t\t\t<td valign='top'>\n\t\t\t\t\t<table style='width:100%'>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign=top>{$strong}" . basename($ligne["cachedir"]) . " ({$cache_type})</strong></a></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign='top'><strong style='font-size:14px'>" . FormatBytes($ligne["currentsize"]) . "/" . FormatBytes($ligne["maxsize"]) . "</strong><div>{$ligne["cachedir"]}</div></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign='top'>" . pourcentage($ligne["pourc"]) . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t\n\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</tbody>\n\t\t\t</table>"; } while (list($path, $array) = each($squid->cache_list)) { if (isset($NICKEL[$path])) { continue; } $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; } $html = $html . "\n\t\t\t<table style='width:99%' class=form>\n\t\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=1%><img src='img/disk-64-hide.png'></td>\n\t\t\t\t<td valign='top'>\n\t\t\t\t\t<table style='width:100%'>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign=top>{$strong}" . basename($path) . " ({$array["cache_type"]})</strong></a></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign='top'><strong style='font-size:14px'>{$array["cache_size"]}{$unit}/{$maxcachesize}</strong><div>{$path}</div></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign='top'> </td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</tbody>\n\t\t\t</table>"; } $html = $html . "\n\t<div style='width:100%;text-align:right'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjax('squid-caches-status','{$page}?squid-caches-status=yes&uuid={$_GET["uuid"]}');") . "</div>\n\t\n\t<script>\n\t\tfunction Squid32RefreshCacheStatusAuto{$t}(){\n\t\t\tif(document.getElementById('squid-caches-status')){\n\t\t\t\tLoadAjax('squid-caches-status','{$page}?squid-caches-status=yes&uuid={$_GET["uuid"]}');\n\t\t\t}\t\t\n\t\t}\n\t\t\n\t\tsetTimeout('Squid32RefreshCacheStatusAuto{$t}',10000);\n\t\t\n\t</script>\n\t\n\n\t\t\n\t\n\t"; $sock = new sockets(); $sock->getFrameWork("squid.php?refresh-caches-infos=yes"); echo $tpl->_ENGINE_parse_body($html); }
function section_blocked_realtime_search() { $_GET["section-blocked-realtime-search"] = url_decode_special_tool($_GET["section-blocked-realtime-search"]); $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); if (!isset($_GET["rp"])) { $_GET["rp"] = 350; } if ($_GET["section-blocked-realtime-search"] != null) { $search = base64_encode($_GET["section-blocked-realtime-search"]); $datas = unserialize(base64_decode($sock->getFrameWork("squid.php?ufdbguard-logs={$search}&rp={$_GET["rp"]}"))); if (count($datas) == 0) { senderror("no data"); } $total = count($datas); } else { $datas = unserialize(base64_decode($sock->getFrameWork("squid.php?ufdbguard-logs=&rp={$_GET["rp"]}"))); if (count($datas) == 0) { senderror("no data"); } $total = count($datas); } $boot = new boostrap_form(); $q2 = new mysql(); $t = time(); while (list($ID, $line) = each($datas)) { if (!preg_match('#(.+?)\\s+\\[(.+?)\\]\\s+(.+)#', $line, $re)) { continue; } $color = "black"; $date = $re[1]; $pid = $re[2]; $event = $re[3]; if (!preg_match("#^BLOCK\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+(.*?)\\s+[A-Z]+#", $event, $re)) { continue; } $account = $re[1]; $group = $re[2]; $category = $re[4]; $rule = $re[3]; $uri = $re[5]; $sitename = null; $js = null; $unblock = null; if (preg_match("#^art(.+)#", $category, $re)) { $category = CategoryCodeToCatName($category); $CATEGORY_PLUS_TXT = "Artica Database"; } if (preg_match("#^tls(.+)#", $category, $re)) { $category = CategoryCodeToCatName($category); $CATEGORY_PLUS_TXT = "Toulouse University Database"; } $URLAR = parse_url($uri); if (isset($URLAR["host"])) { $sitename = $URLAR["host"]; } if (preg_match("#^(.*?):[0-9]+\$#", $sitename, $re)) { $sitename = $re[1]; } if (preg_match("#^www\\.(.*?)\$#", $sitename, $re)) { $sitename = $re[1]; } if ($sitename != null) { $js = "Loadjs('squid.categories.php?category={$category}&website={$sitename}',true)"; $link = $boot->trswitch($js); $unblock = imgsimple("whitelist-24.png", null, "UnBlockWebSite{$t}('{$sitename}')"); $ligne3 = mysql_fetch_array($q2->QUERY_SQL("SELECT items FROM urlrewriteaccessdeny WHERE items='{$sitename}'", "artica_backup")); } if (!$q2->ok) { $unblock = "<img src='img/icon_err.gif'><br>{$q2->mysql_error}"; } else { if ($ligne3["items"] != null) { $unblock = imgsimple("20-check.png", null, null); } } $strlen = strlen($uri); $uriT = wordwrap($uri, 100, "\n", true); $uriT = htmlentities($uriT); $uriT = nl2br($uriT); $uriT = str_replace($sitename, "<a href=\"javascript:blur()\"\n\t\t\t\tOnClick=\"javascript:Loadjs('miniadm.webstats.familysite.all.php?familysite={$sitename}');\"\n\t\t\t\tstyle='text-decoration:underline;color:{$color}'>{$sitename}</a>", $uriT); $tr[] = "<tr>\n\t\t<td nowrap style='font-size:14px' width=1% nowrap>{$date}</td>\n\t\t<td style='font-size:14px' width=1% nowrap>{$pid}</td>\n\t\t<td style='font-size:14px' width=1% nowrap>{$category}<div style='font-size:11px'>{$CATEGORY_PLUS_TXT}</div></td>\n\t\t<td style='font-size:14px' width=1% nowrap>{$account}/{$group}</td>\n\t\t<td style='font-size:14px' width=1% nowrap>{$rule}</td>\n\t\t<td style='font-size:14px'>{$uriT}</td>\n\t\t<td style='font-size:14px' width=1% nowrap>{$unblock}</td>\n\t\t</tr>\n\t\t"; } $tpl = new templates(); $UnBlockWebSiteExplain = $tpl->javascript_parse_text("{UnBlockWebSiteExplain}"); echo $tpl->_ENGINE_parse_body("<table class='table table-bordered'>\n\t\n\t\t\t<thead>\n\t\t\t<tr>\n\t\t\t<th>{date}</th>\n\t\t\t<th>PID</th>\n\t\t\t<th>{category}</th>\n\t\t\t<th>{member}</th>\n\t\t\t<th nowrap>{rulename}</th>\n\t\t\t<th>{url}</th>\n\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("\n", $tr) . " </tbody></table>\t\t\n<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>"; }
function graph0() { $q = new mysql_squid_builder(); $page = CurrentPageName(); $tpl = new templates(); $t = $_GET["t"]; $ff = time(); $tablename = date("Ymd", $_GET["xtime"]) . "_blocked"; $sql = "SELECT COUNT(ID) as thits,HOUR(zDate) as `thour` FROM {$tablename} GROUP BY `thour` ORDER BY `thour`"; $c = 0; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror("{$q->mysql_error}<br>{$sql}"); } if (mysql_num_rows($results) > 0) { $nb_events = mysql_num_rows($results); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $xdata[] = $ligne["hour"]; $ydata[] = $ligne["thits"]; $c++; } } $highcharts = new highcharts(); $highcharts->container = $_GET["container"]; $highcharts->xAxis = $xdata; $highcharts->Title = "{display_blocked_events}: {hits}/{hour}"; $highcharts->yAxisTtitle = "{hits}"; $highcharts->xAxisTtitle = "{hours}"; $highcharts->datas = array("{hits}" => $ydata); echo $highcharts->BuildChart(); }
function replace_search() { $prox = new squid_reverse(); $searchstring = string_to_flexquery("replace-search"); $q = new mysql_squid_builder(); $sql = "SELECT * FROM nginx_replace WHERE groupid={$_GET["groupid"]} {$searchstring} ORDER BY rulename LIMIT 0,250"; $results = $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { senderror($q->mysql_error); } $tpl = new templates(); $boot = new boostrap_form(); $page = CurrentPageName(); $t = time(); if ($GLOBALS["VERBOSE"]) { echo "<H1>{$sql}</H1><br>" . mysql_num_rows($results) . " Entries<hr>"; } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $icon = "www-web-search-64.png"; $icon2 = "folder-network-64.png"; $color = "black"; $md = md5(serialize($ligne)); $stringtosearch = htmlentities($ligne["stringtosearch"]); $delete = imgsimple("delete-64.png", null, "Delete{$t}('{$ligne["ID"]}','{$md}')"); $jsedit = $boot->trswitch("Loadjs('{$page}?js-replace=yes&ID={$ligne["ID"]}')"); $tr[] = "\n\t\t<tr style='color:{$color}' id='{$md}'>\n\t\t<td width=1% nowrap {$jsedit} style='vertical-align:middle' nowrap><img src='img/{$icon}'></td>\n\t\t<td width=80% {$jsedit} style='vertical-align:middle'>\n\t\t\t<span style='font-size:18px;font-weight:bold'>{$ligne["rulename"]}</span>\n\t\t</td>\n\t\t\n\t\t<td width=1% nowrap {$jsedit} style='vertical-align:middle' nowrap>\n\t\t\t<span style='font-size:18px;font-weight:bold'>{$stringtosearch}</span>\n\t\t</td>\n\t\t<td width=1% nowrap style='vertical-align:middle'>{$delete}</td>\n\t\t</tr>\n\t\t"; } 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>{rule}</th>\n\t\t\t\t\t<th >{search}</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>") . @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}(ID,md){\n\tFreeWebIDMEM{$t}=md;\n\tif(confirm('Remove '+ID+'?')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('replace-delete',ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n}</script>\t\t\t \t\t\t\t\t \t\t\n"; }
function graph1_1() { $q = new mysql_squid_builder(); $page = CurrentPageName(); $tpl = new templates(); $t = $_GET["t"]; $ff = time(); $tablename = date("Ymd", $_GET["xtime"]) . "_hour"; $category = mysql_escape_string2($_GET["category"]); if ($_GET["category"] == "unknown") { $_GET["category"] = null; } $sql = "SELECT SUM( hits ) AS size,zDate, category FROM generic_categories GROUP BY category,zDate\n\tHAVING category='{$_GET["category"]}' ORDER BY zDate"; $results = $q->QUERY_SQL($sql); $c = 0; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror("{$q->mysql_error}<br>{$sql}"); } if (mysql_num_rows($results) > 0) { $nb_events = mysql_num_rows($results); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $xdata[] = $ligne["zDate"]; $ydata[] = $ligne["size"]; $c++; } } $highcharts = new highcharts(); $highcharts->container = $_GET["container"]; $highcharts->xAxis = $xdata; $highcharts->Title = "{$category}: {hits}/{day}"; $highcharts->yAxisTtitle = "{hits}"; $highcharts->xAxisTtitle = "{days}"; $highcharts->datas = array("{hits}" => $ydata); echo $highcharts->BuildChart(); }
function section_webrules_search() { $q = new mysql_squid_builder(); $database = "squidlogs"; $sock = new sockets(); $tpl = new templates(); $search = '%'; $table = "websites_caches_params"; $searchstring = string_to_flexquery("search-webrules"); $sql = "SELECT * FROM `{$table}` WHERE 1 {$searchstring} ORDER BY sitename"; $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { senderror($q->mysql_error); } $boot = new boostrap_form(); $t = time(); while ($ligne = mysql_fetch_assoc($results)) { $ID = md5($ligne["sitename"]); $delete = imgtootltip("delete-24.png", "{delete}", "DeleteWebsiteCached{$t}('{$ligne["sitename"]}','{$ID}')"); $select = "Loadjs('squid.miniwebsite.tasks.php?cache-params-js=yes&sitename={$ligne["sitename"]}&table-t={$_GET["t"]}');"; $ligne["MIN_AGE"] = $ligne["MIN_AGE"]; $ligne["MIN_AGE"] = $tpl->javascript_parse_text(distanceOfTimeInWords(time(), mktime() + $ligne["MIN_AGE"] * 60, true)); $ligne["MAX_AGE"] = $ligne["MAX_AGE"]; $ligne["MAX_AGE"] = $tpl->javascript_parse_text(distanceOfTimeInWords(time(), mktime() + $ligne["MAX_AGE"] * 60, true)); if (trim($ligne["sitename"]) == '.') { $ligne["sitename"] = $tpl->_ENGINE_parse_body("{all}"); } $link = $boot->trswitch($select); $tr[] = "\n\t\t<tr id='{$ID}'>\n\t\t<td {$link}><i class='icon-globe'></i> {$ligne["sitename"]}</td>\n\t\t<td {$link} width=1% nowrap>{$ligne["MIN_AGE"]}</td>\n\t\t<td {$link} width=1% nowrap>{$ligne["PERCENT"]}%</td>\n\t\t<td {$link} width=1% nowrap>{$ligne["MAX_AGE"]}</td>\n\t\t<td width=1% nowrap>{$delete}</td>\n\t\t</tr>"; } 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<th>{website}</th>\n\t\t\t<th>{expire_time}</th>\n\t\t\t<th>%</th>\n\t\t\t<th>{limit}</th>\n\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<script>\nvar websiteMem{$t}='';\n\t\tvar x_DeleteWebsiteCached{$t}= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);return;}\n\t\t\t\$('#'+websiteMem{$t}).remove();\t\t\t\n\t\t\t\t\n\t\t}\t\n\n\t\tfunction DeleteWebsiteCached{$t}(domain,id){\n\t\t\twebsiteMem{$t}=id;\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('DELETE',domain);\n\t\t\tXHR.sendAndLoad('squid.caches32.caches-www.php', 'POST',x_DeleteWebsiteCached{$t});\n\t\t}\n</script>\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\n"; }
function today_search() { $now = date("Ymd"); $tablename = "searchwordsD_{$now}"; $q = new mysql_squid_builder(); if (!$q->TABLE_EXISTS($tablename)) { senderror("{$tablename} no such table"); } $tpl = new templates(); $search = string_to_flexquery("search-today"); if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $sql = "SELECT * FROM {$tablename} WHERE 1 {$search} ORDER BY `hour` DESC LIMIT 0,500"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror($q->mysql_error); } while ($ligne = mysql_fetch_assoc($results)) { $ligne["words"] = utf8_decode($ligne["words"]); $time = strtotime($ligne["zDate"]); $ligne["zDate"] = date("H:i:s", $time); $tr[] = "\n\t\t<tr>\n\t\t<td nowrap><i class='icon-time' ></i> {$ligne["hour"]}h</a></td>\n\t\t<td nowrap><i class='icon-user'></i> {$ligne["uid"]}</a></td>\n\t\t<td>{$ligne["ipaddr"]}</a></td>\n\t\t<td>{$ligne["words"]}</td>\n\t\t<td><i class='icon-info-globe'></i> {$ligne["sitename"]}</td>\n\t\t<td nowrap><i class='icon-info-globe'></i> {$ligne["familysite"]}</td>\n\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\n\t\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>{date}</th>\n\t\t\t\t\t<th>{member}</th>\n\t\t\t\t\t<th>{ipaddr}</th>\n\t\t\t\t\t<th>{words}</th>\n\t\t\t\t\t<th colspan=2>{sitename}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t\t") . @implode("", $tr) . "</tbody></table>"; }
function generic_categories_table_search() { $q = new mysql_squid_builder(); $searchstring = string_to_flexquery("generic-categories-table-search"); $boot = new boostrap_form(); $tpl = new templates(); $sql = "SELECT SUM( size ) AS size,SUM(hits) as hits, category FROM generic_categories GROUP BY category \n\t\t\tHAVING LENGTH(category)>1 {$searchstring} ORDER BY size DESC,hits DESC"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror($q->mysql_error); } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $size = FormatBytes($ligne["size"] / 1024); $hits = FormatNumber($ligne["hits"]); $js = "Loadjs('miniadm.webstats.websites.ByCategory.php?category=" . urlencode($ligne["category"]) . "')"; $link = $boot->trswitch($js); $tr[] = "<tr {$link}>\n\t\t\t\t\n\t\t<td width=99% style='font-size:18px'>{$ligne["category"]}</td>\n\t\t<td width=1% nowrap style='font-size:18px'>{$size}</td>\n\t\t<td width=1% nowrap style='text-align:right;font-size:18px'>{$hits}</td>\n\t\t</tr>\n\t\t"; } echo $tpl->_ENGINE_parse_body("\n\t\n\t\t<table class='table table-bordered table-hover'>\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{category}</th>\n\t\t\t\t\t<th>{size}</th>\n\t\t\t\t\t<th>{hits}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>") . @implode("", $tr) . "</tbody></table>"; }
<?php include_once 'includes/config.inc'; include_once 'includes/http.inc'; if (MAINTENANCE_MODE && $_SERVER["REMOTE_ADDR"] != MAINTENANCE_MODE_ADMINIP) { senderror(503); header("Content-Type: text/plain"); echo "Maintenance mode: Bitcoin Block Explorer will be back shortly"; die; } /** * Returns the equivalent of Apache's $_SERVER['REQUEST_URI'] variable. * * Because $_SERVER['REQUEST_URI'] is only available on Apache, we generate an * equivalent using other environment variables. */ function request_uri() { if (isset($_SERVER['REQUEST_URI'])) { $uri = $_SERVER['REQUEST_URI']; } else { if (isset($_SERVER['argv'])) { $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['argv'][0]; } elseif (isset($_SERVER['QUERY_STRING'])) { $uri = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']; } else { $uri = $_SERVER['SCRIPT_NAME']; } } // Prevent multiple slashes to avoid cross site requests via the Form API. $uri = '/' . ltrim($uri, '/');
function exclude_mime_search() { $tpl = new templates(); $page = CurrentPageName(); $q = new mysql_squid_builder(); $table = "webfilters_blkwhlts"; $page = 1; $FORCE_FILTER = "AND blockType=6"; $searchstring = string_to_flexquery($_GET["exclude-mime-search"]); $sql = "SELECT * FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} ORDER BY `pattern`"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror($q->mysql_error . "<hr>{$sql}"); } $PatternTypeH[1] = "{ComputerMacAddress}"; $PatternTypeH[0] = "{addr}"; $PatternTypeH[2] = "{SquidGroup}"; $PatternTypeH[3] = "{browser}"; $PatternTypeH[6] = "{BannedMimetype}"; $t = time(); $GLOBALS["GroupType"]["src"] = "{addr}"; $GLOBALS["GroupType"]["arp"] = "{ComputerMacAddress}"; $GLOBALS["GroupType"]["dstdomain"] = "{dstdomain}"; $GLOBALS["GroupType"]["proxy_auth"] = "{members}"; $GLOBALS["GroupType"]["browser"] = "{browser}"; while ($ligne = mysql_fetch_assoc($results)) { $id = md5($ligne["pattern"]); $PatternTypeInt = $ligne["PatternType"]; $PatternType = $tpl->_ENGINE_parse_body($PatternTypeH[$ligne["PatternType"]]); if ($ligne["PatternType"] == 0) { $PatternType = $tpl->_ENGINE_parse_body("{addr}"); } if ($PatternType == null) { if ($_GET["blk"] > 1) { $PatternType = $tpl->_ENGINE_parse_body("{website}"); } } if ($PatternTypeInt == 0) { if ($_GET["blk"] == 2) { $PatternType = $tpl->_ENGINE_parse_body("{website}"); } } if ($PatternTypeInt == 1) { if ($_GET["blk"] == 6) { $PatternType = $tpl->_ENGINE_parse_body("{BannedMimetype}"); } } $PatternAffiche = $ligne["pattern"]; $description = $tpl->_ENGINE_parse_body($ligne["description"]); if ($ligne["PatternType"] == 2) { $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT GroupName,GroupType FROM webfilters_sqgroups WHERE ID='{$ligne["pattern"]}'")); $description = $tpl->_ENGINE_parse_body($GLOBALS["GroupType"][$ligne2["GroupType"]]); $PatternAffiche = $ligne2["GroupName"]; } if ($ligne["zmd5"] == null) { $q->QUERY_SQL("UPDATE webfilters_blkwhlts SET zmd5='{$id}' WHERE pattern='" . mysql_escape_string2($ligne["pattern"]) . "'"); $ligne["zmd5"] = $id; } $md5 = $ligne["zmd5"]; $delete = imgtootltip("delete-32.png", "{delete} {$ligne["pattern"]}", "BlksProxyDelete('{$md5}')"); $enable = Field_checkbox($id, 1, $ligne["enabled"], "BlksProxyEnable('{$md5}','{$id}')"); $tr[] = "\n\t\t<tr>\n\t\t\t<td style='font-size:16px'>{$PatternAffiche}</td>\n\t\t\t<td style='font-size:16px' width=5% nowrap>{$description}</td>\n\t\t\t<td style='font-size:16px;text-align:center;vertical-align:middle'>{$enable}</td>\n\t\t\t<td style='font-size:16px;text-align:center;vertical-align:middle'>{$delete}</td>\t\t\t\t\t\n\t\t</tr>\t\t\n\t\t"; } $type = $tpl->_ENGINE_parse_body("{sourcetype}"); $pattern = $tpl->_ENGINE_parse_body("{pattern}"); $description = $tpl->_ENGINE_parse_body("{description}"); $add_mime_type_explain = $tpl->javascript_parse_text("{add_mime_type_white_explain}"); echo $tpl->_ENGINE_parse_body("\n<table class='table table-bordered table-hover'>\t\t\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th >{$pattern}</th>\n\t\t\t\t\t<th>{$description}</th>\n\t\t\t\t\t<th> </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>") . @implode("", $tr) . "</tbody></table>\n<script>\n\tvar x_AddByMac= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){alert(res);}\n\t\tExecuteByClassName('SearchFunction');\n\t}\n\t\t\t\n\nfunction AddDefaultMimeType(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('AddDefaultMimeType-white','yes');\n\t\tXHR.sendAndLoad('squid.hosts.blks.php', 'POST',x_AddByMac);\t\n}\n\nfunction AddByMimeType(){\n\tvar mac=prompt('{$add_mime_type_explain}');\n\tif(mac){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('pattern',mac);\n\t\tXHR.appendData('PatternType',1);\n\t\tXHR.appendData('blk',6);\n\t\tXHR.sendAndLoad('squid.hosts.blks.php', 'POST',x_AddByMac);\t\t\n\t}\n}\n\nfunction BlksProxyDelete(pattern){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('delete-pattern',pattern);\n\t\tXHR.sendAndLoad('squid.hosts.blks.php', 'POST',x_AddByMac);\n}\n\nfunction BlksProxyEnable(pattern,id){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById(id).checked){XHR.appendData('enabled',1);}else{XHR.appendData('enabled',0);}\n\t\tXHR.appendData('enable-pattern',pattern);\n\t\tXHR.sendAndLoad('squid.hosts.blks.php', 'POST');\n}\n</script>\n\t\t\t"; }
function routes_search() { $q = new mysql(); $page = CurrentPageName(); $tpl = new templates(); $boot = new boostrap_form(); $t = time(); //$q->QUERY_SQL("DROP TABLE iproute_table","artica_backup"); $q->BuildTables(); $search = string_to_flexquery("routes-search"); $sql = "SELECT * FROM iproute_table WHERE 1 {$search} ORDER BY routename LIMIT 0,500"; $results = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { senderror($q->mysql_error); } while ($ligne = mysql_fetch_assoc($results)) { $link = $boot->trswitch("Loadjs('{$page}?ruleid={$ligne["ID"]}');"); $sql = "SELECT * FROM iproute_rules WHERE ruleid={$ligne["ID"]} ORDER BY priority LIMIT 0,10"; $results2 = $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { senderror($q->mysql_error); } $ff = array(); while ($ligne2 = mysql_fetch_assoc($results2)) { $ff[] = "<div style='font-size:14px'>{$ligne2["src"]} - {$ligne2["destination"]}</div>"; } $delete = imgtootltip("delete-64.png", null, "Delete{$t}({$ligne["ID"]})"); $tr[] = "<tr id='R{$ligne["ID"]}'>\n\t\t<td width=1% nowrap {$link}><img src='img/64-ip-settings.png'></td>\n\t\t<td style='font-size:18px' {$link}>{$ligne["routename"]}</td>\n\t\t<td style='font-size:18px' {$link} width=1% nowrap {$link}>{$ligne["interface"]}</td>\n\t\t<td style='font-size:18px' {$link} width=1% nowrap {$link}>{$ligne["gateway"]}</td>\n\t\t<td {$link} width=1% nowrap>" . @implode("\n", $ff) . "</td>\n\t\t<td width=1% nowrap>{$delete}</td>\n\t\t</tr>\t\t\n\t\t\t\t\n\t\t"; } $deleteTXT = $tpl->javascript_parse_text("{delete_group}"); echo $tpl->_ENGINE_parse_body("\n\t\n\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan=2>{groupname}</th>\n\t\t\t\t\t<th>{interface}</th>\n\t\t\t\t\t<th>{gateway}</th>\n\t\t\t\t\t<th> </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("\n", $tr) . " </tbody>\n\t\t\t\t</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('route-delete',id);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n}\n\t</script>\t\t\t\t\t\n\t\t\t\t\t\n"; }
function members_list() { $page = 1; $MyPage = CurrentPageName(); $users = new usersMenus(); $tpl = new templates(); $sock = new sockets(); $q = new mysql_storelogs(); $table = "user"; $tableOrg = $table; $database = "mysql"; $delete_alert = $tpl->javascript_parse_text("{delete}"); $FORCE_FILTER = 1; $t = $_GET["t"]; if (!is_numeric($t)) { $t = time(); } if ($q->COUNT_ROWS($table, $database) == 0) { senderror("{$table}/{$database} is empty"); } $searchstring = string_to_flexquery("search-members"); $sql = "SELECT * FROM `{$table}` WHERE {$FORCE_FILTER} {$searchstring} ORDER BY `User`"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { senderror("{$q->mysql_error}"); } if (mysql_num_rows($results) == 0) { senderror("Query return empty array, {$sql}"); } while ($ligne = mysql_fetch_assoc($results)) { $password = $ligne["Password"]; $array = array("host" => $ligne["Host"], "user" => $ligne["User"]); $databaseText = null; if ($ligne["Host"] != "%") { if ($ligne["Host"] != "localhost") { if (!preg_match("#^[0-9\\%]+\\.[0-9\\%]+\\.[0-9\\%]+#", $ligne["Host"])) { } } } $ligne["Host"] = str_replace("%", "{all}", $ligne["Host"]); $md5S = md5("{$ligne["User"]}@{$ligne["Host"]}{$databaseText}"); $delete = imgsimple("delete-32.png", "{delete}", "DeleteMysqlUser{$t}('" . base64_encode(serialize($array)) . "','{$ligne["User"]}@{$ligne["Host"]}','{$md5S}')"); if ($ligne["User"] == "root") { $delete = null; } $js = "Loadjs('{$MyPage}?selectDB-js=yes&host={$ligne["Host"]}&user={$ligne["User"]}&instance-id={$_GET["instance-id"]}&t={$t}')"; $tr[] = "\n\t\t\t<tr class='{$class}' id='{$md5S}'>\n\t\t\t<td nowrap>{$ligne["User"]}@{$ligne["Host"]}</td>\n\t\t\t<td width=95% align=center>{$delete}</td>\n\t\t\t</tr>\n\t\t\t"; } $tpl = new templates(); echo $tpl->_ENGINE_parse_body("<table class='table table-bordered'>\n\t\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th width=99%>{members}</th>\n\t\t\t\t\t<th width=1% align=center> </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\n\t\t\t</table>\n\t\t\t<script>\nvar memedb{$t}='';\t\t\t\nvar x_DeleteMysqlUser= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>2){alert(results);return;}\n\t\$('#'+memedb{$t}).remove();\n}\t\t\n\t\nfunction DeleteMysqlUser{$t}(arra,user,md){\n\tmemedb{$t}=md;\n\tif(confirm('{$delete_alert} '+user+' ?')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('members-delete',arra);\n\t\tXHR.sendAndLoad('{$MyPage}', 'POST',x_DeleteMysqlUser);\n\t}\n}\n</script>\n"; }
function rules_search() { $tpl = new templates(); $MyPage = CurrentPageName(); $page = CurrentPageName(); $rule_text = $tpl->_ENGINE_parse_body("{rule}"); $action_delete_rule = $tpl->javascript_parse_text("{action_delete_rule}"); $q = new mysql_squid_builder(); if (!$q->FIELD_EXISTS("webfilter_rules", "zOrder")) { $q->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `zOrder` SMALLINT(2) NOT NULL,ADD INDEX ( `zOrder` )"); } if (!$q->ok) { json_error_show("{$q->mysql_error}"); } if (!$q->FIELD_EXISTS("webfilter_rules", "AllSystems")) { $q->QUERY_SQL("ALTER TABLE `webfilter_rules` ADD `AllSystems` smallint(1),ADD INDEX ( `AllSystems` )"); } if (!$q->ok) { json_error_show("{$q->mysql_error}"); } $t = $_GET["t"]; $search = '%'; $table = "webfilter_rules"; $page = CurrentPageName(); $FORCE_FILTER = null; $total = 0; if (!$q->TABLE_EXISTS($table)) { $q->CheckTables(); } $searchstring = string_to_flexquery("rules-search"); $webfilter = new webfilter_rules(); $styleTD = "style='font-size:16px;font-weight:bold'"; $styleTDCenter = "style='font-size:16px;font-weight:bold;text-align:center !important'"; $sql = "SELECT * FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} ORDER by zOrder"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror("{$q->mysql_error}"); } $sock = new sockets(); $ligne = unserialize(base64_decode($sock->GET_INFO("DansGuardianDefaultMainRule"))); $DefaultPosition = $ligne["defaultPosition"]; if (!is_numeric($DefaultPosition)) { $DefaultPosition = 0; } $AllSystems = $tpl->_ENGINE_parse_body("{AllSystems}"); $boot = new boostrap_form(); if ($DefaultPosition == 0) { $tr[] = DefaultRule(); } while ($ligne = mysql_fetch_assoc($results)) { $ID = $ligne["ID"]; $md5 = md5($ligne["ID"]); $ligne["groupname"] = utf8_encode($ligne["groupname"]); $delete = imgtootltip("delete-24.png", "{delete}", "DansGuardianDeleteMainRule('{$ligne["ID"]}')"); $js = "DansGuardianEditRule('{$ligne["ID"]}','{$ligne["groupname"]}');"; $link = $boot->trswitch($js); $link_blacklist = $boot->trswitch("Loadjs('dansguardian2.edit.php?js-blacklist-list=yes&RULEID={$ligne['ID']}&modeblk=0&group=&TimeID=&t={$t}');"); $link_whitelist = $boot->trswitch("Loadjs('dansguardian2.edit.php?js-blacklist-list=yes&RULEID={$ligne['ID']}&modeblk=1&group=&TimeID=&t={$t}');"); $link_group = $boot->trswitch("Loadjs('dansguardian2.edit.php?js-groups={$ligne["ID"]}&ID={$ligne["ID"]}&t={$t}')"); $TimeSpace = $webfilter->TimeToText(unserialize(base64_decode($ligne["TimeSpace"]))); $color = "black"; if ($ligne["enabled"] == 0) { $color = "#8a8a8a"; } $rules_dans_time_rule = $webfilter->rules_dans_time_rule($ligne["ID"]); if ($ligne["groupmode"] == 0) { $warn = "<div style='float:right'><img src='img/stop-24.png'></div>"; } $duplicate = imgsimple("duplicate-24.png", null, "Loadjs('dansguardian2.duplicate.php?from={$ligne['ID']}&t={$t}')"); $TimeSpace = $webfilter->rule_time_list_explain($ligne["TimeSpace"], $ligne["ID"], $t); $styleupd = "style='border:0px;margin:0px;padding:0px;background-color:transparent'"; $up = imgsimple("arrow-up-32.png", "", "RuleDansUpDown('{$ligne['ID']}',1)"); $down = imgsimple("arrow-down-32.png", "", "RuleDansUpDown('{$ligne['ID']}',0)"); $zorder = "<table {$styleupd}><tr><td {$styleupd}>{$down}</td {$styleupd}><td {$styleupd}>{$up}</td></tr></table>"; $CountDeGroups = "« " . $webfilter->COUNTDEGROUPES($ligne["ID"]) . " »"; $templatejs = $boot->trswitch("Loadjs('dansguardian.template.php?js=yes&ID={$ligne["ID"]}')"); if ($ligne["AllSystems"] == 1) { $jsGroups = "*"; $CountDeGroups = "*"; } $tr[] = "\n\t\t\t<tr id='{$ligne['ID']}'>\n\t\t\t<td {$styleTD} {$link} width=99% ><span id='anim-img-0'>{$ligne["groupname"]}</span> {$TimeSpace}</td>\n\t\t\t<td {$styleTDCenter} {$link_group} width=1% align=center>{$CountDeGroups}</td>\n\t\t\t<td {$styleTDCenter} {$link_blacklist} width=1% align=center>" . $webfilter->COUNTDEGBLKS($ligne['ID']) . "</td>\n\t\t\t<td {$styleTDCenter} {$link_whitelist} width=1% align=center>" . $webfilter->COUNTDEGBWLS($ligne['ID']) . "</td>\n\t\t\t<td {$styleTDCenter} width=35px align=center nowrap>{$zorder}</td>\n\t\t\t<td {$styleTDCenter} {$templatejs} width=35px align=center nowrap><img src='img/banned-template-32.png'></td>\n\t\t\t<td {$styleTDCenter} width=35px align=center nowrap>{$duplicate}</td>\n\t\t\t<td width=35px align='center' nowrap {$styleTDCenter}>{$delete}</td>\n\t\t\t</tr>"; } if ($DefaultPosition == 1) { $tr[] = DefaultRule(); } $table = $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>{rule}</th>\n\t\t\t<th>{groups2}</th>\n\t\t\t<th>{blacklists}</th>\n\t\t\t<th>{whitelists}</th>\n\t\t\t<th>{order}</th>\n\t\t\t<th>{template}</th>\n\t\t\t<th> </th>\n\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("\n", $tr); $js = "\n<script>\t\t\t\nfunction DansGuardianNewRule(){\n\t\tDansGuardianEditRule(-1)\n\t}\n\n\tfunction DansGuardianEditRule(ID,rname){\n\t\tYahooWin3('1010','dansguardian2.edit.php?ID='+ID+'&t={$t}','{$rule_text}::'+ID+'::'+rname);\n\t}\n\t\n\tfunction CompileUfdbGuardRules(){\n\t\tLoadjs('dansguardian2.compile.php');\n\t}\n\t\n\tfunction UfdbGuardConfigs(){\n\t\tLoadjs('ufdbguard.php');\n\t}\n\t\n\tfunction UfdbguardEvents(){\n\t\tLoadjs('dansguardian2.mainrules.php?UfdbguardEvents=yes');\n\t}\n\tvar x_RuleDansUpDown{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\tExecuteByClassName('SearchFunction');\n\t}\t\n\n\t\t\n\tfunction RuleDansUpDown(ID,dir){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('rule-move', ID);\n\t\tXHR.appendData('rule-dir', dir);\n\t\tXHR.sendAndLoad('dansguardian2.mainrules.php', 'POST',x_RuleDansUpDown{$t});\t\n\t}\n\t\n\n\t\n\t\tvar x_DansGuardianDeleteMainRule= function (obj) {\n\t\t\tvar res=obj.responseText;\n\t\t\tif (res.length>3){alert(res);}\n\t\t\t\$('#'+rowid).remove();\n\t\t}\t\t\n\t\t\n\t\tfunction DansGuardianDeleteMainRule(ID){\n\t\t\trowid=ID;\n\t\t\tif(confirm('{$action_delete_rule}')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t \tXHR.appendData('DansGuardianDeleteMainRule', ID);\n\t\t \tXHR.sendAndLoad('dansguardian2.mainrules.php', 'POST',x_DansGuardianDeleteMainRule); \n\t\t\t}\n\t\t}\n\t\t\n\t\tfunction RulesToolBox(){\n\t\t\tLoadAjaxTiny('rules-toolbox','dansguardian2.mainrules.php?rules-toolbox=yes');\n\t\t}\n\t\n\tRulesToolBox();\t\n\tLoadAjaxTiny('rules-toolbox-left','dansguardian2.mainrules.php?rules-toolbox-left=yes');\n\t\n</script>"; echo $table . "\n" . $js; }
function EXPLAIN_REVERSE($servername) { $q = new mysql_squid_builder(); $servernameencode = urlencode($servername); $exp[] = "<div style='float:right;margin:10px'>\n\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('miniadmin.proxy.reverse.reconfigure.php?servername={$servernameencode}')\">\n\t\t\t<img src='img/reconfigure-42.png' style='width:42px'></a></div>"; $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM reverse_www WHERE servername='{$servername}'")); $ssl = "{proto} (HTTP) "; $proxy_buffering = $ligne["proxy_buffering"]; if ($ligne["ssl"] == 1) { $ssl = "{proto} (HTTP<b>S</b>) "; if ($ligne["port"] == 80) { $ssl = "{proto} (HTTP) {and} {proto} (HTTP<b>S</b>) "; } } $page = CurrentPageName(); $cache_peer_id = $ligne["cache_peer_id"]; if ($cache_peer_id > 0) { $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT servername,ipaddr,port,ForceRedirect,OnlyTCP FROM reverse_sources WHERE ID='{$ligne["cache_peer_id"]}'")); if (!$q->ok) { echo "<p class=text-error>{$q->mysql_error} in " . basename(__FILE__) . " line " . __LINE__ . "</p>"; } $ForceRedirect = "<br>{ForceRedirectyes_explain_table}"; if ($ligne["ForceRedirect"] == 0) { $ForceRedirect = "<br>{ForceRedirectno_explain_table}"; } if ($ligne["ssl"] == 1) { $ssl = "{proto} (HTTP<b>S</b>) "; } if ($ligne["OnlyTCP"] == 1) { $ssl = "{proto} TCP"; $ForceRedirect = null; } $js = "Loadjs('{$page}?js-source=yes&source-id={$ligne["cache_peer_id"]}')"; $exp[] = "<div><i style='font-size:12px'>{$ssl}"; if ($cache_peer_id > 0) { $exp[] = "{redirect_communications_to}"; $exp[] = "{$ligne["servername"]} {address} {$ligne["ipaddr"]} {on_port} {$ligne["port"]} id:{$cache_peer_id}"; $exp[] = $ForceRedirect; } } $sql = "SELECT * FROM nginx_exploits WHERE servername='{$servername}' LIMIT 0,5"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror($q->mysql_error); } $filters = array(); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $groupid = $ligne["groupid"]; $jsedit = "Loadjs('miniadmin.nginx.exploits.groups.php?js-group=yes&ID={$groupid}&servername={$_GET["servername"]}')"; $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(*) as tcount FROM nginx_exploits_items WHERE groupid='{$groupid}'")); $RulesNumber = $ligne2["tcount"]; $AF = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$jsedit}\" style='text-decoration:underline'>"; $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT groupname FROM nginx_exploits_groups WHERE ID='{$groupid}'")); $filters[] = "{group} {$AF}{$ligne2["groupname"]} ({$RulesNumber} {items})</a>"; } if (count($filters) > 0) { $exp[] = "<br>{check_anti_exploit_with}:" . @implode(", ", $filters); } $jsban = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('miniadmin.nginx.exploits.php?firewall-js=yes&servername={$servername}')\"\n\tstyle='text-decoration:underline'>"; $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT maxaccess,sendlogs FROM nginx_exploits_fw WHERE servername='{$servername}'")); if ($ligne["maxaccess"] > 0) { $exp[] = "<br>{bann_ip_after} {$jsban}{$ligne["maxaccess"]} {events}</a>"; } if ($ligne["sendlogs"] == 1) { $exp[] = ", {write_logs_for} {$jsban}403 {errors}</a>"; } $proxy_buffering_text = "<br><span style='color:#00B726'>{remote_webpages_are_cached}</span>"; if ($proxy_buffering == 0) { $proxy_buffering_text = "<br><span style='color:#878787'>{caching_webpages_is_disabled}</span>"; } $exp[] = $proxy_buffering_text; $exp[] = "</div>"; $tpl = new templates(); return $tpl->_ENGINE_parse_body(@implode(" ", $exp)); }
<?php session_start(); 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.user.inc"; include_once dirname(__FILE__) . "/ressources/class.squid.inc"; include_once dirname(__FILE__) . "/ressources/class.tcpip.inc"; include_once dirname(__FILE__) . "/ressources/class.squid.reverse.inc"; $PRIV = GetPrivs(); if (!$PRIV) { senderror("no priv"); } if (isset($_GET["tabs"])) { tabs(); exit; } if (isset($_GET["popup"])) { popup(); exit; } if (isset($_POST["import"])) { import(); exit; } if (isset($_GET["export1"])) { export_domains();
function NGINX_EXPLAIN_REVERSE($servername, $color = null) { $q = new mysql_squid_builder(); $servernameencode = urlencode($servername); $tpl = new templates(); if ($color == null) { $color = "black"; } $nginx_zavailb_explain = $tpl->javascript_parse_text("{nginx_zavailb_explain}"); $nginx_zavailb_explain = str_replace(",", ",<br>", $nginx_zavailb_explain); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM reverse_www WHERE servername='{$servername}'")); $proxy_buffering = $ligne["proxy_buffering"]; $RedirectQueries = $ligne["RedirectQueries"]; $servername_pattern = $ligne["servername_pattern"]; $servername_pattern_text = null; $zavail = $ligne["zavail"]; $site_enabled = $ligne["enabled"]; $ssl = "{proto} (HTTP) "; if ($ligne["ssl"] == 1) { $certificate_text = $tpl->_ENGINE_parse_body("<span style='font-weight:bold'>{certificate}: {default}</span><br>"); $ssl = "{proto} (HTTP<b>S</b>) "; if ($ligne["port"] == 80) { $ssl = "{proto} (HTTP) {and} {proto} (HTTP<b>S</b>) "; } } if ($ligne["certificate"] != null) { $CommonName = urlencode($ligne["certificate"]); $js = "<a href=\"javascript:blur()\"\n\t\tOnClick=\"javascript:Loadjs('certificates.center.php?certificate-edit-js=yes&CommonName={$CommonName}');\"\n\t\tstyle='text-decoration:underline'>"; $certificate_text = $tpl->_ENGINE_parse_body("<br>{certificate}: {$js}{$ligne["certificate"]}</a><br>"); } $page = CurrentPageName(); $cache_peer_id = $ligne["cache_peer_id"]; $ssl_backend = $ligne["ssl_backend"]; $DEST = array(); if ($cache_peer_id == 0) { return $tpl->_parse_body("<strong>{no_destination}</strong><br><i>{nginx_destination_none_explain}</i>"); } if ($cache_peer_id > 0) { $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT certificate,servername,ipaddr,port,ForceRedirect,OnlyTCP FROM reverse_sources WHERE ID='{$ligne["cache_peer_id"]}'")); if (!$q->ok) { echo "<p class=text-error>{$q->mysql_error} in " . basename(__FILE__) . " line " . __LINE__ . "</p>"; } $ForceRedirect = "<br>{ForceRedirectyes_explain_table}"; $destination_server = $ligne["servername"]; if ($ligne["ForceRedirect"] == 0) { $ForceRedirect = "<br>{ForceRedirectno_explain_table}"; } if ($ligne["ssl"] == 1) { $ssl = "{proto} (HTTP<b>S</b>) "; } if ($ligne["OnlyTCP"] == 1) { $ssl = "{proto} TCP"; $ForceRedirect = null; } $js = "Loadjs('{$page}?js-source=yes&source-id={$ligne["cache_peer_id"]}')"; if ($ligne["certificate"] != null) { $CommonName = urlencode($ligne["certificate"]); $js = "<a href=\"javascript:blur()\"\n\t\t\tOnClick=\"javascript:Loadjs('certificates.center.php?certificate-edit-js=yes&CommonName={$CommonName}');\"\n\t\t\tstyle='text-decoration:underline'>"; $certificate_text = $tpl->_ENGINE_parse_body("<br>{certificate} - <strong>{from}:{$destination_server}</strong> -: {$js}{$ligne["certificate"]}</a></strong><br>"); } $DEST[] = "<br>{$ssl}, "; if ($cache_peer_id > 0) { $DEST[] = "{redirect_communications_to}:"; if ($ssl_backend == 1) { $ligne["port"] = "<strong>443 (https)</strong>"; } $DEST[] = "<br>«{$ligne["servername"]}» {address} <strong>{$ligne["ipaddr"]}</strong> {on_port} <strong>{$ligne["port"]}</strong> id:{$cache_peer_id}"; if ($ForceRedirect != null) { $DEST[] = $ForceRedirect; } } } if (count($DEST) > 0) { $DESTINATION_TEXT = @implode(" ", $DEST); } $sql = "SELECT * FROM nginx_exploits WHERE servername='{$servername}' LIMIT 0,5"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror($q->mysql_error); } $filters = array(); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $groupid = $ligne["groupid"]; $jsedit = "Loadjs('miniadmin.nginx.exploits.groups.php?js-group=yes&ID={$groupid}&servername={$_GET["servername"]}')"; $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(*) as tcount FROM nginx_exploits_items WHERE groupid='{$groupid}'")); $RulesNumber = $ligne2["tcount"]; $AF = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$jsedit}\" style='text-decoration:underline'>"; $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT groupname FROM nginx_exploits_groups WHERE ID='{$groupid}'")); $filters[] = "{group} {$AF}{$ligne2["groupname"]} ({$RulesNumber} {items})</a>"; } if (count($filters) > 0) { $exp[] = "<br>{check_anti_exploit_with}:" . @implode(", ", $filters); } $jsban = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('miniadmin.nginx.exploits.php?firewall-js=yes&servername={$servername}')\"\n\tstyle='text-decoration:underline'>"; $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT maxaccess,sendlogs FROM nginx_exploits_fw WHERE servername='{$servername}'")); if ($ligne["maxaccess"] > 0) { $exp[] = "<br>{bann_ip_after} {$jsban}{$ligne["maxaccess"]} {events}</a>"; } if ($ligne["sendlogs"] == 1) { $exp[] = ", {write_logs_for} {$jsban}403 {errors}</a>"; } if ($RedirectQueries == null) { $proxy_buffering_text = "<br><span style='color:#00B726'>{remote_webpages_are_cached}</span>"; if ($proxy_buffering == 0) { $proxy_buffering_text = "<br><span style='color:#878787'>{caching_webpages_is_disabled}</span>"; } if ($proxy_buffering_text != null) { $exp[] = $proxy_buffering_text; } } if ($RedirectQueries != null) { $DESTINATION_TEXT = "<br>{RedirectQueries_explain_table}<br><a href=\"{$RedirectQueries}\" target=_new style='text-decoration:underline'>{$RedirectQueries}</a>"; } if ($servername_pattern != null) { $servername_pattern_text = "{replace_server_directive}: <strong>{$servername_pattern}</strong>"; } $sql = "SELECT * FROM nginx_aliases WHERE servername='{$servername}' ORDER BY alias LIMIT 0,250"; $results2 = $q->QUERY_SQL($sql); $ali = array(); $alitext = null; while ($ligne = mysql_fetch_array($results2, MYSQL_ASSOC)) { $ali[] = "<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:Loadjs('nginx.site.aliases.php?popup-js=yes&servername={$servernameencode}');\"\n\t\t\tstyle='text-decoration:underline;color:{$color}'>{$ligne["alias"]}</a>"; } if (count($ali) > 0) { $alitext = "{alias}: (" . @implode("{or} ", $ali) . ") " . "<br>"; } if ($site_enabled == 1) { if ($zavail == 0) { $zavail_text = "<br><i style='font-size:18px;color:#d32d2d'>{$nginx_zavailb_explain}</i>"; } } $html = $tpl->_ENGINE_parse_body("{$zavail_text}<i style='font-size:18px;color:{$color}'>{$certificate_text}{$alitext}{$servername_pattern_text}{$DESTINATION_TEXT}" . @implode(" ", $exp) . "</i>"); $html = str_replace("<br><br>", "<br>", $html); return $html; }
function tabs() { $boot = new boostrap_form(); $page = CurrentPageName(); $tpl = new templates(); if (!is_numeric($_GET["xtime"])) { $_GET["xtime"] = strtotime("{$_GET["year"]}-{$_GET["month"]}-{$_GET["day"]} 00:00:00"); } $dateT = time_to_date($_GET["xtime"]); if (isset($_GET["xtime"])) { $_GET["year"] = date("Y", $_GET["xtime"]); $_GET["month"] = date("m", $_GET["xtime"]); $_GET["day"] = date("d", $_GET["xtime"]); $_GET["tablename"] = date("Ymd", $_GET["xtime"]) . "_members"; } $q = new mysql_squid_builder(); if (!$q->TABLE_EXISTS($_GET["tablename"])) { senderror("{table_does_not_exists} {$_GET["tablename"]} {use_the_tools_section}"); } $t = $_GET["t"]; $display_members_for_this_day = $tpl->javascript_parse_text("{$dateT}: {display_members_for_this_day}"); $subtitle = "<a href=\"javascript:blur();\" OnClick=\"Loadjs(\\'miniadm.webstats.php?calendar-js=yes&div=tab-{$t}&prefix=tabs=yes&t={$t}&source-page={$page}\\')\">{$display_members_for_this_day}</a>"; $title = "<script>\n\t\t\tdocument.getElementById('MembersSubtitlePage').innerHTML='{$subtitle}';\n\t\t</script>"; if (isset($_GET["title"])) { $title = "<H3>{$display_members_for_this_day}</H3>"; } $array["{uid}"] = "{$page}?webstats-middle=yes&t={$t}&year={$_GET["year"]}&month={$_GET["month"]}&day={$_GET["day"]}&tablename={$_GET["tablename"]}&xtime={$_GET["xtime"]}&FILTER=uid');"; $array["{ipaddr}"] = "{$page}?webstats-middle=yes&t={$t}&year={$_GET["year"]}&month={$_GET["month"]}&day={$_GET["day"]}&tablename={$_GET["tablename"]}&xtime={$_GET["xtime"]}&FILTER=client');"; $array["{MAC}"] = "{$page}?webstats-middle=yes&t={$t}&year={$_GET["year"]}&month={$_GET["month"]}&day={$_GET["day"]}&tablename={$_GET["tablename"]}&xtime={$_GET["xtime"]}&FILTER=MAC');"; $array["{hostname}"] = "{$page}?webstats-middle=yes&t={$t}&year={$_GET["year"]}&month={$_GET["month"]}&day={$_GET["day"]}&tablename={$_GET["tablename"]}&xtime={$_GET["xtime"]}&FILTER=hostname');"; echo $title . $boot->build_tab($array); }
function list_nets() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql(); $t = $_GET["t"]; $search = '%'; $table = "dhcpd_logs"; $database = 'artica_events'; $page = 1; $FORCE_FILTER = ""; $ORDER = "ORDER BY zDate DESC"; if (!$q->TABLE_EXISTS($table, $database)) { throw new Exception("{$table}, No such table...", 500); } if ($q->COUNT_ROWS($table, $database) == 0) { throw new Exception("No data...", 500); } 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("search-records"); $sql = "SELECT * FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} limit 0,250"; $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { senderror($q->mysql_error, 1); } if (mysql_num_rows($results) == 0) { senderror("no data"); } $sock = new sockets(); $cmp = new computers(); $boot = new boostrap_form(); $computers = new computers(); while ($ligne = mysql_fetch_assoc($results)) { $color = "black"; $uid = null; $mac = null; if (preg_match("#to\\s+([0-9a-z:]+)\\s+via#", $ligne["description"], $re)) { $mac = $re[1]; } if (preg_match("#from\\s+([0-9a-z:]+)\\s+via#", $ligne["description"], $re)) { $mac = $re[1]; } $js = "zBlur();"; if ($mac != null) { $uid = $computers->ComputerIDFromMAC($mac); if ($uid != null) { $js = MEMBER_JS($uid, 1, 1); $ligne["description"] = str_replace($mac, "<strong><i class='icon-info-sign'></i> {$mac}</strong></strong>", $ligne["description"]); } } $link = $boot->trswitch($js); $tr[] = "\n\t\t<tr id='{$id}'>\n\t\t<td nowrap {$link}><i class='icon-time'></i> {$ligne["zDate"]}</td>\n\t\t<td {$link} ><i class='icon-info-sign'></i> {$ligne["description"]}</td>\n\t\t</tr>"; } echo $tpl->_ENGINE_parse_body("\n\t\n\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{zDate}</th>\n\t\t\t\t\t<th>{events}</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\t\t</table>\n\t\t\t\t"; }
function graph1_1() { $q = new mysql_squid_builder(); $page = CurrentPageName(); $tpl = new templates(); $t = $_GET["t"]; $ff = time(); $tablename = date("Ymd", $_GET["xtime"]) . "_hour"; $category = mysql_escape_string2($_GET["category"]); if ($_GET["category"] == "unknown") { $_GET["category"] = null; } $sql = "SELECT SUM(size) as size, `hour`,`category` FROM {$tablename} GROUP BY `hour`,`category`\n\tHAVING `category`='{$_GET["category"]}'\n\tORDER BY `hour`"; $c = 0; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror("{$q->mysql_error}<br>{$sql}"); } if (mysql_num_rows($results) > 0) { $nb_events = mysql_num_rows($results); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $xdata[] = $ligne["hour"]; $ligne["size"] = round($ligne["size"] / 1024 / 1000); $ydata[] = $ligne["size"]; $c++; } } $highcharts = new highcharts(); $highcharts->container = $_GET["container"]; $highcharts->xAxis = $xdata; $highcharts->Title = "{$category}: {size}/{hour}"; $highcharts->yAxisTtitle = "{size}"; $highcharts->xAxisTtitle = "{hours}"; $highcharts->datas = array("{size}" => $ydata); echo $highcharts->BuildChart(); }
function splash_search() { $q = new mysql(); $searchstring = string_to_flexquery(); $q->QUERY_SQL("DELETE FROM freeweb WHERE servername=''", "artica_backup"); $sql = "SELECT * FROM freeweb WHERE groupware='CHILLI' {$searchstring}"; $results = $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { senderror($q->mysql_error); } $tpl = new templates(); $deleteTXT = $tpl->javascript_parse_text("{delete}"); $t = time(); if (mysql_num_rows($results) == 0) { senderror("No data"); } $boot = new boostrap_form(); $page = CurrentPageName(); $t = time(); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $md = md5(serialize($ligne)); $servername = $ligne["servername"]; $delete = imgtootltip("delete-64.png", null, "Delete{$t}('{$servername}','{$md}')"); $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t<td width=1% nowrap {$jsedit} style='vertical-align:middle'><img src='img/webfilter-64.png'></td>\n\t\t<td width=80% {$jsedit} style='vertical-align:middle'><span style='font-size:18px;font-weight:bold'>{$servername}</span></td>\n\t\t<td width=1% nowrap style='vertical-align:middle'>{$delete}</td>\n\t\t</tr>\n\t\t"; } $page = CurrentPageName(); $freeweb_compile_background = $tpl->javascript_parse_text("{freeweb_compile_background}"); $reset_admin_password = $tpl->javascript_parse_text("{reset_admin_password}"); $delete_freeweb_text = $tpl->javascript_parse_text("{delete_freeweb_text}"); $delete_freeweb_dnstext = $tpl->javascript_parse_text("{delete_freeweb_dnstext}"); echo $tpl->_ENGINE_parse_body("\n\t\n\t\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>{servername2}</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>") . @implode("", $tr) . "</tbody></table>\n\t\t\t\t\t<script>\n\t\t\t\t\tvar FreeWebIDMEM{$t}='';\n\t\n\t\t\t\t\tvar xDelete{$t}=function (obj) {\n\t\t\t\t\tvar results=obj.responseText;\n\t\t\t\t\tif(results.length>10){alert(results);return;}\n\t\t\t\t\t\$('#'+FreeWebIDMEM{$t}).remove();\n\t}\n\t\n\tfunction Delete{$t}(id,md){\n\tFreeWebIDMEM{$t}=md;\n\tif(confirm('{$deleteTXT}')){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('splash-delete',id);\n\tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n\t}\n</script>"; }
function search_database() { $page = 1; $MyPage = CurrentPageName(); $users = new usersMenus(); $tpl = new templates(); $sock = new sockets(); $q = new mysql_storelogs(); if (!$q->BD_CONNECT()) { senderror($q->mysql_error); } if ($q->start_error != null) { senderror($q->start_error); } $table = "files_info"; $tableOrg = $table; $database = $q->database; $t = time(); $delete_alert = $tpl->javascript_parse_text("{delete_this_item}"); $MySQLType = $tpl->_ENGINE_parse_body($q->MYSQLTypeText); //if(!$q->TABLE_EXISTS($table,$database)==0){senderror("{table_does_not_exists}: <strong>$database/$table</strong> $MySQLType: `$q->SocketName`!");} if ($q->COUNT_ROWS($table, $database) == 0) { senderror("{$table}/{$database} is empty"); } $searchstring = string_to_flexquery("search-database"); $limit = "LIMIT 0,250"; if (is_numeric($_GET["xtime"])) { $WHERE1 = " (DATE_FORMAT(filetime,'%Y-%m-%d')='" . date("Y-m-d") . "') AND"; unset($_SESSION["QUERY_SYSLOG_DATE"]); } if ($_SESSION["QUERY_SYSLOG_LIMIT"] > 0) { $limit = "LIMIT 0,{$_SESSION["QUERY_SYSLOG_LIMIT"]}"; } $filters = array(); $filters[] = SearchToSql("DATE_FORMAT(filetime,'%Y-%m-%d')", $_SESSION["QUERY_SYSLOG_DATE"]); $filters[] = SearchToSql("filename", $_SESSION["QUERY_SYSLOG_FILE"]); $filters[] = SearchToSql("hostname", $_SESSION["QUERY_SYSLOG_HOST"]); $table = "(SELECT `filename`,`taskid`,`storeid`,`filesize`,`filetime`,`hostname` FROM {$table}\n\t\t\tWHERE {$WHERE1} (`filename` LIKE 'auth.log%') OR (filename LIKE 'squid-access%')) as t"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} " . @implode(" ", $filters) . " ORDER BY `filetime` DESC LIMIT 0,250"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); if (!$q->ok) { senderror("{$q->mysql_error}"); } if (mysql_num_rows($results) == 0) { senderror("Query return empty array"); } $boot = new boostrap_form(); while ($ligne = mysql_fetch_assoc($results)) { $md5S = md5(serialize($ligne)); $filename = $ligne["filename"]; $hostname = $ligne["hostname"]; $storeid = $ligne["storeid"]; $taskid = $ligne["taskid"]; $filesize = FormatBytes($ligne["filesize"] / 1024); $filetime = $ligne["filetime"]; $delete = imgsimple("delete-32.png", null, "Delete{$t}('{$storeid}','{$md5S}')"); $action = " "; if (preg_match("#auth\\.log-.*?#", $ligne["filename"])) { $action = imgsimple("32-import.png", null, "Loadjs('squid.restoreSource.php?filename={$ligne["filename"]}&storeid={$storeid}')"); } if (preg_match("#squid-access-(.*?)\\.log\\.#", $ligne["filename"])) { $action = imgsimple("32-import.png", null, "Loadjs('squid.restoreSource.php?filename={$ligne["filename"]}&storeid={$storeid}')"); } $download = "<a href=\"{$MyPage}?download={$storeid}&filename={$ligne["filename"]}&storeid={$storeid}\"><img src='img/arrow-down-32.png'></a>"; $js = "Loadjs('logrotate.php?log-js=yes&filename={$filename}&storeid={$storeid}&t=1368560783');"; $trlink = $boot->trswitch($js); $tr[] = "\n\t\t<tr id='{$md5S}'>\n\t\t<td nowrap {$trlink}>{$filetime}</td>\n\t\t<td nowrap {$trlink}>{$filename}</td>\n\t\t<td nowrap {$trlink}>{$hostname}</td>\n\t\t<td nowrap {$trlink}>{$filesize}</td>\n\t\t<td width=1% align=center>{$download}</td>\n\t\t<td width=1% align=center>{$action}</td>\n\t\t<td width=1% align=center>{$delete}</td>\n\t\t</tr>\n\t\t"; } 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>{date}</th>\n\t\t\t\t\t<th>{filename}</th>\n\t\t\t\t\t<th>{hostname}</th>\n\t\t\t\t\t<th>{size}</th>\n\t\t\t\t\t<th> </th>\n\t\t\t\t\t<th> </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>\n\t\t\t<script>\n\t\t\tvar memedb{$t}='';\n\t\t\tvar xDelete{$t}= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>2){alert(results);return;}\n\t\t\t\$('#'+memedb{$t}).remove();\n}\n\n\t\t\tfunction Delete{$t}(ID,md){\n\t\t\tmemedb{$t}=md;\n\t\t\tif(confirm('{$delete_alert} '+ID+' ?')){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('syslog-delete',ID);\n\t\t\tXHR.sendAndLoad('{$MyPage}', 'POST', xDelete{$t});\n}\n}\n\t\t\t</script>"; }
function search() { $prox = new squid_reverse(); $searchstring = string_to_flexquery("group-search"); $q = new mysql_squid_builder(); if (!$q->TABLE_EXISTS("nginx_exploits")) { $sql = "CREATE TABLE IF NOT EXISTS `nginx_exploits` (\n\t\t\t `zmd5` VARCHAR(90) NOT NULL,\n\t\t\t `groupid` INT NOT NULL,\n\t\t\t `servername` CHAR(255) NOT NULL,\n\t\t\t PRIMARY KEY (`zmd5`),\n\t\t\t KEY `servername` (`servername`),\n\t\t\t KEY `groupid` (`groupid`)\n\t\t\t) ENGINE = MYISAM;"; $q->QUERY_SQL($sql); if (!$q->ok) { senderror($q->mysql_error); } } $sql = "SELECT * FROM nginx_exploits WHERE servername='{$_GET["servername"]}' LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderror($q->mysql_error); } $tpl = new templates(); $boot = new boostrap_form(); $page = CurrentPageName(); $t = time(); if ($GLOBALS["VERBOSE"]) { echo "<H1>{$sql}</H1><br>" . mysql_num_rows($results) . " Entries<hr>"; } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $groupid = $ligne["groupid"]; $icon = "www-web-search-64.png"; $icon2 = "folder-network-64.png"; $color = "black"; $md = md5(serialize($ligne)); $delete = imgsimple("delete-64.png", null, "Loadjs('{$page}?unlink-js=yes&zmd5={$ligne["zmd5"]}&groupid={$groupid}&servername={$_GET["servername"]}')"); $jsedit = $boot->trswitch("Loadjs('miniadmin.nginx.exploits.groups.php?js-group=yes&ID={$groupid}&servername={$_GET["servername"]}')"); $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(*) as tcount FROM nginx_exploits_items WHERE groupid='{$groupid}'")); $RulesNumber = $ligne2["tcount"]; $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT groupname FROM nginx_exploits_groups WHERE ID='{$groupid}'")); if (!$q->ok) { echo $q->mysql_error_html(); } $groupname = $ligne2["groupname"]; $tr[] = "\n\t\t<tr style='color:{$color}' id='{$md}'>\n\t\t<td width=1% nowrap {$jsedit} style='vertical-align:middle' nowrap><img src='img/{$icon}'></td>\n\t\t<td width=80% {$jsedit} style='vertical-align:middle'>\n\t\t<span style='font-size:18px;font-weight:bold'>{$groupname}</span>\n\t\t</td>\n\n\t\t<td width=1% nowrap {$jsedit} style='vertical-align:middle;text-align:center' nowrap>\n\t\t<span style='font-size:18px;font-weight:bold'>{$RulesNumber}</span>\n\t\t</td>\n\t\t<td width=1% nowrap style='vertical-align:middle;text-align:center'>{$delete}</td>\n\t\t</tr>\n\t\t"; } 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 colspan=2>{group}</th>\n\t\t\t\t\t<th >{items}</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>") . @implode("", $tr) . "</tbody></table>\n\t\t\t <script>\n\t\t\t var FreeWebIDMEM{$t}='';\n\t\t\t var xDelete{$t}=function (obj) {\n\t\t\t var results=obj.responseText;\n\t\t\t if(results.length>10){alert(results);return;}\n\t\t\t \$('#'+FreeWebIDMEM{$t}).remove();\n}\n\nfunction Delete{$t}(ID,md){\nFreeWebIDMEM{$t}=md;\nif(confirm('Remove '+ID+'?')){\nvar XHR = new XHRConnection();\nXHR.appendData('replace-group-delete',ID);\nXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n}\n}</script>\n"; }