function popup()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $zdate = $tpl->javascript_parse_text("{time}");
    $ipaddr = $tpl->javascript_parse_text("{ipaddr}");
    $mac = $tpl->javascript_parse_text("{MAC}");
    $familysite = $tpl->javascript_parse_text("{familysite}");
    $uid = $tpl->javascript_parse_text("{uid}");
    $size = $tpl->javascript_parse_text("{size}");
    // ipaddr        | familysite            | servername                                | uid               | MAC               | size
    $t = time();
    $q = new mysql_squid_builder();
    $title = $tpl->javascript_parse_text("{downloaded_size}::" . $q->time_to_date(time()));
    $html = "\n<table class='flexRT{$t}' style='display:none' id='flexRT{$t}'></table>\n<script>\nfunction StartLogsSquidTable{$t}(){\n\t\n\t\$('#flexRT{$t}').flexigrid({\n\t\turl: '{$page}?list=yes',\n\t\tdataType: 'json',\n\t\tcolModel : [\n\t\t\t{display: '{$uid}', name : 'uid', width : 141, sortable : true, align: 'left'},\n\t\t\t{display: '{$ipaddr}', name : 'ipaddr', width :95, sortable : true, align: 'left'},\n\t\t\t{display: '{$mac}', name : 'MAC', width : 122, sortable : true, align: 'left'},\n\t\t\t{display: '{$familysite}', name : 'familysite', width : 349, sortable : true, align: 'left'},\n\t\t\t{display: '{$size}', name : 'size', width : 142, sortable : true, align: 'left'},\n\t\t\t],\n\t\n\t\tsearchitems : [\n\t\t\t{display: '{$ipaddr}', name : 'ipaddr'},\n\t\t\t{display: '{$familysite}', name : 'familysite'},\n\t\t\t{display: '{$uid}', name : 'uid'},\n\t\t\t{display: '{$mac}', name : 'mac'},\n\t\t\t],\n\t\tsortname: 'size',\n\t\tsortorder: 'desc',\n\t\tusepager: true,\n\t\ttitle: '{$title}',\n\t\tuseRp: true,\n\t\trp: 50,\n\t\tshowTableToggleBtn: false,\n\t\twidth: 935,\n\t\theight: 600,\n\t\tsingleSelect: true,\n\t\trpOptions: [10, 20, 30, 50,100,200,500,1000,1500]\n\t\t\n\t\t});   \n\n}\n\nStartLogsSquidTable{$t}();\n</script>\t\t\t\n";
    echo $html;
}
Example #2
0
function checkcreds()
{
    $sock = new sockets();
    $GLOBALS["CACHE_AUTH"] = $sock->GET_INFO("ArticaSplashHotSpotCacheAuth");
    $GLOBALS["MAX_TIME"] = $sock->GET_INFO("ArticaSplashHotSpotEndTime");
    if (!is_numeric($GLOBALS["CACHE_AUTH"])) {
        $GLOBALS["CACHE_AUTH"] = 60;
    }
    if (!is_numeric($GLOBALS["MAX_TIME"])) {
        $GLOBALS["MAX_TIME"] = 0;
    }
    $gateway_addr = $_REQUEST["gw_address"];
    $gw_port = $_REQUEST["gw_port"];
    $gw_id = $_REQUEST["gw_id"];
    $ARP = $_REQUEST["mac"];
    $url = $_REQUEST["url"];
    $token = $_REQUEST["token"];
    $MAC = $ARP;
    ToSyslog("Verify credentials for {$ARP}/{$_POST["username"]} Token:{$token}");
    $LOGIN = $_POST["username"];
    $IPADDR = null;
    $HOST = gethostbyaddr($IPADDR);
    $URI = $url;
    $array["LOGIN"] = $LOGIN;
    $array["IPADDR"] = null;
    $array["MAC"] = $MAC;
    $array["ARP"] = $MAC;
    $array["HOST"] = $HOST;
    $array["token"] = $token;
    $q = new mysql_squid_builder();
    $sql = "SELECT uid,creationtime,ttl,enabled FROM hotspot_members WHERE uid='{$LOGIN}'";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    if (trim($ligne["uid"]) != null) {
        if ($ligne["enabled"] == 0) {
            $Created = $q->time_to_date($ligne["creationtime"], true);
            ToSyslog("checkcreds:: {$LOGIN} is disabled {$Created}");
            $GLOBALS["ERROR"] = "<strong>{$LOGIN}</strong> {your_account_is_disabled}<br>{created}:{$Created}";
            return false;
        }
        $ttl = $ligne["ttl"];
        if ($ligne["creationtime"] > 0) {
            if ($ligne["ttl"] > 0) {
                $EnOfLife = strtotime("+{$ttl} minutes", $ligne["creationtime"]);
                if (time() > $EnOfLife) {
                    ToSyslog("checkcreds:: {$LOGIN} expired - End of Life");
                    $GLOBALS["ERROR"] = "{accesstime_to_internet_expired}";
                    return false;
                }
            }
        }
    }
    $auth = false;
    include_once dirname(__FILE__) . "/ressources/class.user.inc";
    if (checkcreds_AD()) {
        if ($GLOBALS["HOTSPOT_DEBUG"]) {
            ToSyslog("checkcreds_AD return true... in line:" . __LINE__);
        }
        checkcreds_mysql($array, true);
        return UnLock($array);
    }
    if (checkcreds_ldap()) {
        if ($GLOBALS["HOTSPOT_DEBUG"]) {
            ToSyslog("checkcreds_ldap return true... in line:" . __LINE__);
        }
        checkcreds_mysql($array, true);
        return UnLock($array);
    }
    if (checkcreds_mysql($array)) {
        if ($GLOBALS["HOTSPOT_DEBUG"]) {
            ToSyslog("checkcreds_mysql return true... in line:" . __LINE__);
        }
        return UnLock($array);
    }
    events(1, "Login failed for {$LOGIN}/{$IPADDR}", "MAC:{$MAC}\nHost:{$HOST}\n" . @implode("\n", $GLOBALS["LOGS"]));
    return false;
}
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 wifidog_status()
{
    $tpl = new templates();
    $sock = new sockets();
    $errT = array();
    $js_hostpot = "GotoHostpotv3()";
    $icon = "wifidog-ok-128.png";
    $err = array();
    $ini = new Bs_IniHandler();
    $q = new mysql_squid_builder();
    $data = base64_decode($sock->getFrameWork("hotspot.php?services-status=yes"));
    $ARRAY = unserialize(@file_get_contents("/usr/share/artica/postfix/ressources/logs/web/wifidog.status"));
    $genrate = $q->time_to_date($ARRAY["TIME"], true);
    $uptime = $ARRAY["UPTIME"];
    $ArticaHotSpotEmergency = intval($sock->GET_INFO("ArticaHotSpotEmergency"));
    $ini->loadString($data);
    while (list($key, $array) = each($ini->_params)) {
        $service_name = $array["service_name"];
        $service_disabled = intval($array["service_disabled"]);
        if ($service_disabled == 0) {
            continue;
        }
        $running = intval($array["running"]);
        $c++;
        if ($running == 0) {
            $js = $js_hostpot;
            if ($key == "SQUID") {
                $js = "Loadjs('squid.start.progress.php');";
            }
            $icon = "wifidog-critic-128.png";
            $err[] = proxy_status_warning("{{$service_name}} {stopped}", "{{$service_name}} {stopped}", "GoToServices()");
        }
    }
    if ($ArticaHotSpotEmergency == 1) {
        $icon = "wifidog-critic-128.png";
        $err[] = proxy_status_warning("{global_urgency_mode}", "{hotspot_in_emergency_mode_explain}", "Loadjs('squid.webauth.maintenance.php')");
    }
    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>\n\t\t\t\t";
    }
    $curs = "OnMouseOver=\"this.style.cursor='pointer';\"\n\tOnMouseOut=\"this.style.cursor='auto'\"";
    $hotSpotSession = $q->COUNT_ROWS("hotspot_sessions");
    $icon = imgtootltip($icon, "{dashboard_hotspot}", $js_hostpot);
    $html = "\n\t<table style='width:100%'>\n\t<tr>\n\t<td valign='top' style='width:128px'>\n\t{$icon}\n\t</td>\n\t<td style='width:99%'>\n\t<table style='width:100%'>\n\t<tr>\n\t<td style='font-size:30px'>HotSpot</td>\n\t</tr>\n\t<tr>\n\t<td style='font-size:30px;text-decoration:underline'\n\tOnClick=\"javascript:{$js_hostpot}\" {$curs}>{$hotSpotSession} {sessions}</td>\n\t\n\t" . @implode("\n", $errT) . "\n\t" . @implode("\n", $err) . "\n\t\n\t</tr>\n\t</table>\n\t</td>\n\t</tr>\n\t</table>\n\t";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
function websites_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,familysite,`zDate`,{$_GET["field"]}\n\tFROM {$date}_maccess GROUP BY familysite,zDate,{$_GET["field"]} \n\tHAVING {$_GET["field"]}='{$_GET["value"]}' AND familysite='{$_GET["familysite"]}') 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();
        $size = FormatBytes($ligne["size"] / 1024);
        $hits = FormatNumber($ligne["hits"]);
        $zDate = $ligne["zDate"];
        $time = strtotime($zDate);
        $time_text = $tpl->_ENGINE_parse_body($q->time_to_date($time));
        $FILTER = "Loadjs('squid.users-stats.currentmonth.website.day.php?" . "field={$_GET["field"]}&value=" . urlencode($_GET["value"]) . "&familysite={$_GET["familysite"]}&time={$time}')";
        $link = "<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:{$FILTER}\" {$styleHref}>";
        $cell = array();
        $cell[] = "<span {$style}>{$link}{$zDate} - {$time_text}</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 rtt_hour()
{
    $page = CurrentPageName();
    $q = new mysql_squid_builder();
    $xtime = $q->HIER_TIME();
    $table = "RTTD_" . date("Ymd", $q->HIER_TIME());
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $results = $q->QUERY_SQL("SELECT zHour as MIN ,SUM(`size`) as `SIZE` FROM `{$table}` GROUP BY MIN ORDER BY MIN");
    $CountRow = mysql_num_rows($results);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $size = intval($ligne["SIZE"]);
        $min = $ligne["MIN"];
        if (strlen($min) == 1) {
            $min = "0{$min}";
        }
        $min = "{$min}:00";
        $xdata[] = $min;
        $size = $size / 1024;
        $size = $size / 1024;
        $ydata[] = round($size, 2);
        if ($GLOBALS["VERBOSE"]) {
            echo "<li>{$min} = {$ligne["SIZE"]}Bytes ,{$size}MB</li>";
        }
    }
    $t = time();
    $title = "{realtime_flow}/{hour} (MB) " . $q->time_to_date($xtime);
    $timetext = "{minutes}";
    $highcharts = new highcharts();
    $highcharts->container = $_GET["container"];
    $highcharts->xAxis = $xdata;
    $highcharts->Title = $title;
    $highcharts->TitleFontSize = "14px";
    $highcharts->AxisFontsize = "12px";
    $highcharts->yAxisTtitle = "MB";
    $highcharts->xAxis_labels = false;
    $highcharts->LegendPrefix = $tpl->_ENGINE_parse_body("{hour} ");
    $highcharts->LegendSuffix = "MB";
    $highcharts->xAxisTtitle = $timetext;
    $highcharts->datas = array("{size}" => $ydata);
    $highcharts->SetRefreshCallBack = "Refresh{$t}";
    $highcharts->RemoveLock = true;
    $charts = $highcharts->BuildChart();
    $script = "\n\n\t\n\n\n{$charts}\n";
    echo $script;
}
Example #7
0
function main()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $users = new usersMenus();
    $sock = new sockets();
    $t = time();
    $SquidGuardIPWeb = $sock->GET_INFO("SquidGuardIPWeb");
    $SquidGuardApachePort = intval($sock->GET_INFO("SquidGuardApachePort"));
    if ($SquidGuardApachePort == 0) {
        $SquidGuardApachePort = 9020;
    }
    $UseRemoteUfdbguardService = intval($sock->GET_INFO("UseRemoteUfdbguardService"));
    $UfdbGuardThreads = $sock->GET_INFO("UfdbGuardThreads");
    $ufdbclass = new compile_ufdbguard();
    $UFDB = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig")));
    $UFDB = $ufdbclass->SetDefaultsConfig($UFDB);
    $datas = $UFDB;
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    $EnableGoogleSafeSearch = $sock->GET_INFO("EnableGoogleSafeSearch");
    $EnableGoogleSafeBrowsing = intval($sock->GET_INFO("EnableGoogleSafeBrowsing"));
    $EnableGoogleSafeBrowsing_popupon = $tpl->javascript_parse_text("{EnableGoogleSafeBrowsing_popupon}");
    $EnableGoogleSafeBrowsing_popupoff = $tpl->javascript_parse_text("{EnableGoogleSafeBrowsing_popupoff}");
    $DisableGoogleSSL = intval($sock->GET_INFO("DisableGoogleSSL"));
    $PhishTankApiKey = $sock->GET_INFO("PhishTankApiKey");
    $EnableSquidPhishTank = intval($sock->GET_INFO("EnableSquidPhishTank"));
    if (!is_numeric($EnableGoogleSafeSearch)) {
        $EnableGoogleSafeSearch = 1;
    }
    $SquidUrgency = intval($sock->GET_INFO("SquidUrgency"));
    $ufdbguardConfig = unserialize(base64_decode($sock->GET_INFO("ufdbguardConfig")));
    if (!is_numeric($ufdbguardConfig["DebugAll"])) {
        $ufdbguardConfig["DebugAll"] = 0;
    }
    if ($ufdbguardConfig["DebugAll"] == 1) {
        echo FATAL_ERROR_SHOW_128("<strong>{webfiltering_in_debug_mode}</strong><p>&nbsp;</p>{webfiltering_in_debug_mode_text}\n\t\t\t\t<div style='margin:20px;text-align:right'>" . button("{disable}", "Loadjs('ufdbguard.debug.php')", 20) . "</div>\n\t\t\t\t\n\t\t\t\t");
    }
    if ($SquidUrgency == 1) {
        echo FATAL_ERROR_SHOW_128("<strong>{proxy_in_emergency_mode}</strong><p>&nbsp;</p>{proxy_in_emergency_mode_explain}\n\t\t<div style='margin:20px;text-align:right'>" . button("{urgency_mode}", "Loadjs('squid.urgency.php?justbutton=yes')", 20) . "</div>\n\t\t");
    }
    $GoogleSafeBrowsingApiKey = $sock->GET_INFO("GoogleSafeBrowsingApiKey");
    $UfdbUseArticaClient = $sock->GET_INFO("UfdbUseArticaClient");
    if (!is_numeric($UfdbUseArticaClient)) {
        $UfdbUseArticaClient = 1;
    }
    $GoogleSafeBrowsingApiKey_color = "#04A910";
    $GoogleSafeBrowsingApiKey_link = $tpl->_ENGINE_parse_body("{defined}");
    $PhishTankApiKey_color = "#04A910";
    $PhishTankApiKey_link = $tpl->_ENGINE_parse_body("{defined}");
    if (strlen($PhishTankApiKey) < 10) {
        $PhishTankApiKey_color = "#A90404";
        $PhishTankApiKey_link = $tpl->_ENGINE_parse_body("{not_set}");
    }
    if (strlen($GoogleSafeBrowsingApiKey) < 10) {
        $GoogleSafeBrowsingApiKey_color = "#A90404";
        $GoogleSafeBrowsingApiKey_link = $tpl->_ENGINE_parse_body("{not_set}");
    }
    $EnableGoogleSafeBrowsing_field = Paragraphe_switch_img("{EnableGoogleSafeBrowsing}", "{EnableGoogleSafeBrowsing_explain}\n\t\t\t\t<div style='margin-top:10px;text-align:right'>\n\t\t\t\t\t<a href=\"javascript:Loadjs('{$page}?GoogleSafeBrowsingApiKey-js=yes')\"\n\t\t\t\t\tstyle='font-size:22px;color:{$GoogleSafeBrowsingApiKey_color};text-decoration:underline'>{API_KEY}:{$GoogleSafeBrowsingApiKey_link}</a>\n\t\t\t\n\t\t\t\t\t</div>\n\t\t\t<div style='margin-top:10px;text-align:right'>\n\t\t\t\t\t<a href=\"https://developers.google.com/safe-browsing/key_signup\"\n\t\t\t\t\tstyle='font-size:18px;text-decoration:underline' target=_new>Google:&nbsp;{free_register}</a>\n\t\t\t\t\t</div>\n\t\t\t\t", "EnableGoogleSafeBrowsing-{$t}", $EnableGoogleSafeBrowsing, null, 750);
    $EnablePhishtank = Paragraphe_switch_img("{PhishTank_enable}", "{PhishTank_about}\n\t\t\t<div style='margin-top:10px;text-align:right'>\n\t\t\t<a href=\"javascript:Loadjs('{$page}?PhishTankApiKey-js=yes')\"\n\t\t\tstyle='font-size:22px;color:{$PhishTankApiKey_color};text-decoration:underline'>{API_KEY}:{$PhishTankApiKey_link}</a>\n\t\t\t\t\n\t\t\t</div>\n\t\t\t<div style='margin-top:10px;text-align:right'>\n\t\t\t<a href=\"https://www.phishtank.com/api_register.php\"\n\t\t\tstyle='font-size:18px;text-decoration:underline' target=_new>PhishTank:&nbsp;{free_register}</a>\n\t\t\t</div>\n\t\t\t", "EnableSquidPhishTank-{$t}", $EnableSquidPhishTank, null, 750);
    $EnableGoogleSafeBrowsing_button = button("{apply}", "EnableGoogleSafeBrowsing{$t}()", 26);
    $EnablePhishtank_button = button("{apply}", "EnablePhishtank{$t}()", 26);
    if ($UfdbUseArticaClient == 0) {
        $EnableGoogleSafeBrowsing_field = Paragraphe_switch_disable("{EnableGoogleSafeBrowsing}", "{EnableGoogleSafeBrowsing_explain}", "EnableGoogleSafeBrowsing-{$t}", $EnableGoogleSafeBrowsing, null, 750);
        $EnablePhishtank = Paragraphe_switch_disable("{PhishTank_enable}", "{PhishTank_about}", "EnableSquidPhishTank-{$t}", $EnableSquidPhishTank, null, 750);
        $EnableGoogleSafeBrowsing_button = null;
        $EnablePhishtank_button = null;
    }
    if ($UFDB["UseRemoteUfdbguardService"] == 1) {
        $sock->SET_INFO("UseRemoteUfdbguardService", 1);
        $UseRemoteUfdbguardService = 1;
    }
    if ($DisableGoogleSSL == 1) {
        $DisableGoogleSSL_text = "{enabled}";
    } else {
        $DisableGoogleSSL_text = "{disabled}";
    }
    echo $tpl->_ENGINE_parse_body("<div style='margin-bottom:20px;margin-top:20px;width:98%' class=form>\n\t\t\t{$EnablePhishtank}\n\t\t\t<div style='text-align:right'>{$EnablePhishtank_button}</div>\n\t\t\t</div>");
    if ($UseRemoteUfdbguardService == 0) {
        echo $tpl->_ENGINE_parse_body("<div style='margin-bottom:20px;margin-top:20px;width:98%' class=form>" . Paragraphe_switch_img("{EnableGoogleSafeSearch}", "{safesearch_explain}\n\t\t\t\t<div style='margin-top:10px;text-align:right'>\n\t\t\t\t\t<a href=\"javascript:Loadjs('squid.google.ssl.php')\" \n\t\t\t\t\tstyle='font-size:22px;text-decoration:underline'>{disable_google_ssl} ({$DisableGoogleSSL_text})</a></div>\n\t\t\t\t\n\t\t\t\t", "EnableGoogleSafeSearch-{$t}", $EnableGoogleSafeSearch, null, 750) . "\n\t\t\t\t\t\n\t\t<div style='text-align:right'>" . button("{apply}", "EnableGoogleSafeSearch{$t}()", 26) . "</div>\t\t\t\n\t\t</div>");
    }
    echo $tpl->_ENGINE_parse_body("<div style='margin-bottom:20px;margin-top:20px;width:98%' class=form>\n\t\t{$EnableGoogleSafeBrowsing_field}\n\t\t<div style='text-align:right'>{$EnableGoogleSafeBrowsing_button}</div>\n\t\t</div>");
    if ($SquidGuardIPWeb == null) {
        $SquidGuardIPWeb = "http://" . $_SERVER['SERVER_ADDR'] . ':' . $SquidGuardApachePort . "/exec.squidguard.php";
        $fulluri = "http://" . $_SERVER['SERVER_ADDR'] . ':' . $SquidGuardApachePort . "/exec.squidguard.php";
        $sock->SET_INFO("SquidGuardIPWeb", $fulluri);
    } else {
        $fulluri = $SquidGuardIPWeb;
    }
    if (!$users->CORP_LICENSE) {
        $MyVersion = "{license_error}";
    } else {
        $q = new mysql_squid_builder();
        $MyVersion = trim($sock->getFrameWork("ufdbguard.php?articawebfilter-database-version=yes"));
        $MyVersion = $q->time_to_date($MyVersion, true);
    }
    if ($UseRemoteUfdbguardService == 0) {
        $wizard = "\n\t\t<tr><td colspan=3>&nbsp;</td></tr>\n\t\t<tr>\n\t\t\t<td colspan=3 align='center'>" . button("{wizard_rule}", "Loadjs('dansguardian2.wizard.rule.php')", 26) . "\n\t\t\t\t\t<div style='font-size:14px;margin-top:15px'>{wizard_rule_ufdb_explain}</div>\n\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\n\t\t</tr>";
        $build_rules = "<tr><td colspan=3>&nbsp;</td></tr>\n\t\t<tr>\n\t\t\t<td colspan=3 align='center'>" . button("{compile_rules}", "Loadjs('dansguardian2.compile.php');", 26) . "\n\t\t\t\t\t<div style='font-size:14px;margin-top:15px'>{wizard_rule_ufdb_compile_explain}</div>\n\t\t\t\t\t\n\t\t\t\t\t</td>\n\t\t\t\n\t\t</tr>";
    }
    $t = time();
    $html = "\n\t<div style='width:98%' class=form>\n\t\t<div style='font-size:28px;font-weight:bold'>\n\t\t<table style='width:100%;margin-top:30px'>\n\t\t<tr>\n\t\t\t<td style='vertical-align:middle;font-size:18px' class=legend>{listen_address}:</td>\n\t\t\t<td style='vertical-align:middle;font-size:18px'>{$datas["listen_addr"]}:{$datas["listen_port"]}</td>\n\t\t\t<td>&nbsp;</td>\n\t\t</tr>\t\n\t\t<tr><td colspan=2>&nbsp;</td></tr>\t\n\t\t<tr>\n\t\t\t<td style='vertical-align:middle;font-size:18px' class=legend>{webpage_deny_url}:</td>\n\t\t\t<td style='vertical-align:middle;font-size:18px'>{$fulluri}</td>\n\t\t\t<td>" . button("{options}", "Loadjs('ufdbguard.urichange.php')", 16) . "</td>\n\t\t</tr>\n\t\t<tr><td colspan=2>&nbsp;</td></tr>\n\t\t<tr>\n\t\t\t<td style='vertical-align:middle;font-size:18px' class=legend>{artica_databases}:</td>\n\t\t\t<td style='vertical-align:middle;font-size:18px'>{$MyVersion}</td>\n\t\t\t<td>" . button("{options}", "LoadAjax('BodyContent','artica.update.php?webfiltering-tabs=yes&from-ufdbguard=yes')", 16) . "</td>\n\t\t</tr>\n\n\t\t{$wizard}\n\t\t{$build_rules}\n\t\t\n\t\t\n\t\t</table>\n\n\t\t\n\t\t<script>\n\t\t\n\tvar xEnableGoogleSafeSearch{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tLoadjs('dansguardian2.compile.php');\n\t\t\n\t}\t\t\n\t\t\n\tfunction EnableGoogleSafeSearch{$t}(){\n\t\tif(!document.getElementById('EnableGoogleSafeSearch-{$t}')){ alert('Error in field, please refresh...'); return; }\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('EnableGoogleSafeSearch', document.getElementById('EnableGoogleSafeSearch-{$t}').value);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xEnableGoogleSafeSearch{$t});  \n\t}\n\t\n\tvar xEnableGoogleSafeBrowsing{$t}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tLoadAjaxRound('main-ufdb-frontend','ufdbguard.status.php');\n\t\tLoadjs('squid.compile.progress.php');\n\t\t\n\t}\t\n\t\n\tfunction EnableGoogleSafeBrowsing{$t}(){\n\t\tif(!document.getElementById('EnableGoogleSafeBrowsing-{$t}')){alert('Error in field, please refresh...'); return; }\n\t\tvar XHR = new XHRConnection();\n\t\tvar EnableGoogleSafeBrowsing=document.getElementById('EnableGoogleSafeBrowsing-{$t}').value;\n\t\tif(EnableGoogleSafeBrowsing==1){ if(!confirm('{$EnableGoogleSafeBrowsing_popupon}')){return;} }\n\t\tif(EnableGoogleSafeBrowsing==0){if(!confirm('{$EnableGoogleSafeBrowsing_popupoff}')){return;} }\n\t\tXHR.appendData('EnableGoogleSafeBrowsing', EnableGoogleSafeBrowsing);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xEnableGoogleSafeBrowsing{$t}); \t\n\t\n\t}\n\t\n\tfunction  EnablePhishtank{$t}(){\n\t\tif(!document.getElementById('EnableSquidPhishTank-{$t}')){alert('Error in field, please refresh...'); return; }\n\t\tvar XHR = new XHRConnection();\n\t\tvar EnableSquidPhishTank=document.getElementById('EnableSquidPhishTank-{$t}').value;\n\t\tXHR.appendData('EnableSquidPhishTank', EnableSquidPhishTank);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xEnableGoogleSafeBrowsing{$t}); \n\t}\n\t\n</script>\n\t\t\n\t\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Example #8
0
function search()
{
    $Mypage = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $t = time();
    $fontsize = 13;
    $type = $_GET["type"];
    $field_query = "size";
    $field_query2 = "SUM(size)";
    $table_field = "{size}";
    $category = $tpl->_ENGINE_parse_body("{category}");
    $table = "WEEK_RTTH";
    $member = $tpl->_ENGINE_parse_body("{member}");
    $sitename = $tpl->_ENGINE_parse_body("{website}");
    $search = '%';
    $page = 1;
    $ORDER = "ORDER BY ID DESC";
    $ip = new IP();
    $Select = "MAC";
    $FORCE_FILTER = " AND `MAC`='{$_GET["MAC"]}'";
    if ($ip->isIPAddress($_GET["ipaddr"])) {
        $Select = "ipaddr";
        $FORCE_FILTER = "ipaddr='{$_GET["ipaddr"]}'";
    }
    if ($ip->IsvalidMAC($_GET["MAC"])) {
        $Select = "MAC";
        $FORCE_FILTER = "MAC='{$_GET["MAC"]}'";
    }
    $table = "(SELECT `day`,SUM(size) as size,{$Select} FROM WEEK_RTTH GROUP BY `day`,{$Select} HAVING {$FORCE_FILTER}) as t";
    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'];
    }
    $search = string_to_flexquery();
    if ($search != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT* FROM {$table} WHERE 1 {$search} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $data = array();
    $data['page'] = 0;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error);
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data");
    }
    $data['total'] = mysql_num_rows($results);
    $style = "style='font-size:22px'";
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $ligne["size"] = FormatBytes($ligne["size"] / 1024);
        $categorize = "Loadjs('squid.categorize.php?www={$ligne["sitename"]}')";
        if (trim($ligne["category"]) == null) {
            $ligne["category"] = "<span style='color:#D70707'>{categorize_this_website}</span>";
        }
        $id = md5(@implode("", $ligne));
        if (trim($ligne["uid"]) == "-") {
            $ligne["uid"] = null;
        }
        if (trim($ligne["uid"]) == null) {
            $ligne["uid"] = $q->UID_FROM_MAC($ligne["MAC"]);
        }
        if (trim($ligne["uid"]) == null) {
            $ligne["uid"] = $q->UID_FROM_IP($ligne["CLIENT"]);
        }
        $categorize = "<a href=\"javascript:blur()\" \n\t\tOnClick=\"javascript:{$categorize}\" \n\t\tstyle='font-size:{$fontsize}px;text-decoration:underline'>";
        $familysite = $q->GetFamilySites($ligne["sitename"]);
        $TrafficHour = "<a href=\"javascript:blur()\" \n\t\tOnClick=\"javascript:Loadjs('squid.traffic.statistics.hours.php?familysite={$ligne["sitename"]}&day={$_GET["day"]}')\" \n\t\tstyle='font-size:{$fontsize}px;text-decoration:underline'>";
        $dd = date("Y-m");
        $D = $q->time_to_date(strtotime("{$dd}-{$ligne["day"]} 00:00:00"));
        $data['rows'][] = array('id' => $id, 'cell' => array("<span {$style}>{$D}</span>", "<span {$style}>{$ligne["size"]}</a></span>"));
    }
    echo json_encode($data);
}
Example #9
0
function checkcreds()
{
    $gateway_addr = $_REQUEST["gw_address"];
    $gw_port = $_REQUEST["gw_port"];
    $gw_id = $_REQUEST["gw_id"];
    $ARP = $_REQUEST["mac"];
    $url = $_REQUEST["url"];
    $token = $_REQUEST["token"];
    $ruleid = $_REQUEST["ruleid"];
    if ($ruleid == 0) {
        if (isset($_SESSION["WIFIDOG_RULES"])) {
            $ruleid = $_SESSION["WIFIDOG_RULES"];
        }
    }
    $MAC = $ARP;
    $sock = new wifidog_settings($ruleid);
    $USE_MYSQL = intval($sock->GET_INFO("USE_MYSQL"));
    $USE_ACTIVEDIRECTORY = intval($sock->GET_INFO("USE_ACTIVEDIRECTORY"));
    $DO_NOT_AUTENTICATE = intval($sock->GET_INFO("DO_NOT_AUTENTICATE"));
    wifidog_logs("Verify credentials for {$ARP}/{$_POST["username"]} Active Directory:{$USE_ACTIVEDIRECTORY}; Token:{$token} ruleid:{$ruleid}", __FUNCTION__, __LINE__);
    $LOGIN = $_POST["username"];
    $IPADDR = null;
    $HOST = gethostbyaddr($IPADDR);
    $URI = $url;
    $array["LOGIN"] = $LOGIN;
    $array["IPADDR"] = null;
    $array["MAC"] = $MAC;
    $array["ARP"] = $MAC;
    $array["HOST"] = $HOST;
    $array["token"] = $token;
    $array["ruleid"] = $ruleid;
    if ($DO_NOT_AUTENTICATE == 1) {
        return UnLock($array, true);
    }
    $q = new mysql_squid_builder();
    $sql = "SELECT uid,creationtime,ttl,enabled FROM hotspot_members WHERE uid='{$LOGIN}'";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    if (trim($ligne["uid"]) != null) {
        $enabled = intval($ligne["enabled"]);
        if ($enabled == 0) {
            events(1, "Login failed for {$LOGIN}/{$IPADDR}, account locked");
            $GLOBALS["ERROR"] = "{your_account_is_disabled}";
            return false;
        }
    }
    if ($USE_MYSQL == 0) {
        if ($USE_ACTIVEDIRECTORY == 0) {
            $USE_MYSQL = 1;
        }
    }
    if ($USE_MYSQL == 0) {
        $q->QUERY_SQL("DELETE FROM hotspot_members WHERE uid='{$LOGIN}'");
    } else {
        if (trim($ligne["uid"]) != null) {
            if ($ligne["enabled"] == 0) {
                $Created = $q->time_to_date($ligne["creationtime"], true);
                wifidog_logs("checkcreds:: {$LOGIN} is disabled {$Created}");
                $GLOBALS["ERROR"] = "<strong>{$LOGIN}</strong> {your_account_is_disabled}<br>{created}:{$Created}";
                return false;
            }
            $ttl = $ligne["ttl"];
            if ($ligne["creationtime"] > 0) {
                if ($ligne["ttl"] > 0) {
                    $EnOfLife = strtotime("+{$ttl} minutes", $ligne["creationtime"]);
                    if (time() > $EnOfLife) {
                        wifidog_logs("checkcreds:: {$LOGIN} expired - End of Life");
                        $GLOBALS["ERROR"] = "{accesstime_to_internet_expired}";
                        return false;
                    }
                }
            }
        }
    }
    $auth = false;
    include_once dirname(__FILE__) . "/ressources/class.user.inc";
    if ($USE_ACTIVEDIRECTORY == 1) {
        if (checkcreds_AD($ruleid)) {
            return UnLock($array);
        }
    }
    if (checkcreds_ldap()) {
        if ($GLOBALS["HOTSPOT_DEBUG"]) {
            wifidog_logs("checkcreds_ldap return true... in line:" . __LINE__);
        }
        return UnLock($array);
    }
    if ($USE_MYSQL == 1) {
        if (checkcreds_mysql($array)) {
            if ($GLOBALS["HOTSPOT_DEBUG"]) {
                wifidog_logs("checkcreds_mysql return true... in line:" . __LINE__);
            }
            return UnLock($array);
        }
    }
    events(1, "Login failed for {$LOGIN}/{$IPADDR}", "MAC:{$MAC}\nHost:{$HOST}\n" . @implode("\n", $GLOBALS["LOGS"]));
    $GLOBALS["ERROR"] = "{wrong_unername_or_password}";
    return false;
}
Example #10
0
function history_month_data_items()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $t = $_GET["t"];
    $search = '%';
    $table = "(SELECT `day` as zDate,SUM(size) as size FROM\n\t`{$_GET["table"]}`  WHERE `{$_GET["field"]}`='{$_GET["value"]}'\n\tGROUP BY zDate) as t";
    $page = 1;
    $FORCE_FILTER = null;
    $total = 0;
    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 {$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"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error . "<br>{$sql}");
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data");
    }
    $fontsize = "16";
    //ipaddr          | hostname      | uid               | MAC               | account | QuerySize    | hits
    $time = $q->TIME_FROM_QUOTAMONTH_TABLE($_GET["table"]);
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $md = md5(serialize($ligne));
        $ligne["size"] = FormatBytes($ligne["size"] / 1024);
        //$ligne["hits"]=FormatNumber($ligne["hits"]);
        if (strlen($ligne["zDate"]) == 1) {
            $ligne["zDate"] = "0" . $ligne["zDate"];
        }
        $xdate = date("Y", $time) . "-" . date("m", $time) . "-" . $ligne["zDate"] . " 00:00:00";
        $xtime = strtotime($xdate);
        $ligne["zDate"] = $q->time_to_date($xtime);
        $uiduri = "<a href=\"javascript:Loadjs('squid.members.zoom.php?field=uid&value=" . urlencode($ligne["uid"]) . "')\"\n\t\tstyle='font-size:{$fontsize}px;color:{$color};text-decoration:underline'>";
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;color:{$color}'>{$ligne["zDate"]}</span>", "<span style='font-size:{$fontsize}px;color:{$color}'>{$ligne["size"]}</span>"));
    }
    echo json_encode($data);
}
function members_items()
{
    $myPage = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $table = "hotspot_members";
    $uid = $_SESSION["uid"];
    $t = $_GET["t"];
    $tm = array();
    $search = '%';
    $page = 1;
    $FORCE_FILTER = "";
    $sock = new sockets();
    if (strpos($table, ",") == 0) {
        if (!$q->TABLE_EXISTS($table)) {
            json_error_show("{$table}: No such table", 0, true);
        }
    }
    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 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        if (!$q->ok) {
            json_error_show($q->mysql_error);
        }
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        if (!$q->ok) {
            json_error_show($q->mysql_error);
        }
        $total = $ligne["TCOUNT"];
    }
    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}";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        json_error_show($q->mysql_error);
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data");
    }
    $minutes = $tpl->_ENGINE_parse_body("{minutes}");
    $unlimited = $tpl->_ENGINE_parse_body("{unlimited}");
    $ttl = $tpl->_ENGINE_parse_body("{ttl}");
    $waiting_confirmation = $tpl->_ENGINE_parse_body("{waiting_confirmation}");
    $confirmed = $tpl->_ENGINE_parse_body("{confirmed}");
    while ($ligne = mysql_fetch_assoc($results)) {
        $activedirectory_text = null;
        $md5 = md5(serialize($ligne));
        $uid = $ligne["uid"];
        $uid_url = urlencode($uid);
        $ttl = intval($ligne["ttl"]);
        $EnOfLife = strtotime("+{$ttl} minutes", $ligne["creationtime"]);
        $delete = imgsimple("delete-42.png", null, "DeleteMember{$t}('{$ligne["uid"]}','{$md5}')");
        $MAC_text = null;
        $creationtime = $q->time_to_date($ligne["creationtime"], true);
        $End = $q->time_to_date($EnOfLife, true);
        $hostname = $ligne["hostname"];
        $MAC = $ligne["MAC"];
        $ipaddr = $ligne["ipaddr"];
        $ttl = intval($ligne["ttl"]);
        $color = "black";
        if ($ligne["enabled"] == 0) {
            $color = "#A4A1A1";
        }
        $urlend = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('{$myPage}?ttl-js={$uid_url}&t={$t}');\"\n\t\tstyle='font-size:22px;text-decoration:underline;color:{$color}'>";
        if ($ttl == 0) {
            $ttl = $unlimited;
            $End = $unlimited;
        } else {
            $ttl = "{$ttl} {$minutes}";
        }
        $enabled = Field_checkbox("enable_{$uid}", 1, $ligne["enabled"], "MemberEnable{$t}('{$uid}')");
        $uid_url = urlencode($ligne["uid"]);
        $urljs = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:YahooWin4('750','{$myPage}?uid={$uid_url}&t={$t}','{$ligne["uid"]}');\"\n\t\tstyle='font-size:22px;text-decoration:underline;color:{$color}'>";
        $urlttl = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:YahooWin4('500','{$myPage}?ttl={$uid_url}&t={$t}','{$ttl}:{$ligne["uid"]}');\"\n\t\tstyle='font-size:22px;text-decoration:underline;color:{$color}'>";
        if ($ligne["activedirectory"] == 1) {
            $activedirectory_text = "<br><span style='font-style:italic;font-size:18px'>Active Directory: " . ActiveDirectoryCnx($ligne["activedirectorycnx"]) . "</span>";
        }
        if ($ligne["autocreate"] == 1) {
            if ($ligne["autocreate_confirmed"] == 1) {
                $activedirectory_text = "<br><span style='font-style:italic;font-size:18px'>{$confirmed}</span>";
            } else {
                $activedirectory_text = "<br><span style='font-style:italic;font-size:18px'>{$waiting_confirmation}</span>";
            }
        }
        if ($MAC != null) {
            $MAC_text = " <span style='font-size:12px'>({$MAC})</span>";
        }
        //$subject=mime_decode($subject);
        $data['rows'][] = array('id' => $md5, 'cell' => array("<span style='font-size:22px;color:{$color}'>{$creationtime}</a></span>", "<span style='font-size:22px;color:{$color}'>{$urljs}{$ligne["uid"]}</a>{$MAC_text}</span>{$activedirectory_text}", "<span style='font-size:22px;color:{$color}'>{$ttl}</a></span>", "<span style='font-size:22px;color:{$color}'>{$urlend}{$End}</a></span>", "<span style='font-size:22px;color:{$color}'>{$enabled}</a></span>", "<center style='font-size:22px;color:{$color}'>{$delete}</a></center>"));
    }
    echo json_encode($data);
}
Example #12
0
function services_status()
{
    $sock = new sockets();
    $page = CurrentPageName();
    $tpl = new templates();
    $ini = new Bs_IniHandler();
    $q = new mysql_squid_builder();
    $data = base64_decode($sock->getFrameWork("hotspot.php?services-status=yes"));
    $ARRAY = unserialize(@file_get_contents("/usr/share/artica/postfix/ressources/logs/web/wifidog.status"));
    $genrate = $q->time_to_date($ARRAY["TIME"], true);
    $uptime = $ARRAY["UPTIME"];
    $ini->loadString($data);
    $f[] = "<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{uptime}:</td>\n\t\t<td><strong style='font-size:16px' nowrap>{$uptime}</strong>\n\t</tr>\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{sessions}:</td>\n\t\t<td><strong style='font-size:16px'>{$ARRAY["CLIENTS"]}</strong>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:16px' nowrap>{generated_on}:</td>\n\t\t<td><strong style='font-size:16px' nowrap>{$genrate}</strong>\n\t</tr>\t\t\n\t</table><hr>\t\t\n\t";
    $f[] = DAEMON_STATUS_ROUND("HOTSPOT_WWW", $ini);
    $f[] = DAEMON_STATUS_ROUND("HOTSPOT_SERVICE", $ini);
    $f[] = "<div style='text-align:right'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjax('hostspot-status','{$page}?hostspot-status=yes');") . "</div>";
    $f[] = "<center style='margin:10px'>" . button("{maintenance}", "Loadjs('squid.webauth.maintenance.php');", 18) . "</center>";
    echo $tpl->_ENGINE_parse_body(@implode("<p>&nbsp;</p>", $f));
}
Example #13
0
function popup()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $sock = new sockets();
    $squid = new squidbee();
    $users = new usersMenus();
    $t = time();
    $HyperCacheStoreID = intval($sock->GET_INFO("HyperCacheStoreID"));
    $HyperCacheStoreIDLicense = $sock->GET_INFO("HyperCacheStoreIDLicense");
    $HyperCacheMemEntries = intval($sock->GET_INFO("HyperCacheMemEntries"));
    $HyperCacheBuffer = intval($sock->GET_INFO("HyperCacheBuffer"));
    $HyperCacheLicStatus = unserialize($sock->GET_INFO("HyperCacheLicStatus"));
    $HyperCacheLicensedMode = intval($sock->GET_INFO("HyperCacheLicensedMode"));
    if ($HyperCacheMemEntries == 0) {
        $HyperCacheMemEntries = 500000;
    }
    if ($HyperCacheBuffer == 0) {
        $HyperCacheBuffer = 50;
    }
    $error_SSL_BUMP = null;
    $HyperCacheWebsitesList = $sock->GET_INFO("HyperCacheWebsitesList");
    $HyperCacheWebsitesList_json = json_decode($HyperCacheWebsitesList);
    foreach ($HyperCacheWebsitesList_json as $key) {
        $HyperCacheWebsitesList_AR[$key->url] = $key->site;
    }
    $HyperCacheHTTPListenPort = intval($sock->GET_INFO("HyperCacheHTTPListenPort"));
    if (!is_numeric($HyperCacheHTTPListenPort)) {
        $HyperCacheHTTPListenPort = 8700;
    }
    $HyperCacheHTTPListenPortSSL = $sock->GET_INFO("HyperCacheHTTPListenPortSSL");
    if (!is_numeric($HyperCacheHTTPListenPort)) {
        $HyperCacheHTTPListenPort = 8700;
    }
    if (!is_numeric($HyperCacheHTTPListenPortSSL)) {
        $HyperCacheHTTPListenPortSSL = 8900;
    }
    if ($HyperCacheHTTPListenPort == 0) {
        $HyperCacheHTTPListenPort = 8700;
    }
    $ip = new networking();
    $ipsH = $ip->ALL_IPS_GET_ARRAY();
    unset($ipsH["127.0.0.1"]);
    $q = new mysql_squid_builder();
    $eval = null;
    if (count($HyperCacheWebsitesList_AR)) {
        $count = count($HyperCacheWebsitesList_AR);
        $HyperCacheWebsitesList_text = "<div style='width:100%;text-align:right;margin-top:15px'>\n\t\t<a href=\"javascript:blur();\" OnClick=\"Loadjs('{$page}?websites-js=yes');\" style='text-decoration:underline'>{$count} {supported_websites}</a></div>";
    }
    if (isset($HyperCacheLicStatus["expired"])) {
        $step_text = "{license_expired}";
        $textcolor = "#C90505";
        if ($HyperCacheLicStatus["expired"] == 0) {
            $textcolor = "#23A83E";
            $step_text = "{license_active}";
        }
        if (intval($HyperCacheLicStatus["edate"]) > 10) {
            $t = time();
            $seconds_restantes = intval($HyperCacheLicStatus["edate"]) - $t;
            $minutes_restantes = $seconds_restantes / 60;
            $heures = $minutes_restantes / 60;
            $jours = $heures / 24;
            if ($jours < 31) {
                $eval = " - {evaluation_mode}&nbsp;";
            }
            $jours = round($jours);
            $dateexp = $q->time_to_date($HyperCacheLicStatus["edate"]) . " " . date("Y", $HyperCacheLicStatus["edate"]);
            $licestatus = "<table style='margin-top:10px;margin-bottom:10px'>\n\t\t\t<tr>\n\t\t\t\t<td valign='top' nowrap><img src='img/license-64.png'></td>\n\t\t\t\t<td style='padding-left:15px;font-size:18px'>{hypercache_license}:&nbsp;\n\t\t\t\t<span style='color:{$textcolor}'>{$step_text}</span>&nbsp;&nbsp;<i style='font-size:18px'>{expiredate}:&nbsp;{$dateexp} ({$jours} {days}{$eval})</i></td>\n\t\t\t</tr>\n\t\t\t</table>";
        }
    }
    $SSL_BUMP = $squid->SSL_BUMP;
    if ($SSL_BUMP == 0) {
        $error_SSL_BUMP = "<table style='margin-top:10px;margin-bottom:10px'>\n\t\t<tr>\n\t\t\t<td valign='top' nowrap><img src='img/warning-panneau-64.png'></td>\n\t\t\t<td style='padding-left:15px;font-size:18px'>{warn_videocache_nossl}</td>\n\t\t</tr>\n\t\t</table>";
    }
    $html = "<table style='width:100%'>\n\t<tr>\n\t\t<td style='width:240px;vertical-align:top'><div id='status-hypercache-testa'></div></td>\n\t\t<td style='width:99%'>{$error_SSL_BUMP}{$licestatus}\n\t\t\t<div style='width:98%' class=form>\n\t\t\t" . Paragraphe_switch_img("{HYPERCACHE_STOREID}", "{HYPERCACHE_STOREID_EXPLAIN}", "HyperCacheStoreID", $HyperCacheStoreID, null, 1160) . "\n\t\t\t" . Paragraphe_switch_img("{use_licensed_plugin}", "{HYPERCACHE_LICENSED_EXPLAIN}{$HyperCacheWebsitesList_text}", "HyperCacheLicensedMode", $HyperCacheLicensedMode, null, 1160) . "\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t{$HyperCacheLicensedMode}\n\t\t\t<table style='width:100%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class=legend style='font-size:26px'>{hypercache_license}:</td>\n\t\t\t\t\t<td>" . Field_text("HyperCacheStoreIDLicense", $HyperCacheStoreIDLicense, "font-size:26px;width:520px") . "</td>\n\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t</tr>\n\t\t\t<tr><td colspan=3 align='right'><hr>" . button("{apply}", "Save{$t}()", 30) . "</td></tr>\n\t\t</table>\n\t\t</div>\n\t</td>\n</tr>\n</table>\n<script>\nvar xSave{$t}=function (obj) {\n\tvar tempvalue=obj.responseText;\n\tLoadjs('squid.hypercache.progress.php');\n}\n\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tvar EnableSquidCacheBoosters=0;\n\tXHR.appendData('HyperCacheStoreIDLicenseLastLic','{$HyperCacheStoreIDLicense}');\n\tXHR.appendData('HyperCacheStoreID',document.getElementById('HyperCacheStoreID').value);\n\tXHR.appendData('HyperCacheStoreIDLicense',document.getElementById('HyperCacheStoreIDLicense').value);\n\tXHR.appendData('HyperCacheLicensedMode',document.getElementById('HyperCacheLicensedMode').value);\n\t\n\t\n\t\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n}\n\nLoadAjax('status-hypercache-testa','{$page}?service-status=yes');\n\n</script>\n";
    echo $tpl->_ENGINE_parse_body($html);
}
Example #14
0
function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $database = "artica_backup";
    $sock = new sockets();
    $search = '%';
    $table = "squeezer";
    $page = 1;
    $FORCE_FILTER = null;
    if ($q->COUNT_ROWS($table, $database) == 0) {
        json_error_show("no data");
        return;
    }
    if (!$q->TABLE_EXISTS($table, $database)) {
        json_error_show("no report");
        return;
    }
    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) {
        $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')";
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    if (!is_numeric($rp)) {
        $rp = 1;
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql, $database);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error);
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data");
    }
    $fontsize = 18;
    while ($ligne = mysql_fetch_assoc($results)) {
        $ID = $ligne["filemd5"];
        $color = "black";
        $select = "s_PopUpFull('{$MyPage}?filemd5={$ID}',1600,650,'{$ID}')";
        $link = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:{$select}\" \n\t\tstyle='font-size:{$fontsize}px;text-decoration:underline;color:{$color}'>";
        $ftime = strtotime($ligne["datefrom"]);
        $stime = strtotime($ligne["dateto"]);
        $fftime = $q->time_to_date($ftime, true);
        $sstime = $q->time_to_date($stime, true);
        $data['rows'][] = array('id' => $ID, 'cell' => array("<span style='font-size:{$fontsize}px;color:{$color}'>{$link}{$fftime}</a></span>", "<span style='font-size:{$fontsize}px;color:{$color}'>{$link}{$sstime}</a></span>"));
    }
    echo json_encode($data);
}