Beispiel #1
0
function report()
{
    if (!is_file("/usr/share/artica-postfix/ressources/logs/categorized.array")) {
        return;
    }
    $ARRAY = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/categorized.array"));
    $stats_sites = $ARRAY["stats_sites"];
    $stats_categorized = $ARRAY["stats_categorized"];
    $stats_not_categorized = $ARRAY["stats_not_categorized"];
    $SumOflines = $ARRAY["SumOflines"];
    $stats_ip = $ARRAY["stats_ip"];
    $FIRSTTIME = $ARRAY["firsttime"];
    $LASTTIME = $ARRAY["lasttime"];
    $rate = $stats_categorized / $stats_sites;
    $rate = $rate * 100;
    $rate = round($rate, 2);
    $stats_not_categorized = FormatNumber($stats_not_categorized);
    $stats_categorized = FormatNumber($stats_categorized);
    $stats_sites = FormatNumber($stats_sites);
    $stats_ip = FormatNumber($stats_ip);
    $SumOflines = FormatNumber($SumOflines);
    if ($rate > 60) {
        $rate_color = "46a346";
    }
    if ($rate < 60) {
        $rate_color = "d32d2d";
    }
    $tpl = new templates();
    $html = "<div style='width:98%' class=form>\n\t\n\t<div style='font-size:18px;margin-bottom:15px'>{from} " . $tpl->time_to_date($FIRSTTIME) . " {to} " . $tpl->time_to_date($LASTTIME) . " (" . distanceOfTimeInWords($FIRSTTIME, $LASTTIME) . ")</div>\n\t\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{rate}:</td>\n\t\t<td style='font-size:22px;text-align:right'><strong style='font-size:36px;color:{$rate_color}'>{$rate}%</strong></td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{duration}:</td>\n\t\t<td style='font-size:22px;text-align:right'><strong>{$ARRAY["DURATION"]}</strong></td>\n\t\t<td>&nbsp;</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{lines}:</td>\n\t\t<td style='font-size:22px;text-align:right'><strong>{$SumOflines}</strong></td>\n\t\t<td>&nbsp;</td>\n\t</tr>\t\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{not_categorized}:</td>\n\t\t<td style='font-size:22px;text-align:right'><strong>{$stats_not_categorized}</strong></td>\n\t\t<td><a href=\"ressources/logs/notcategorized.csv\"><img src='img/csv-32.png'></a></td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{categorized}:</td>\n\t\t<td style='font-size:22px;text-align:right'><strong>{$stats_categorized}</strong></td>\n\t\t<td><a href=\"ressources/logs/categorized.csv\"><img src='img/csv-32.png'></a></td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{ipaddresses}:</td>\n\t\t<td style='font-size:22px;text-align:right'><strong>{$stats_ip}</strong></td>\n\t\t<td><a href=\"ressources/logs/ipcategorized.csv\"><img src='img/csv-32.png'></a></td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:22px'>{websites}:</td>\n\t\t<td style='font-size:22px;text-align:right'><strong>{$stats_sites}</strong></td>\n\t\t<td>&nbsp;</td>\n\t\t\n\t</tr>\t\n\t</table>\n\t</div>\t\t\t\t\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Beispiel #2
0
function table()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $t = time();
    $explain_section = $tpl->_ENGINE_parse_body("{routes_center_explain}");
    $t = time();
    $type = $tpl->_ENGINE_parse_body("{type}");
    $gateway = $tpl->_ENGINE_parse_body("{gateway}");
    $items = $tpl->_ENGINE_parse_body("{items}");
    $nic = $tpl->javascript_parse_text("{nic}");
    $order = $tpl->javascript_parse_text("{order}");
    $title = $tpl->javascript_parse_text("{boots}");
    $ttl = $tpl->_ENGINE_parse_body("{ttl}");
    $date = $tpl->_ENGINE_parse_body("{date}");
    $subject = $tpl->_ENGINE_parse_body("{infos}");
    $q = new mysql();
    $sys_alerts = FormatNumber($q->COUNT_ROWS("last_boot", "artica_events"));
    // 	$sql="INSERT INTO nic_routes (`type`,`gateway`,`pattern`,`zmd5`,`nic`)
    // VALUES('$type','$gw','$pattern/$cdir','$md5','$route_nic');";
    $buttons = "\n\tbuttons : [\n\t{name: '{$new_route}', bclass: 'add', onpress : Add{$t}},\n\t{name: '{$test_a_route}', bclass: 'Search', onpress : TestRoute{$t}},\n\t{name: '{$apply}', bclass: 'apply', onpress : Apply{$t}},\n\n\n\t],";
    $buttons = null;
    $html = "\n\t<table class='flexRT{$t}' style='display: none' id='flexRT{$t}' style='width:100%'></table>\n\n\t<script>\n\tvar rowid=0;\n\t\$(document).ready(function(){\n\t\$('#flexRT{$t}').flexigrid({\n\turl: '{$page}?search=yes&t={$t}',\n\tdataType: 'json',\n\tcolModel : [\n\t{display: '{$date}', name : 'zDate', width : 450, sortable : true, align: 'left'},\n\t{display: '{$subject}', name : 'subject', width : 341, sortable : true, align: 'left'},\n\t{display: '{$ttl}', name : 'load', width : 312, sortable : true, align: 'right'},\n\t\n\t],\n\t{$buttons}\n\tsearchitems : [\n\t{display: '{$date}', name : 'zDate'},\n\t{display: '{$subject}', name : 'subject'},\n\t],\n\tsortname: 'zDate',\n\tsortorder: 'desc',\n\tusepager: true,\n\ttitle: '{$title}:: {$sys_alerts}',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 450,\n\tsingleSelect: true,\n\trpOptions: [10, 20, 30, 50,100,200]\n\n});\n});\n\n\nfunction Add{$t}(){\nLoadjs('{$page}?route-js=yes&zmd5=&t={$t}');\n}\nfunction TestRoute{$t}(){\n\tLoadjs('{$page}?test-route-js=yes');\n}\n\nfunction Apply{$t}(){\n\tLoadjs('network.restart.php?t={$t}')\n\n}\n\nvar x_DansGuardianDelGroup= function (obj) {\n\tvar res=obj.responseText;\n\tif (res.length>3){alert(res);}\n\t\$('#row'+rowid).remove();\n}\n\nfunction DansGuardianDelGroup(ID){\n\tif(confirm('{$do_you_want_to_delete_this_group} ?')){\n\t\trowid=ID;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('Delete-Group', ID);\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_DansGuardianDelGroup);\n\t}\n}\n</script>\n";
    echo $html;
}
Beispiel #3
0
function status(){
	
	$q=new mysql();
	$page=CurrentPageName();
	$tpl=new templates();
	$total=FormatNumber($q->COUNT_ROWS("dansguardian_community_categories","artica_backup"),0,'.',' ',3);
	
	
	$sql="SELECT count(*) as tcount FROM `dansguardian_sitesinfos` WHERE `dbpath` = ''";	
	$ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup'));
	
	
	$pp=Paragraphe("64-categories.png",$ligne["tcount"]." {websites_not_categorized}",
	"{websites_not_categorized_text}","javascript:Loadjs('squid.visited.php')",null,300,76);	
	
	
	$html="
	<table style='width:100%'>
	<tr>
	<td valign='top'><img src='img/webfilter-community-128.png'></td>
	<td valign='top' width=99%'>
		<div class=explain>{APP_WEBFILTER_COMMUNITY_EXPLAIN}</div>
		<div style='font-size:14px;font-weight:bold'>$total {websites} ({community})</div>
		$pp
	</td>
	</tr>
	</table>
	
	
	";
	
	echo $tpl->_ENGINE_parse_body($html);
	
}
function popup()
{
    $artica_meta = new mysql_meta();
    $LicenseInfos = $artica_meta->LicenseInfos($_GET["uuid"]);
    $page = CurrentPageName();
    $tpl = new templates();
    $FINAL_TIME = 0;
    if (isset($LicenseInfos["FINAL_TIME"])) {
        $FINAL_TIME = intval($LicenseInfos["FINAL_TIME"]);
    }
    $LICT = "Community Edition";
    if ($LicenseInfos["CORP_LICENSE"]) {
        $LICT = "Entreprise Edition";
    }
    if ($LicenseInfos["ExpiresSoon"] > 0) {
        if ($LicenseInfos["ExpiresSoon"] < 31) {
            $LICT = "<span style='color:red'>{trial_mode}</span>";
        }
    }
    if ($FINAL_TIME > 0) {
        $ExpiresSoon = intval(time_between_day_Web($FINAL_TIME));
        if ($ExpiresSoon < 7) {
            $ExpiresSoon_text = "<strong style='color:red;font-size:16px'>&nbsp;{ExpiresSoon}</strong>";
        }
        $licenseTime = "\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:24px'>{expiredate}:</td>\n\t\t\t\t<td style='font-size:24px'>" . $tpl->time_to_date($FINAL_TIME) . " (" . distanceOfTimeInWords(time(), $FINAL_TIME) . "{$ExpiresSoon_text})</td>\n\t\t\t\t\t</tr>";
    }
    if (is_numeric($LicenseInfos["TIME"])) {
        $tt = distanceOfTimeInWords($LicenseInfos["TIME"], time());
        $last_access = "\n\t\t<tr>\n\t\t<td class=legend style='font-size:24px'>{last_update}:</td>\n\t\t<td style='font-size:24px'>{since} {$tt}</td>\n\t\t</tr>";
    }
    $html = "<div style='font-size:30px'>{$LICT}</div><div style='width:98%' class=form>\n<table style='width:100%'>\n\t</tr>\n\t{$last_access}\n\t<tr>\n\t\t<td class=legend style='font-size:24px'>{company}:</td>\n\t\t<td><span style='font-size:24px;font-weight:bold'>{$LicenseInfos["COMPANY"]}</span></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:24px'>{your_email_address}:</td>\n\t\t\t\t<td><span style='font-size:24px;font-weight:bold'>{$LicenseInfos["EMAIL"]}</span></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:24px'>{nb_employees}:</td>\n\t\t\t\t<td><span style='font-size:24px;font-weight:bold'>" . FormatNumber($LicenseInfos["EMPLOYEES"]) . "</span></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:24px'>{license_number}:</td>\n\t\t\t\t<td style='font-size:24px'>{$LicenseInfos["license_number"]}</td>\n\t\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:24px'>{license_status}:</td>\n\t\t\t<td style='font-size:24px;'>{$LicenseInfos["license_status"]}</td>\n\t\t</tr>\n\t\t{$licenseTime}\n\t</table>\n</td>\n</table></div>";
    echo $tpl->_ENGINE_parse_body($html);
}
function popup()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $q = new postgres_sql();
    $ligne = pg_fetch_assoc($q->QUERY_SQL("SELECT * FROM suricata_sig WHERE signature='{$_GET["sig"]}'"));
    $ligne2 = pg_fetch_assoc($q->QUERY_SQL("SELECT SUM(xcount) as tcount FROM suricata_events WHERE signature='{$_GET["sig"]}'"));
    $sum = FormatNumber($ligne2["tcount"]);
    $t = time();
    $html = "<div style='font-size:30px;margin-bottom:8px;'>{signature} {ID} <strong>{$_GET["sig"]}</strong></div>\n\t<div style='font-size:18px;margin-bottom:30px;border-top:1px solid #CCCCCC;padding-top:8px'><i>{$ligne["description"]}</i></div>\n\t<div style='width:98%' class=form>\n\t\n\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:22px'>{events}:</td>\n\t\t\t<td style='font-size:22px'>{$sum}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:22px'>{enabled}:</td>\n\t\t\t<td>" . Field_checkbox_design("enabled-{$t}", 1, $ligne["enabled"]) . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td class=legend style='font-size:22px'>" . texttooltip("{firewall}", "{suricata_firewall}") . ":</td>\n\t\t\t<td>" . Field_checkbox_design("firewall-{$t}", 1, $ligne["firewall"]) . "</td>\n\t\t</tr>\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t<tr>\n\t\t\t<td colspan=2 align='right'><hr>" . button("{apply}", "Save{$t}()", 30) . "</td>\n\t</table>\n\t</div>\t\t\t\n\t<script>\n\tvar xSave{$t}=function (obj) {\n\t\tvar tempvalue=obj.responseText;\n\t\tif(tempvalue.length>3){alert(tempvalue);return;}\n\t\t\$('#TABLE_SURICATA_EVENTS').flexReload();\n\t\tYahooWinHide();\n\t\tLoadjs('suricata.progress.php');\n\t}\t\n\t\n\tfunction Save{$t}(){\n\t\tvar XHR = new XHRConnection();\n\t\tvar enabled=0;\n\t\tvar firewall=0;\n\t\tif(document.getElementById('enabled-{$t}').checked){enabled=1;}\n\t\tif(document.getElementById('firewall-{$t}').checked){firewall=1;}\n\t\tXHR.appendData('enabled',enabled);\n\t\tXHR.appendData('firewall',firewall);\n\t\tXHR.appendData('sig','{$_GET["sig"]}');\n\t\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\t\n\t}\t\n\n\t</script>\t\t\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Beispiel #6
0
function popup()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $sock = new sockets();
    $ini = new Bs_IniHandler();
    $users = new usersMenus();
    $sock->getFrameWork("clamav.php?sigtool=yes");
    $bases = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/interface-cache/ClamAVBases"));
    if (count($bases) > 0) {
        $DBS[] = "<table style='width:100%; -webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;border:2px solid #CCCCCC'>\n\t\t\t<tr style='height:80px'>\n\t\t\t\t\t\t<td style='font-size:26px' colspan=2><strong>{clamav_antivirus_patterns_status}</td>\n\t\t\t\t</tr>\n\t\t\t</table>";
        while (list($db, $MAIN) = each($bases)) {
            $DBS[] = "\n\t\t\t<table style='width:100%;margin-top:15px;-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;border:2px solid #CCCCCC'>\n\t\t\t<tr>\n\t\t\t\t<td style='font-size:24px' colspan=2><strong>{$db}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td style='font-size:22px' class=legend>{date}:</td>\n\t\t\t\t<td style='font-size:22px'><strong>{$MAIN["zDate"]}</strong></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td style='font-size:22px' class=legend>{version}:</td>\n\t\t\t\t<td style='font-size:22px'><strong>{$MAIN["version"]}</strong></td>\n\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td style='font-size:22px' class=legend>{signatures}:</td>\n\t\t\t\t\t<td style='font-size:22px'><strong>" . FormatNumber($MAIN["signatures"]) . "</strong></td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t";
        }
    } else {
        $DBS[] = FATAL_ERROR_SHOW_128("{missing_clamav_pattern_databases}");
    }
    $DBS[] = "\n\t<table style='width:100%'>\n\t<tr  style='height:80px'>\n\t\t<td align='right'><hr>" . button("{update_now}", "Loadjs('clamav.update.progress.php')", 42) . "</td>\n\t</tr>\n\t</table>";
    $html = "\n\t<div style='font-size:30px;margin-bottom:20px'>{clamav_antivirus_databases}</div>\t\t\n\t<div style='width:98%' class=form>\n\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td valign='top' style='width:600px'>\n\t\t\t\t<div id='FreshClamOptions'></div>\n\t\t\t</td>\n\t\t\t<td valign='top' style='width:600px'>\n\t\t\t" . @implode("\n", $DBS) . "</td>\n\t\t</tr>\n\t</table>\n\t</div>\n\t<script>\n\t\tLoadAjax('FreshClamOptions','{$page}?FreshClamOptions=yes');\n\t</script>\t\t\t\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
function loggers_status()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $data = unserialize(base64_decode($sock->getFrameWork("squid.php?loggers-status=yes")));
    if (!is_array($data)) {
        return;
    }
    while (list($PID, $ARRAY) = each($data)) {
        $timettl = $ARRAY["TTL"];
        $PURGED = $ARRAY["PURGED"];
        $COUNT_RQS = $ARRAY["COUNT_RQS"];
        $PURGED = FormatNumber($PURGED);
        $COUNT_RQS = FormatNumber($COUNT_RQS);
        if ($ARRAY["LASTTIME"] > 0) {
            $Laststatus = distanceOfTimeInWords($ARRAY["LASTTIME"], time(), true);
        } else {
            $Laststatus = "-";
        }
        $f[] = "\n\t\t<div style='width:550px;margin-bottom:20px' class=form>\n\t\t<table>\n\t\t<tr>\n\t\t\t<td style='min-width:68px;vertical-align:top'><img src='img/process-64.png'></td>\n\t\t\t<td style='min-width:482px;vertical-align:top'>\t\t\n\t\t\t\t<table>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign='top' style='font-size:18px' class=legend>{PID}:</td>\n\t\t\t\t\t\t<td valign='top' style='font-size:18px'>{$PID}</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' style='font-size:18px' class=legend>{running_since}:</td>\n\t\t\t\t\t\t<td valign='top' style='font-size:18px'>{$timettl}mn</td>\n\t\t\t\t\t</tr>\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign='top' style='font-size:18px' class=legend>{purged_events}:</td>\n\t\t\t\t\t\t<td valign='top' style='font-size:18px'>{$PURGED}</td>\n\t\t\t\t\t</tr>\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign='top' style='font-size:18px' class=legend>{received_connections}:</td>\n\t\t\t\t\t\t<td valign='top' style='font-size:18px'>{$COUNT_RQS}</td>\n\t\t\t\t\t</tr>\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td valign='top' style='font-size:18px' class=legend>{last_status}:</td>\n\t\t\t\t\t\t<td valign='top' style='font-size:18px'>{$Laststatus}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t\t</div>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t";
    }
    echo $tpl->_ENGINE_parse_body(CompileTr2($f) . "\n\t\t\t<div style='width:100%;height:160px'>\n\t\t\t <div style='float:right;margin-left:10px;'>" . button("{refresh}", "LoadAjax('logger-status','{$page}?logger-status=yes',true);", 26) . "</div>\n\t\t\t<div style='float:right'>" . button("{reload_proxy}", "Loadjs('squid.reload.php');", 26) . "</div></div>");
}
function BACKUP_EMAIL_BEHAVIOR_DASHBOARD()
{
    $tpl = new templates();
    $ou = $_SESSION["ou"];
    @mkdir("/usr/share/artica-postfix/ressources/web/cache_{$ou}", 0755, true);
    $filebackup = "/usr/share/artica-postfix/ressources/web/cache_{$ou}/BACKUP_EMAIL_BEHAVIOR_DASHBOARD";
    if (file_time_min_Web($filebackup) > 30) {
        $q = new postgres_sql();
        $ldap = new clladp();
        $domains = $ldap->hash_get_domains_ou($ou);
        while (list($domain, $MAIN) = each($domains)) {
            $domain = trim(strtolower($domain));
            if ($domain == null) {
                continue;
            }
            $FDOMS[] = "domainto='{$domain}'";
            $FDOMS2[] = "domainfrom='{$domain}'";
        }
        $imploded1 = @implode(" OR ", $FDOMS);
        $imploded2 = @implode(" OR ", $FDOMS2);
        $sql = "select count(*) as tcount, SUM(size) as size FROM backupmsg WHERE ({$imploded1}) OR ({$imploded2})";
        $ligne = pg_fetch_array($q->QUERY_SQL($sql));
        @unlink($filebackup);
        @file_put_contents($filebackup, serialize($ligne));
    }
    $ligne = unserialize(@file_get_contents($filebackup));
    $tcount = $ligne["tcount"];
    $size = $ligne["size"];
    if ($tcount == 0) {
        echo $tpl->_ENGINE_parse_body("0 {message}");
        return;
    }
    $size = FormatBytes($size / 1024);
    $tcount = FormatNumber($tcount);
    echo $tpl->_ENGINE_parse_body("<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:GotoBackupMails()\"\n\t\tstyle='text-decoration:underline'>{$tcount} {messages}</a> ({$size})");
}
Beispiel #9
0
		/**
		 * EditCustomerGroup
		 * Load up a customer group's details for editing. Why am I working on this at 11:10pm on a Saturday night?! - Mitch
		 *
		 * @param string $MsgDesc The optional message to display
		 * @param string $MsgStatus The optional status of the message
		 * @param bool $PreservePost TRUE to use the REQUEST variable, FALSE to read from the database. Default is FALSE
		 * @return Void
		 */
		private function EditCustomerGroup($MsgDesc = "", $MsgStatus = "", $PreservePost = false)
		{
			$groupId = 0;

			if (isset($_GET['groupId']) && is_numeric($_GET['groupId'])) {
				$groupId = (int)$_GET['groupId'];
			}

			if ($MsgDesc != "") {
				$GLOBALS['Message'] = MessageBox($MsgDesc, $MsgStatus);
			}

			if ($PreservePost) {
				$data = $this->GetCustomerGroupData(0);
			} else {
				$data = $this->GetCustomerGroupData($groupId);
			}

			if (!$data) {
				return $this->ManageCustomerGroups();
			}

			$GLOBALS['GroupId'] = $groupId;
			$GLOBALS['GroupName'] = isc_html_escape($data['groupname']);
			if ($data['discountmethod'] == 'percent') {
				$GLOBALS['Discount'] = FormatNumber($data['discount']);
			}
			else {
				$GLOBALS['Discount'] = FormatPrice($data['discount'], false, false);
			}

			if ($data['discountmethod'] == '') {
				$data['discountmethod'] = 'price';
			}

			$GLOBALS['StoreDiscountMethod' . ucfirst(isc_strtolower($data['discountmethod']))] = 'selected';

			if ($data['isdefault']) {
				$GLOBALS['IsDefault'] = "checked='checked'";
			}

			$access_cats = array();
			if ($data['categoryaccesstype'] == "all") {
				$GLOBALS['AccessAllCategories'] = "checked='checked'";
				$GLOBALS['HideAccessCategories'] = "none";
				$GLOBALS['HideAccessCatLinks'] = "none";
			}

			$GLOBALS['FormAction'] = "editCustomerGroup2";
			$GLOBALS['Title'] = GetLang("EditACustomerGroup");

			// Reuse them for the categories which the group has access to and make them all selected by default
			$GLOBALS['AccessCategoryOptions'] = $GLOBALS["ISC_CLASS_ADMIN_CATEGORY"]->GetCategoryOptions($data['accesscategorieslist'], "<option %s value='%d'>%s</option>", 'selected="selected"', "", false);

			$GLOBALS['HiddenDiscounts'] = $this->buildHiddenDiscountFields($data['discountlist'], $products, $categories);

			$GLOBALS['HideNoCatgeory'] = '';
			$GLOBALS['HideNoProduct'] = '';
			$GLOBALS['HideCategoryGridContainer'] = '';
			$GLOBALS['HideProductGridContainer'] = '';

			if (empty($categories['items'])) {
				$GLOBALS['HideCategoryGridContainer'] = 'none';
			} else {
				$GLOBALS['HideNoCatgeory'] = 'none';
			}

			if (empty($products['items'])) {
				$GLOBALS['HideProductGridContainer'] = 'none';
			} else {
				$GLOBALS['HideNoProduct'] = 'none';
			}

			/**
			 * Add in the category and product items
			 */
			$GLOBALS['DiscountsPerPage'] = ISC_GROUPDISCOUNT_ITEMS_PER_PAGE;
			$GLOBALS['CategoryDataGrid'] = $this->ManageGroupDiscountGrid($categories);
			$GLOBALS['ProductDataGrid'] = $this->ManageGroupDiscountGrid($products);

			if (GetConfig('CurrencyLocation') == 'right') {
				$GLOBALS['AmountPrefix'] = '';
				$GLOBALS['AmountPostfix'] = GetConfig('CurrencyToken');
			} else {
				$GLOBALS['AmountPrefix'] = GetConfig('CurrencyToken');
				$GLOBALS['AmountPostfix'] = '';
			}

			$this->template->display('customers.group.form.tpl');
		}
function table3()
{
    $page = CurrentPageName();
    $q = new postgres_sql();
    $tpl = new templates();
    $zmd5 = $_GET["zmd5"];
    if ($zmd5 == null) {
        echo "alert('no key sended');UnlockPage();";
        die;
    }
    $table = "{$zmd5}report";
    $results = $q->QUERY_SQL("SELECT SUM(rqs) as rqs, category FROM \"{$table}\" GROUP BY category order by rqs DESC LIMIT 15");
    $html[] = "<table style='width:100%'>";
    $html[] = $tpl->_ENGINE_parse_body("<tr><th style='font-size:18px;padding:8px'>{categories}</td>\n\t\t\t<th style='font-size:18px'>{hits}</th></tr>");
    while ($ligne = @pg_fetch_assoc($results)) {
        $siteENC = urlencode($ligne["category"]);
        $href = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('squid.statistics.report.category.php?from-zmd5={$zmd5}&USER_DATA={$siteENC}');\"\n\t\tstyle='font-size:18px;text-decoration:underline'>";
        $site = $ligne["category"];
        if ($site == null) {
            $site = "unknown";
        }
        $size = FormatNumber($ligne["rqs"]);
        //$js="Loadjs('squid.statistics.report.member.php?from-zmd5=$zmd5&USER_DATA=".urlencode($site)."');";
        $html[] = "<tr><td style='font-size:18px;padding:8px'>{$href}{$site}</a></td>\n\t\t<td style='font-size:18px'>" . FormatNumber($size) . "</td></tr>";
    }
    $html[] = "</table>";
    $html[] = "<script>";
    $html[] = "Loadjs('{$page}?graph4=yes&zmd5={$_GET["zmd5"]}&t={$_GET["t"]}')";
    $html[] = "</script>";
    echo @implode("", $html);
}
function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $t = $_GET["t"];
    $total = 0;
    if ($q->COUNT_ROWS("dashboard_user_day", "artica_backup") == 0) {
        json_error_show("no data [" . __LINE__ . "]", 0);
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $table = "(SELECT SUM(RQS) as RQS, SUM(SIZE) as SIZE,USER FROM dashboard_user_day GROUP BY USER ) as t";
    $searchstring = string_to_flexquery();
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    if (!is_numeric($rp)) {
        $rp = 100;
    }
    $pageStart = ($page - 1) * $rp;
    if ($pageStart < 0) {
        $pageStart = 0;
    }
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql, "artica_events");
    $total = mysql_num_rows($results);
    if (!$q->ok) {
        json_error_show($q->mysql_error . "<br>{$sql}", 0);
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $CurrentPage = CurrentPageName();
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data");
    }
    $searchstring = string_to_flexquery();
    $results = $q->QUERY_SQL($sql, 'artica_backup');
    if (!$q->ok) {
        json_error_show($q->mysql_error . "<br>{$sql}");
    }
    $q1 = new mysql();
    $t = time();
    $fontsize = 22;
    $span = "<span style='font-size:{$fontsize}px'>";
    $IPTCP = new IP();
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $zmd5 = $ligne["zmd5"];
        $member_value = trim($ligne["USER"]);
        $hits = FormatNumber($ligne["RQS"]);
        $size = FormatBytes($ligne["SIZE"] / 1024);
        $ahref = null;
        $member_assoc = null;
        $graph = imgtootltip("graph2-48.png", "{statistics}", "Loadjs('{$MyPage}?graph-js=yes&uid=" . urlencode($member_value) . "')");
        $graph2 = imgtootltip("graphs-48.png", "{statistics}", "Loadjs('{$MyPage}?graph2-js=yes&uid=" . urlencode($member_value) . "')");
        if ($IPTCP->IsvalidMAC($member_value)) {
            $mac_encoded = urlencode($member_value);
            $uid = $q->MacToUid($member_value);
            if ($uid != null) {
                $member_assoc = "&nbsp; ({$uid})";
            }
            $ahref = "<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&MAC={$mac_encoded}');\"\n\t\t\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>";
        }
        $data['rows'][] = array('id' => $member_value, 'cell' => array("{$span}{$ahref}{$member_value}</a>{$member_assoc}</span>", "{$span}{$hits}</a></span>", "{$span}{$size}</a></span>", "<center>{$graph}</center>", "<center>{$graph2}</center>"));
    }
    echo json_encode($data);
}
function community_status(){
	$page=CurrentPageName();
	$tpl=new templates();	
	$q=new mysql_squid_builder();
	$all_count=FormatNumber($q->COUNT_ROWS("dansguardian_community_categories","artica_backup"),0,'.',' ',3);
	$artica_community=Paragraphe('webfilter-community-64.png','{community}','{webfilter_community_text}',"javascript:Loadjs('webfilter.community.php')");
	if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";}
	$html="	
	
	<table style='width:100%'>
	<tr>
		<td width=99% valign='top'>
	<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>
	<thead class='thead'>
		<tr>
		<th colspan=2></th>
		<th>&nbsp;</th>
		</tr>
	</thead>
	<tbody class='tbody'>
	<tr class=$classtr>
		<td style='font-size:14px' colspan=2><i>{websites_number}:</i>&nbsp;<strong>$all_count</i></td>
	</tr>
	";
	
	$array=unserialize(@file_get_contents("ressources/logs/web.community.db.status.txt"));
	
	while (list ($num, $ligne) = each ($array) ){
		if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";}
		$f=FormatNumber($ligne,0,'.',' ',3);
		$html=$html."<tr class=$classtr>
		<td style='font-size:14px;text-align:right' width=1% nowrap><strong>$num:</td>
		<td style='font-size:14px' width=99%><strong>$f</strong></td>
	</tr>";
	}
	
	$html=$html."</table>
	</td>
	<td valign='top' width=1%>$artica_community</td>
	</tr>
	</table>
	
	";
	echo $tpl->_ENGINE_parse_body($html);
}
Beispiel #13
0
function category_list()
{
    //ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string','');ini_set('error_append_string','');
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $users = new usersMenus();
    $text_license = null;
    if (!$users->CORP_LICENSE) {
        $text_license = $tpl->_ENGINE_parse_body("({category_no_license_explain})");
    }
    $search = '%';
    $table = "webfilters_categories_caches";
    $tableProd = "cicap_profiles_blks";
    $page = 1;
    $ORDER = "ORDER BY categorykey ASC";
    $FORCE_FILTER = null;
    if (trim($_GET["group"]) != null) {
        $FORCE_FILTER = " AND master_category='{$_GET["group"]}'";
    }
    if (isset($_GET["CatzByEnabled"])) {
        $OnlyEnabled = true;
    }
    $count_webfilters_categories_caches = $q->COUNT_ROWS("webfilters_categories_caches");
    writelogs("webfilters_categories_caches {$count_webfilters_categories_caches} rows", __FUNCTION__, __FILE__, __LINE__);
    if ($count_webfilters_categories_caches == 0) {
        $ss = new dansguardian_rules();
        $ss->CategoriesTableCache();
    }
    if (!$q->TABLE_EXISTS($tableProd)) {
        $q->CheckTables();
    }
    $sql = "SELECT `category` FROM {$tableProd} WHERE `mainid`={$_GET["mainid"]} AND bltype={$_GET["bltype"]}";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        json_error_show("{$q->mysql_error}", 1);
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $cats[$ligne["category"]] = true;
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `webfilters_categories_caches` WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        if (!$q->ok) {
            $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($q->mysql_error, "", "", ""));
            json_encode($data);
            return;
        }
        $total = $ligne["TCOUNT"];
        writelogs("{$sql} = {$total} rows", __FUNCTION__, __FILE__, __LINE__);
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `webfilters_categories_caches` WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        if (!$q->ok) {
            $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($q->mysql_error, "", "", ""));
            json_encode($data);
            return;
        }
        $total = $ligne["TCOUNT"];
    }
    if ($OnlyEnabled) {
        $limitSql = null;
    }
    $sql = "SELECT *  FROM `webfilters_categories_caches` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($q->mysql_error, "", "", ""));
        json_encode($data);
        return;
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (mysql_num_rows($results) == 0) {
        $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($sql, "", "", ""));
    }
    $items = $tpl->_ENGINE_parse_body("{items}");
    $compile = $tpl->_ENGINE_parse_body("{compile}");
    $catz = new mysql_catz();
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($ligne["picture"] == null) {
            $ligne["picture"] = "20-categories-personnal.png";
        }
        $category_table = "category_" . $q->category_transform_name($ligne['categorykey']);
        $category_table_elements = $q->COUNT_ROWS($category_table);
        $DBTXT = array();
        $database_items = null;
        if ($category_table_elements > 0) {
            $category_table_elements = FormatNumber($category_table_elements);
            $DBTXT[] = "<a href=\"javascript:blurt();\" OnClick=\"javascript:Loadjs('squid.categories.php?category=" . urlencode($ligne['categorykey']) . "',true)\"\n\t\t\tstyle='font-size:11px;font-weight:bold;text-decoration:underline'>{$category_table_elements}</a> {$items}";
            $DBTXT[] = "<a href=\"javascript:blurt();\" OnClick=\"javascript:Loadjs('ufdbguard.compile.category.php?category=" . urlencode($ligne['categorykey']) . "',true)\"\n\t\t\tstyle='font-size:11px;font-weight:bold;text-decoration:underline'>{$compile}</a>";
        }
        $ligneTLS = mysql_fetch_array($q->QUERY_SQL("SELECT websitesnum FROM univtlse1fr WHERE category='{$ligne['categorykey']}'"));
        $category_table_elements_tlse = $ligneTLS["websitesnum"];
        if ($category_table_elements_tlse > 0) {
            $category_table_elements_tlse = FormatNumber($category_table_elements_tlse);
            $DBTXT[] = "{$category_table_elements_tlse} Toulouse University {$items}";
        }
        $catz = new mysql_catz();
        $category_table_elements_artica = $catz->COUNT_ROWS($category_table);
        if ($category_table_elements_artica > 0) {
            $category_table_elements_artica = FormatNumber($category_table_elements_artica);
            $DBTXT[] = "{$category_table_elements_artica} Artica {$items} <i style='font-size:10px;font-weight:normal'>{$text_license}</i>";
        }
        if (count($DBTXT) > 0) {
            $database_items = "<span style='font-size:11px;font-weight:bold'>" . @implode("&nbsp;|&nbsp;", $DBTXT) . "</span>";
        }
        $img = "img/{$ligne["picture"]}";
        $val = 0;
        if ($cats[$ligne['categorykey']]) {
            $val = 1;
        }
        if ($OnlyEnabled) {
            if ($val == 0) {
                continue;
            }
        }
        $disable = Field_checkbox("cats_{$_GET['RULEID']}_{$_GET['bltype']}_{$ligne['categorykey']}", 1, $val, "Loadjs('{$MyPage}?category-enable-js={$ligne['categorykey']}&mainid={$_GET["mainid"]}&bltype={$_GET["bltype"]}')");
        $ligne['description'] = utf8_encode($ligne['description']);
        $data['rows'][] = array('id' => $ligne['categorykey'], 'cell' => array("<img src='{$img}'>", "{$js}{$ligne['categorykey']}</a>", $ligne['description'] . "<br>\n\t\t\t\t{$database_items}", $disable));
    }
    echo json_encode($data);
}
Beispiel #14
0
function snort_query_search(){
	$page=CurrentPageName();	
	$tpl=new templates();	
	include_once(dirname(__FILE__) . '/ressources/class.rtmm.tools.inc');
	$limit=100;
	if(isset($_GET["zoom"])){$limit=200;}
	if(strlen($_GET["snort-query-search"])>1){
		$search=$_GET["snort-query-search"];
		$search="*$search*";
		$search=str_replace("*","%",$search);
		$search=str_replace("%%","%",$search);
	}
	if(is_numeric($_GET["prio"])){$prio=" AND priority={$_GET["prio"]}";}
	if(strlen($_GET["classification"])>5){$classification=" AND classification='{$_GET["classification"]}'";}
	
	if($search<>null){
	$quersearch="AND (hostname LIKE '$search'$prio$classification) 
	OR (ipaddr LIKE '$search'$prio$classification) 
	OR (port LIKE '$search'$prio$classification) 
	OR (infos LIKE '$search'$prio$classification)";
	}else{
		$quersearch="$classification$prio";
	}
	
	$sql="SELECT * FROM snort WHERE 1 $quersearch ORDER BY zDate DESC LIMIT 0,$limit";
	
	$q=new mysql();
	$results=$q->QUERY_SQL($sql,"artica_events");
	if(!$q->ok){echo "<H2>$q->mysql_error</H2>";}	
	$events=$q->COUNT_ROWS("snort","artica_events");
	$events=FormatNumber($events,0,'.',' ',3);
	
	
	
$html="
<p>&nbsp;</p>
<div style='text-align:right'><i style='font-size:13px;font-weight:bold'>$events {events}&nbsp;|&nbsp;{your_ip_address}:{$_SERVER["REMOTE_ADDR"]} (".gethostbyaddr($_SERVER["REMOTE_ADDR"]).")&nbsp;&nbsp;</i></div>
<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>
<thead class='thead'>
	<tr>
		<th width=1%>&nbsp;</th>
		<th width=1%>{date}</th>
		<th>PRIO</th>
		<th>{hostname} $search</th>
		<th>{proto}</th>
		
	</tr>
</thead>
<tbody class='tbody'>";	
	while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){	
	if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";}
	
	
	if($ligne["success"]==1){$img='fleche-20-right.png';}else{$img='fleche-20-red-right.png';}
	$flag=imgtootltip(GetFlags($ligne["country"]),$ligne["country"],null);
	$html=$html."
	<tr  class=$classtr>
	<td style='font-size:12px;font-weight:bold' width=1%>$flag</td>
	<td style='font-size:12px;font-weight:bold'  width=1% nowrap>{$ligne["zDate"]}</a></td>
	<td style='font-size:12px;font-weight:bold' width=1% align='center'>{$ligne["priority"]}</a></td>
	<td style='font-size:12px;font-weight:bold' nowrap>{$ligne["hostname"]} [{$ligne["ipaddr"]}]</a></td>
	<td style='font-size:12px;font-weight:bold' nowrap>{port}:{$ligne["port"]} [{$ligne["proto"]}]</a></td>
	</tr>
	<tr  class=$classtr>
	<td>&nbsp;</td>
	<td colspan=4 style='font-size:12px'>({$ligne["classification"]}) <i>{$ligne["infos"]}</i></td>
	</tr>";
	}
	
$html=$html."</table>\n";


echo $tpl->_ENGINE_parse_body($html);return;	
	
}
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();
    if (!$q->TABLE_EXISTS($dansguardian_table)) {
        echo "<p class=text-error>No table &laquo;{$dansguardian_table}&raquo; for {$_GET["uid"]}</p>";
        return;
    }
    $sql = "SELECT * FROM (SELECT hits as hits,QuerySize as size,uri,HOUR(zDate) as `hour`,\n\tsitename FROM `{$dansguardian_table}` WHERE uid='{$_GET["uid"]}'\n\tAND sitename LIKE '%{$_GET["familysite"]}' \n\tAND LENGTH(uri)>4\n\tORDER BY zDate LIMIT 0,250) as t WHERE 1 {$search}";
    $results = $q->QUERY_SQL($sql);
    $_GET["uid"] = urlencode($_GET["uid"]);
    if (!$q->ok) {
        echo "<p class=text-error>{$q->mysql_error}<br>{$sql}</p>";
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $size = FormatBytes($ligne["size"] / 1024);
        $hits = FormatNumber($ligne["hits"]);
        $link = $boot->trswitch("blur()");
        $date = $ligne["hour"];
        $uri = $ligne["uri"];
        $urilenth = strlen($ligne["uri"]);
        if ($urilenth > 80) {
            $uri = substr($uri, 0, 77) . "...";
        }
        $tr[] = "\n\t<tr id='{$id}'>\n\t\t<td {$link} nowrap><i class='icon-clock'></i> {$date}H</td>\n\t\t<td {$link}><i class='icon-globe'></i> <a href=\"{$ligne["uri"]}\" target=_new>{$uri}</a></a></td>\n\t\t<td {$link} nowrap><i class='icon-info-sign'></i>&nbsp;{$size}</td>\n\t\t<td {$link} nowrap><i class='icon-info-sign'></i>&nbsp;{$hits}</td>\n\t</tr>";
    }
    echo $tpl->_ENGINE_parse_body("\n\t\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>{hour}</th>\n\t\t\t\t\t<th>{url}</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>\n\t\t\t") . @implode("", $tr) . "</tbody></table>";
}
Beispiel #16
0
function categories_details_title()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $f = unserialize(@file_get_contents("ressources/squid.categories.count.cache"));
    $rows = FormatNumber($f[$_GET["category-details-md-title"]]);
    $html = "{$_GET["category-details-md-title"]}&nbsp;{$rows}&nbsp;{rows}";
    echo $tpl->_ENGINE_parse_body($html);
}
function websites_search()
{
    $sock = new sockets();
    $q = new mysql();
    $CountDeFreeWebs = $q->COUNT_ROWS("freeweb", "artica_backup");
    $EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb");
    if (!is_numeric($EnableFreeWeb)) {
        $EnableFreeWeb = 0;
    }
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS("reverse_www")) {
        $f = new squid_reverse();
    }
    if (!$q->TABLE_EXISTS("reverse_sources")) {
        $f = new nginx_sources();
        $f->PatchTables();
    }
    if (!$q->FIELD_EXISTS("reverse_sources", "OnlyTCP")) {
        $q->QUERY_SQL("ALTER TABLE `reverse_sources` ADD `OnlyTCP` smallint(1) NOT NULL DEFAULT '0'");
        if (!$q->ok) {
            echo "<p class=text-error>{$q->mysql_error} in " . basename(__FILE__) . " line " . __LINE__ . "</p>";
        }
    }
    $CountDereverse = $q->COUNT_ROWS("reverse_www");
    if ($CountDereverse == 0) {
        if ($CountDeFreeWebs > 0) {
            $sock->getFrameWork("nginx.php?sync-freewebs=yes");
        }
    }
    $STATUS = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/nginx.status.acl"));
    $searchstring = string_to_flexquery("websites-search");
    $sql = "SELECT * FROM reverse_www WHERE 1 {$searchstring} ORDER BY servername LIMIT 0,250";
    if (!AdminPrivs()) {
        $sql = "SELECT reverse_www.* FROM reverse_www,reverse_privs \n\t\tWHERE reverse_privs.servername=reverse_www.servername\n\t\tAND reverse_privs.uid='{$_SESSION["uid"]}' {$searchstring} ORDER BY servername LIMIT 0,250";
    }
    $results = $q->QUERY_SQL($sql, 'artica_backup');
    if (!$q->ok) {
        echo $q->mysql_error_html();
        return;
    }
    $tpl = new templates();
    $all_text = $tpl->_ENGINE_parse_body("{all}");
    $GLOBALS["CLASS_TPL"] = $tpl;
    $boot = new boostrap_form();
    $page = CurrentPageName();
    $q1 = new mysql();
    $t = time();
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $icon2 = "arrow-right-64.png";
        $icon = "domain-main-64.png";
        $freewebicon = "64-firewall-search.png";
        $color = "black";
        $status = array();
        $portText = null;
        if ($ligne["ssl"] == 1) {
            $certificate_text = $tpl->_ENGINE_parse_body("<div>{certificate}: {default}</div>");
        }
        $md = md5(serialize($ligne));
        $RedirectQueries = $ligne["RedirectQueries"];
        $default_server = $ligne["default_server"];
        $explain_text = null;
        $SiteEnabled = $ligne["enabled"];
        $servername = $ligne["servername"];
        $servername_enc = urlencode($servername);
        $limit_rate = $ligne["limit_rate"];
        $limit_rate_after = $ligne["limit_rate_after"];
        $DeleteFreeWeb = "Loadjs('{$page}?delete-websites-js=yes&servername={$servername_enc}&md={$md}')";
        if ($ligne["DenyConf"] == 1) {
            $icon = "hearth-blocked-64.png";
        }
        if ($SiteEnabled == 0) {
            $icon = "domain-main-64-grey.png";
            $color = "#8a8a8a";
            $icon2 = "arrow-right-64-grey.png";
        }
        $delete = imgsimple("delete-48.png", null, $DeleteFreeWeb);
        $jsEditWW = $boot->trswitch("Loadjs('website-js=yes&servername={$servername_enc}')");
        $jsedit = $boot->trswitch("Loadjs('{$page}?website-js=yes&servername={$servername_enc}')");
        $jseditA = $jsedit;
        $jseditC = $boot->trswitch("Loadjs('{$page}?website-script-js=yes&servername={$servername}')");
        if ($ligne["certificate"] != null) {
            $certificate_text = "" . $tpl->_ENGINE_parse_body("<div>{certificate}: {$ligne["certificate"]}</div>");
        }
        if (isset($STATUS[$servername])) {
            $ac = FormatNumber($STATUS[$servername]["AC"]);
            $ACCP = FormatNumber($STATUS[$servername]["ACCP"]);
            $ACHDL = FormatNumber($STATUS[$servername]["ACHDL"]);
            $ACRAQS = FormatNumber($STATUS[$servername]["ACRAQS"]);
            if ($STATUS[$servername]["ACCP"] > 0) {
                $ss = round($STATUS[$servername]["ACRAQS"] / $STATUS[$servername]["ACCP"], 2);
            }
            $reading = FormatNumber($STATUS[$servername]["reading"]);
            $writing = FormatNumber($STATUS[$servername]["writing"]);
            $waiting = FormatNumber($STATUS[$servername]["waiting"]);
            $status[] = "{active_connections}: {$ac}&nbsp;|&nbsp;{accepteds}: {$ACCP}&nbsp;|&nbsp;{handles}:{$ACRAQS} ({$ss}/{second})";
            $status[] = "&nbsp;|&nbsp;{keepalive}: {$waiting}&nbsp;|&nbsp;{reading}: {$reading}&nbsp;|&nbsp;{writing}:{$writing}";
        }
        if ($limit_rate > 0) {
            $limit_rate_after_caption = $tpl->_ENGINE_parse_body("{limit_rate_after_caption}");
            $limit_rate_after_caption = str_replace("%s", "{$limit_rate}MB/s", $limit_rate_after_caption);
            $limit_rate_after_caption = str_replace("%f", "{$limit_rate_after}MB", $limit_rate_after_caption);
            $status[] = "<div style='font-size:12px;font-weight:bold;color:#EEB853'>{$limit_rate_after_caption}</div>";
        }
        if (count($status) > 0) {
            $status_text = $tpl->_ENGINE_parse_body("<div style='font-size:12px'>" . @implode("", $status) . "</div>");
        }
        $FreeWebText = null;
        $explain_text = null;
        if ($EnableFreeWeb == 0) {
            if ($ligne["ipaddr"] == "127.0.0.1") {
                $ligne["ipaddr"] = "{error}";
            }
            if ($ligne["cache_peer_id"] == 0) {
                $ligne["cache_peer_id"] = -1;
            }
        }
        if ($ligne["ipaddr"] == "127.0.0.1" or $ligne["cache_peer_id"] == 0) {
            $jsedit = $boot->trswitch("Loadjs('freeweb.edit.php?hostname={$servername}&t={$t}')");
            $certificate_text = null;
            $explain_text = EXPLAIN_REVERSE($ligne["servername"]);
            $delete = imgsimple("delete-48.png", null, $DeleteFreeWeb);
            $jseditS = null;
            $freewebicon = "domain-64.png";
            $FreeWebText = "\n\t\t\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('freeweb.edit.php?hostname={$servername}&t={$t}')\">\n\t\t\t\t\t127.0.0.1:82 (FreeWeb)</a>";
        } else {
            $explain_text = EXPLAIN_REVERSE($ligne["servername"]);
            if ($ligne["port"] > 0) {
                $portText = ":{$ligne["port"]}";
            }
            $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT servername,ipaddr,port,OnlyTCP FROM reverse_sources WHERE ID='{$ligne["cache_peer_id"]}'"));
            $OnlyTCP = $ligne2["OnlyTCP"];
            $FreeWebText = "{$ligne2["servername"]}:{$ligne2["port"]}";
            $jseditS = $boot->trswitch("Loadjs('{$page}?js-source=yes&source-id={$ligne["cache_peer_id"]}')");
            if ($OnlyTCP == 0) {
                $ligne["owa"] = 0;
                if ($ligne["ssl"] == 1) {
                    if ($ligne["port"] == 80) {
                        $portText = $portText . "/443";
                    }
                }
            }
            if ($OnlyTCP == 1) {
                $certificate_text = null;
                $portText = $portText . " <strong>TCP</strong>";
            }
        }
        if ($ligne["owa"] == 1) {
            $freewebicon = "exchange-2010-64.png";
        }
        if ($ligne["poolid"] > 0) {
            $freewebicon = "64-cluster.png";
            $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT poolname FROM nginx_pools WHERE ID='{$ligne["poolid"]}'"));
            $ligne["ipaddr"] = $ligne2["poolname"];
            $jseditS = $boot->trswitch("Loadjs('miniadmin.proxy.reverse.nginx-pools.php?poolid-js={$ligne["poolid"]}&pool-id={$ligne["poolid"]}')");
        }
        $sql = "SELECT * FROM nginx_aliases WHERE servername='{$servername}' {$searchstring} ORDER BY alias LIMIT 0,250";
        $results2 = $q->QUERY_SQL($sql);
        $ali = array();
        $alitext = null;
        while ($ligne = mysql_fetch_array($results2, MYSQL_ASSOC)) {
            $ali[] = "{$ligne["alias"]}";
        }
        if (count($ali) > 0) {
            $alitext = "&nbsp;<i>(" . @implode("{or} ", $ali) . ")</i>&nbsp;";
        }
        $stats = null;
        $ligne2 = mysql_fetch_array($q1->QUERY_SQL("SELECT COUNT(*) as tcount FROM awstats_files WHERE servername='{$servername}'", "artica_backup"));
        if (!$q1->ok) {
            echo "<p class=text-error>{$q1->mysql_error}</p>";
        }
        if ($ligne2["tcount"] > 0) {
            // Abandonné pour l'instant
            //$stats="<a href='miniadmin.proxy.reverse.awstats.php?servername=".urlencode($servername)."'><img src='img/statistics-48.png'></a>";
        }
        $FinalDestination = "{$ligne["ipaddr"]}{$FreeWebText}";
        if ($RedirectQueries != null) {
            $FinalDestination = $RedirectQueries;
            $explain_text = $tpl->_ENGINE_parse_body("<br>{RedirectQueries_explain_table}");
        }
        if ($default_server == 1) {
            $servername = "{$servername} ({$all_text} * )";
            $icon = "free-web-64.png";
            if ($SiteEnabled == 0) {
                $icon = "free-web-64-grey.png";
            }
        }
        $tr[] = "\n\t\t\t\t<tr style='color:{$color}' id='{$md}'>\n\t\t\t\t\t<td width=64px nowrap {$jseditC}><img src='img/script-64.png' style='width:64px'></td>\n\t\t\t\t\t<td width=64px nowrap {$jseditA}><img src='img/{$icon}' style='width:64px'></td>\n\t\t\t\t\t<td width=80% style='vertical-align:middle'>\n\t\t\t\t\t\t<a href=\"javascript:blur();\" \n\t\t\t\t\t\tstyle='font-size:18px;font-weight:bold;text-decoration:underline'\n\t\t\t\t\t\tOnClick=\"javascript:Loadjs('{$page}?website-js=yes&servername={$servername_enc}')\">{$servername}{$portText}</a>\n\t\t\t\t\t\t{$alitext}{$certificate_text}{$status_text}\n\t\t\t\t\t\t{$explain_text}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t<td width=1% nowrap style='vertical-align:middle'>{$stats}</td>\n\t\t\t\t\t<td width=64px nowrap {$jsedit} style='vertical-align:middle'><img src='img/{$freewebicon}' style='width:64px'></td>\n\t\t\t\t\t<td width=64px nowrap {$jsedit} style='vertical-align:middle'><img src='img/{$icon2}' style='width:64px'></td>\n\t\t\t\t\t<td width=1% nowrap {$jseditS} style='vertical-align:middle'>\n\t\t\t\t\t\t<span style='font-size:18px;font-weight:bold'>{$FinalDestination}</span>\n\t\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t<td width=1% nowrap style='vertical-align:middle'>{$delete}</td>\n\t\t\t\t</tr>\n\t\t\t\t";
    }
    $t = time();
    $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_nginx_text = $tpl->javascript_parse_text("{delete_freeweb_nginx_text}");
    $delete_freeweb_dnstext = $tpl->javascript_parse_text("{delete_freeweb_dnstext}");
    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=4>{website}</th>\n\t\t\t\t\t\n\t\t\t\t\t<th colspan=2>{destination}</th>\n\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>") . @implode("", $tr) . "</tbody></table>\n<script>\nvar FreeWebIDMEM{$t}='';\n\t\t\n\tfunction FreeWebWebDavPerUsers(){\n\t\tLoadjs('freeweb.webdavusr.php?t={$t}')\n\t}\n\t\n\tfunction RestoreSite(){\n\t\tLoadjs('freeweb.restoresite.php?t={$t}')\n\t}\n\t\n\tfunction FreeWebsRefreshWebServersList(){\n\t\tExecuteByClassName('SearchFunction');\n\t}\n\t\n\t\n\tvar x_EmptyEvents= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);return;}\n\t\tExecuteByClassName('SearchFunction');\n\n\t\t\n\t}\t\n\t\n\tvar x_FreeWebsRebuildvHostsTable= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);return;}\n\t\talert('{$freeweb_compile_background}');\n\t\tExecuteByClassName('SearchFunction');\n\t\t}\n\n\t\n\tvar x_klmsresetwebpassword{$t}= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);return;}\n\t\tExecuteByClassName('SearchFunction');\n\t}\t\n\t\nvar xDelete{$t}=function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>10){alert(results);return;}\t\n\t\$('#'+FreeWebIDMEM{$t}).remove();\n}\t\n\t\t\nfunction Delete{$t}(server,md){\n\tFreeWebIDMEM{$t}=md;\n\tif(confirm('{$delete_freeweb_text}')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('website-delete',server);\n    \tXHR.sendAndLoad('{$page}', 'POST',xDelete{$t});\n\t}\n}\n\nvar xDeleteFreeWeb{$t}=function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>10){alert(results);return;}\t\n\t\$('#'+FreeWebIDMEM{$t}).remove();\n}\t\n\nfunction DeleteFreeWeb{$t}(server,md){\n\tFreeWebIDMEM{$t}=md;\n\tif(confirm('{$delete_freeweb_nginx_text}')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('delete-servername',server);\n    \tXHR.sendAndLoad('freeweb.php', 'GET',xDeleteFreeWeb{$t});\n\t}\n}\n\nvar x_FreeWebRefresh=function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>10){alert(results);return;}\t\n\tExecuteByClassName('SearchFunction');\n}\t\t\n\t\t\n\t\tfunction FreeWebAddDefaultVirtualHost(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('AddDefaultOne','yes');\n    \t\tXHR.sendAndLoad('freeweb.php', 'POST',x_FreeWebRefresh);\t\t\n\t\t}\n\t\t\n\t\tfunction FreeWeCheckVirtualHost(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('CheckAVailable','yes');\n    \t\tXHR.sendAndLoad('freeweb.php', 'POST',x_FreeWebDelete);\t\t\t\n\t\t}\n\t\t\n\t\tvar x_RebuildFreeweb{$t}=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);}\t\t\t\n\t\t\tExecuteByClassName('SearchFunction');\n\t\t}\t\t\t\n\t\t\n\t\tfunction RebuildFreeweb(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('rebuild-items','yes');\n    \t\tXHR.sendAndLoad('freeweb.php', 'GET',x_RebuildFreeweb{$t});\n\t\t\n\t\t}\n\n\t\tfunction klmsresetwebpassword(){\n\t\t  if(confirm('{$reset_admin_password} ?')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tXHR.appendData('klms-reset-password','yes');\n    \t\t\tXHR.sendAndLoad('klms.php', 'POST',x_klmsresetwebpassword{$t});\n    \t\t}\t\t\n\t\t}\n\t\t\n\tfunction FreeWebsRebuildvHostsTable(servername){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('FreeWebsRebuildvHosts',servername);\n\t\tXHR.sendAndLoad('freeweb.edit.php', 'POST',x_FreeWebsRebuildvHostsTable);\n\t}\n\n\tfunction FreeWebsEnableSite(servername){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('FreeWebsEnableSite',servername);\n\t\tXHR.sendAndLoad('freeweb.servers.php', 'POST',x_FreeWebRefresh);\t\n\t}\n</script>\t\t\t \t\t\t\t\t \t\t\t\t \t\t\n";
}
function www_top_table()
{
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $boot = new boostrap_form();
    $tablename = "www_" . $q->uid_to_tablename($_GET["uid"]);
    $member = urlencode($_GET["uid"]);
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS($tablename)) {
        echo "<p class=text-error>No table &laquo;{$tablename}&raquo; for {$_GET["uid"]}</p>";
        return;
    }
    $sql = "SELECT SUM(hits) as hits,SUM(size) as size,familysite FROM `{$tablename}` GROUP BY\n\tcategory,familysite HAVING category='{$_GET["category"]}' ORDER BY size DESC,hits DESC LIMIT 0,100";
    if ($_GET["category"] == null) {
        $sql = "SELECT SUM(hits) as hits,SUM(size) as size,familysite FROM `{$tablename}` GROUP BY\n\tcategory,familysite HAVING category IS NULL ORDER BY size DESC,hits DESC LIMIT 0,100";
    }
    $results = $q->QUERY_SQL($sql);
    $_GET["uid"] = urlencode($_GET["uid"]);
    if (!$q->ok) {
        echo "<p class=text-error>{$q->mysql_error}<br>{$sql}</p>";
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $size = FormatBytes($ligne["size"] / 1024);
        $hits = FormatNumber($ligne["hits"]);
        $familysite = $ligne["familysite"];
        $fsite = urlencode($familysite);
        $jslink = "Loadjs('miniadm.webstats.ByMember.website.php?familysite={$fsite}&member-value={$member}&by=uid')";
        $link = $boot->trswitch($jslink);
        $tr[] = "\n\t<tr>\n\t<td {$link}><i class='icon-globe'></i> {$familysite}</a></td>\n\t<td {$link}><i class='icon-info-sign'></i> {$size}</td>\n\t<td {$link}><i class='icon-info-sign'></i> {$hits}</td>\n\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>{websites}</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>\n\t\t\t") . @implode("", $tr) . "</tbody></table>";
}
Beispiel #19
0
function database_table_list_json()
{
    $search = $_GET["search"];
    $MyPage = CurrentPageName();
    $page = 1;
    $users = new usersMenus();
    $tpl = new templates();
    $sock = new sockets();
    $q = new mysql();
    $table = "mysqldbtables";
    $database = "artica_backup";
    $t = $_GET["t"];
    $FORCE_FILTER = null;
    if ($_GET["instance-id"] > 0) {
        $table = "mysqldbtablesmulti";
        $FORCE_FILTER = " AND instance_id={$_GET["instance-id"]}";
    }
    $t = $_GET["t"];
    if ($q->COUNT_ROWS($table, $database) == 0) {
        json_error_show("{$table} is empty");
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    if ($_POST["query"] != null) {
        $_POST["query"] = str_replace("*", "%", $_POST["query"]);
        $search = $_POST["query"];
        $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')";
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE databasename='{$_GET["databasename"]}' {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE databasename='{$_GET["databasename"]}'{$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        if (!$q->ok) {
            json_error_show("{$q->mysql_error}<br>{$sql}");
        }
        $total = $ligne["TCOUNT"];
        if ($total == 0) {
            if (!$q->ok) {
                json_error_show("No rows<br>{$sql}");
            }
        }
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    if ($OnlyEnabled) {
        $limitSql = null;
    }
    $sql = "SELECT *  FROM `{$table}` WHERE databasename='{$_GET["databasename"]}' {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql, $database);
    writelogs("Instance:{$_GET["instance-id"]}/{$database} {" . mysql_num_rows($results) . " items.} \"{$sql}\"", __FUNCTION__, __FILE__, __LINE__);
    if (!$q->ok) {
        json_error_show("Instance:{$_GET["instance-id"]}/{$database}::`{$q->mysql_error}`<br>{$sql}");
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (mysql_num_rows($results) == 0) {
        $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($sql, "", "", ""));
    }
    $ldap = new clladp();
    while ($ligne = mysql_fetch_assoc($results)) {
        $tablename = $ligne["tablename"];
        $TableCount = $ligne["tableRows"];
        $dbsize = $ligne["tablesize"];
        $md5S = md5($ligne["tablename"]);
        $js = "LoadMysqlTables('{$ligne["databasename"]}');";
        $href = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='text-decoration:underline'>";
        $spanStyle1 = "<span style='font-size:13px;font-weight:bold;color:#5F5656;'>";
        $dbsize = FormatBytes($dbsize / 1024);
        $mysqlcheck = imgsimple("tables-failed-22.png", "MySQL check", "MysqlCheck('{$tablename}','{$_GET["databasename"]}')");
        $delete = imgsimple("delete-24.png", "MySQL check", "Loadjs('system.mysql.table.crashed.php?database={$_GET["databasename"]}&table={$tablename}&t={$t}')");
        $TableCount = FormatNumber($TableCount, 0, '.', ' ', 3);
        $databasename = $_GET["databasename"];
        $empty = "<a href=\"javascript:blur();\" OnClick=\"javascript:TableEmpty{$t}('{$tablename}','{$_GET["databasename"]}');\"><img src='img/table-delete-24.png'></a>";
        $mysqlcheck = "<a href=\"javascript:blur();\" OnClick=\"javascript:MysqlCheck('{$tablename}','{$_GET["databasename"]}');\"><img src='img/tables-failed-22.png'></a>";
        if ($databasename == "artica_backup") {
            $empty = "&nbsp;";
        }
        if ($databasename == "mysql") {
            $empty = "&nbsp;";
        }
        $href = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('mysql.browse.table.php?table={$tablename}&database={$_GET["databasename"]}&instance-id={$_GET["instance-id"]}')\" style='text-decoration:underline'>";
        $data['rows'][] = array('id' => $md5S, 'cell' => array("<strong style='font-size:14px;style='color:{$color}'>{$href}{$tablename}</a></strong>", "<span style='font-size:14px'>{$spanStyle}{$dbsize}</span>", "<span style='font-size:14px'>{$spanStyle1}{$TableCount}</span>", $mysqlcheck, $empty, $delete));
    }
    echo json_encode($data);
}
function liste()
{
    $Mypage = CurrentPageName();
    $table = "UserAuthDays";
    $page = 1;
    $data = array();
    $data['rows'] = array();
    $field = $_GET["field"];
    $value = $_GET["value"];
    $tpl = new templates();
    $q = new mysql_squid_builder();
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $table = "(SELECT {$field},zDate,SUM(hits) as hits, SUM(QuerySize) as size FROM {$table} \n\tGROUP BY  {$field},zDate HAVING {$field}='{$value}' ) as t";
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"] + 1;
    }
    $rp = 50;
    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} {$limitSql}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        json_error_show("{$q->mysql_error}");
    }
    $data['page'] = $page;
    $data['total'] = $total;
    $style = "style='font-size:15px'";
    $stylehReF = "style='font-size:15px;text-decoration:underline'";
    while ($ligne = mysql_fetch_assoc($results)) {
        $ligne["size"] = FormatBytes($ligne["size"] / 1024);
        $ligne["hits"] = FormatNumber($ligne["hits"]);
        $zdtTime = strtotime($ligne["zDate"]);
        $tableDest = date("Ymd", $zdtTime) . "_hour";
        $zdtTimeT = $tpl->_ENGINE_parse_body(date("{l} {F} d", $zdtTime)) . " [ " . date("Y-m-d", $zdtTime) . " ]";
        $uriUid = "Loadjs('squid.traffic.statistics.day.user.php?user={$value}&field={$field}&table={$tableDest}');";
        $data['rows'][] = array('id' => md5(serialize($ligne)), 'cell' => array("<span {$style}><a href=\"javascript:blur();\" OnClick=\"javascript:{$uriUid}\" {$stylehReF}>{$zdtTimeT}</a></span>", "<span {$style}>{$ligne["size"]}</span>", "<span {$style}>{$ligne["hits"]}</span>"));
    }
    echo json_encode($data);
}
Beispiel #21
0
function search()
{
    $MyPage = CurrentPageName();
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $q = new mysql_meta();
    $ArticaMetaPooling = intval($sock->GET_INFO("ArticaMetaPooling"));
    $ArticaMetaUseSendClient = intval($sock->GET_INFO("ArticaMetaUseSendClient"));
    $ArticaLinkAutoconnect = intval($sock->GET_INFO("ArticaLinkAutoconnect"));
    $MetaUfdbArticaVer = intval($sock->GET_INFO("MetaUfdbArticaVer"));
    if ($ArticaMetaPooling == 0) {
        $ArticaMetaPooling = 15;
    }
    $switch = intval($_GET["switch"]);
    $table = "metahosts";
    if (isset($_POST["qtype"])) {
        if (preg_match("#prxy([0-9\\.]+)#", $_POST["qtype"], $re)) {
            $_POST["query"] = $re[1];
            $_POST["qtype"] = "squidver";
        }
        if (preg_match("#^([0-9\\.]+)#", $_POST["qtype"])) {
            $_POST["query"] = $_POST["qtype"];
            $_POST["qtype"] = "version";
        }
    }
    $searchstring = string_to_flexquery();
    $page = 1;
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY `{$_POST["sortname"]}` {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    if ($searchstring != null) {
        $sql = "SELECT COUNT( * ) AS tcount FROM {$table} WHERE 1 {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        if (!$q->ok) {
            json_error_show("Mysql Error [" . __LINE__ . "]: <br>{$q->mysql_error}.<br>{$sql}", 1);
        }
        $total = $ligne["tcount"];
    } else {
        $total = $q->COUNT_ROWS($table);
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    if (!is_numeric($rp)) {
        $rp = 50;
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql} ";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        if ($q->mysql_error != null) {
            json_error_show(date("H:i:s") . "<br>SORT:{$_POST["sortname"]}:<br>Mysql Error [L." . __LINE__ . "]: {$q->mysql_error}<br>{$sql}", 1);
        }
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data", 1);
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $fontsize = "18";
    if ($switch == 1) {
        $fontsize = 12;
    }
    $style = "<span style='font-size:{$fontsize}px'>";
    $free_text = $tpl->javascript_parse_text("{free}");
    $computers = $tpl->javascript_parse_text("{computers}");
    $overloaded_text = $tpl->javascript_parse_text("{overloaded}");
    $orders_text = $tpl->javascript_parse_text("{orders}");
    $policies_text = $tpl->javascript_parse_text("{policies}");
    $directories_monitor = $tpl->javascript_parse_text("{directories_monitor}");
    $proxy_statistics = $tpl->javascript_parse_text("{SQUID_STATS1}");
    $cache_rate = $tpl->javascript_parse_text("{cache_rate}");
    $clone_of_text = $tpl->javascript_parse_text("{clone_of}");
    $proxy_in_emergency_mode = $tpl->javascript_parse_text("{proxy_in_emergency_mode}");
    $webfiltering = $tpl->javascript_parse_text("{webfiltering}");
    $activedirectory_emergency_mode = $tpl->javascript_parse_text("{activedirectory_emergency_mode}");
    $NeCommuniquePlus_text = "<br><span style='font-size:14px;font-weight:bold;color:d32d2d'>" . $tpl->_ENGINE_parse_body("{did_not_talk_with_meta}") . "</span>";
    $memory_exceed_80 = $tpl->javascript_parse_text("{memory_exceed_80}");
    $memory_exceed_90 = $tpl->javascript_parse_text("{memory_exceed_90}");
    while ($ligne = mysql_fetch_assoc($results)) {
        $LOGSWHY = array();
        $overloaded = null;
        $cloneFrom = $ligne["cloneFrom"];
        $loadcolor = "black";
        $StatHourColor = "black";
        $uuid = $ligne["uuid"];
        $hostname = $ligne["hostname"];
        $public_ip = $ligne["public_ip"];
        $updated = $ligne["updated"];
        $version = $ligne["version"];
        $ColorTime = "black";
        $CPU_NUMBER = $ligne["CPU_NUMBER"];
        $CPU_NUMBER_MAX = $ligne["CPU_NUMBER"] + 1.5;
        $load = $ligne["load"];
        $mem_perc = $ligne["mem_perc"];
        $mem_total = FormatBytes($ligne["mem_total"]);
        $proxyversion = null;
        $CountdeComputers_text = null;
        $policies_text_line = null;
        $CountdeComputers = $q->network_hosts_count($uuid);
        $icon_warning_32 = "warning32.png";
        $icon_red_32 = "32-red.png";
        $icon = "ok-32.png";
        $icon_panneau_32 = "warning-panneau-32.png";
        $BANDWIDTH = $ligne["BANDWIDTH"];
        $TaskPercent = intval($ligne["TaskPercent"]);
        $BANDWIDTH_text = null;
        $hostag_switch = null;
        $uuidenc = urlencode($uuid);
        $PING_URI_SWITCH = null;
        $PROXY_PERFS = null;
        $END_PROXY = null;
        $PROXY_LINE = null;
        $PROXYEMERG = $ligne["PROXYEMERG"];
        $webfiltering_version = null;
        $UFDBARTICA = intval($ligne["UFDBARTICA"]);
        $UFDB_ENABLED = intval($ligne["UFDB_ENABLED"]);
        $WINDOWSAD = intval($ligne["WINDOWSAD"]);
        $ADEMERG = intval($ligne["ADEMERG"]);
        $PROXYEMERG_ICON = 0;
        $link_ip = null;
        $secondincon = null;
        $NeCommuniquePlus = null;
        $MemoryColor = null;
        $Loadbr = "<br>";
        $StyleLoad = "font-size:30px;font-weight:bold";
        if (preg_match("#^([0-9\\.]+)-#", $ligne["squidver"], $rz)) {
            $ligne["squidver"] = $rz[1];
        }
        if ($ArticaMetaUseSendClient == 1) {
            $PING_URI = "&nbsp;<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('artica-meta.menus.php?send-ping-js=yes&uuid={$uuidenc}&gpid=0');\"\n\t\t\tstyle='font-size:12px;text-decoration:underline;color:#0021C6'\n\t\t\t>Ping</a>";
        }
        if ($UFDB_ENABLED == 1) {
            if ($UFDBARTICA > 0) {
                $UFDBARTICAT = date("Y-m-d H:i:s", $UFDBARTICA);
                $webfiltering_version = "<br>{$webfiltering} {$UFDBARTICAT}";
            }
        }
        if ($BANDWIDTH > 0) {
            $BANDWIDTH_text = " (" . FormatBytes($BANDWIDTH / 1024) . ")";
        }
        if ($switch == 1) {
            $icon_warning_32 = "22-warn.png";
            $icon_red_32 = "22-red.png";
            $icon = "ok22.png";
            $icon_panneau_32 = "warning-panneau-24.png";
            $StyleLoad = "font-size:14px;";
            $Loadbr = null;
        }
        if ($load > $CPU_NUMBER_MAX) {
            $overloaded = "<br><strong style='color:#d32d2d'>{$overloaded_text}</strong>";
            $icon = $icon_warning_32;
            $loadcolor = "#d32d2d";
            $LOGSWHY[] = "{$overloaded_text} {$load}>{$CPU_NUMBER_MAX}";
        }
        $xtime = strtotime($updated);
        $diff = time_diff_min($xtime);
        $Difftext = distanceOfTimeInWords($xtime, time(), true);
        if ($diff > $ArticaMetaPooling * 1.5) {
            $icon = $icon_warning_32;
            $ColorTime = "#d32d2d";
            $LOGSWHY[] = $Difftext . "/{$ArticaMetaPooling}Mn";
            $loadcolor = $ColorTime;
        }
        if ($diff > $ArticaMetaPooling * 4) {
            $icon = $icon_red_32;
            $ColorTime = "#d32d2d";
            $LOGSWHY[] = $Difftext . "/{$ArticaMetaPooling}Mn";
            $NeCommuniquePlus = $NeCommuniquePlus_text;
        }
        if ($PROXYEMERG == 1) {
            $icon = $icon_panneau_32;
            $ColorTime = "#d32d2d";
            $loadcolor = $ColorTime;
            $LOGSWHY[] = "<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('artica-meta.urgency.php?uuid={$uuid}');\" style='color:{$ColorTime};text-decoration:underline'>{$proxy_in_emergency_mode}</a>";
        }
        if ($WINDOWSAD == 1) {
            $secondincon = "windows-server-32.png";
            if ($ADEMERG == 1) {
                $icon = $icon_warning_32;
                $ColorTime = "#d32d2d";
                $secondincon = "windows-server-32-red.png";
                $LOGSWHY[] = $activedirectory_emergency_mode;
                $loadcolor = $ColorTime;
            }
        }
        if ($MetaUfdbArticaVer > 0) {
            if ($UFDB_ENABLED == 1) {
                if ($UFDBARTICA < $MetaUfdbArticaVer) {
                    $LOGSWHY[] = "{$webfiltering} < " . date("Y-m-d H:i:s", $MetaUfdbArticaVer);
                }
            }
        }
        if ($mem_perc > 80) {
            $MemoryColor = "#f59c44";
            $icon = $icon_panneau_32;
            $LOGSWHY[] = "<span style='color:{$MemoryColor}'>{$memory_exceed_80}</span>";
        }
        if ($mem_perc > 90) {
            $icon = $icon_red_32;
            $MemoryColor = "#d32d2d";
            $icon = $icon_panneau_32;
            $LOGSWHY[] = "{$memory_exceed_90}";
        }
        $disks = unserialize($ligne["disks"]);
        $SIZE = 0;
        $USED = 0;
        $infodisk = null;
        $DISKS_TEXT = array();
        $squid_db = "squid_{$uuid}";
        if ($q->DATABASE_EXISTS($squid_db)) {
            $DISKS_TEXT[] = "<ul><li><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.hosts.squid.stats.php?uuid={$uuid}')\"\n\t\t\tstyle='font-size:14px;font-weight:bold;text-decoration:underline'>{$proxy_statistics}</a></li>";
        }
        if ($q->philesight_count($uuid) > 0) {
            if (count($DISKS_TEXT) == 0) {
                $DISKS_TEXT[] = "<ul>";
            }
            $DISKS_TEXT[] = "<li><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.hosts.philesight.php?uuid={$uuid}')\"\n\t\t\tstyle='font-size:14px;font-weight:bold;text-decoration:underline'>{$directories_monitor}</a></li>";
        }
        if (count($DISKS_TEXT) > 0) {
            $DISKS_TEXT[] = "</ul>";
        }
        // -------------------------------------------- DISKS INFOS
        if (is_array($disks)) {
            if (count($disks) > 0) {
                $DISKS_TEXT[] = "<ul>";
                while (@(list($disks, $mainarray) = each($disks))) {
                    $SIZE = FormatBytes(intval($mainarray["SIZE"]) / 1024);
                    $DISKS_TEXT[] = "<li style='font-weight:bold;font-size:14px'>{$disks} {$SIZE}</li>";
                    $DISKS_TEXT[] = "<ul>";
                    while (list($part, $partArray) = each($mainarray["PARTS"])) {
                        $color_disk = "black";
                        $POURC = $partArray["POURC"];
                        if ($POURC > 95) {
                            $color_disk = "red";
                            $icon = $icon_red_32;
                            $LOGSWHY[] = "{$part} {used}:{$POURC}%";
                        }
                        $TOT = FormatBytes($partArray["TOT"] / 1024);
                        $AIV = FormatBytes($partArray["AIV"] / 1024);
                        $DISKS_TEXT[] = "<li style='color:{$color_disk}'>{$part} {$TOT} - {used}:{$POURC}% {free}: {$AIV}</li>";
                    }
                    $DISKS_TEXT[] = "</ul>";
                }
                $DISKS_TEXT[] = "</ul>";
                $infodisk = $tpl->_ENGINE_parse_body(@implode("", $DISKS_TEXT));
            }
        }
        // --------------------------------------------	--------------------------------------------------------------------
        if ($switch == 1) {
            $infodisk = null;
        }
        $info = $tpl->_ENGINE_parse_body("<br>{last_status}:&nbsp;<span style='color:{$ColorTime}'>{$Difftext}</span><br><span style='font-size:12px'>{$CPU_NUMBER} CPU(s), {memory}:{$mem_total}{$overloaded}</span>");
        $cell = array();
        $linkver = "<a href=\"javascript:Loadjs('artica-meta.update.artica.php?uuid={$uuid}');\" \n\t\tstyle='text-decoration:underline'>";
        if ($q->isOrder($uuid, "UPDATE_ARTICA")) {
            $version = "<center style='margin:10px'><img src='img/preloader.gif'></center>";
        }
        if ($ligne["PROXY"] == 1) {
            $proxyuri = "<br><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.squid.watchdog-events.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='text-decoration:underline'>";
            $proxyversion = "<br><span style='font-size:12px'>{$proxyuri}Proxy: {$ligne["squidver"]}</a>{$webfiltering_version} {$BANDWIDTH_text}</span>";
            $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM squid_perfs_gb WHERE uuid='{$uuid}'"));
            $client_http_hits = $ligne2["client_http_hits"];
            $client_http_requests = round($ligne2["client_http_requests"], 2);
            $client_http_kbytes_out = round($ligne2["client_http_kbytes_out"]);
            $TOTALS_NOT_CACHED = $ligne2["TOTALS_NOT_CACHED"];
            $TOTALS_CACHED = $ligne2["TOTALS_CACHED"];
            $TOTALS_CACHED_AVG = round($ligne2["TOTALS_CACHED_AVG"], 2);
            $END_PROXY = "</span><br>";
            if ($ligne2["uuid"] != null) {
                $PROXY_PERFS = "<br><span style='font-size:12px'>{$client_http_requests}Req/s, {$client_http_kbytes_out}KB/s\n\t\t\t\t<br>{$cache_rate}: {$TOTALS_CACHED_AVG}%";
                $PROXY_LINE = "<span style='font-size:12px'>{$client_http_requests}Req/s&nbsp;|&nbsp;{$client_http_kbytes_out}KB/s&nbsp;|&nbsp;{$cache_rate}: {$TOTALS_CACHED_AVG}%</span>";
            }
        }
        if ($CountdeComputers > 0) {
            $CountdeComputers = FormatNumber($CountdeComputers);
            $CountdeComputers_uri = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.networks.hosts.php?js=yes&uuid={$uuid}');\"\n\t\t\tstyle='text-decoration:underline'>";
            $CountdeComputers_text = "<br><span style='font-size:12px'>{$CountdeComputers_uri}{$computers}: <strong>{$CountdeComputers}</strong></a></span>";
        }
        $OrdersText = null;
        $ligneOrders = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(orderid) as tcount FROM `metaorders` WHERE `uuid`='{$uuid}'"));
        $OrdersCount = $ligneOrders["tcount"];
        if ($OrdersCount > 0) {
            $OrdersText = "<br><a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('artica-meta.hosts.orders.php?uuid={$uuid}');\">\n\t\t\t<strong style='text-decoration:underline;color:#E48407'>{$orders_text}:{$OrdersCount} ({$TaskPercent}%)</strong>";
        }
        $ligneOrders = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(uuid) as tcount FROM `policies_storage` WHERE `uuid`='{$uuid}'"));
        $OrdersCount = $ligneOrders["tcount"];
        if ($OrdersCount > 0) {
            $policies_text_line = "<br><strong style='text-decoration:underline;color:#E48407'>{$policies_text}:{$OrdersCount}</strong>";
        }
        $events = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.events.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='float:right'><img src='css/images-flexigrid/magnifier.png'></a>";
        $cpus = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.cpustats.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='text-decoration:underline'>";
        $hostsCommands = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('artica-meta.menus.php?js=yes&uuid={$uuid}');\"\n\t\tstyle='text-decoration:underline'>";
        $hostag = utf8_encode($ligne["hostag"]);
        if ($hostag != null) {
            $hostag = "<br><i style='font-size:12px'>{$hostag}</i>";
        }
        if ($cloneFrom != null) {
            $cloneFrom = "<br><i style='font-weight:bold;font-size:12px'>{$clone_of_text}:&nbsp;" . $q->uuid_to_host($cloneFrom) . "</i>";
        }
        if ($secondincon != null) {
            $secondincon = "<br><img src='img/{$secondincon}' style='margin-top:10px'>";
        }
        $LicenseJs = "OnClick=\"javascript:Loadjs('artica-meta.host.license.php?uuid={$uuid}')\"";
        $LicenseInfos = $q->LicenseInfos($uuid);
        $LICT = "Community Edition";
        if ($LicenseInfos["CORP_LICENSE"]) {
            $LICT = "Entreprise Edition";
        }
        if ($LicenseInfos["ExpiresSoon"] > 0) {
            if ($LicenseInfos["ExpiresSoon"] < 31) {
                $LICT = "<span style='color:red'>{trial_mode}</span>";
            }
        }
        $LicenseText = "<br><a href=\"javascript:blur();\" {$LicenseJs} style='font-size:12px;text-decoration:underline'>" . $tpl->_ENGINE_parse_body($LICT) . "</a>";
        if ($switch == 1) {
            $info = null;
            $secondincon = null;
            $hostag = null;
            $cloneFrom = null;
            $proxyversion = null;
            $CountdeComputers_text = null;
            $events = null;
            $hostag_switch = utf8_encode($ligne["hostag"]);
            $PING_URI_SWITCH = $PING_URI;
            $PING_URI = null;
            $PROXY_PERFS = null;
            $END_PROXY = null;
            $LicenseText = null;
            if (count($LOGSWHY) > 0) {
                $infodisk = $tpl->_ENGINE_parse_body("<span style='color:#d32d2d;font-size:14px'>" . @implode("<br>", $LOGSWHY) . "</span>");
            }
        } else {
            $GroupsList = GetGroups($uuid);
            $PROXY_LINE = null;
            if (count($LOGSWHY) > 0) {
                $infodisk = $tpl->_ENGINE_parse_body("<span style='color:#d32d2d;font-size:14px'>" . @implode("<br>", $LOGSWHY) . "</span>") . "<hr>" . $infodisk;
            }
        }
        $cell = array();
        if ($ArticaMetaUseSendClient == 1) {
            $uriAdd = null;
            if ($ArticaLinkAutoconnect == 1) {
                if ($ligne["system_adm"] != null) {
                    $uriAdd = "/logon.php?autologmeta=" . md5($ligne["system_adm"] . $ligne["system_password"]);
                }
            }
            $link_ip = "<a href=\"https://{$public_ip}:9000{$uriAdd}\" style='text-decoration:underline;color:{$loadcolor}' target=_new>";
        }
        if ($MemoryColor == null) {
            $MemoryColor = $loadcolor;
        }
        $cell[] = "{$Loadbr}<center><img src=\"img/{$icon}\">{$secondincon}</center>";
        $cell[] = "{$style}{$hostsCommands}{$hostname}{$hostag}</a>{$LicenseText}{$NeCommuniquePlus}{$cloneFrom}{$PING_URI_SWITCH}{$events} </span>{$info}\n\t\t{$proxyversion}{$PROXY_PERFS}{$END_PROXY}\n\t\t{$CountdeComputers_text}{$OrdersText}{$policies_text_line}";
        $cell[] = "<span style='color:{$loadcolor};{$StyleLoad}'>{$Loadbr}{$load}</span></span>";
        $cell[] = "{$style}{$cpus}<span style='{$StyleLoad};color:{$MemoryColor}'>{$Loadbr}{$mem_perc}%</a></span>";
        $cell[] = $hostag_switch . "&nbsp;" . $infodisk . $PROXY_LINE;
        $cell[] = "{$style}<span style='color:{$loadcolor} !important'>{$link_ip}{$public_ip}</span></a>{$PING_URI}</span>{$GroupsList}";
        $cell[] = "{$style}{$ligne["squidver"]}</span>";
        $cell[] = "{$style}{$linkver}{$version}</a></span>";
        $data['rows'][] = array('id' => $ligne['uuid'], 'cell' => $cell);
    }
    echo json_encode($data);
}
function categories_search()
{
    $MyPage = CurrentPageName();
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $q = new mysql_squid_builder();
    $date = date("Ym", $_GET["time"]);
    $table = "(SELECT SUM(hits) as hits,SUM(size) as size,category,{$_GET["field"]}\n\tFROM {$date}_maccess GROUP BY category,{$_GET["field"]} HAVING {$_GET["field"]}='{$_GET["value"]}') as t";
    $searchstring = string_to_flexquery();
    $page = 1;
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY `{$_POST["sortname"]}` {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $sql = "SELECT COUNT( * ) AS tcount FROM {$table} WHERE 1 {$searchstring}";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events"));
    if (!$q->ok) {
        json_error_show("Mysql Error [" . __LINE__ . "]: <br>{$q->mysql_error}.<br>{$sql}", 1);
    }
    $total = $ligne["tcount"];
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    if (!is_numeric($rp)) {
        $rp = 50;
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql} ";
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        if ($q->mysql_error != null) {
            json_error_show(date("H:i:s") . "<br>SORT:{$_POST["sortname"]}:<br>Mysql Error [L." . __LINE__ . "]: {$q->mysql_error}<br>{$sql}", 1);
        }
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data", 1);
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $fontsize = "18";
    $style = " style='font-size:{$fontsize}px'";
    $styleHref = " style='font-size:{$fontsize}px;text-decoration:underline'";
    $free_text = $tpl->javascript_parse_text("{free}");
    $computers = $tpl->javascript_parse_text("{computers}");
    $overloaded_text = $tpl->javascript_parse_text("{overloaded}");
    $orders_text = $tpl->javascript_parse_text("{orders}");
    $directories_monitor = $tpl->javascript_parse_text("{directories_monitor}");
    while ($ligne = mysql_fetch_assoc($results)) {
        $LOGSWHY = array();
        $uid = $ligne["uid"];
        $MAC = $ligne["MAC"];
        $ipaddr = $ligne["ipaddr"];
        $size = FormatBytes($ligne["size"] / 1024);
        $hits = FormatNumber($ligne["hits"]);
        $category = $ligne["category"];
        $MAC_FILTER = "Loadjs('squid.users-stats.currentmonth.php?field=MAC&value=" . urlencode($MAC) . "')";
        $UID_FILTER = "Loadjs('squid.users-stats.currentmonth.php?field=uid&value=" . urlencode($uid) . "')";
        $IPADDR_FILTER = "Loadjs('squid.users-stats.currentmonth.php?field=ipaddr&value=" . urlencode($ipaddr) . "')";
        $MAC_FILTERlink = "<a href=\"javascript:blur();\"\n\tOnClick=\"javascript:{$MAC_FILTER}\" {$styleHref}>";
        $UID_FILTERlink = "<a href=\"javascript:blur();\"\n\tOnClick=\"javascript:{$UID_FILTER}\" {$styleHref}>";
        $IPADDR_FILTERlink = "<a href=\"javascript:blur();\"\n\tOnClick=\"javascript:{$IPADDR_FILTER}\" {$styleHref}>";
        $cell = array();
        $cell[] = "<span {$style}>{$UID_FILTERlink}{$category}</a></span>";
        $cell[] = "<span {$style}>{$size}</a></span>";
        $cell[] = "<span {$style}>{$hits}</a></span>";
        $data['rows'][] = array('id' => $ligne['zmd5'], 'cell' => $cell);
    }
    echo json_encode($data);
}
Beispiel #23
0
function table1()
{
    $page = CurrentPageName();
    $q = new postgres_sql();
    $tpl = new templates();
    $zmd5 = $_GET["zmd5"];
    if ($zmd5 == null) {
        echo "alert('no key sended');UnlockPage();";
        die;
    }
    $table = "{$zmd5}report";
    $html[] = "<table style='width:100%'>";
    $html[] = $tpl->_ENGINE_parse_body("<tr><th style='font-size:18px;padding:8px'>{signatures}</td><th style='font-size:18px'>{events}</td></tr>");
    $results = $q->QUERY_SQL("SELECT SUM(xcount) as xcount,signature FROM \"{$table}\"\n\t\t\tGROUP BY signature ORDER BY xcount DESC LIMIT 10");
    while ($ligne = @pg_fetch_assoc($results)) {
        $xcount = $ligne["xcount"];
        $signature = $ligne["signature"];
        $ligne2 = pg_fetch_assoc($q->QUERY_SQL("SELECT description FROM suricata_sig WHERE signature='{$signature}'"));
        $xcount = FormatNumber($xcount);
        $html[] = "<tr><td style='font-size:16px;padding:8px'>{$ligne2["description"]}</a></td>\n\t\t\t<td style='font-size:16px'>{$xcount}</td></tr>";
    }
    $html[] = "</table>";
    $html[] = "<script>";
    $html[] = "Loadjs('{$page}?graph2=yes&zmd5={$_GET["zmd5"]}&t={$_GET["t"]}')";
    $html[] = "</script>";
    echo @implode("", $html);
}
function parse($filename)
{
    $unix = new unix();
    $LastScannLine = 0;
    $GLOBALS["MYSQL_CATZ"] = new mysql_catz();
    $GLOBALS["SQUID_FAMILY_CLASS"] = new squid_familysite();
    if (!isset($GLOBALS["MYHOSTNAME"])) {
        $unix = new unix();
        $GLOBALS["MYHOSTNAME"] = $unix->hostname_g();
    }
    $filesource = dirname(__FILE__) . "/ressources/conf/upload/{$filename}";
    if (!is_file($filesource)) {
        build_progress(110, "{$filename} no such file");
        return;
    }
    $tmpfile = $unix->FILE_TEMP();
    if (!@copy($filesource, $tmpfile)) {
        @unlink($filesource);
        build_progress(110, "{$filename} -> {$tmpfile} {failed}");
        return;
    }
    @unlink($filesource);
    $SumOflines = $unix->COUNT_LINES_OF_FILE($tmpfile);
    echo "{$tmpfile} {$SumOflines} lines\n";
    $handle = @fopen($tmpfile, "r");
    if (!$handle) {
        echo "Fopen failed on {$tmpfile}\n";
        build_progress(110, "{$tmpfile} {failed}");
        @unlink($tmpfile);
        return false;
    }
    $c = 0;
    $d = 0;
    $e = 0;
    $prc = 0;
    $prc_text = 0;
    $mysql_first_time = 0;
    $SITES = array();
    $NOT_CATEGORIZED = array();
    $CATEGORIZED = array();
    $RQS = array();
    $IPClass = new IP();
    $FIRSTTIME = 0;
    $LASTTIME = 0;
    $TIME1 = time();
    while (!feof($handle)) {
        $c++;
        $d++;
        $e++;
        $prc = $c / $SumOflines;
        $prc = round($prc * 100);
        $buffer = trim(fgets($handle));
        if ($buffer == null) {
            continue;
        }
        $stats_sites = count($SITES);
        $stats_categorized = count($CATEGORIZED);
        $stats_not_categorized = count($NOT_CATEGORIZED);
        if (!isset($GLOBALS["LAST_PRC"])) {
            build_progress($prc, "{$c}/{$SumOflines} {please_wait}");
            $GLOBALS["LAST_PRC"] = $prc;
        }
        if ($prc > 5) {
            if ($prc < 95) {
                if ($GLOBALS["LAST_PRC"] != $prc) {
                    $array_load = sys_getloadavg();
                    $internal_load = $array_load[0];
                    $mem = round(memory_get_usage() / 1024 / 1000, 2);
                    echo "Load: {$internal_load}, Memory {$mem}MB\n";
                    echo "Categorized: " . FormatNumber($stats_categorized) . "\n";
                    echo "Unknown....: " . FormatNumber($stats_not_categorized) . "\n";
                    echo "Web sites..: " . FormatNumber($stats_sites) . "\n";
                    build_progress($prc, FormatNumber($c) . "/" . FormatNumber($SumOflines) . " {please_wait} - {$mem}MB {memory}");
                    $GLOBALS["LAST_PRC"] = $prc;
                }
            }
        }
        $array = parseAccessLine($buffer);
        if (count($array) == 0) {
            continue;
        }
        $TIME = $array["TIME"];
        $LASTTIME = $TIME;
        if ($FIRSTTIME == 0) {
            $FIRSTTIME = $TIME;
        }
        $CATEGORY = $array["CATEGORY"];
        $FAMILYSITE = $array["FAMILYSITE"];
        $SIZE = intval($array["SIZE"]);
        if ($IPClass->isIPAddress($FAMILYSITE)) {
            if (!isset($IPADDRESSES[$FAMILYSITE]["RQS"])) {
                $IPADDRESSES[$FAMILYSITE]["RQS"] = 1;
                $IPADDRESSES[$FAMILYSITE]["SIZE"] = 0;
                $IPADDRESSES[$FAMILYSITE]["CATEGORY"] = $CATEGORY;
            } else {
                $IPADDRESSES[$FAMILYSITE]["RQS"] = $IPADDRESSES[$FAMILYSITE]["RQS"] + 1;
                $IPADDRESSES[$FAMILYSITE]["SIZE"] = $IPADDRESSES[$FAMILYSITE]["SIZE"] + $SIZE;
            }
            continue;
        }
        if (!isset($SITES[$FAMILYSITE])) {
            $SITES[$FAMILYSITE] = 0;
        }
        if (!isset($RQS[$FAMILYSITE])) {
            $RQS[$FAMILYSITE] = 0;
        }
        $SITES[$FAMILYSITE] = $SITES[$FAMILYSITE] + $SIZE;
        $RQS[$FAMILYSITE] = $RQS[$FAMILYSITE] + 1;
        if ($CATEGORY != null) {
            $CATEGORIZED[$FAMILYSITE] = $CATEGORY;
            continue;
        }
        $NOT_CATEGORIZED[$FAMILYSITE] = true;
    }
    fclose($handle);
    @unlink($tmpfile);
    build_progress(91, "{building_report}");
    $TIME2 = time();
    $stats_sites = count($SITES);
    $stats_categorized = count($CATEGORIZED);
    $stats_not_categorized = count($NOT_CATEGORIZED);
    $ARRAY["DURATION"] = $unix->distanceOfTimeInWords($TIME1, $TIME2);
    $ARRAY["SumOflines"] = $SumOflines;
    $ARRAY["stats_sites"] = $stats_sites;
    $ARRAY["stats_ip"] = count($IPADDRESSES);
    $ARRAY["firsttime"] = $FIRSTTIME;
    $ARRAY["lasttime"] = $LASTTIME;
    $ARRAY["stats_categorized"] = $stats_categorized;
    $ARRAY["stats_not_categorized"] = $stats_not_categorized;
    build_progress(92, "{building_report}");
    $CSV1[] = array("website", "size", "requests");
    while (list($familysite, $ligne) = each($NOT_CATEGORIZED)) {
        $CSV1[] = array($familysite, $SITES[$familysite], $RQS[$familysite]);
    }
    build_progress(95, "{building_report}");
    $CSV2[] = array("website", "category", "size", "requests");
    while (list($familysite, $category) = each($CATEGORIZED)) {
        $CSV2[] = array($familysite, $category, $SITES[$familysite], $RQS[$familysite]);
    }
    build_progress(97, "{building_report}");
    $CSV3[] = array("Public IP addresses", "category", "size", "requests");
    while (list($ip, $ARRAYIPS) = each($IPADDRESSES)) {
        $category = $ARRAYIPS["CATEGORY"];
        $size = $ARRAYIPS["SIZE"];
        $RQS = $ARRAYIPS["RQS"];
        $CSV3[] = array($ip, $category, $size, $RQS);
    }
    build_progress(99, "{saving_reports}");
    outputCSV($CSV1, "/usr/share/artica-postfix/ressources/logs/notcategorized.csv");
    outputCSV($CSV2, "/usr/share/artica-postfix/ressources/logs/categorized.csv");
    outputCSV($CSV3, "/usr/share/artica-postfix/ressources/logs/ipcategorized.csv");
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/categorized.array", serialize($ARRAY));
    @chmod("/usr/share/artica-postfix/ressources/logs/notcategorized.csv", 0755);
    @chmod("/usr/share/artica-postfix/ressources/logs/ipcategorized.csv", 0755);
    @chmod("/usr/share/artica-postfix/ressources/logs/categorized.csv", 0755);
    @chmod("/usr/share/artica-postfix/ressources/logs/categorized.array", 0755);
    build_progress(100, "{done}");
}
function showlist(){
	$page=1;
	$q=new mysql_squid_builder();
	$table=date("Ymd")."_daccess";

	if($_GET["uuid"]<>null){
		$q=new mysql_meta();
		$table="{$_GET["uuid"]}_CACHED_SITES";
	}



	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();
	if($searchstring<>null){
		$sql="SELECT COUNT(*) as TCOUNT FROM $table WHERE 1 $searchstring";
		$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_events"));
		$total = $ligne["TCOUNT"];

	}else{
		$sql="SELECT COUNT(*) as TCOUNT FROM $table";
		$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_events"));
		$total = $ligne["TCOUNT"];
	}

	if (isset($_POST['rp'])) {$rp = $_POST['rp'];}
	if(!is_numeric($rp)){$rp=50;}


	$pageStart = ($page-1)*$rp;
	$limitSql = "LIMIT $pageStart, $rp";



	$sql="SELECT *  FROM $table WHERE 1 $searchstring $ORDER $limitSql";

	if(isset($_GET["verbose"])){echo "<hr><code>$sql</code></hr>";}
	$results = $q->QUERY_SQL($sql,"artica_events");

	if(!$q->ok){json_error_show($q->mysql_error,1);}

	if(mysql_num_rows($results)==0){
		json_error_show("$table no data",1);
	}




	$data = array();
	$data['page'] = 1;
	$data['total'] = mysql_num_rows($results);
	$data['rows'] = array();

	//if(mysql_num_rows($results)==0){$data['rows'][] = array('id' => $ligne[time()],'cell' => array($sql,"", "",""));}

	while ($ligne = mysql_fetch_assoc($results)) {
		$familysite=$ligne["familysite"];
		$size=FormatBytes($ligne["size"]/1024);
		$hits=FormatNumber($ligne["hits"]);
		
		$macenc=urlencode($ligne["MAC"]);
		$macuri="<a href=\"javascript:blur();\" 
		Onclick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&MAC=$macenc',true);\"
		style='text-decoration:underline;font-size:18px'>";

		if(strlen($ligne["hour"])==1){$ligne["hour"]="0{$ligne["hour"]}";}
			
		$data['rows'][] = array(
				'id' => md5(serialize($ligne)),
				'cell' => array(
						"<span style='font-size:16px'>{$ligne["hour"]}h</span>",
						"<span style='font-size:16px'>$familysite</span>",
						"<span style='font-size:16px'>{$ligne["category"]}</span>",
						"<span style='font-size:16px'>{$ligne["uid"]}</span>",
						"<span style='font-size:16px'>{$ligne["ipaddr"]}</span>",
						"<span style='font-size:16px'>$macuri{$ligne["MAC"]}</a></span>",
						"<span style='font-size:16px'>$hits</span>",
						"<span style='font-size:16px'>$size</span>"
				)
		);

	}


	echo json_encode($data);
}
function proxy_status()
{
    $ntmlauthenticators_array = array();
    $COUNT_DE_CACHES_TEXT = null;
    $webfilters_paranoid_text = null;
    $users = new usersMenus();
    if ($users->STATS_APPLIANCE) {
        return influxdb_status();
    }
    if ($users->POSTFIX_INSTALLED) {
        return postfix_status();
    }
    $sock = new sockets();
    $SQUIDEnable = $sock->GET_INFO("SQUIDEnable");
    if (!is_numeric($SQUIDEnable)) {
        $SQUIDEnable = 1;
    }
    $EnableArticaMetaServer = intval($sock->GET_INFO("EnableArticaMetaServer"));
    $EnableNginx = intval($sock->GET_INFO("EnableNginx"));
    $EnableHaProxy = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableHaProxy"));
    if ($SQUIDEnable == 0) {
        if ($EnableArticaMetaServer == 1) {
            return meta_server_status();
        }
        if ($EnableNginx == 1) {
            return nginx_server_status();
        }
        if ($EnableHaProxy == 1) {
            return haproxy_server_status();
        }
    }
    $SquidCacheLevel = $sock->GET_INFO("SquidCacheLevel");
    $HTTrackInSquid = intval($sock->GET_INFO("HTTrackInSquid"));
    if (!is_numeric($SquidCacheLevel)) {
        $SquidCacheLevel = 4;
    }
    unset($_GET["_"]);
    $sock = new sockets();
    if (!isset($_GET["ForceCache"])) {
        $md5CacheF = md5("proxy_status{$_SESSION["uid"]}{$tpl->language}" . serialize($_GET));
        $cachefile = "/usr/share/artica-postfix/ressources/interface-cache/{$md5CacheF}";
        if (file_time_sec_Web($cachefile) < 5) {
            return @file_get_contents($cachefile);
        }
    }
    if (isset($_GET["ForceCache"])) {
        $sock->getFrameWork("cmd.php?Global-Applications-Status=yes");
    }
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $page = CurrentPageName();
    $ini = new Bs_IniHandler();
    $users = new usersMenus();
    $perc_cache = null;
    $active_resquests = null;
    $important_events = null;
    $CountDeServices = null;
    $icon = "disks-128-ok.png";
    $rqs = null;
    $NOT_CATEGORIZED_ROW = null;
    $mgr_client_list = $q->COUNT_ROWS("mgr_client_list");
    $SNMP_WALK = proxy_snmp();
    $EnableUfdbGuard = intval($sock->EnableUfdbGuard());
    $SquidUrgency = intval($sock->GET_INFO("SquidUrgency"));
    $MacToUidUrgency = intval($sock->GET_INFO("MacToUidUrgency"));
    $SquidSSLUrgency = intval($sock->GET_INFO("SquidSSLUrgency"));
    $EnableKerbAuth = intval($sock->GET_INFO("EnableKerbAuth"));
    $LogsWarninStop = intval($sock->GET_INFO("LogsWarninStop"));
    $SquidUFDBUrgency = intval($sock->GET_INFO("SquidUFDBUrgency"));
    $IsPortsConverted = intval($sock->GET_INFO("IsPortsConverted"));
    $SquidCacheFullHideWarn = intval($sock->GET_INFO("SquidCacheFullHideWarn"));
    $ActiveDirectoryEmergency = intval($sock->GET_INFO("ActiveDirectoryEmergency"));
    $BasicAuthenticatorEmergency = intval($sock->GET_INFO("BasicAuthenticatorEmergency"));
    $eCAPClamavEmergency = intval($sock->GET_INFO("eCAPClamavEmergency"));
    $ParanoidBlockerEmergency = intval($sock->GET_INFO("ParanoidBlockerEmergency"));
    $EnableeCapClamav = intval($sock->GET_INFO("EnableeCapClamav"));
    $curs = "OnMouseOver=\"this.style.cursor='pointer';\"\n\tOnMouseOut=\"this.style.cursor='auto'\"";
    $WebFiltering_blocked = null;
    $CACHES_AVG = round(@file_get_contents("{$GLOBALS["BASEDIR"]}/CACHES_AVG"), 1);
    $COUNT_DE_BLOCKED = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/COUNT_DE_BLOCKED"));
    $SquidDebugAcls = intval($sock->GET_INFO("SquidDebugAcls"));
    $AsTransparent = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/COUNT_DE_TRANSPARENT"));
    $WATCHDOG_COUNT_EVENTS = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/WATCHDOG_COUNT_EVENTS"));
    $COUNT_DE_CACHES = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/COUNT_DE_CACHES"));
    $SUM_FAMILYSITES = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/SUM_FAMILYSITES"));
    $WindowsUpdateCaching = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WindowsUpdateCaching"));
    $TOP_WEBSITE = unserialize(@file_get_contents("{$GLOBALS["BASEDIR"]}/TOP_WEBSITE"));
    $NOT_CATEGORIZED = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/NOT_CATEGORIZED"));
    $CACHES_RATES = unserialize(@file_get_contents("{$GLOBALS["BASEDIR"]}/TOTAL_CACHED_ARRAY"));
    $TOTALS_NOT_CACHED = intval($CACHES_RATES["TOTALS_NOT_CACHED"]);
    $TOTALS_CACHED = intval($CACHES_RATES["TOTALS_CACHED"]);
    if ($users->AsProxyMonitor) {
        if ($EnableKerbAuth == 1) {
            $ntmlauthenticators = _ntmlauthenticators();
            while (list($cpu, $purc) = each($ntmlauthenticators)) {
                $color = "black";
                if ($purc > 95) {
                    $color = "#d32d2d";
                }
                $ntmlauthenticators_array[] = "\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td style='font-size:18px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"javscript:Loadjs('squid.ntmlauthenticators.php?cpu={$cpu}')\"\n\t\t\t\t\tstyle='text-decoration:underline;color:{$color}'>{ntlm_processes}: CPU#{$cpu} {$purc}%</a></td>\n\t\t\t\t\t</tr>";
            }
        }
    }
    $SERVICES_STATUS = SERVICES_STATUS();
    if (!is_array($SERVICES_STATUS)) {
        $CountDeServices = $SERVICES_STATUS;
    } else {
        $icon = "disks-128-warn.png";
        $err = $SERVICES_STATUS;
    }
    $scriptEnd = "LoadAjaxTiny('active-directory-dash-infos','{$page}?active-directory-dash-infos=yes');";
    $EnableUfdbGuard = $sock->EnableUfdbGuard();
    $realsquidversion = @file_get_contents("/etc/artica-postfix/settings/Daemons/SquidRealVersion");
    $sql = "SELECT COUNT(*) as tcount FROM proxy_ports WHERE enabled=1";
    $results = $q->QUERY_SQL($sql);
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    if (!$q->ok) {
        $err[] = proxy_status_warning("MySQL error", $q->mysql_error_html(), "blur()");
    }
    $COUNTDePorts = $ligne["tcount"];
    $js_icon_stats = null;
    $icon_stats = "<div style='float:left;margin-right:10px;margin-top:5px'><img src='img/statistics-24-grey.png'></div>";
    $GotoNotCategorized = "GotoNotCategorized()";
    $ActiveRequests_js = "Loadjs('squid.active.requests.php')";
    $GotoNotCategorized_underline = "underline";
    $ActiveRequests_underline = "underline";
    $GotoMysQLAllWebsites_underline = "underline";
    $GoToCachedStatistics = "GoToCachedStatistics()";
    $GotoMysQLAllWebsites = "GotoMysQLAllWebsites()";
    $LoadProxyUpdate = "LoadProxyUpdate();";
    $LOadUfdbUpdate = "GoToWebfilteringDBstatus();";
    if (!$users->AllowViewStatistics) {
        $GotoNotCategorized = "blur();";
        $ActiveRequests_js = "blur()";
        $GotoNotCategorized_underline = "none";
        $ActiveRequests_underline = "none";
        $GoToCachedStatistics = "blur()";
        $GotoMysQLAllWebsites = "blur()";
        $GotoMysQLAllWebsites_underline = "none";
    }
    if (!$users->AsSquidAdministrator) {
        $LoadProxyUpdate = "blur()";
        $LOadUfdbUpdate = "blur()";
    }
    $SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
    if ($SquidPerformance < 2) {
        $prec = round(@file_get_contents("{$GLOBALS["BASEDIR"]}/CACHED_AVG"), 1);
        $PROXY_REQUESTS_NUMBER = @file_get_contents("{$GLOBALS["BASEDIR"]}/PROXY_REQUESTS_NUMBER");
        $PROXY_REQUESTS_NUMBER = FormatNumber($PROXY_REQUESTS_NUMBER);
        if ($COUNT_DE_CACHES > 0) {
            $COUNT_DE_CACHES_KB = $COUNT_DE_CACHES * 1024;
            $COUNT_DE_CACHES_TEXT = FormatBytes($COUNT_DE_CACHES_KB);
        }
        $js_icon_stats = "OnMouseOver=\"this.style.cursor='pointer';\"\n\t\tOnMouseOut=\"this.style.cursor='auto'\"\n\t\tOnClick=\"javascript:{$GoToCachedStatistics};\"";
        if (is_file("{$GLOBALS["BASEDIR"]}/CACHED_ROW_DAY")) {
            $icon_stats = "<div style='float:left;margin-right:10px;margin-top:5px'>\n\t\t\t\t\t<img src='img/statistics-24.png'></div>";
        }
        if ($SUM_FAMILYSITES > 0) {
            $SUM_FAMILYSITES = FormatNumber($SUM_FAMILYSITES);
            $SUM_FAMILYSITES_TEXT = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:20px'>{websites}:\n\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:{$GotoMysQLAllWebsites};\"\n\t\t\tstyle='text-decoration:{$GotoMysQLAllWebsites_underline}'>{$SUM_FAMILYSITES}</a></td>\n\t\t\t</tr>";
        }
    }
    $ActiveRequestsR = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/active_requests.inc"));
    $ActiveRequestsNumber = count($ActiveRequestsR["CON"]);
    $ActiveRequestsIpaddr = count($ActiveRequestsR["IPS"]);
    $ActiveRequestsMembers = count($ActiveRequestsR["USERS"]);
    if ($NOT_CATEGORIZED > 0) {
        $NOT_CATEGORIZED = FormatNumber($NOT_CATEGORIZED);
        $NOT_CATEGORIZED_ROW = "<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"{$GotoNotCategorized}\"\n\t\tstyle='text-decoration:{$GotoNotCategorized_underline}'>{websites}: {$NOT_CATEGORIZED} {not_categorized}</a></td>\n\t\t</tr>";
    }
    $TITLE_REQUESTS = "\n\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"{$ActiveRequests_js}\"\n\t\tstyle='text-decoration:{$ActiveRequests_underline}'>{$ActiveRequestsNumber} {active_requests}</a></td>\n\t\t</tr>";
    if ($COUNTDePorts == 0) {
        $err[] = proxy_status_warning("{no_listening_port_defined}", "{no_listening_port_proxydefined_explain}", "GotoSquidPorts()");
    }
    if ($SquidDebugAcls == 1) {
        $err[] = proxy_status_warning("{debug_acls}", "{debug_acls_explain}", "Loadjs('squid.acls.options.php')");
    }
    if ($SNMP_WALK["ERROR"]) {
        $err[] = proxy_status_warning("SNMP:{need_to_restart_webconsole}", "{click_to_install}", "Loadjs('php-snmp.progress.php'");
    }
    preg_match("#^([0-9]+)\\.([0-9]+)#", $realsquidversion, $re);
    $MAJOR = intval($re[1]);
    $MINOR = intval($re[2]);
    $INCOMPATIBLE = true;
    $REV = 0;
    $BUILD = 0;
    if ($MAJOR > 2) {
        if ($MINOR > 4) {
            $INCOMPATIBLE = false;
        }
    }
    if ($MAJOR == 0) {
        $INCOMPATIBLE = false;
    }
    if ($MAJOR == 4) {
        $INCOMPATIBLE = false;
    }
    if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)#", $realsquidversion, $re)) {
        $REV = intval($re[3]);
    }
    if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)-([0-9]+)-r([0-9]+)#", $realsquidversion, $re)) {
        $BUILD = intval($re[4] . $re[5]);
    }
    if ($SQUIDEnable == 1) {
        if ($INCOMPATIBLE) {
            $incompatible_proxy_version = $tpl->_ENGINE_parse_body("{incompatible_proxy_version}");
            $incompatible_proxy_version = str_replace("%s", $realsquidversion, $incompatible_proxy_version);
            $err[] = proxy_status_warning($incompatible_proxy_version, $incompatible_proxy_version, $LoadProxyUpdate);
        }
        $ArticaTechNetSquidRepo = unserialize(base64_decode($sock->GET_INFO("ArticaTechNetSquidRepo")));
        $NEWVER = null;
        while (list($key, $array) = each($ArticaTechNetSquidRepo)) {
            $AVVERSION = $array["VERSION"];
            $XREV = 0;
            $XBUILD = 0;
            preg_match("#^([0-9]+)\\.([0-9]+)#", $AVVERSION, $re);
            $XMAJOR = intval($re[1]);
            $XMINOR = intval($re[2]);
            if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)#", $AVVERSION, $re)) {
                $XREV = intval($re[3]);
            }
            if (preg_match("#^([0-9]+)\\.([0-9]+)\\.([0-9]+)-([0-9]+)-r([0-9]+)#", $AVVERSION, $re)) {
                $XBUILD = intval($re[4] . $re[5]);
            }
            $KEY = intval("{$XMAJOR}{$XMINOR}{$XREV}{$XBUILD}");
            if ($MAJOR > $XMAJOR) {
                continue;
            }
            if ($GLOBALS["VERBOSE"]) {
                echo "<strong> squidver check {$XMAJOR}/{$XMINOR}/{$XREV}/{$XBUILD} - {$MAJOR}/{$MINOR}/{$REV}/{$BUILD}</strong>\n<br>";
            }
            if ($XMAJOR > $MAJOR) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "<strong> squidver check {$XMAJOR}>{$MAJOR}</strong>\n<br>";
                }
                $NEWVER = $AVVERSION;
                break;
            }
            if ($XMAJOR == $MAJOR) {
                if ($XMINOR > $MINOR) {
                    $NEWVER = $AVVERSION;
                    break;
                }
            }
            if ($XMAJOR == $MAJOR) {
                if ($XMINOR == $MINOR) {
                    if ($XREV > $REV) {
                        $NEWVER = $AVVERSION;
                        break;
                    }
                }
            }
            if ($XMAJOR == $MAJOR) {
                if ($XMINOR == $MINOR) {
                    if ($XREV == $REV) {
                        if ($XBUILD > $BUILD) {
                            $NEWVER = $AVVERSION;
                            break;
                        }
                    }
                }
            }
        }
        if ($users->AsSquidAdministrator) {
            if ($NEWVER != null) {
                $INFOS[] = status_info_event("{SQUID_NEWVERSION} {$NEWVER}", "{SQUID_NEWVERSION_TEXT}", $LoadProxyUpdate);
            }
        }
    }
    if ($SquidUrgency == 1) {
        $jsOn = "Loadjs('squid.urgency.php?justbutton=yes')";
        if (!$users->AsSquidAdministrator) {
            $jsOn = "blur()";
        }
        $err[] = proxy_status_warning("{proxy_in_emergency_mode}", "{proxy_in_emergency_mode_explain}", $jsOn);
        $icon = "disks-128-red.png";
        //proxy_in_emergency_mode
        //proxy_in_emergency_mode_explain
    }
    if ($SquidSSLUrgency == 1) {
        $jsOn = "Loadjs('squid.urgency.php?ssl=yes');";
        if (!$users->AsSquidAdministrator) {
            $jsOn = "blur()";
        }
        $icon = "disks-128-red.png";
        $err[] = proxy_status_warning("{proxy_in_ssl_emergency_mode}", "{proxy_in_ssl_emergency_mode_explain}", $jsOn);
    }
    if ($MacToUidUrgency == 1) {
        $jsOn = "Loadjs('squid.urgency.php?justbutton=yes');";
        if (!$users->AsSquidAdministrator) {
            $jsOn = "blur()";
        }
        $icon = "disks-128-red.png";
        $err[] = proxy_status_warning("{proxy_in_MacToUid_emergency_mode}", "{proxy_in_MacToUid_emergency_mode_explain}", $jsOn);
    }
    if ($SQUIDEnable == 1) {
        if ($SquidUFDBUrgency == 1) {
            $jsOn = "Loadjs('squid.urgency.php?ufdb=yes');";
            if (!$users->AsSquidAdministrator) {
                $jsOn = "blur()";
            }
            $icon = "disks-128-red.png";
            $err[] = proxy_status_warning("{proxy_in_webfiltering_emergency_mode}", "{proxy_in_webfiltering_emergency_mode_explain}", $jsOn);
        }
        if ($EnableUfdbGuard == 1) {
            if ($users->CORP_LICENSE) {
                $ufdbguard_artica_cloud_version = ufdbguard_artica_cloud_version();
                if ($ufdbguard_artica_cloud_version == 0) {
                    $jsOn = "Loadjs('dansguardian2.articadb-progress.php')";
                    if (!$users->AsSquidAdministrator) {
                        $jsOn = "blur()";
                    }
                    $important_events[] = status_important_event("{update_webfiltering_artica_databases}", "{update_webfiltering_artica_databases_not_updated}", $jsOn);
                }
                if ($ufdbguard_artica_cloud_version > 1) {
                    $jsOn = "Loadjs('dansguardian2.articadb-progress.php')";
                    if (!$users->AsSquidAdministrator) {
                        $jsOn = "blur()";
                    }
                    $important_events[] = status_important_event("{webfiltering_artica_databases_available}", "{webfiltering_artica_databases_available_explain}", $jsOn);
                }
            }
            $ufdbguard_toulouse_cloud_version = ufdbguard_toulouse_cloud_version();
            if ($ufdbguard_toulouse_cloud_version == 0) {
                $jsOn = "Loadjs('dansguardian2.articadb-progress.php')";
                if (!$users->AsSquidAdministrator) {
                    $jsOn = "blur()";
                }
                $important_events[] = status_important_event("{update_webfiltering_toulouse_databases}", "{update_webfiltering_toulouse_databases_not_updated}", $jsOn);
            }
            if ($ufdbguard_toulouse_cloud_version > 1) {
                $jsOn = "Loadjs('dansguardian2.articadb-progress.php')";
                if (!$users->AsSquidAdministrator) {
                    $jsOn = "blur()";
                }
                $important_events[] = status_important_event("{webfiltering_toulouse_databases_available}", "{webfiltering_artica_databases_available_explain}", $jsOn);
            }
        }
    }
    if ($SQUIDEnable == 1) {
        if ($LogsWarninStop == 1) {
            $jsOn = "Loadjs('system.log.emergency.php');";
            if (!$users->AsSquidAdministrator) {
                $jsOn = "blur()";
            }
            $help = help_icon("{squid_logs_urgency}");
            $text = texttooltip("{squid_logs_urgency_section}", "{squid_logs_urgency}", $jsOn);
            $icon = "disks-128-red.png";
            $err[] = proxy_status_warning("{squid_logs_urgency_section}", "{squid_logs_urgency}", $jsOn);
        }
    }
    if ($SQUIDEnable == 1) {
        if ($IsPortsConverted == 0) {
            $jsOn = "Loadjs('squid.compile.progress.php');";
            if (!$users->AsSquidAdministrator) {
                $jsOn = "blur()";
            }
            $icon = "disks-128-warn.png";
            $err[] = proxy_status_warning("{IsPortsConverted_requested}", "{squid_IsPortsConverted_explain}", $jsOn);
        } else {
            if ($AsTransparent > 0) {
                $FireHolConfigured = intval($sock->GET_INFO("FireHolConfigured"));
                if ($FireHolConfigured == 0) {
                    $icon = "disks-128-warn.png";
                    $err[] = proxy_status_warning("{transparent_mode_issue}", "{squid_transparent_no_firewall}", $jsOn);
                }
            }
        }
    }
    $GoToCategoriesServiceA = "GoToCategoriesServiceA()";
    $GotoAdConnection = "GotoAdConnection()";
    $LoadMainDashProxy = "LoadMainDashProxy()";
    $GoToServices = "GoToServices()";
    $GoToUfdb = "GoToUfdb()";
    $GoToCaches = "GoToCaches()";
    $GoToCaches_underline = "underline";
    if (!$users->AsDansGuardianAdministrator) {
        $GoToCategoriesServiceA = "blur()";
        $GoToUfdb = "blur()";
    }
    if (!$users->AsSquidAdministrator) {
        $GotoAdConnection = "blur()";
        $LoadMainDashProxy = "blur()";
        $GoToServices = "blur()";
        $GoToCaches = "blur()";
        $GoToCaches_underline = "none";
    }
    if ($SQUIDEnable == 1) {
        $catz = new mysql_catz();
        if ($catz->UfdbCatEnabled == 1) {
            $categories = $catz->ufdbcat("google.com");
            if (!$catz->ok) {
                $icon = "disks-128-warn.png";
                $err[] = proxy_status_warning("{APP_UFDBCAT}: {connection_error}", $catz->mysql_error, $GoToCategoriesServiceA);
            }
        }
    }
    if ($SQUIDEnable == 1) {
        if ($sock->SQUID_IS_EXTERNAL_LDAP()) {
            $tests = CHECK_SQUID_EXTERNAL_LDAP();
            if ($tests != null) {
                $err[] = proxy_status_warning("{$tests}", "{$tests}", "GotoOpenldap()");
            }
        }
    }
    if ($BasicAuthenticatorEmergency == 1) {
        $jsOn = "Loadjs('squid.urgency.php?justbutton=yes');";
        if (!$users->AsSquidAdministrator) {
            $jsOn = "blur()";
        }
        $icon = "disks-128-warn.png";
        $err[] = proxy_status_warning("{authentication_emergency_mode}", "{authentication_emergency_mode_explain}", $jsOn);
    }
    if ($SQUIDEnable == 1) {
        if ($EnableKerbAuth == 1) {
            if ($ActiveDirectoryEmergency == 1) {
                $jsOn = "Loadjs('squid.urgency.php?activedirectory=yes');";
                if (!$users->AsSquidAdministrator) {
                    $jsOn = "blur()";
                }
                $icon = "disks-128-warn.png";
                $err[] = proxy_status_warning("{activedirectory_emergency_mode}", "{activedirectory_emergency_mode_explain}", $jsOn);
            }
            if (!$users->CORP_LICENSE) {
                $Days = 86400 * 30;
                $DayToLeft = 30;
                if (is_file("/usr/share/artica-postfix/ressources/class.pinglic.inc")) {
                    include_once "/usr/share/artica-postfix/ressources/class.pinglic.inc";
                    $EndTime = $GLOBALS['ADLINK_TIME'] + $Days;
                    $seconds_diff = $EndTime - time();
                    $DayToLeft = floor($seconds_diff / 3600 / 24);
                }
                $MAIN_ERROR = $tpl->_ENGINE_parse_body("{warn_no_license_activedirectory_30days}");
                $MAIN_ERROR = str_replace("%s", $DayToLeft, $MAIN_ERROR);
                $important_events[] = status_important_event($MAIN_ERROR, $MAIN_ERROR, $jsOn);
            }
            if ($ActiveDirectoryEmergency == 0) {
                $IsConnected = IsKerconnected();
                if ($IsConnected != "TRUE") {
                    $err[] = proxy_status_warning("{proxy_is_not_configured_ad}", null, $GotoAdConnection);
                }
            }
            $TestLDAPAD = TestLDAPAD();
            if ($TestLDAPAD != null) {
                $err[] = $TestLDAPAD;
            }
            $AdminAsSeenNTLMPerfs = intval($sock->GET_INFO("AdminAsSeenNTLMPerfs"));
            if ($AdminAsSeenNTLMPerfs == 0) {
                $err[] = proxy_status_warning("{NTLM_PERFORMANCES_NOT_DEFINED}", null, $GotoAdConnection);
            }
        }
    }
    if ($EnableeCapClamav == 1) {
        if ($eCAPClamavEmergency == 1) {
            $jsOn = "Loadjs('squid.urgency.php?eCAPClamavEmergency=yes');";
            if (!$users->AsSquidAdministrator) {
                $jsOn = "blur()";
            }
            $icon = "disks-128-warn.png";
            $err[] = proxy_status_warning("{eCAPClamav_emergency_mode}", "{activedirectory_emergency_mode_explain}", $jsOn);
        }
    }
    if ($ParanoidBlockerEmergency == 1) {
        $jsOn = "Loadjs('squid.urgency.php?ParanoidBlockerEmergency=yes');";
        if (!$users->AsSquidAdministrator) {
            $jsOn = "blur()";
        }
        $icon = "disks-128-warn.png";
        $err[] = proxy_status_warning("{paranoid_emergency_mode}", "{paranoid_emergency_mode_explain}", $jsOn);
    }
    if ($SquidCacheFullHideWarn == 0) {
        if ($COUNT_DE_CACHES > 0) {
            if ($CACHES_AVG > 85) {
                $err[] = proxy_status_warning("{caches_are_full}", "{caches_are_full_explain}", $GoToCaches);
            }
        }
    }
    if ($COUNT_DE_CACHES > 0) {
        $COUNT_DE_MEMBERS = intval(@file_get_contents("{$GLOBALS["BASEDIR"]}/MEMBERS_COUNT"));
        if ($COUNT_DE_MEMBERS > 15) {
            if ($COUNT_DE_CACHES < 20000) {
                $undersized_proxy_caches_explain = $tpl->_ENGINE_parse_body("{undersized_proxy_caches_explain}");
                $COUNT_DE_CACHES_KB = $COUNT_DE_CACHES * 1024;
                $COUNT_DE_CACHES_TEXT = FormatBytes($COUNT_DE_CACHES_KB);
                $undersized_proxy_caches_explain = str_replace("%S", $COUNT_DE_CACHES_TEXT, $undersized_proxy_caches_explain);
                $undersized_proxy_caches_explain = str_replace("%U", $COUNT_DE_MEMBERS, $undersized_proxy_caches_explain);
                if ($SquidCacheLevel > 0) {
                    $err[] = proxy_status_warning("{undersized_proxy_caches}", $undersized_proxy_caches_explain, $GoToCaches);
                }
            }
        }
    }
    if (!$users->AsSquidAdministrator) {
        $err = array();
    }
    if (count($err) > 0) {
        $errT[] = "<tr><td style='font-size:32px;color:#d32d2d;vertical-align:middle'>" . count($err) . " {issues}</td></tr>\n\t\t<tr><td colspan=2>&nbsp;</td></tr>\t\n\t\t\t\t";
    }
    $ActiveRequestsR = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/active_requests.inc"));
    $ActiveRequestsNumber = count($ActiveRequestsR["CON"]);
    $ActiveRequestsIpaddr = count($ActiveRequestsR["IPS"]);
    $ActiveRequestsMembers = count($ActiveRequestsR["USERS"]);
    $GotoParanoidMode = "GotoParanoidMode()";
    $GotoParanoidMode_underline = "underline";
    $GoToUfdb_underline = "underline";
    if (!$users->AsDansGuardianAdministrator) {
        $GotoParanoidMode = "blur()";
        $GoToUfdb = "blur()";
        $GotoParanoidMode_underline = "none";
        $GoToUfdb_underline = "none";
    }
    $UfdbEnableParanoidMode = intval($sock->GET_INFO("UfdbEnableParanoidMode"));
    if ($UfdbEnableParanoidMode == 1) {
        $q = new mysql_squid_builder();
        $webfilters_paranoid = $q->COUNT_ROWS("webfilters_paranoid");
        if ($webfilters_paranoid > 0) {
            $webfilters_paranoid_text = "\n\t\t<tr>\n\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:{$GotoParanoidMode}\"\n\t\tstyle='text-decoration:{$GotoParanoidMode_underline}'>{paranoid_mode}: " . FormatNumber($webfilters_paranoid) . " {rules}</a></td>\n\t\t</tr>";
        }
    }
    if ($EnableUfdbGuard == 1) {
        if ($COUNT_DE_BLOCKED > 0) {
            $WebFiltering_blocked = "\n\t\t<tr>\n\t\t<td style='font-size:20px'>\n\t\t<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:{$GoToUfdb}\"\n\t\tstyle='text-decoration:{$GoToUfdb_underline}'>{blocked_events}: " . FormatNumber($COUNT_DE_BLOCKED) . "</a></td>\n\t\t</tr>";
        }
    }
    if (intval($ini->_params["SQUID"]["service_disabled"]) == 1) {
        if ($ini->_params["SQUID"]["running"] == 0) {
            $icon = "disks-128-red.png";
        }
    }
    $mgr_client_list_TR = "\n\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:GotoMgrClientList()\"\n\t\t\tstyle='text-decoration:underline'>{active_clients}: " . FormatNumber($SNMP_WALK["CLIENTS_NUMBER"]) . "</a></td>\n\t\t</tr>";
    $active_resquests_js = "Loadjs('squid.active.requests.php')";
    $active_resquests_underline = "underline";
    if (!$users->AsSquidAdministrator) {
        $active_resquests_js = "blur()";
        $active_resquests_underline = "none";
    }
    if ($ActiveRequestsNumber > 1) {
        $active_resquests = "\n\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:{$active_resquests_js}\"\n\t\t\tstyle='text-decoration:underline'>{active_requests}: {$ActiveRequestsNumber}</a></td>\n\t\t</tr>";
    }
    if (intval($WATCHDOG_COUNT_EVENTS) > 0) {
        $important_events[] = status_important_event("{$WATCHDOG_COUNT_EVENTS} {important_events_48h}", null, "GotoWatchdog()");
    }
    $CACHES_AVG_COLOR = "black";
    if ($CACHES_AVG > 85) {
        if ($SquidCacheFullHideWarn == 0) {
            $CACHES_AVG_COLOR = "#d32d2d";
        }
    }
    if (count($important_events) > 0) {
        $important_events_text = "<tr><td colspan=2>&nbsp;</td></tr>" . @implode("\n", $important_events);
    }
    if ($SQUIDEnable == 0) {
        $icon = "disks-128-ok-grey.png";
    }
    if (count($INFOS) > 0) {
        $INFOS[] = "<tr><td><br></td></tr>";
    }
    if ($SquidCacheLevel == 0) {
        $SNMP_WALK["PERC_CACHE"] = 0;
        $SNMP_WALK["STORED_OBJECTS"] = 0;
    }
    $prec = intval($SNMP_WALK["PERC_CACHE"]);
    if ($prec > 0) {
        $perc_cache = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px;vertical-align:middle'>{$prec}% {cache} ({currently})</td>\n\t\t</tr>";
    }
    $REQUESTS = intval($SNMP_WALK["REQUESTS"]);
    if ($REQUESTS > 0) {
        $current_req = "<tr>\n\t\t<td style='font-size:18px;vertical-align:middle'>" . FormatNumber($REQUESTS) . " {requests}</td>\n\t\t</tr>";
    }
    if ($SNMP_WALK["CPU"] > 0) {
        $current_cpu_use = "<tr>\n\t\t<td style='font-size:18px;vertical-align:middle'>{$SNMP_WALK["CPU"]}% {cpu_use}</td>\n\t\t</tr>";
    }
    $windowsUpdate = null;
    if ($WindowsUpdateCaching == 1) {
        $cacheFile = "/usr/share/artica-postfix/ressources/logs/web/WindowsUpdate.state";
        $ARRAY = unserialize(@file_get_contents($cacheFile));
        if (intval($ARRAY["SIZEKB"]) > 4) {
            $windowsUpdate = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:18px;vertical-align:middle'> \n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:GotoWindowsUpdate()\"\n\t\t\tstyle='text-decoration:underline'>Windows Update:</a> " . FormatBytes($ARRAY["SIZEKB"]) . "</td>\n\t\t\t</tr>";
        }
    }
    $HTTrack = null;
    if ($HTTrackInSquid == 1) {
        $HTTRackSize = $sock->GET_INFO("HTTRackSize");
        if ($HTTRackSize > 0) {
            $HTTrack = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:18px;vertical-align:middle'>\n\t\t\t<a href=\"javascript:blur();\"\n\t\t\tOnClick=\"javascript:GotoWebCopy()\"\n\t\t\tstyle='text-decoration:underline'>WebCopy:</a> " . FormatBytes($HTTRackSize / 1024) . "</td>\n\t\t\t</tr>";
        }
    }
    if ($SNMP_WALK["STORED_OBJECTS"] > 0) {
        $current_stored_objects = "<tr>\n\t\t<td style='font-size:18px;vertical-align:middle'>" . FormatNumber($SNMP_WALK["STORED_OBJECTS"]) . " {stored_objects}</td>\n\t\t</tr>";
    }
    if ($SquidCacheLevel > 0) {
        if ($COUNT_DE_CACHES_TEXT != null) {
            $INFO_STORAGE_CACHE = "\n\t\t\t<tr>\n\t\t\t<td style='font-size:20px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"{$GoToCaches}\"\n\t\t\t\t\tstyle='text-decoration:{$GoToCaches_underline};color:{$CACHES_AVG_COLOR}'>\n\t\t\t\t\t\t{storage}: {$CACHES_AVG}%&nbsp;/&nbsp;{$COUNT_DE_CACHES_TEXT}</a>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>";
        }
    }
    $CACHED_DETAILS_TOTAL = null;
    $NOT_CACHED_DETAILS_TOTAL = null;
    if ($TOTALS_CACHED > 0) {
        $CACHED_DETAILS_TOTAL = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"{$GoToCaches}\"\n\t\t\t\t\tstyle='text-decoration:{$GoToCaches_underline};color:black'>\n\t\t\t\t\t\t{cached}: " . FormatBytes($TOTALS_CACHED / 1024) . "</a>\n\t\t\t</td>\n\t\t</tr>\n\t";
    }
    if ($TOTALS_NOT_CACHED > 0) {
        $NOT_CACHED_DETAILS_TOTAL = "\n\t\t<tr>\n\t\t\t<td style='font-size:18px'>\n\t\t\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"{$GoToCaches}\"\n\t\t\t\t\tstyle='text-decoration:{$GoToCaches_underline};color:black'>\n\t\t\t\t\t\t{not_cached}: " . FormatBytes($TOTALS_NOT_CACHED / 1024) . "</a>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t";
    }
    if (!$users->AsSquidAdministrator) {
        $important_events_text = null;
        $errT = array();
        $windowsUpdate = null;
        $mgr_client_list_TR = null;
    }
    $icon = imgtootltip($icon, "position:right:{configure_your_proxy}", "{$LoadMainDashProxy}");
    $html = "\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top' style='width:128px' >\n\t\t\t{$icon}\n\t\t\t<div id='active-directory-dash-infos'>" . active_directory_infos() . "</div>\t\n\t\t</td>\n\t\t<td>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td style='font-size:30px'>\n\t\t\t\t" . texttooltip("{your_proxy}", "{configure_your_proxy}", "{$LoadMainDashProxy}") . "\n\t\t\t\t&nbsp;<span style='font-size:22px'>[&nbsp;<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:Loadjs('squid.infos.php');\"\n\t\t\t\tstyle='text-decoration:underline'>Infos.</a>&nbsp;]</span>\t\t\n\t\t\t\t\t\t\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<!-- perc_cache -->\n\t\t\t{$perc_cache}\n\t\t\t<!-- TOTALS_CACHED:{$TOTALS_CACHED} -->\n\t\t\t{$CACHED_DETAILS_TOTAL}\n\t\t\t<!-- TOTALS NOT CACHED:{$TOTALS_NOT_CACHED} -->\n\t\t\t{$NOT_CACHED_DETAILS_TOTAL}\n\t\t\t<!-- windowsUpdate -->\n\t\t\t{$windowsUpdate}\n\t\t\t<!-- HTTrack -->\n\t\t\t{$HTTrack}\n\t\t\t<!-- current_req -->\n\t\t\t{$current_req}\n\t\t\t<!-- SUM_FAMILYSITES_TEXT -->\n\t\t\t{$SUM_FAMILYSITES_TEXT}\n\t\t\n\t\t\t{$active_resquests}\n\t\t\t{$mgr_client_list_TR}\n\t\t\t{$rqs}\n\t\t\t\t" . @implode("", $ntmlauthenticators_array) . "\n\t\t\t\n\t\t\t\n\t\t<!-- WebFiltering_blocked -->\n\t\t{$WebFiltering_blocked}\n\t\t<!-- webfilters_paranoid -->\n\t\t{$webfilters_paranoid_text}\t\n\t\t<!-- INFO_STORAGE_CACHE -->\n\t\t{$INFO_STORAGE_CACHE}\n\t\t\n\t\t\n\t\t\n\t<!-- current_stored_objects -->\n\t\t\t{$current_stored_objects}\n\t<!-- TITLE_REQUESTS -->\n\t\t\t{$TITLE_REQUESTS}\n\t<!-- TOP_GRAPHS -->\n\t\t\t" . TOP_GRAPHS() . "\n\t\t\t{$CountDeServices}\n\t\t\t" . @implode("", $INFOS) . "\n\t\t\t" . @implode("", $errT) . "\n\t\t\t" . @implode("", $err) . "\n\t\t\t{$important_events_text}\n\t\t\t\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n\t</table>\n\t<script>\n\t\tLoadAjaxSilent('proxy_dashboard_counters','{$page}?proxy_dashboard_counters=yes');\n\t</script>\n\t";
    $html = $tpl->_ENGINE_parse_body($html);
    if (!is_dir("/usr/share/artica-postfix/ressources/interface-cache")) {
        @mkdir("/usr/share/artica-postfix/ressources/interface-cache");
    }
    @file_put_contents($cachefile, $html);
    return $html;
}
function table2()
{
    $page = CurrentPageName();
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $zmd5 = $_GET["zmd5"];
    if ($zmd5 == null) {
        echo "alert('no key sended');UnlockPage();";
        die;
    }
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT `values` FROM reports_cache WHERE `zmd5`='{$zmd5}'"));
    $values = $ligne["values"];
    $MAIN = unserialize(base64_decode($values));
    $html[] = "<table style='width:100%'>";
    $html[] = $tpl->_ENGINE_parse_body("<tr><th style='font-size:18px;padding:8px'>{websites}</td>\n\t\t\t<th style='font-size:18px'>{hits}</td></tr>");
    while (list($site, $size) = each($MAIN["TOP_WEBSITES_HITS"])) {
        $size = FormatNumber($size);
        $html[] = "<tr><td style='font-size:18px;padding:8px'>{$site}</a></td>\n\t\t<td style='font-size:18px'>{$size}</td></tr>";
    }
    $html[] = "</table>";
    $html[] = "<script>";
    $html[] = "Loadjs('{$page}?graph3=yes&zmd5={$_GET["zmd5"]}&t={$_GET["t"]}')";
    $html[] = "</script>";
    echo @implode("", $html);
}
function members_search(){
		$MyPage=CurrentPageName();
		$page=CurrentPageName();
		$tpl=new templates();
		$sock=new sockets();
		$q=new mysql_squid_builder();
		$date=date("Ym",$_GET["time"]);
	
	
	
		$table="(SELECT SUM(hits) as hits,SUM(size) as size,uid,ipaddr,MAC,{$_GET["field"]}
		FROM {$date}_maccess GROUP BY uid,ipaddr,MAC,{$_GET["field"]} HAVING {$_GET["field"]}='{$_GET["value"]}') as t";
		$searchstring=string_to_flexquery();
		$page=1;
	
	
		if(isset($_POST["sortname"])){if($_POST["sortname"]<>null){ $ORDER="ORDER BY `{$_POST["sortname"]}` {$_POST["sortorder"]}"; }}
		if (isset($_POST['page'])) {$page = $_POST['page'];}
	
	
				$sql="SELECT COUNT( * ) AS tcount FROM $table WHERE 1 $searchstring";
				$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_events"));
		if(!$q->ok){json_error_show("Mysql Error [".__LINE__."]: <br>$q->mysql_error.<br>$sql",1);}
			$total = $ligne["tcount"];
	
	
					if (isset($_POST['rp'])) {$rp != $_POST['rp'];}
		if(!is_numeric($rp)){$rp=50;}
	
	
	$pageStart = ($page-1)*$rp;
	$limitSql = "LIMIT $pageStart, $rp";
	$sql="SELECT * FROM $table WHERE 1 $searchstring $ORDER $limitSql ";
	$results = $q->QUERY_SQL($sql,"artica_events");
	if(!$q->ok){if($q->mysql_error<>null){json_error_show(date("H:i:s")."<br>SORT:{$_POST["sortname"]}:<br>Mysql Error [L.".__LINE__."]: $q->mysql_error<br>$sql",1);}}
	
	$suffix=suffix();
	if(mysql_num_rows($results)==0){json_error_show("no data",1);}
	
	
	$data = array();
	$data['page'] = $page;
	$data['total'] = $total;
	$data['rows'] = array();
	$fontsize="18";
	$style=" style='font-size:{$fontsize}px'";
	$styleHref=" style='font-size:{$fontsize}px;text-decoration:underline'";
	$free_text=$tpl->javascript_parse_text("{free}");
	$computers=$tpl->javascript_parse_text("{computers}");
	$overloaded_text=$tpl->javascript_parse_text("{overloaded}");
	$orders_text=$tpl->javascript_parse_text("{orders}");
	$directories_monitor=$tpl->javascript_parse_text("{directories_monitor}");
	
	
	while ($ligne = mysql_fetch_assoc($results)) {
			$LOGSWHY=array();
	
			$uid=$ligne["uid"];
			$MAC=$ligne["MAC"];
			$ipaddr=$ligne["ipaddr"];
			$size=FormatBytes($ligne["size"]/1024);
			$hits=FormatNumber($ligne["hits"]);
			$zDate=$ligne["zDate"];
			$zDateEnc=urlencode($zDate);
			
			$FILTER_uid="<a href=\"javascript:blur();\"
			OnClick=\"javascript:Loadjs('squid.users-stats.currentmonth.website.php?zdate=$zDateEnc&field=uid&value=$uid&familysite={$_GET["value"]}')\" 
			$styleHref>";
			
			$FILTER_MAC="<a href=\"javascript:blur();\"
			OnClick=\"javascript:Loadjs('squid.users-stats.currentmonth.website.php?zdate=$zDateEnc&field=MAC&value=$MAC&familysite={$_GET["value"]}')\"
			$styleHref>";

			$FILTER_IPADDR="<a href=\"javascript:blur();\"
			OnClick=\"javascript:Loadjs('squid.users-stats.currentmonth.website.php?zdate=$zDateEnc&field=ipaddr&value=$ipaddr&familysite={$_GET["value"]}')\"
			$styleHref>";
	
			$time=strtotime($zDate);
			$time_text=$tpl->_ENGINE_parse_body($q->time_to_date($time));
	
						
	
			$cell=array();
			$cell[]="<span $style>$FILTER_uid$uid</a></span>";
			$cell[]="<span $style>$FILTER_MAC$MAC</a></span>";
			$cell[]="<span $style>$FILTER_IPADDR$ipaddr</a></span>";
			$cell[]="<span $style>$size</a></span>";
			$cell[]="<span $style>$hits</a></span>";
	
	
			$data['rows'][] = array(
			'id' => $ligne['zmd5'],
			'cell' => $cell
			);
	}
	
	
			echo json_encode($data);
		}
function table1()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $q = new postgres_sql();
    $zmd5 = $_GET["zmd5"];
    if ($zmd5 == null) {
        echo "alert('no key sended');UnlockPage();";
        die;
    }
    $table = "{$zmd5}report";
    $results = $q->QUERY_SQL("SELECT SUM(rqs) as rqs,client FROM \"{$table}\" GROUP BY client ORDER BY rqs DESC LIMIT 10");
    $html[] = "<table style='width:100%'>";
    $html[] = $tpl->_ENGINE_parse_body("<tr><th style='font-size:18px;padding:8px'>{members}</td><th style='font-size:18px'>{size}</td></tr>");
    while ($ligne = @pg_fetch_assoc($results)) {
        $size = $ligne["rqs"];
        $site = $ligne["client"];
        if ($site == null) {
            continue;
        }
        $size = FormatNumber($size);
        $html[] = "<tr><td style='font-size:18px;padding:8px'>{$site}</a></td>\n\t\t<td style='font-size:18px'>{$size}</td></tr>";
    }
    $html[] = "</table>";
    $html[] = "<script>";
    $html[] = "Loadjs('{$page}?graph2=yes&zmd5={$_GET["zmd5"]}&t={$_GET["t"]}')";
    $html[] = "</script>";
    echo @implode("", $html);
}
function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new postgres_sql();
    $t = $_GET["t"];
    $search = '%';
    $table = "smtpstats_day";
    $page = 1;
    $table = "(SELECT SUM(grey) as grey, SUM(black) AS black, SUM(cnx) as cnx,AVG(domains) as domains,cdir FROM smtpcdir_day GROUP BY cdir) as t";
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            if ($_POST["sortname"] == "servername") {
                $_POST["sortname"] = "value";
            }
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $searchstring = string_to_flexPostGresquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as tcount FROM {$table} WHERE {$searchstring}";
        $ligne = pg_fetch_assoc($q->QUERY_SQL($sql, "artica_events"));
        $total = $ligne["tcount"];
    } else {
        $sql = "SELECT COUNT(*) as tcount FROM {$table}";
        $ligne = pg_fetch_assoc($q->QUERY_SQL($sql, "artica_events"));
        $total = $ligne["tcount"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$rp} OFFSET {$pageStart}";
    $sql = "SELECT *  FROM {$table} WHERE {$searchstring} {$FORCE} {$ORDER} {$limitSql}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        json_error_show($q->mysql_error, 0);
    }
    $divstart = "<span style='font-size:12px;font-weight:normal'>";
    $divstop = "</div>";
    if (pg_num_rows($results) == 0) {
        pg_num_rows("no data");
    }
    while ($ligne = pg_fetch_assoc($results)) {
        $id = md5(serialize($ligne));
        $color = "black";
        $color_black = "black";
        $fontweight = "normal";
        if ($ligne["black"] > 0) {
            $color_black = "#d32d2d";
        }
        if ($ligne["grey"] > 0) {
            $fontweight = "bold";
        }
        $BLACK = FormatNumber($ligne["black"]);
        $GREY = FormatNumber($ligne["grey"]);
        $CNX = FormatNumber($ligne["cnx"]);
        $CDIR = $ligne["cdir"];
        $DOMAINS = FormatNumber($ligne["domains"]);
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:18px;color:{$color}'>{$CDIR}</strong>", "<strong  style='font-size:18px;color:{$color}'>{$DOMAINS}</strong><a>", "<strong  style='font-size:18px;color:{$color}'>{$CNX}</strong><a>", "<span  style='font-size:18px;color:{$color_black}'>{$BLACK}</span>", "<span style='font-size:18px;color:{$color};font-weight:{$fontweight}'>{$GREY}</strong></a>"));
    }
    echo json_encode($data);
}