function tabs()
{
    $sock = new sockets();
    $fontsize = 16;
    $tpl = new templates();
    $page = CurrentPageName();
    $md5 = md5(serialize($_GET));
    $date = date("Ym");
    $table = "{$date}_maccess";
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS($table)) {
        echo FATAL_ERROR_SHOW_128("{no_table_see_support}");
        return;
    }
    $suffix = suffix();
    $array["flow-day"] = "{$_GET["familysite"]}: {flow_by_day}";
    $array["websites"] = "{$_GET["familysite"]}: {chronology}";
    while (list($num, $ligne) = each($array)) {
        if ($num == "parameters") {
            $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.accesslogs.params.php?parameters=yes\" style='font-size:{$fontsize}px'><span>{$ligne}</span></a></li>\n");
            continue;
        }
        if ($num == "schedule") {
            $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.databases.schedules.php?TaskType=54\" style='font-size:{$fontsize}px'><span>{$ligne}</span></a></li>\n");
            continue;
        }
        $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?{$num}=yes{$suffix}\" style='font-size:{$fontsize}px'><span>{$ligne}</span></a></li>\n");
    }
    echo build_artica_tabs($html, "squid_users_stats_{$md5}", 990) . "";
}
function tabs()
{
    $sock = new sockets();
    $fontsize = 16;
    $tpl = new templates();
    $page = CurrentPageName();
    $date = date("Ym");
    $table = "{$date}_maccess";
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS($table)) {
        echo FATAL_ERROR_SHOW_128("{no_table_see_support}");
        return;
    }
    $array["popup"] = '{members_this_month}';
    while (list($num, $ligne) = each($array)) {
        if ($num == "parameters") {
            $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.accesslogs.params.php?parameters=yes\" style='font-size:{$fontsize}px'><span>{$ligne}</span></a></li>\n");
            continue;
        }
        if ($num == "schedule") {
            $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.databases.schedules.php?TaskType=54\" style='font-size:{$fontsize}px'><span>{$ligne}</span></a></li>\n");
            continue;
        }
        $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?{$num}=yes\" style='font-size:{$fontsize}px'><span>{$ligne}</span></a></li>\n");
    }
    echo build_artica_tabs($html, "squid_users_profiling", 1100) . "<script>LeftDesign('user-stats-256.png');</script>";
}
function table()
{
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $page = CurrentPageName();
    $page = CurrentPageName();
    $sock = new sockets();
    $t = time();
    if (!$q->TABLE_EXISTS("ufdbunlock")) {
        $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`ufdbunlock` (\n\t\t\t`md5` VARCHAR( 90 ) NOT NULL ,\n\t\t\t`logintime` BIGINT UNSIGNED ,\n\t\t\t`finaltime` INT UNSIGNED ,\n\t\t\t`uid` VARCHAR(128) NOT NULL,\n\t\t\t`MAC` VARCHAR( 90 ) NULL,\n\t\t\t`www` VARCHAR( 128 ) NOT NULL ,\n\t\t\t`ipaddr` VARCHAR( 128 ) ,\n\t\t\tPRIMARY KEY ( `md5` ) ,\n\t\t\tKEY `MAC` (`MAC`),\n\t\t\tKEY `logintime` (`logintime`),\n\t\t\tKEY `finaltime` (`finaltime`),\n\t\t\tKEY `uid` (`uid`),\n\t\t\tKEY `www` (`www`),\n\t\t\tKEY `ipaddr` (`ipaddr`)\n\t\t\t)  ENGINE = MEMORY;";
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            echo FATAL_ERROR_SHOW_128($q->mysql_error_html());
            return;
        }
    }
    //
    $ipaddr = $tpl->_ENGINE_parse_body("{ipaddr}");
    $uid = $tpl->_ENGINE_parse_body("{uid}");
    $sitename = $tpl->_ENGINE_parse_body("{sitename}");
    $date = $tpl->_ENGINE_parse_body("{created}");
    $finish = $tpl->_ENGINE_parse_body("{finish}");
    $delete = $tpl->_ENGINE_parse_body("{delete}");
    $member = $tpl->javascript_parse_text("{members}");
    $parameters = $tpl->javascript_parse_text("{settings}");
    $title = $tpl->_ENGINE_parse_body("{unblock_queue}");
    $buttons = "\n\tbuttons : [\n\t\t{name: '{$parameters}', bclass: 'Reconf', onpress : unblock_parms},\n\t\n\t],";
    $buttons = null;
    $html = "\n\n<table class='UFDBGUARD_QUEUE_RELEASE' style='display: none' id='UFDBGUARD_QUEUE_RELEASE' style='width:100%'></table>\n<script>\nvar rowid{$t}='';\n\$(document).ready(function(){\n\$('#UFDBGUARD_QUEUE_RELEASE').flexigrid({\n\turl: '{$page}?rules-table-list=yes&t={$t}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$date}', name : 'logintime', width : 180, sortable : true, align: 'left'},\t\n\t\t{display: '{$ipaddr}', name : 'ipaddr', width : 160, sortable : true, align: 'left'},\n\t\t{display: '{$uid}', name : 'uid', width : 160, sortable : true, align: 'left'},\t\t\n\t\t{display: '{$sitename}', name : 'www', width : 299, sortable : true, align: 'left'},\n\t\t{display: '{$finish}', finaltime : 'uid', width :180, sortable : true, align: 'left'},\n\t\t{display: '{$delete}', name : 'delete', width : 70, sortable : false, align: 'center'},\n\t\t],\n\t{$buttons}\n\tsearchitems : [\n\t\t{display: '{$ipaddr}', name : 'ipaddr'},\n\t\t{display: '{$member}', name : 'uid'},\n\t\t{display: '{$sitename}', name : 'www'},\n\t\t],\n\tsortname: 'logintime',\n\tsortorder: 'desc',\n\tusepager: true,\n\ttitle: '<strong style=font-size:22px>{$title}</strong>',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 400,\n\tsingleSelect: true,\n\trpOptions: [10, 20, 30, 50,100,200]\n\t\n\t});   \n});\n\n\tfunction unblock_parms(){\n\t\tLoadjs('squidguardweb.unblock.php')\n\t}\n\n\tvar xBannedDeleteQueueUFDB= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){alert(res);return;}\n\t\t\$('#row'+rowid{$t}).remove();\n\t\t\$('#UFDBGUARD_QUEUE_RELEASE').flexReload();\n\t}\t\t\n\t\t\n\tfunction BannedDeleteQueueUFDB(md5){\n\t\trowid{$t}=md5;\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('DeleteWhiteListed', md5);\n\t\tXHR.sendAndLoad('{$page}', 'POST',xBannedDeleteQueueUFDB);  \n\t}\n\n</script>\n";
    echo $html;
}
Example #4
0
function tabs()
{
    $t = time();
    $page = CurrentPageName();
    $users = new usersMenus();
    $tpl = new templates();
    $array["popup"] = '{panel}';
    $array["members"] = '{members}';
    $q = new mysql_squid_builder();
    $table = "RTTD_" . date("Ymd", $q->HIER_TIME());
    if ($q->TABLE_EXISTS($table)) {
        $array["yesterday"] = '{yesterday}';
    }
    $page = CurrentPageName();
    while (list($num, $ligne) = each($array)) {
        if ($num == "members") {
            $html[] = "<li style='font-size:18px'><a href=\"squid.rrt-members.php\"><span>{$ligne}</span></a></li>\n";
            continue;
        }
        if ($num == "yesterday") {
            $html[] = "<li style='font-size:18px'><a href=\"squid.rrt-yesterday.php\"><span>{$ligne}</span></a></li>\n";
            continue;
        }
        $html[] = "<li style='font-size:18px'><a href=\"{$page}?{$num}=yes\"><span>{$ligne}</span></a></li>\n";
    }
    echo build_artica_tabs($html, "squid_rrtt_tabs", 1100) . "\n\t\t\t<script>LeftDesign('statistics-white-256-opac20.png');</script>";
}
function page(){
	$q=new mysql_squid_builder();
	$timekey=date('Ymd');
	$timekeyMonth=date("Ym");
	$time=time();
	$page=CurrentPageName();
	$tpl=new templates();
	$q=new mysql_squid_builder();
	$table="squidmemory_$timekey";
	$TableMonth="squidmemoryM_$timekeyMonth";
	if($q->TABLE_EXISTS($table)){
		if($q->COUNT_ROWS($table)>1){
		$f1[]="<div style='width:1150px;height:340px' id='$time-squid-02'></div>";
		$f2[]="
		function XSquid02$time(){
			AnimateDiv('$time-squid-02');
			Loadjs('$page?graph-hour=yes&container=$time-squid-02&time=$time',true);
		}
		setTimeout(\"XSquid02$time()\",500);";
		
		$f1[]="<div style='width:1150px;height:340px' id='$time-squid-03'></div>";
		$f2[]="
		function XSquid03$time(){
			AnimateDiv('$time-squid-03');
			Loadjs('$page?graph-hour-day=yes&container=$time-squid-03&time=$time',true);
		}
		setTimeout(\"XSquid03$time()\",500);";	
		}	
	}
	
	if($q->TABLE_EXISTS($TableMonth)){
		if($q->COUNT_ROWS($table)>1){
			$f1[]="<div style='width:1150px;height:340px' id='$time-squid-04'></div>";
			$f2[]="
			function XSquid04$time(){
			AnimateDiv('$time-squid-04');
			Loadjs('$page?graph-hour-month=yes&container=$time-squid-04&time=$time',true);
			}
			setTimeout(\"XSquid04$time()\",500);";
			
		}
	}
	
	
	$tpl=new templates();
	echo "<div style='font-size:26px'>".$tpl->_ENGINE_parse_body("{proxy_memory_service_status}")."</div><p>&nbsp;</p>".@implode($f1, "\n")."<script>\n".@implode($f2, "\n")."</script>";
}
Example #6
0
function table()
{
    $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>";
        }
    }
    $page = CurrentPageName();
    $tpl = new templates();
    $date = $tpl->_ENGINE_parse_body("{zDate}");
    $description = $tpl->_ENGINE_parse_body("{description}");
    $context = $tpl->_ENGINE_parse_body("{context}");
    $events = $tpl->_ENGINE_parse_body("{events}");
    $destination = $tpl->_ENGINE_parse_body("{destination}");
    $website = $tpl->_ENGINE_parse_body("{website}");
    $settings = $tpl->javascript_parse_text("{watchdog_squid_settings}");
    $empty_events_text_ask = $tpl->javascript_parse_text("{empty_events_text_ask}");
    $apply_parameters = $tpl->javascript_parse_text("{rebuild_all_websites}");
    $purge_caches = $tpl->javascript_parse_text("{purge_caches}");
    $import_export = $tpl->javascript_parse_text("{import_export}");
    $new_server = $tpl->javascript_parse_text("{new_server}");
    $TB_HEIGHT = 450;
    $TB_WIDTH = 927;
    $TB2_WIDTH = 551;
    $all = $tpl->_ENGINE_parse_body("{all}");
    $t = time();
    $buttons = "\n\tbuttons : [\n\t\n\t{name: '{$apply_parameters}', bclass: 'apply', onpress :  apply_parameters{$t}},\n\t{name: '{$purge_caches}', bclass: 'Delz', onpress :  purge_caches{$t}},\n\t{name: '{$import_export}', bclass: 'Down', onpress :  import_export{$t}},\n\n\n\n\n\t],\t";
    $buttons = "\n\tbuttons : [\n\t{name: '{$new_server}', bclass: 'add', onpress : New{$t}},\n\t{name: '{$apply_parameters}', bclass: 'apply', onpress :  apply_parameters{$t}},\n\t],\t";
    $html = "\n\t<table class='NGINX_MAIN_TABLE2' style='display: none' id='NGINX_MAIN_TABLE2' style='width:99%'></table>\n\t<script>\n\tfunction BuildTable{$t}(){\n\t\$('#NGINX_MAIN_TABLE2').flexigrid({\n\turl: '{$page}?list=yes&t={$t}&ID={$_GET["ID"]}',\n\tdataType: 'json',\n\tcolModel : [\n\t{display: '&nbsp;', name : 'severity', width :70, sortable : false, align: 'center'},\n\t{display: '{$website}', name : 'servername', width :560, sortable : true, align: 'left'},\n\t{display: '&nbsp;', name : 'compile', width :60, sortable : false, align: 'center'},\n\t{display: '&nbsp;', name : 'delete', width :60, sortable : false, align: 'center'},\n\t],\n\t{$buttons}\n\n\tsearchitems : [\n\t{display: '{$website}', name : 'servername'},\n\t],\n\tsortname: 'zOrder',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 550,\n\tsingleSelect: true,\n\trpOptions: [10, 20, 30, 50,100,200,500]\n\n});\n}\n\nfunction apply_parameters{$t}(){\n\tLoadjs('nginx.destination.progress.php?cacheid={$_GET["ID"]}')\n}\nfunction purge_caches{$t}(){\nLoadjs('system.services.cmd.php?APPNAME=APP_NGINX&action=purge&cmd=%2Fetc%2Finit.d%2Fnginx&appcode=APP_NGINX');\n}\nfunction import_export{$t}(){\nLoadjs('miniadmin.proxy.reverse.import.php');\n}\n\nfunction New{$t}(){\nLoadjs('nginx.new.php?peer-id={$_GET["ID"]}');\n}\n\tBuildTable{$t}();\n\t</script>";
    echo $html;
}
Example #7
0
function items_add()
{
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS("webfilter_avwhitedoms")) {
        $q->CheckTables();
    }
    $q->QUERY_SQL("INSERT IGNORE INTO webfilter_avwhitedoms (websitename) VALUES ('{$_POST["add-item"]}')");
    if (!$q->ok) {
        echo $q->mysql_error;
    }
}
function migrate_categories_single($category)
{
    $categoryTB = str_replace('/', "_", $category);
    $categoryTB = str_replace('-', "_", $categoryTB);
    $qA = new mysql_squid_builder();
    $q = new mysql();
    $qA->CreateCategoryTable($categoryTB);
    if (!$qA->TABLE_EXISTS("category_{$categoryTB}")) {
        events_tail("Unable to create category_{$categoryTB} table");
        return false;
    }
    $sql = "SELECT * FROM dansguardian_community_categories WHERE category='{$category}'";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        writelogs("Fatal Error: {$q->mysql_error}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $mysql_num_rows = mysql_num_rows($results);
    if ($GLOBALS["VERBOSE"]) {
        echo $sql . " => {$mysql_num_rows}\n";
    }
    $prefix = "INSERT IGNORE INTO category_{$categoryTB}(`zmd5`,`zDate`,`category`,`pattern`,`enabled`,`uuid`) VALUES ";
    $c = 0;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $c++;
        $f[] = "('{$ligne["zmd5"]}','{$ligne["zDate"]}','{$ligne["category"]}','{$ligne["pattern"]}','{$ligne["enabled"]}','{$ligne["uuid"]}')";
        if (count($f) > 500) {
            events_tail("Injecting {$c} rows");
            $qA->QUERY_SQL("{$prefix}" . @implode(",", $f));
            $f = array();
            if (!$q->ok) {
                writelogs("Fatal Error: {$q->mysql_error}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
                return;
            }
        }
    }
    if (count($f) > 0) {
        $c = $c + count($f);
        events_tail("Injecting {$c} rows");
        $qA->QUERY_SQL("{$prefix}" . @implode(",", $f));
        if (!$q->ok) {
            writelogs("Fatal Error: {$q->mysql_error}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
            return;
        }
    }
    events_tail("removing category {$category} in original table");
    $sql = "DELETE FROM dansguardian_community_categories WHERE category='{$category}'";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        writelogs("Fatal Error: {$q->mysql_error}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    return true;
}
function STATS_LINE()
{
    $sock = new sockets();
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    if (!is_numeric($EnableWebProxyStatsAppliance)) {
        $EnableWebProxyStatsAppliance = 0;
    }
    if ($EnableWebProxyStatsAppliance == 0) {
        die;
    }
    $q = new mysql_squid_builder();
    $q->CheckTables();
    if (isset($_POST["MYSSLPORT"])) {
        writelogs($_SERVER["REMOTE_ADDR"] . ":{$_POST["MYSSLPORT"]} production server....", __FUNCTION__, __FILE__, __LINE__);
        $hostname = gethostbyaddr($_SERVER["REMOTE_ADDR"]);
        $time = date('Y-m-d H:i:s');
        $sql = "INSERT IGNORE INTO `squidservers`\n\t\t (ipaddr,hostname,port,created,udpated) \n\t\t VALUES ('{$_SERVER["REMOTE_ADDR"]}','{$hostname}','{$_POST["MYSSLPORT"]}','{$time}','{$time}')";
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT ipaddr FROM squidservers WHERE ipaddr='{$_SERVER["REMOTE_ADDR"]}'"));
        if ($ligne["ipaddr"] == null) {
            $q->QUERY_SQL($sql);
        } else {
            $q->QUERY_SQL("UPDATE `squidservers` SET udpated='{$time}' WHERE ipaddr='{$ligne["ipaddr"]}'");
        }
    } else {
        writelogs("MYSSLPORT is not set....", __FUNCTION__, __FILE__, __LINE__);
    }
    $array = unserialize(base64_decode($_POST["STATS_LINE"]));
    while (list($table, $contentArray) = each($array)) {
        if (preg_match("#squidhour_([0-9]+)#", $table, $re)) {
            $q->TablePrimaireHour($re[1]);
        }
        if (!$q->TABLE_EXISTS($table)) {
            writelogs("{$table} no such table, aborting ", __FUNCTION__, __FILE__, __LINE__);
            echo "<ANSWER>{$table} no such table</ANSWER>\n";
            die;
        }
        $prefixsql = "INSERT IGNORE INTO {$table} (`sitename`,`uri`,`TYPE`,`REASON`,`CLIENT`,`zDate`,`zMD5`,`remote_ip`,`country`,`QuerySize`,`uid`,`cached`,`MAC`,`hostname`) VALUES ";
        if (count($contentArray) > 0) {
            $sql = "{$prefixsql}" . @implode(",", $contentArray);
            $q->QUERY_SQL($sql);
            if (!$q->ok) {
                writelogs($q->mysql_error, __FUNCTION__, __FILE__, __LINE__);
                if (preg_match("#Column count doesn.+?t match#", $q->mysql_error)) {
                    continue;
                }
                echo "ERROR: {$q->mysql_error}\n";
                return;
            }
        }
    }
    writelogs("Received " . strlen($_POST["STATS_LINE"]) . " bytes " . count($array) . " lines from " . $_SERVER["REMOTE_ADDR"] . ":{$_POST["MYSSLPORT"]} (success)", __FUNCTION__, __FILE__, __LINE__);
    echo "<ANSWER>OK</ANSWER>\n";
}
function tabs(){
	$sock=new sockets();
	$fontsize=16;
	$tpl=new templates();
	$page=CurrentPageName();

	$md5=md5($_GET["field"].$_GET["value"]);

	$date=date("Ym");
	$table="{$date}_maccess";


	$q=new mysql_squid_builder();
	if(!$q->TABLE_EXISTS($table)){
		echo FATAL_ERROR_SHOW_128("{no_table_see_support}");
		return;
	}

	$suffix=suffix();
	$array["flow-day"]='{flow_by_day}';
	$array["members"]='{members}';
	//$array["categories"]='{categories}';
	$array["days"]='{day_tracking}';
	
	




	while (list ($num, $ligne) = each ($array) ){

		if($num=="parameters"){
			$html[]= $tpl->_ENGINE_parse_body("<li><a href=\"squid.accesslogs.params.php?parameters=yes\" style='font-size:{$fontsize}px'><span>$ligne</span></a></li>\n");
			continue;

		}

		if($num=="schedule"){
			$html[]= $tpl->_ENGINE_parse_body("<li><a href=\"squid.databases.schedules.php?TaskType=54\" style='font-size:{$fontsize}px'><span>$ligne</span></a></li>\n");
			continue;

		}

		$html[]= $tpl->_ENGINE_parse_body("<li><a href=\"$page?$num=yes$suffix\" style='font-size:{$fontsize}px'><span>$ligne</span></a></li>\n");
	}

	echo build_artica_tabs($html, "squid_users_stats_$md5",990)."";

}
Example #11
0
function tabs(){
	$tpl=new templates();
	$q=new mysql_squid_builder();
	$sock=new sockets();
	
	$status=trim($sock->getFrameWork("squid.php?videocache-streamsquidcache=yes"));
	
	if($status<>"TRUE"){
		echo $tpl->_ENGINE_parse_body(FATAL_WARNING_SHOW_128("{module_in_squid_not_installed}<hr>{EnableStreamCache_text}"));
		return;
	}
	
	$page=CurrentPageName();
	$array["status"]='{status}';
	$array["parameters"]='{parameters}';
	$array["events"]='{events}';
	$array["events-retriver"]='{retreiver_events}';
	if($q->TABLE_EXISTS("videocacheA")){
		$array["stats"]='{statistics}';
	}
	
	$array["websites"]="{supported_websites}";
	
	$t=time();
	while (list ($num, $ligne) = each ($array) ){
		if($num=="events"){
			$html[]= $tpl->_ENGINE_parse_body("<li><a href=\"squid.videocache.events.php\" style='font-size:18px'><span>$ligne</span></a></li>\n");
			continue;
		}
		if($num=="events-retriver"){
			$html[]= $tpl->_ENGINE_parse_body("<li><a href=\"squid.videocache.events-retreiver.php\" style='font-size:18px'><span>$ligne</span></a></li>\n");
			continue;
		}
		
		if($num=="master"){
			$html[]= $tpl->_ENGINE_parse_body("<li><a href=\"squid.master-proxy.php?byQuicklinks=yes\" style='font-size:18px'><span>$ligne</span></a></li>\n");
			continue;
		}
	
		$html[]= $tpl->_ENGINE_parse_body("<li><a href=\"$page?$num=yes\" style='font-size:18px'><span>$ligne</span></a></li>\n");
		}
	
	echo build_artica_tabs($html, "main_squid_videocache_tabs",1200)."<script>LeftDesign('videocache-256-white-opac20.png');</script>";
}
Example #12
0
function popup()
{
    $q = new mysql_squid_builder();
    $page = CurrentPageName();
    if (!$q->TABLE_EXISTS("webfilter_dnsbl")) {
        $q->CheckTables();
    }
    $tpl = new templates();
    $add = $tpl->_ENGINE_parse_body("{add}");
    $dsnbl_service = $tpl->_ENGINE_parse_body("{dnsbl_service}");
    $service_name = $tpl->_ENGINE_parse_body("{description}");
    $CICAP_DNSBL = $tpl->_ENGINE_parse_body("{CICAP_DNSBL}");
    $DNSBL_WHY = $tpl->_ENGINE_parse_body("{DNSBL_WHY}");
    $p = Paragraphe_switch_img("{enable_dnsbl_service}", $DNSBL_WHY);
    $buttons = "buttons : [\n\t\t{name: '{$add}', bclass: 'add', onpress : AddDnsblService}\n\t\t\n\t\t],";
    $buttons = null;
    $html = "<div class=text-info style='font-size:13px'>{$DNSBL_WHY}</div>\n\t<table class='dnsbl-table' style='display: none' id='dnsbl-table' style='width:99%'></table>\n<script>\n\t\$(document).ready(function(){\n\$('#dnsbl-table').flexigrid({\n\turl: '{$page}?list=yes',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$dsnbl_service}', name : 'dnsbl', width :233, sortable : true, align: 'left'},\n\t\t{display: '{$service_name}', name : 'name', width : 541, sortable : true, align: 'left'},\n\t\t{display: '&nbsp;', name : 'none3', width : 24, sortable : false, align: 'left'},\n\t],\n{$buttons}\t\n\tsearchitems : [\n\t\t{display: '{$extension}', name : 'ext'},\n\t\t{display: '{$description}', name : 'description'},\n\t\t],\n\tsortname: 'name',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '{$CICAP_DNSBL}',\n\tuseRp: true,\n\trp: 15,\n\tshowTableToggleBtn: false,\n\twidth: 854,\n\theight: 350,\n\tsingleSelect: true\n\t\n\t});   \n});\n\nfunction AddDnsblService(){\n\n}\n\n\n\n\n\n\nvar x_EnableDisableCiCapDNSBL= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){alert(res);}\n\t\t\n\t}\t\t\t\n\t\n\t\n\tfunction EnableDisableCiCapDNSBL(md5,serv){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('EnableDNSBL',serv);\n\t\tif(document.getElementById(md5).checked){\n\t\tXHR.appendData('enabled',1);}else{XHR.appendData('enabled',0);}\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_EnableDisableCiCapDNSBL);\t\n\t}\n\n</script>";
    echo $html;
}
function table()
{
    $error = null;
    $page = CurrentPageName();
    $tpl = new templates();
    $users = new usersMenus();
    $sock = new sockets();
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS("artica_caches")) {
        create_table();
    }
    $hits = $tpl->javascript_parse_text("{hits}");
    $rulename = $tpl->javascript_parse_text("{rulename}");
    $new_rule = $tpl->javascript_parse_text("{new_rule}");
    $lang = $tpl->javascript_parse_text("{language}");
    $rule = $tpl->javascript_parse_text("{rule}");
    $title = $tpl->javascript_parse_text("{subject}");
    $new_template = $tpl->javascript_parse_text("{new_template}");
    $apply = $tpl->javascript_parse_text("{apply}");
    $online_help = $tpl->javascript_parse_text("{online_help}");
    $date = $tpl->javascript_parse_text("{zDate}");
    $replace = $tpl->_ENGINE_parse_body("{replace}");
    $sitename = $tpl->javascript_parse_text("{sitename}");
    $size = $tpl->javascript_parse_text("{size}");
    $sitename_explain = $tpl->javascript_parse_text("{artica_cache_rule_explain_sitename}");
    $t = time();
    $backToDefault = $tpl->javascript_parse_text("{backToDefault}");
    $ERROR_SQUID_REBUILD_TPLS = $tpl->javascript_parse_text("{ERROR_SQUID_REBUILD_TPLS}");
    $q = new mysql_squid_builder();
    $q = new mysql_squid_builder();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT rulename,foldersize FROM artica_caches WHERE ID='{$_GET["ID"]}'", "artica_backup"));
    $enforce_rules = $tpl->javascript_parse_text("{enforce_rules}:{$ligne["rulename"]} (" . FormatBytes($ligne["foldersize"] / 1024) . ")");
    //if(!$users->CORP_LICENSE){
    //$error="<p class=text-error>".$tpl->_ENGINE_parse_body("{MOD_TEMPLATE_ERROR_LICENSE}")."</p>";
    //}
    $buttons = "\n\tbuttons : [\n\t{name: '{$new_rule}', bclass: 'add', onpress : NewRule{$t}},\n\t{name: '{$apply}', bclass: 'Reconf', onpress : Apply{$t}},\n\n\t],";
    $buttons = null;
    $html = "\n\t{$error}\n\t<table class='squid_enforce_foldersize' style='display: none' id='squid_enforce_foldersize' style='width:99%'></table>\n\n\t<script>\n\tvar mem{$t}='';\n\t\$(document).ready(function(){\n\t\$('#squid_enforce_foldersize').flexigrid({\n\turl: '{$page}?liste-rules=yes&ID={$_GET["ID"]}',\n\tdataType: 'json',\n\tcolModel : [\n\t{display: '{$sitename}', name : 'sitename', width : 629, sortable : false, align: 'left'},\n\t{display: '{$size}', name : 'foldersize', width : 184, sortable : true, align: 'right'},\n\n\t],\n\t{$buttons}\n\tsearchitems : [\n\t{display: '{$sitename}', name : 'sitename'},\n\t],\n\tsortname: 'sizebytes',\n\tsortorder: 'desc',\n\tusepager: true,\n\ttitle: '<span style=font-size:18px>{$enforce_rules}</span>',\n\tuseRp: true,\n\trp: 250,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 400,\n\tsingleSelect: true\n\n});\n});\n\n\n\nvar xNewRule{$t}= function (obj) {\nvar tempvalue=obj.responseText;\nif(tempvalue.length>3){alert(tempvalue);}\n\$('#squid_enforce_foldersize').flexReload();\n}\n\nfunction NewRule{$t}(){\nvar rule=prompt('{$rulename} ?');\nif(!rule){return;}\nvar sitename=prompt('{$sitename_explain}');\nif(!sitename){return;}\nvar XHR = new XHRConnection();\nXHR.appendData('new-rule',encodeURIComponent(rule));\nXHR.appendData('sitename',encodeURIComponent(sitename));\nXHR.sendAndLoad('{$page}', 'POST',xNewRule{$t});\n}\n\nfunction Apply{$t}(){\nLoadjs('squid.artica-rules.progress.php');\n}\n\n</script>\n";
    echo $html;
}
function week_uris_blocked_verify()
{
    $q = new mysql_squid_builder();
    $sql = "SELECT tablename,DATE_FORMAT( zDate, '%Y%m%d' ) AS tablesource, DAYOFWEEK(zDate) \n\t\t\tas DayNumber,WEEK( zDate ) AS tweek, YEAR( zDate ) \n\t\t\tAS tyear FROM tables_day  WHERE zDate < DATE_SUB( NOW( ) , INTERVAL 1 DAY ) ORDER BY zDate";
    $results = $GLOBALS["Q"]->QUERY_SQL($sql);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $tablename = $ligne["tablename"];
        $week_table = "{$ligne["tyear"]}{$ligne["tweek"]}_blocked_week";
        if ($GLOBALS["VERBOSE"]) {
            echo "\n*********** WEEK {$week_table} -> {$ligne["tweek"]} of year {$ligne["tyear"]} ***********\n";
        }
        if (!$q->TABLE_EXISTS($week_table)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Restart {$tablename}\n";
            }
            $q->QUERY_SQL("UPDATE tables_day SET weekbdone=0 WHERE `tablename`='{$tablename}'");
        }
        $Rows = $q->COUNT_ROWS($week_table);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$week_table} =  {$Rows} rows\n";
        }
    }
}
function tabs()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $q = new mysql_squid_builder();
    $familysite = $q->GetFamilySites($_GET["sitename"]);
    $_GET["xtime"] = strtotime("{$_GET["day"]} 00:00:00");
    if (is_numeric($_GET["xtime"])) {
        $dateT = " " . date("{l} {F} d", $_GET["xtime"]);
        if ($tpl->language == "fr") {
            $dateT = date("{l} d {F} ", $_GET["xtime"]);
        }
    }
    $tablesource = "dansguardian_events_" . date("Ymd", $_GET["xtime"]);
    $array["popup"] = "{status} {$dateT}";
    if ($q->TABLE_EXISTS($tablesource)) {
        $array["uris"] = "{urls}";
    }
    while (list($num, $ligne) = each($array)) {
        $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?{$num}=yes&field={$_GET["field"]}&value=" . urlencode($_GET["value"]) . "&familysite={$_GET["familysite"]}&day={$_GET["day"]}\"><span style='font-size:14px'>{$ligne}</span></a></li>\n");
    }
    echo "\n\t<div id=main_config_zoomwebsiteAndUser>\n\t\t<ul>" . implode("\n", $html) . "</ul>\n\t</div>\n\t\t<script>\n\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\t\$('#main_config_zoomwebsiteAndUser').tabs();\n\t\t\n\t\t\n\t\t\t});\n\t\t</script>";
}
Example #16
0
function popup_dansguardian_main()
{
    $table = true;
    $mysql = new mysql();
    $mysqlSquid = new mysql_squid_builder();
    $users = new usersMenus();
    if (!$mysqlSquid->TABLE_EXISTS("dansguardian_categories", "artica_backup")) {
        $table = false;
    }
    if (!$mysql->TABLE_EXISTS("dansguardian_files", "artica_backup")) {
        $table = false;
    }
    if (!$mysql->TABLE_EXISTS("dansguardian_rules", "artica_backup")) {
        $table = false;
    }
    if (!$mysql->TABLE_EXISTS("dansguardian_weightedphraselist", "artica_backup")) {
        $table = false;
    }
    if (!$mysql->TABLE_EXISTS("dansguardian_ipgroups", "artica_backup")) {
        $table = false;
    }
    if (!$mysql->TABLE_EXISTS("dansguardian_whitelists", "artica_events")) {
        $table = false;
    }
    if (!$table) {
        popup_mysql_error();
        exit;
    }
    $page = CurrentPageName();
    $performances = Paragraphe("folder-tasks2-64.png", "{performances}", '{performances_text}', "javascript:YahooWin(500,'{$page}?main=performances');");
    $content_scanner = Paragraphe("64-webscanner.png", "{content_scanner}", '{content_scanner_text}', "javascript:YahooWin(651,'{$page}?main=scanner');");
    $download = Paragraphe("icon-download.gif", "{download}", '{download_text}', "javascript:YahooWin(600,'{$page}?main=download');");
    $rules = Paragraphe("folder-rules2-64.png", "{rules}", '{rules_text}', "javascript:YahooWin(600,'{$page}?popup-rules=yes');");
    $apply = applysettings_dansguardian();
    $squidguardweb = Paragraphe("parameters2-64-grey.png", "{banned_page_webservice}", "{banned_page_webservice_text}", null);
    $sock = new sockets();
    $logsize = trim($sock->getfile('DansGuardianLogSize'));
    $dansguardian_enabled = $sock->GET_INFO("DansGuardianEnabled");
    if ($dansguardian_enabled == null) {
        $dansguardian_enabled = 0;
        $sock->SET_INFO("DansGuardianEnabled", 0);
    }
    $squidGuardEnabled = $sock->GET_INFO("squidGuardEnabled");
    if ($squidGuardEnabled == null) {
        $squidGuardEnabled = 0;
        $sock->SET_INFO("squidGuardEnabled", 0);
    }
    $cicap_enabled = $sock->GET_INFO('CicapEnabled');
    $EnableUfdbGuard = $sock->GET_INFO("EnableUfdbGuard");
    $EnableSquidClamav = $sock->GET_INFO("EnableSquidClamav");
    $others = "\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td valign='top' class=caption nowrap>{logs_size}:</td>\n\t\t\t<td style='width:99%' valign='top'><strong>{$logsize}&nbsp;Ko</strong></td>\n\t\t\t<td>" . imgtootltip('22-recycle.png', '{rotate_logs}', "DansGuardianRotateLogs();") . "</td>\n\t\t</tr>\n\t\t</table>\n\t\t\t\n\t\t\n\t\n\t\n\t";
    if ($_GET["switch"] == "from-squid") {
        $OnMouseOver = "OnMouseOver=\";this.style.cursor='pointer'\"";
        $OnMouseOut = "OnMouseOut=\"this.style.cursor='default'\"";
        $from_squid = "<div style='padding:3px;font-size:13px'>{web_proxy}&nbsp;&raquo;<span {$OnMouseOver} {$OnMouseOut} OnClick=\"javascript:Loadjs('squid.newbee.php?yes=yes&#bullet#')\" >{filters}</span></div>";
    }
    $simple_intro = "{danseguardian_simple_intro}";
    if ($squidGuardEnabled == 1) {
        $simple_intro = "{squidguard_simple_intro}";
        $tool = "<div style='text-align:right'>" . texttooltip("&laquo;&nbsp;{squidguard_testrules}&nbsp;&raquo;", "{squidguard_testrules}", "Loadjs('squidguard.tests.php')", null, 0, "font-size:14px") . "</div>";
    }
    if ($EnableUfdbGuard == 1) {
        $simple_intro = "{ufdbguard_simple_intro}";
        $tool = null;
        $others = null;
    }
    $html = "\n\t <table style='width:100%;'>\n\t \t<tr>\n\t\t \t\t<td valign='top'>\n\t\t \t\t\t<img src='img/bg_dansguardian.png'>\n\t\t \t\t\t\n\t\t \t\t\t{$others}\n\t\t  \t\t</td>\n\t\t  \t\t<td valign='top'>\n\t\t  \t\t\t<p  style='font-size:13px'>{$from_squid}{$simple_intro}</p>\n\t\t  \t\t\t{$tool}\n\t\t  \t\t</td>\n\t\t  \t</tr>\n\t\t  </table>";
    $blackcomputer = Paragraphe("64-black-computer.png", "{black_ip_group}", '{black_ip_group_text}', "javascript:Loadjs('dansguardian.bannediplist.php');");
    $whitecomputer = Paragraphe("64-white-computer.png", "{white_ip_group}", '{white_ip_group_text}', "javascript:Loadjs('dansguardian.exceptioniplist.php');");
    $template = Paragraphe("banned-template-64.png", "{template_label}", '{template_explain}', "javascript:s_PopUp('dansguardian.template.php',800,800)");
    $denywebistes = Paragraphe('folder-64-denywebistes.png', '{deny_websites}', '{deny_websites_text}', "javascript:Loadjs('squid.popups.php?script=url_regex')");
    $whitelisting = Paragraphe('domain-whitelist-64-grey.png', '{www_whitelisting}', '{www_whitelisting_text}');
    // -> $cicap_enabled
    $cicap_dnsbl = Paragraphe("64-cop-acls-dnsbl.png", "{CICAP_DNSBL}", "{CICAP_DNSBL_TEXT}", "javascript:Loadjs('c-icap.dnsbl.php')");
    if ($cicap_enabled == 0) {
        $cicap_dnsbl = null;
    }
    if (!$users->C_ICAP_DNSBL) {
        $cicap_dnsbl = null;
    }
    if ($dansguardian_enabled == 0) {
        $download = null;
        $performances = null;
        $content_scanner = null;
        $apply = null;
    }
    writelogs("squidGuardEnabled={$squidGuardEnabled} - EnableUfdbGuard={$EnableUfdbGuard}", __FUNCTION__, __FILE__, __LINE__);
    if ($squidGuardEnabled == 1) {
        $squidguard_status = Paragraphe('squidguard-status-64.png', '{squidguard_status}', '{squidguard_status_text}', "javascript:Loadjs('squidguard.status.php')");
        $squidguardweb = Paragraphe("parameters2-64.png", "{banned_page_webservice}", "{banned_page_webservice_text}", "javascript:Loadjs('squidguardweb.php')");
        $whitelisting = Paragraphe('domain-whitelist-64.png', '{www_whitelisting}', '{www_whitelisting_text}', "javascript:Loadjs('squid.filters.whitelisting.php')");
        $whitelisting = Paragraphe('domain-whitelist-64.png', '{www_whitelisting}', '{www_whitelisting_text}', "javascript:echo('under construction')");
    }
    if ($EnableUfdbGuard == 1) {
        $squidguardweb = Paragraphe("parameters2-64.png", "{banned_page_webservice}", "{banned_page_webservice_text}", "javascript:Loadjs('squidguardweb.php')");
        $whitelisting = Paragraphe('domain-whitelist-64.png', '{www_whitelisting}', '{www_whitelisting_text}', "javascript:Loadjs('squid.filters.whitelisting.php')");
        $whitelisting = Paragraphe('domain-whitelist-64.png', '{www_whitelisting}', '{www_whitelisting_text}', "javascript:echo('under construction')");
    }
    if ($EnableSquidClamav == 1) {
        $squidguardweb = Paragraphe("parameters2-64.png", "{banned_page_webservice}", "{banned_page_webservice_text}", "javascript:Loadjs('squidguardweb.php')");
    }
    if ($users->APP_UFDBGUARD_INSTALLED) {
        $ufdbguard_settings = Paragraphe("filter-sieve-64.png", "{APP_UFDBGUARD}", "{APP_UFDBGUARD_PARAMETERS}", "javascript:Loadjs('ufdbguard.php')");
    }
    $tr[] = $apply;
    $tr[] = $whitelisting;
    $tr[] = $squidguard_status;
    $tr[] = $denywebistes;
    $tr[] = $cicap_dnsbl;
    $tr[] = $blackcomputer;
    $tr[] = $whitecomputer;
    $tr[] = $download;
    $tr[] = $ufdbguard_settings;
    $tr[] = $performances;
    $tr[] = $content_scanner;
    $tr[] = $template;
    $tr[] = $squidguardweb;
    $tables[] = "<table style='width:100%'><tr>";
    $t = 0;
    while (list($key, $line) = each($tr)) {
        $line = trim($line);
        if ($line == null) {
            continue;
        }
        $t = $t + 1;
        $tables[] = "<td valign='top'>{$line}</td>";
        if ($t == 3) {
            $t = 0;
            $tables[] = "</tr><tr>";
        }
    }
    if ($t < 3) {
        for ($i = 0; $i <= $t; $i++) {
            $tables[] = "<td valign='top'>&nbsp;</td>";
        }
    }
    $tables[] = "</table>";
    $html = $html . implode("\n", $tables);
    $tpl = new templates();
    $html = $tpl->_ENGINE_parse_body($html, "squid.newbee.php,squid.index.php");
    echo $html;
}
function listext()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $t = $_GET["t"];
    $search = '%';
    $table = "webfilter_bannedextsdoms";
    $page = 1;
    $ORDER = "ORDER BY ext ASC";
    $FORCE_FILTER = " AND ruleid={$_GET["RULEID"]}";
    $total = 0;
    if (!$q->TABLE_EXISTS($table)) {
        $q->CheckTables();
    }
    if ($q->COUNT_ROWS($table, "artica_backup") == 0) {
        $data['page'] = $page;
        $data['total'] = $total;
        $data['rows'] = array();
        echo json_encode($data);
        return;
    }
    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 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $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}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    $divstart = "<span style='font-size:14px;font-weight:bold'>";
    $divstop = "</div>";
    $noneTXT = $tpl->_ENGINE_parse_body("{none}");
    while ($ligne = mysql_fetch_assoc($results)) {
        $img = "img/ext/def_small.gif";
        if (file_exists("img/ext/{$ligne['ext']}_small.gif")) {
            $img = "img/ext/{$ligne['ext']}_small.gif";
        }
        $disable = Field_checkbox("disable_{$ligne["zmd5"]}", 1, $ligne["enabled"], "bannedextensionlist_enable{$t}('{$ligne["zmd5"]}')");
        $delete = imgtootltip("delete-24.png", "{delete} {$ligne['ext']}", "bannedextensionlist_delete{$t}('{$ligne["zmd5"]}')");
        $data['rows'][] = array('id' => $ligne['zmd5'], 'cell' => array("<strong style='font-family:Courier New;font-size:14px'>http://*domain.<span style='color:#A40000'>{$ligne['ext']}</span>/...</strong>", "<span style='font-size:13px'>{$ligne['description']}</span>", "<div style='margin-top:5px'>{$disable}</div>", $delete));
    }
    // http://*domain.<span style='color:#A40000'>
    echo json_encode($data);
}
function members_mac()
{
    $GLOBALS["Q"] = new mysql_squid_builder();
    if ($GLOBALS["VERBOSE"]) {
        "echo Loading...\n";
    }
    $unix = new unix();
    if ($GLOBALS["VERBOSE"]) {
        "echo Loading done...\n";
    }
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pid = @file_get_contents($pidfile);
    if (!$GLOBALS["FORCE"]) {
        if ($pid < 100) {
            $pid = null;
        }
        $unix = new unix();
        if ($unix->process_exists($pid, basename(__FILE__))) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid}\n";
            }
            return;
        }
        $timeexec = $unix->file_time_min($timefile);
        if ($timeexec < 540) {
            return;
        }
        $mypid = getmypid();
        @file_put_contents($pidfile, $mypid);
    }
    if (isset($GLOBALS["members_mac_executed"])) {
        return;
    }
    $GLOBALS["members_mac_executed"] = true;
    $sock = new sockets();
    $EnableMacAddressFilter = $sock->GET_INFO("EnableMacAddressFilter");
    if (!is_numeric($EnableMacAddressFilter)) {
        $EnableMacAddressFilter = 1;
    }
    if ($EnableMacAddressFilter == 0) {
        return;
    }
    $q = new mysql_squid_builder();
    $sql = "SELECT tablename,zDate FROM `tables_day` WHERE members_mac=0 AND zDate<DATE_SUB(NOW(),INTERVAL 1 DAY)";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        if ($GLOBALS["VERBOSE"]) {
            echo "############# ERROR #########\n{$q->mysql_error}\\Line:" . __LINE__ . "\n#############\n";
        }
    }
    if (mysql_num_rows($results) == 0) {
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $date = $ligne["zDate"];
        $time = strtotime($date . " 00:00:00");
        $tablename = $ligne["tablename"];
        if ($q->TABLE_EXISTS($tablename)) {
            if (members_mac_from_dansguardian_events($tablename, $time)) {
                $q->QUERY_SQL("UPDATE tables_day SET members_mac=1 WHERE tablename='{$tablename}'");
                continue;
            }
        }
        $hourtable = date("Ymd", $time) . "_hour";
        if ($q->TABLE_EXISTS($hourtable)) {
            if (members_mac_from_hourtable($hourtable, $time)) {
                $q->QUERY_SQL("UPDATE tables_day SET members_mac=1 WHERE tablename='{$tablename}'");
                continue;
            }
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "############# ERROR #########\nNO TABLE FOR {$date}\n#############\n";
        }
    }
}
function quota_destination_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();
    $ID = $_GET["ID"];
    $acl = new squid_acls();
    $t0 = $_GET["t"];
    $search = '%';
    $table = "(SELECT webfilters_quotas_grp.gpid,webfilters_quotas_grp.zmd5, webfilters_quotas_grp.ID as LINKID, webfilters_sqgroups.* FROM webfilters_quotas_grp, webfilters_sqgroups WHERE webfilters_quotas_grp.gpid=webfilters_sqgroups.ID AND webfilters_quotas_grp.ruleid={$ID}) as t";
    $page = 1;
    if (!$q->TABLE_EXISTS("webfilters_quotas_grp")) {
        $q->CheckTables(null, true);
    }
    if ($q->COUNT_ROWS("webfilters_quotas_grp") == 0) {
        json_error_show("No datas");
    }
    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;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        json_error_show($q->mysql_error . "\n{$sql}");
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (mysql_num_rows($results) == 0) {
        json_error_show("No item");
    }
    $rules = $tpl->_ENGINE_parse_body("{rules}");
    $acl = new squid_acls_groups();
    while ($ligne = mysql_fetch_assoc($results)) {
        $val = 0;
        $ID = $ligne["ID"];
        $md5 = $ligne["zmd5"];
        $arrayF = $acl->FlexArray($ligne['gpid']);
        $delete = imgsimple("delete-24.png", null, "DeleteObjectLinks{$t0}('{$md5}')");
        $data['rows'][] = array('id' => "{$md5}", 'cell' => array($arrayF["ROW"], "<span style='font-size:14px;font-weight:bold'>{$arrayF["ITEMS"]}</span>", $delete));
    }
    echo json_encode($data);
}
function items()
{
    include_once dirname(__FILE__) . "/ressources/class.squid.inc";
    $tpl = new templates();
    $squid = new squidbee();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $t = $_GET["t"];
    $search = '%';
    $table = "transparent_networks";
    $page = 1;
    $FORCE_FILTER = null;
    $total = 0;
    $SSL = $squid->SSL_BUMP;
    if (!$q->TABLE_EXISTS("transparent_networks")) {
        $q->CheckTables(null, 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));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS($table);
    }
    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);
    $no_rule = $tpl->_ENGINE_parse_body("{no_item}");
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $fontsize = "18";
    $color = "black";
    $check32 = "<img src='img/check-32.png'>";
    $arrow_right = "<img src='img/arrow-right-32.png'>";
    $AllSystems = $tpl->_ENGINE_parse_body("{AllSystems}");
    $AllDestinations = $tpl->_ENGINE_parse_body("{all_destinations}");
    $local_proxy = $tpl->_ENGINE_parse_body("{local_proxy}");
    $proxy = $local_proxy;
    $port = $tpl->_ENGINE_parse_body("{port}");
    if (!$q->ok) {
        json_error_show($q->mysql_error . "<br>{$sql}", 1);
    }
    if (mysql_num_rows($results) == 0) {
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>0</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>HTTP</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>* - {$AllSystems}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$arrow_right}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>* - {$AllDestinations} {$port} 80<div style='font-size:12px;text-align:right'>{$proxy}</div></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$check32}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$check32}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>&nbsp;</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>&nbsp;</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>&nbsp;</span>"));
        if ($SSL == 0) {
            $color = "#8a8a8a";
            $check32 = "<img src='img/check-32-grey.png'>";
            $arrow_right = "<img src='img/arrow-right-32-grey.png'>";
        }
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>0</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>HTTPS</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>* - {$AllSystems}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$arrow_right}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>* - {$AllDestinations} {$port} 443<div style='font-size:12px;text-align:right'>{$proxy}</div></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$check32}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$check32}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>&nbsp;</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>&nbsp;</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>&nbsp;</span>"));
        $data['total'] = 1;
        echo json_encode($data);
        return;
    }
    $all = $tpl->_ENGINE_parse_body("{all}");
    $fontsize = "18";
    $color = "black";
    $check32 = "<img src='img/check-32.png'>";
    $local_proxy = $tpl->_ENGINE_parse_body("{local_proxy}");
    $redirect_to = $tpl->_ENGINE_parse_body("{redirect_to}");
    $not = $tpl->_ENGINE_parse_body("{not} ");
    $AVAILABLE_MACROS["google"] = true;
    $AVAILABLE_MACROS["teamviewer"] = true;
    $AVAILABLE_MACROS["office365"] = true;
    $AVAILABLE_MACROS["skype"] = true;
    $AVAILABLE_MACROS["dropbox"] = true;
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $check32 = "<img src='img/check-32.png'>";
        $check32T = "<img src='img/cloud-filtered-42.png'>";
        $arrow_right = "<img src='img/arrow-right-32.png'>";
        $proxy = $local_proxy;
        $ligne["remote_proxy"] = trim($ligne["remote_proxy"]);
        if (!preg_match("#^(.+?):(.+)#", $ligne["remote_proxy"])) {
            $ligne["remote_proxy"] = null;
        }
        $eth = $ligne["eth"];
        if (is_numeric($eth)) {
            $eth = null;
        }
        if ($eth != null) {
            $eth = "{$eth}:";
        }
        $isnot = null;
        if ($ligne["destination_port"] == 443) {
            $ligne["ssl"] = 1;
        }
        if ($ligne["destination_port"] == 80) {
            $ligne["ssl"] = 0;
        }
        if ($ligne["destination_port"] == 0) {
            $ligne["destination_port"] = 80;
            if ($ligne["ssl"] == 1) {
                $ligne["destination_port"] == 443;
            }
        }
        $proto = "HTTP";
        $destination_port = "{$port} {$ligne["destination_port"]}";
        if ($ligne["ssl"] == 1) {
            $proto = "HTTPS";
            $destination_port = "{$port} {$ligne["destination_port"]}";
            if ($SSL == 0) {
                $ligne["enabled"] = 0;
            }
        }
        if ($ligne["enabled"] == 0) {
            $color = "#8a8a8a";
            $check32 = "<img src='img/check-32-grey.png'>";
            $check32T = "<img src='img/cloud-filtered-42-grey.png'>";
            if ($ligne["block"] == 1) {
                $check32T = "<img src='img/webpage-settings-32-grey.png'>";
            }
            $arrow_right = "<img src='img/arrow-right-32-grey.png'>";
        }
        if ($ligne["transparent"] == 0) {
            $check32T = "<img src='img/cloud-goto-42.png'>";
            $proxy = null;
        }
        $delete = imgsimple("delete-32.png", null, "Loadjs('{$MyPage}?delete-js={$ligne["ID"]}&t={$_GET["t"]}',true)");
        $pattern = $ligne["pattern"];
        if ($ligne["remote_proxy"] == "*") {
            $ligne["remote_proxy"] = null;
        }
        if ($ligne["remote_proxy"] != null) {
            $proxy = "{$redirect_to} {$ligne["remote_proxy"]}";
        }
        $link = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?item-js=yes&ID={$ligne["ID"]}&t={$_GET["t"]}',true)\"\n\t\tstyle='font-size:{$fontsize}px;font-weight:normal;color:{$color};text-decoration:underline'>";
        if ($ligne["destination_port"] > 0) {
            $destination_port = "{$port} {$ligne["destination_port"]}";
        }
        if ($ligne["destination"] == "*") {
            $ligne["destination"] = null;
        }
        $destination_clean = trim(strtolower($ligne["destination"]));
        if (isset($AVAILABLE_MACROS[$destination_clean])) {
            $ligne["destination"] = $tpl->javascript_parse_text("{macro}: {$destination_clean} {websites}");
        }
        if ($ligne["destination"] == null) {
            $ligne["destination"] = "{$AllDestinations} {$destination_port}";
            $proxy = null;
        }
        if ($ligne["isnot"] == 1) {
            $isnot = $not;
        }
        $up = imgsimple("arrow-up-32.png", null, "Loadjs('{$MyPage}?move-item-js=yes&ID={$ligne["ID"]}&dir=0&t={$_GET["t"]}')");
        $down = imgsimple("arrow-down-32.png", null, "Loadjs('{$MyPage}?move-item-js=yes&ID={$ligne["ID"]}&dir=1&t={$_GET["t"]}')");
        $groups = groups($ligne["ID"]);
        if ($groups[0] != null) {
            $ligne["pattern"] = $groups[0];
        }
        if ($groups[1] != null) {
            $ligne["destination"] = $groups[1];
        }
        if ($ligne["block"] == 1) {
            $check32T = "<img src='img/cloud-deny-42.png'>";
            if ($ligne["enabled"] == 0) {
                $check32T = "<img src='img/cloud-deny-42-grey.png'>";
            }
        }
        if ($ligne["pattern"] == null) {
            $ligne["pattern"] = "* - {$AllSystems}";
        }
        if ($ligne["pattern"] == "*") {
            $ligne["pattern"] = "* - {$AllSystems}";
        }
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$ligne["zOrder"]}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$proto}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$isnot}{$link}{$eth}{$ligne["pattern"]}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$arrow_right}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$ligne["destination"]}</a><div style='font-size:12px;text-align:right'>{$proxy}</div></span></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$check32T}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$check32}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$up}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$down}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
function table_sites_search()
{
    $t = $_GET["t"];
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $users = new usersMenus();
    $sock = new sockets();
    $boot = new boostrap_form();
    $database = "squidlogs";
    $search = '%';
    $table = "generic_categories";
    $rp = 250;
    $page = 1;
    $FORCE_FILTER = null;
    $ORDER = "ORDER BY size DESC";
    if (!$q->TABLE_EXISTS($table, $database)) {
        senderror("{$table} doesn't exists...");
    }
    if ($q->COUNT_ROWS($table, $database) == 0) {
        senderror("No data");
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $search = string_to_flexquery("category-search");
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $category = mysql_escape_string2($_GET["category"]);
    $sql = "SELECT SUM( size ) AS size,SUM(hits) as hits, zDate, category FROM generic_categories GROUP BY category,zDate\n\tHAVING category='{$_GET["category"]}' ORDER BY zDate";
    $results = $q->QUERY_SQL($sql);
    $results = $q->QUERY_SQL($sql, $database);
    if (!$q->ok) {
        senderror($q->mysql_error . "<br>{$sql}");
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " ");
        $ligne["size"] = FormatBytes($ligne["size"] / 1024);
        $xtime = strtotime($ligne["zDate"] . " 00:00:00");
        $dateText = time_to_date($xtime);
        $catz = urlencode($_GET["category"]);
        $jsSitename = $boot->trswitch("Loadjs('miniadm.webstats.websites.ByDayByCategory.php?category={$catz}&xtime={$xtime}')");
        $tr[] = "\n\t\t\t\t<tr {$jsSitename}>\n\t\t\t\t\t<td><i class='icon-time'></i>&nbsp;{$dateText}</a></td>\n\t\t\t\t\t<td><i class='icon-info-sign'></i>&nbsp;{$ligne["size"]}</td>\n\t\t\t\t\t<td><i class='icon-info-sign'></i>&nbsp;{$ligne["hits"]}</td>\n\t\t\t\t</tr>";
    }
    echo $tpl->_ENGINE_parse_body("\n\t\n\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{day}</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\t") . @implode("", $tr) . "</tbody></table>";
}
function CheckTable()
{
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS('generic_categories')) {
        $sql = "CREATE TABLE `squidlogs`.`generic_categories` (\n\t\t\t `category` VARCHAR(250),\n\t\t\t `hits` BIGINT(250) NOT NULL,\n\t\t\t `size` BIGINT(250) NOT NULL,\n\t\t\t `zDate` date NOT NULL,\n\t\t\t KEY `category`(`category`),\n\t\t\t KEY `size`(`size`),\n\t\t\t KEY `hits`(`hits`),\n\t\t\t KEY `zDate`(`zDate`)\n\t\t\t )  ENGINE = MYISAM;";
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            return false;
        }
        return true;
    }
    return true;
}
Example #23
0
function checkcreds_mysql($array, $noauthent = false)
{
    $q = new mysql_squid_builder();
    $REMOTE_ADDR = $array["REMOTE_ADDR"];
    $SERVER_NAME = $array["SERVER_NAME"];
    $redirecturi = $array["redirecturi"];
    $LOGIN = $array["LOGIN"];
    $uid = $array["LOGIN"];
    $ARP = $array["ARP"];
    $MAC = $array["MAC"];
    $username = $_POST["username"];
    $HOST = $array["HOST"];
    $CACHE_AUTH = $GLOBALS["CACHE_AUTH"];
    $IPADDR = $array["IPADDR"];
    $md5key = md5(strtolower("{$username}{$IPADDR}{$MAC}{$HOST}"));
    $tpl = new templates();
    $time = time();
    $password = trim($_POST["password"]);
    if (!$q->TABLE_EXISTS("hotspot_members")) {
        $q->CheckTables();
    }
    $sql = "SELECT * FROM hotspot_members WHERE uid='{$username}' AND activedirectory=0";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    if ($ligne["uid"] != null) {
        $GLOBALS["CACHE_AUTH"] = $ligne["sessiontime"];
        $GLOBALS["MAX_TIME"] = $ligne["ttl"];
    }
    if ($noauthent) {
        return;
    }
    if ($ligne["enabled"] == 0) {
        $GLOBALS["ERROR"] = $tpl->javascript_parse_text("{access_to_internet_disabled} ({disabled})");
        return false;
    }
    if ($ligne["uid"] == null) {
        $GLOBALS["LOGS"][] = __FUNCTION__ . ":: uid is null";
        return false;
    }
    if ($ligne["password"] != $password) {
        if ($ligne["password"] != md5($password)) {
            $GLOBALS["LOGS"][] = __FUNCTION__ . ":: {$username} `password` mismatch expected `{$ligne["password"]}`";
            return false;
        }
    }
    return true;
}
function group_defaults($ID)
{
    $f[] = "union.*select.*\\(";
    $f[] = "union.*all.*select.*";
    $f[] = "concat.*\\(";
    $f[] = "[a-zA-Z0-9_]=http://";
    $f[] = "[a-zA-Z0-9_]=(\\.\\.//?)+";
    $f[] = "[a-zA-Z0-9_]=/([a-z0-9_.]//?)+";
    $f[] = "(<|%3C).*script.*(>|%3E)";
    $f[] = "GLOBALS(=|\\[|\\%[0-9A-Z]{0,2)";
    $f[] = "_REQUEST(=|\\[|\\%[0-9A-Z]{0,2)";
    $f[] = "proc/self/environ";
    $f[] = "mosConfig_[a-zA-Z_]{1,21(=|\\%3D)";
    $f[] = "base64_(en|de)code\\(.*\\)";
    $f[] = "\\b(ultram|unicauca|valium|viagra|vicodin|xanax|ypxaieo)\\b";
    $f[] = "\\b(erections|hoodia|huronriveracres|impotence|levitra|libido)\\b";
    $f[] = "\\b(ambien|blue\\spill|cialis|cocaine|e*********n|erectile)\\b";
    $f[] = "\\b(lipitor|phentermin|pro[sz]ac|sandyauer|tramadol|troyhamby)\\b";
    $prefix = "INSERT IGNORE INTO nginx_exploits_items (`groupid`,`enabled`,`pattern`,`token`) VALUES";
    while (list($head, $pattern) = each($f)) {
        $n[] = "({$ID},1,'" . mysql_escape_string2($pattern) . "','query_string')";
    }
    $f = array();
    $f[] = "Wget";
    $f[] = "Indy Library";
    $f[] = "libwww-perl";
    $f[] = "GetRight";
    $f[] = "GetWeb!";
    $f[] = "Go!Zilla";
    $f[] = "Download Demon";
    $f[] = "Go-Ahead-Got-It";
    $f[] = "TurnitinBot";
    $f[] = "GrabNet";
    $f[] = "Nmap";
    $f[] = "(SBIder/Nutch-1.0-dev|Purebot/1.1|spbot/2.0.2|Toata|Python-urllib)";
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS("nginx_exploits_items")) {
        $sql = "CREATE TABLE IF NOT EXISTS `nginx_exploits_items` (\n\t\t\t  `ID` INT NOT NULL AUTO_INCREMENT,\n\t\t\t  `groupid` INT NOT NULL DEFAULT '0',\n\t\t\t  `enabled` smallint(1)  NOT NULL,\n\t\t\t  `pattern` TEXT,\n\t\t\t  `token` CHAR(20)  NOT NULL,\n\t\t\t  PRIMARY KEY (`ID`),\n\t\t\t  KEY `groupid` (`groupid`),\n\t\t\t  KEY `enabled` (`enabled`),\n\t\t\t  KEY `token` (`token`)\n\t\t\t)  ENGINE = MYISAM;";
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            echo $q->mysql_error;
        }
    }
    while (list($head, $pattern) = each($f)) {
        $n[] = "({$ID},1,'" . mysql_escape_string2($pattern) . "','http_user_agent')";
    }
    $q->QUERY_SQL($prefix . @implode(",", $n));
    if (!$q->ok) {
        echo $q->mysql_error;
    }
}
Example #25
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);
}
function last_days()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($GLOBALS["VERBOSE"]) {
        echo "last_days Loading done...\nTimeFile:{$timefile}\n";
    }
    $unix = new unix();
    if (!$GLOBALS["VERBOSE"]) {
        if (SquidStatisticsTasksOverTime()) {
            stats_admin_events(1, "Statistics overtime... Aborting", null, __FILE__, __LINE__);
            return;
        }
    }
    $pid = @file_get_contents($pidfile);
    if (!$GLOBALS["FORCE"]) {
        if ($pid < 100) {
            $pid = null;
        }
        if ($unix->process_exists($pid, basename(__FILE__))) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid}\n";
            }
            return;
        }
        $timeexec = $unix->file_time_min($timefile);
        if ($timeexec < 7200) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$timeexec} <> 7200...\n";
            }
            return;
        }
    }
    $q = new mysql_squid_builder();
    $mypid = getmypid();
    @file_put_contents($pidfile, $mypid);
    @file_put_contents($timefile, time());
    $current_table = date("Ymd") . "_hour";
    $t = time();
    $sql = "SELECT DATE_FORMAT(zDate,'%Y%m%d') AS `suffix` FROM tables_day \n\t\t\tWHERE DAY(zDate)<DAY(NOW()) AND YEAR(zDate) = YEAR(NOW()) AND MONTH(zDate) = MONTH(NOW()) AND zDate>DATE_SUB(NOW(),INTERVAL 7 DAY)";
    $results = $q->QUERY_SQL($sql);
    $num = mysql_num_rows($results);
    if ($num == 0) {
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $current_table = $ligne["suffix"] . "_hour";
        if (!$q->TABLE_EXISTS($current_table)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$current_table} no such table\n";
            }
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "Processing {$current_table}\n";
        }
        if (!$GLOBALS["VERBOSE"]) {
            if (SquidStatisticsTasksOverTime()) {
                stats_admin_events(1, "Statistics overtime... Aborting", null, __FILE__, __LINE__);
                return;
            }
        }
        _xprocess_table($current_table, true);
        $f[] = $current_table;
    }
    $took = $unix->distanceOfTimeInWords($t, time(), true);
    stats_admin_events(2, "Processing categorization of {$num} tables {$took}", @implode("\n", $f), __FILE__, __LINE__);
}
function topwebsites_graph(){
	$tpl=new templates();
	$page=CurrentPageName();
	$q=new mysql_squid_builder();
	
	
	$table=$_GET["table"];
	$id=md5($_GET["table"].$_GET["hour"]);
	if(!$q->TABLE_EXISTS($table)){echo "<H3>".$tpl->_ENGINE_parse_body("{ERROR_NO_DATA}")."</h3>";}

	$sql="SELECT SUM(size) as tsize,`hour`,familysite FROM $table GROUP BY familysite,`hour` HAVING `hour`='{$_GET["hour"]}' ORDER BY tsize DESC LIMIT 0,5";
	$results=$q->QUERY_SQL($sql);
	while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){
		$downloaded_bin=$ligne["tsize"];
		$downloaded_text=FormatBytes($downloaded_bin/1024);
		$downloaded_text=str_replace("&nbsp;", " ", $downloaded_text);
		$downloaded_bin=round((($downloaded_bin/1024)/1000));
		
		$website=$ligne["familysite"];
		$ydata[]="MB $website $downloaded_text";
		$xdata[]=$downloaded_bin;	
		
		
	}
	
	
	$targetedfile="ressources/logs/".basename(__FILE__).".".__FUNCTION__.".".time().".png";
	$gp=new artica_graphs($targetedfile);	
	$gp->xdata=$xdata;
	$gp->ydata=$ydata;	
	$gp->width=250;
	$gp->height=400;
	$gp->ViewValues=true;
	//$gp->PieLegendHide=true;
	$gp->x_title=$tpl->_ENGINE_parse_body("{cache}");
	$gp->pie();		
	echo $tpl->_ENGINE_parse_body("<center style='margin:0px;margin-bottom:5px;padding:3px;border:1px solid #CCCCCC'>
		<strong style='font-size:12px'>{phrase_topwebsize_bysize}</strong>
		<img src='$targetedfile' style='margin-bottom:5px'>
		
	 	</center>
	 	
	")."<script>LoadAjax('panel-right-$id','$page?users-usually=yes&time={$_GET["time"]}&hour={$_GET["hour"]}&table={$_GET["table"]}')</script>";
	
}
function today_search()
{
    $now = date("Ymd");
    $tablename = "searchwordsD_{$now}";
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS($tablename)) {
        senderror("{$tablename} no such table");
    }
    $tpl = new templates();
    $search = string_to_flexquery("search-today");
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $sql = "SELECT * FROM {$tablename} WHERE 1 {$search} ORDER BY `hour` DESC LIMIT 0,500";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        senderror($q->mysql_error);
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $ligne["words"] = utf8_decode($ligne["words"]);
        $time = strtotime($ligne["zDate"]);
        $ligne["zDate"] = date("H:i:s", $time);
        $tr[] = "\n\t\t<tr>\n\t\t<td nowrap><i class='icon-time' ></i>&nbsp;{$ligne["hour"]}h</a></td>\n\t\t<td nowrap><i class='icon-user'></i>&nbsp;{$ligne["uid"]}</a></td>\n\t\t<td>{$ligne["ipaddr"]}</a></td>\n\t\t<td>{$ligne["words"]}</td>\n\t\t<td><i class='icon-info-globe'></i>&nbsp;{$ligne["sitename"]}</td>\n\t\t<td nowrap><i class='icon-info-globe'></i>&nbsp;{$ligne["familysite"]}</td>\n\t\t</tr>";
    }
    echo $tpl->_ENGINE_parse_body("\n\n\t\t\t\t<table class='table table-bordered table-hover'>\n\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{date}</th>\n\t\t\t\t\t<th>{member}</th>\n\t\t\t\t\t<th>{ipaddr}</th>\n\t\t\t\t\t<th>{words}</th>\n\t\t\t\t\t<th colspan=2>{sitename}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t\t") . @implode("", $tr) . "</tbody></table>";
}
Example #29
0
function accounts_search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $sock = new sockets();
    $q = new mysql_squid_builder();
    $t = $_GET["t"];
    $tt = $_GET["tt"];
    $search = '%';
    $table = "rdpproxy_items";
    $page = 1;
    $data = array();
    $data['rows'] = array();
    $FORCE_FILTER = "userid='{$_GET["ID"]}'";
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (!$q->TABLE_EXISTS($table)) {
        $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`rdpproxy_items` (\n\t\t\t`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n\t\t\t`userid` BIGINT(11),\n\t\t\t`service` VARCHAR(128) ,\n\t\t\t`rhost` VARCHAR(128),\n\t\t\t`username` VARCHAR(128),\n\t\t\t`domain` VARCHAR(128),\n\t\t\t`password` VARCHAR(128),\n\t\t\t`servicetype` VARCHAR(15),\n\t\t\t`serviceport` smallint(15),\n\t\t\t`alive` INT UNSIGNED NOT NULL,\n\t\t\t`is_rec` smallint(1),\n\t\t\t KEY `username`(`username`),\n\t\t\t KEY `password`(`password`),\n\t\t\t KEY `service`(`service`),\n\t\t\t KEY `rhost`(`rhost`),\n\t\t\t KEY `userid`(`userid`)\n\t\t\t )  ENGINE = MYISAM;";
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            json_error_show("{$q->mysql_error}", 1);
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        if (!$q->ok) {
            json_error_show("{$q->mysql_error}", 1);
        }
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `rdpproxy_items` WHERE {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        if (!$q->ok) {
            json_error_show("{$q->mysql_error}", 1);
        }
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM `{$table}` WHERE {$FORCE_FILTER} {$searchstring} {$ORDER} {$limitSql}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        json_error_show("{$q->mysql_error},{$sql}", 1);
    }
    $data['page'] = $page;
    $data['total'] = $total;
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data", 1);
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $val = 0;
        $color = "black";
        $download = "&nbsp;";
        $delete = imgsimple("delete-48.png", null, "ItemsDelete{$tt}('{$ligne['ID']}')");
        $href = "<a href=\"javascript:blur();\"\n\t\t\t\t\t\tOnClick=\"javascript:Loadjs('{$MyPage}?accounts-js=yes&userid={$_GET["ID"]}&ID={$ligne['ID']}&t={$t}&tt={$tt}');\"\n\t\t\t\t\t\tstyle=\"font-size:22px;text-decoration:underline;color:{$color}\">";
        $img = "computer-windows-48.png";
        if ($ligne['servicetype'] == "RDP") {
            if (!fsock_perform($ligne['rhost'], 3389)) {
                $img = "computer-windows-48-red.png";
            } else {
                $download = "<a href=\"{$MyPage}?rdp-download={$ligne['ID']}\"><img src='img/download-48.png'></a>";
            }
        }
        $data['rows'][] = array('id' => "ACC{$ligne['ID']}", 'cell' => array("\n\t\t\t\t\t\t<center><img src='img/{$img}'></center>", "{$href}{$ligne['service']}</a>", "{$href}{$ligne['username']}/{$ligne['service']}</a>", "{$href}{$ligne['rhost']}</a>", "<center{$href}{$ligne['servicetype']}</a></center>", "<center>{$download}</center>", "<center>{$delete}</center>"));
    }
    echo json_encode($data);
}
function webstats_middle_table_items()
{
    $t = $_GET["t"];
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $users = new usersMenus();
    $sock = new sockets();
    $xtime = $_GET["xtime"];
    $database = "squidlogs";
    $tablename_members = date("Ymd", $_GET["xtime"]) . "_members";
    if ($_GET["FILTER"] == null) {
        $_GET["FILTER"] = which_filter($tablename_members);
    }
    $subtable = "( SELECT {$_GET["FILTER"]},SUM(size) as size, SUM(hits) as hits FROM `{$tablename_members}` \n\tGROUP BY {$_GET["FILTER"]} HAVING LENGTH({$_GET["FILTER"]})>0) as t";
    $search = '%';
    $table = $subtable;
    $page = 1;
    $FORCE_FILTER = null;
    $dansguardian_events = date("Ymd", $xtime) . "_hour";
    if (!$q->TABLE_EXISTS($tablename_members, $database)) {
        json_error_show("{$table} doesn't exists...");
    }
    if ($q->COUNT_ROWS($tablename_members, $database) == 0) {
        json_error_show("No data");
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $searchstring = string_to_flexquery("items");
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $boot = new boostrap_form();
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} ORDER BY size DESC LIMIT 0,150";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql, $database);
    while ($ligne = mysql_fetch_assoc($results)) {
        $zmd5 = md5(serialize($ligne));
        $color = "black";
        //familysite 	size 	hits
        $colorsize = "black";
        $sizeorg = $ligne["size"];
        $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " ");
        $ligne["size"] = FormatBytes($ligne["size"] / 1024);
        if ($sizeorg > 102400000) {
            $colorsize = "#4E0000";
        }
        if ($sizeorg > 512000000) {
            $colorsize = "#9A0000";
        }
        // https://192.168.1.106:9000/
        $urljs = "Loadjs('squid.members.zoom.php?table={$dansguardian_events}&field={$_GET["FILTER"]}&value={$ligne["{$_GET["FILTER"]}"]}')";
        $link = $boot->trswitch($urljs);
        $tr[] = "\n\t<tr id='{$id}'>\n\t<td {$link}><i class='icon-user'></i> {$ligne["name"]}</a>{$ligne["{$_GET["FILTER"]}"]}</td>\n\t<td {$link}><i class='icon-globe'></i> {$ligne["hits"]}</td>\n\t<td {$link}><i class='icon-globe'></i> {$ligne["size"]}</td>\n\t</tr>";
    }
    echo $tpl->_ENGINE_parse_body("\n\t\t\n\t\t<table class='table table-bordered table-hover'>\n\t\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{{$_GET["FILTER"]}}</th>\n\t\t\t\t\t<th>{hits}</th>\n\t\t\t\t\t<th>{size}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("\n", $tr) . " </tbody>\n\t\t</table>";
}