function apc_compile()
{
    if (!function_exists('apc_compile_file')) {
        if (posix_getuid() == 0) {
            echo "Starting lighttpd............: Compiling engine no APC engine found\n";
        }
        return;
    }
    if (posix_getuid() == 0) {
        echo "Starting lighttpd............: Please wait, compiling engine to APC\n";
    }
    compile_files(dirname(__FILE__));
    compile_files(dirname(__FILE__) . '/ressources');
    compile_files(dirname(__FILE__) . '/framework');
    compile_files(dirname(__FILE__) . '/user-backup');
    compile_files(dirname(__FILE__) . '/user-backup/framework');
    compile_files(dirname(__FILE__) . '/user-backup/ressources');
    if (is_dir("/usr/share/roundcube")) {
        compile_files(dirname(__FILE__));
        compile_files("/usr/share/roundcube");
        compile_files("/usr/share/roundcube/bin");
        compile_files("/usr/share/roundcube/program");
        compile_files("/usr/share/roundcube/program/lib");
        compile_files("/usr/share/roundcube/program/lib/include");
    }
    if (posix_getuid() == 0) {
        echo "Starting lighttpd............: done: {$GLOBALS["COMPILED"]} APC files compiled\n";
    } else {
        writelogs("{$GLOBALS["COMPILED"]} APC files compiled", __FUNCTION__, __FILE__, __LINE__);
    }
}
function save()
{
    $sock = new sockets();
    if ($_POST["ID"] == 0) {
        $ligne = unserialize(base64_decode($sock->GET_INFO("DansGuardianDefaultMainRule")));
        $ligne["bypass"] = $_POST["bypass"];
        $ligne["BypassSecretKey"] = $_POST["BypassSecretKey"];
        writelogs("Default rule, saving DansGuardianDefaultMainRule", __FUNCTION__, __FILE__, __LINE__);
        $sock->SaveConfigFile(base64_encode(serialize($ligne)), "DansGuardianDefaultMainRule");
        writelogs("Ask to compile rule...", __FUNCTION__, __FILE__, __LINE__);
        $sock->getFrameWork("webfilter.php?compile-rules=yes");
        return;
    }
    $q = new mysql_squid_builder();
    $sql = "UPDATE webfilter_rules SET bypass='******',BypassSecretKey='{$_POST["bypass"]}' WHERE ID='{$_POST["ID"]}'";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        if (strpos($q->mysql_error, "Unknown column") > 0) {
            $q->CheckTables();
            $q->QUERY_SQL($sql);
        }
    }
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock->getFrameWork("webfilter.php?compile-rules=yes");
}
Exemple #3
0
function popup_list(){
	$dhcp=new dhcpd(0);
	writelogs(count($dhcp->routes)." routes in array",__FUNCTION__,__FILE__,__LINE__);
	if(!is_array($dhcp->routes)){
		writelogs(count($dhcp->routes)." -> return null",__FUNCTION__,__FILE__,__LINE__);
		return null;}
	$html="<table style='width:99%'>";
	$array=$dhcp->routes;
	while (list ($ip, $arr) = each ($array) ){
		$delete=imgtootltip("ed_delete.gif","{delete}","DHCPDeleteRoute('$ip')");
		$info=$arr[2];
		
		$html=$html. "
		<tr ". CellRollOver().">
		<td><strong>$ip</strong></td>
		<td><strong>{$arr[0]}</strong></td>
		<td width=1%><img src='img/fw_bold.gif'></td>
		<td><strong>{$arr[1]}</td>
		<td width=1% nowrap><strong>$info</strong></td>
		<td width=1%>$delete</td>
		
		</tr>
		";
	}
	
	$html=$html."</table>";
	$tpl=new templates();
	return $tpl->_ENGINE_parse_body($html);	
	
}
Exemple #4
0
function ParseEvents()
{
    $path = "/var/log/artica-postfix/events";
    $f = new filesClasses();
    $hash = $f->DirListTable($path);
    if (!is_array($hash)) {
        return null;
    }
    echo date('Y-m-d h:i:s') . " " . count($hash) . " file(s) notifications...\n";
    $mysql = new mysql();
    while (list($num, $file) = each($hash)) {
        $text = null;
        $processname = null;
        $date = null;
        $context = null;
        $subject = null;
        $recipient = null;
        $bigtext = @file_get_contents($path . '/' . $file);
        echo date('Y-m-d h:i:s') . " Parsing {$file} " . strlen($bigtext) . " bytes text\n";
        $ini = new Bs_IniHandler();
        if (preg_match("#<text>(.+?)</text>#is", $bigtext, $re)) {
            $text = $re[1];
            if (strlen($text) > 0) {
                $bigtext = str_replace($re[0], '', $bigtext);
            }
        }
        if (preg_match("#<attachedfiles>(.+?)</attachedfiles>#is", $bigtext, $re)) {
            $files_text = addslashes($re[1]);
        }
        $ini->loadString($bigtext);
        $processname = $ini->_params["LOG"]["processname"];
        $date = $ini->_params["LOG"]["date"];
        $context = $ini->_params["LOG"]["context"];
        $context = addslashes($context);
        if (strlen($text) < 2) {
            $text = $ini->_params["LOG"]["text"];
        }
        $text = addslashes($text);
        $subject = $ini->_params["LOG"]["subject"];
        $recipient = $ini->_params["LOG"]["recipient"];
        $subject = addslashes($subject);
        echo date('Y-m-d h:i:s') . " Parsing subject {$subject} " . strlen($text) . " bytes text\n";
        writelogs("New notification: {$subject} (" . strlen($text) . " bytes)", __FUNCTION__, __FILE__, __LINE__);
        $sql = "INSERT INTO events (zDate,hostname,\n        \tprocess,text,context,content,attached_files,recipient) VALUES(\n        \t'{$date}',\n        \t'{$mysql->hostname}',\n        \t'{$processname}',\n        \t'{$subject}',\n        \t'{$context}','{$text}','{$files_text}','{$recipient}')";
        echo date('Y-m-d h:i:s') . " run mysql query\n";
        if ($mysql->QUERY_SQL($sql, 'artica_events')) {
            unlink($path . '/' . $file);
        } else {
            error_log("Mysql error keep {$path}/{$file};");
            error_log("{$mysql->mysql_error}");
            if (preg_match("#Unknown column#", $mysql->mysql_error)) {
                error_log("->BuildTables()");
                $mysql->BuildTables();
            }
        }
    }
    if (count($hash) > 0) {
        events(count($hash) . " events queue parsed...");
    }
}
Exemple #5
0
function alias_add()
{
    $free = new freeweb($_POST["servername"]);
    writelogs("Add ServerAlias {$_POST["AddAlias"]} -> {$_POST["servername"]}", __FUNCTION__, __FILE__, __LINE__);
    $free->Params["ServerAlias"][$_POST["AddAlias"]] = true;
    $free->SaveParams();
}
function FindComputerByIP()
{
    if ($_GET["SelectDansGuardianExceptionipList"] == '*') {
        $_GET["SelectDansGuardianExceptionipList"] = null;
    }
    if ($_GET["SelectDansGuardianExceptionipList"] == null) {
        $tofind = "*";
    } else {
        $tofind = "{$_GET["SelectDansGuardianExceptionipList"]}*";
    }
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    writelogs($filter_search, __FUNCTION__, __FILE__, __LINE__);
    $ldap = new clladp();
    $attrs = array("uid", "ComputerIP", "ComputerOS", "ComputerMachineType");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs, 10);
    $html = "<table style='width:250px' class=table_form>";
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = str_replace('$', '', $hash[$i]["uid"][0]);
        $ip = $hash[$i][strtolower("ComputerIP")][0];
        if (trim($ip) == null) {
            continue;
        }
        $js = "AddDansGuardianExceptionipList('{$ip}');";
        $html = $html . "<tr " . CellRollOver($js, "{add}") . ">\n\t\t<td width=1%><img src='img/base.gif'></td>\n\t\t<td nowrap><strong>{$hash[$i]["uid"][0]}</strong></td>\n\t\t<td ><strong>{$ip}</strong></td>\n\t</tr>\n\t";
    }
    $html = $html . "</table>";
    $html = "<center><div style='height:300px;overflow:auto'>{$html}</div></center>";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
Exemple #7
0
function status()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $script = null;
    if (is_file("ressources/logs/global.status.ini")) {
        $ini = new Bs_IniHandler("ressources/logs/global.status.ini");
    } else {
        writelogs("ressources/logs/global.status.ini no such file");
        $sock = new sockets();
        $datas = base64_decode($sock->getFrameWork('cmd.php?Global-Applications-Status=yes'));
        $ini = new Bs_IniHandler($datas);
    }
    $sock = new sockets();
    $datas = $sock->getFrameWork('cmd.php?refresh-status=yes');
    $status = DAEMON_STATUS_ROUND("CLAMAV", $ini, null, 1);
    $q = new mysql();
    if ($q->TABLE_EXISTS("clamd_mem", "artica_events")) {
        if ($q->COUNT_ROWS("clamd_mem", "artica_events") > 1) {
            $script = "LoadAjax('clamd-graphs','{$page}?clamd-graphs=yes');";
        }
    }
    $html = "\n\t<div style='width:100%'>{$status}</div>\n\t<center style='margin-top:10px' id='clamd-graphs'></center>\n\t\n\t<script>\n\t\t{$script}\n\t</script>\n\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
function IMPORT_MEMBERS()
{
    $me = $_SERVER["SERVER_NAME"];
    $error = array();
    $members = unserialize(base64_decode($_POST["MEMBERS"]));
    writelogs("Analyze " . count($members) . " members for ou " . $_POST["OU"], __FUNCTION__, __FILE__, __LINE__);
    while (list($uid, $array) = each($members)) {
        writelogs("Analyze {$uid} for ou " . $_POST["OU"], __FUNCTION__, __FILE__, __LINE__);
        $user = new user($uid);
        if ($user->UserExists) {
            $user->password = $array["password"];
            if ($user->add_user()) {
                $success[] = "{$me}::IMPORT_MEMBERS:: Success updating {$uid} in LDAP database";
            } else {
                $error[] = "Failed updating {$uid} in LDAP database\n {$user->ldap_error}";
            }
            continue;
        }
        while (list($key, $value) = each($array)) {
            $user->{$key} = $value;
        }
        if ($user->add_user()) {
            $success[] = "{$me}::IMPORT_MEMBERS:: Success adding {$uid} in LDAP database";
        } else {
            $error[] = "Failed adding {$uid} in LDAP database\n {$user->ldap_error}";
        }
    }
    if (count($error) > 0) {
        echo "<ERROR>" . @implode("\n", $error) . "</ERROR>";
    }
    if (count($success) > 0) {
        echo "<SUCCESS>" . @implode("\n", $success) . "</SUCCESS>";
    }
}
function start()
{
    $unix = new unix();
    if (!$GLOBALS["VERBOSE"]) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = @file_get_contents($pidfile);
        if ($unix->process_exists($pid)) {
            writelogs("Already running pid {$pid}", __FUNCTION__, __FILE__, __LINE__);
            return;
        }
    }
    $ldap = new clladp();
    $pattern = "(&(objectclass=userAccount))";
    $attr = array();
    $sr = @ldap_search($ldap->ldap_connection, "dc=organizations,{$ldap->suffix}", $pattern, $attr);
    $hash = ldap_get_entries($ldap->ldap_connection, $sr);
    $unix = new unix();
    $users_array = array();
    if (!is_array($hash)) {
        blackwhite_admin_mysql(0, "Unable to obtain users from LDAP server", $ldap->ldap_last_error, __FILE__, __LINE__);
        return;
    }
    for ($i = 0; $i < $hash["count"]; $i++) {
        $usersArray[$hash[$i]["uid"][0]] = true;
    }
    while (list($uid, $none) = each($usersArray)) {
        imapopen_White($uid);
        imapopen_black($uid);
    }
}
function find_member()
{
    $tofind = $_GET["find-member"];
    if ($_SESSION["uid"] == -100) {
        $ou = $_GET["ou"];
    } else {
        $ou = $_SESSION["ou"];
    }
    $ldap = new clladp();
    if (is_base64_encoded($ou)) {
        $ou = base64_decode($ou);
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $tofind = str_replace('***', '*', $tofind);
    writelogs("FIND {$tofind} IN OU \"{$ou}\"", __FUNCTION__, __FILE__, __LINE__);
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind}) ))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber");
    $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs, 20);
    $users = new user();
    $number = $hash["count"];
    for ($i = 0; $i < $number; $i++) {
        $user = $hash[$i];
        $html = $html . formatUser($user);
    }
    return $html;
}
Exemple #11
0
function vlan_add()
{
    $sock = new sockets();
    $tpl = new templates();
    $ERROR_NO_PRIVS = $tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
    $DisableNetworksManagement = $sock->GET_INFO("DisableNetworksManagement");
    if ($DisableNetworksManagement == null) {
        $DisableNetworksManagement = 0;
    }
    if ($DisableNetworksManagement == 1) {
        echo $ERROR_NO_PRIVS;
        return;
    }
    if ($_GET["nic"] == null) {
        echo $tpl->_ENGINE_parse_body("{nic}=null");
        exit;
    }
    $sql = "INSERT INTO nics_vlan (nic,org,ipaddr,netmask,cdir,gateway)\n\t\tVALUES('{$_GET["nic"]}','{$_GET["org"]}','{$_GET["vlan-ipaddr"]}','{$_GET["netmask"]}','{$_GET["cdir"]}','{$_GET["gateway"]}');\n\t\t";
    if ($_GET["ID"] > 0) {
        $sql = "UPDATE nics_vlan SET nic='{$_GET["nic"]}',\n\t\torg='{$_GET["org"]}',\n\t\tipaddr='{$_GET["vlan-ipaddr"]}',\n\t\tnetmask='{$_GET["netmask"]}',\n\t\tcdir='{$_GET["cdir"]}',\n\t\tgateway='{$_GET["gateway"]}' WHERE ID={$_GET["ID"]}";
    }
    writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
}
function Launch()
{
    $sock = new sockets();
    $cmd = "squid2.php?reload-progress=yes";
    writelogs("launch {$cmd}", __FUNCTION__, __FILE__, __LINE__);
    $sock->getFrameWork($cmd);
}
function routes_listes()
{
    $tpl = new templates();
    $html = "<p class=text-error>{routes_goto_miniadm}</p>";
    echo $tpl->_ENGINE_parse_body($html);
    return;
    $page = CurrentPageName();
    $types[1] = "{network_nic}";
    $types[2] = "{host}";
    $ERROR_NO_PRIVS = $tpl->javascript_parse_text("{ERROR_NO_PRIVS}");
    $users = new usersMenus();
    if ($users->AsSystemAdministrator) {
        $AsNetworksAdministrator = 1;
    } else {
        $AsNetworksAdministrator = 0;
    }
    $html = "\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t\t<th>{type}</th>\n\t\t<th>{nic}</th>\n\t\t<th>{pattern}</th>\n\t\t<th>{gateway}</th>\n\t\t<th>&nbsp;</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    $sql = "SELECT * FROM nic_routes ORDER BY `nic`";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2>";
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t<td style='font-size:14px' nowrap>&nbsp;{$types[$ligne["type"]]}</td>\n\t\t<td style='font-size:14px' nowrap>&nbsp;{$ligne["nic"]}</td>\n\t\t<td style='font-size:14px' nowrap>&nbsp;{$ligne["pattern"]}</td>\n\t\t<td style='font-size:14px' nowrap>&nbsp;{$ligne["gateway"]}</td>\n\t\t<td>" . imgtootltip("delete-32.png", "{delete}", "DeleteRouteNicsList('{$ligne["zmd5"]}')") . "</td>\n\t\t</tr>\n\t\t";
    }
    echo $tpl->_ENGINE_parse_body($html . "</table>\n\t<script>\n\t\tvar x_DeleteRouteNicsList= function (obj) {\n\t\t\t\tvar results=obj.responseText;\n\t\t\t\tif(results.length>0){alert(results);return;}\n\t\t\t\tRefreshRoutes();\n\t\t\t}\t\t\n\t\n\t\n\t\tfunction DeleteRouteNicsList(md){\n\t\t\tvar AsNetworksAdministrator='{$AsNetworksAdministrator}';\n\t\t\tif(AsNetworksAdministrator!=='1'){alert('{$ERROR_NO_PRIVS}');return;}\t\t\t\t\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('del-route',md);\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',x_DeleteRouteNicsList);\t\t\n\t\t\n\t\t}\n\t</script>\t\n\t");
}
Exemple #14
0
function config_popup()
{
    $vpn = new openvpn();
    $config = $vpn->BuildClientconf($_SESSION["uid"]);
    $tbconfig = explode("\n", $config);
    $html_logs[] = htmlentities("VPN config -> " . strlen($config) . " bytes length (" . count($tbconfig) . " lines)");
    $uid = $_SESSION["uid"];
    writelogs("VPN config -> " . strlen($config) . " bytes length (" . count($tbconfig) . " lines)", __FUNCTION__, __FILE__, __LINE__);
    $sock = new sockets();
    if (!$sock->SaveConfigFile($config, "{$uid}.ovpn")) {
        $html_logs[] = htmlentities("Framework error while saving  -> {$uid}.ovpn;" . strlen($config) . " bytes length (" . count($tbconfig) . " lines)");
    }
    writelogs("sockets() OK", __FUNCTION__, __FILE__, __LINE__);
    //$datas=$sock->getfile('OpenVPNGenerate:'.$uid);
    $datas = $sock->getFrameWork("openvpn.php?build-vpn-user={$_SESSION["uid"]}&basepath=" . dirname(__FILE__));
    $tbl = explode("\n", $datas);
    $tbl = array_reverse($tbl);
    while (list($num, $line) = each($tbl)) {
        if (trim($line) == null) {
            continue;
        }
        $html_logs[] = "<div><code style='font-size:10px;color:black;'>" . htmlentities($line) . "</code></div>";
    }
    if (is_file('ressources/logs/' . $uid . '.zip')) {
        $download = "\n\t\t<center>\n\t\t\t<a href='ressources/logs/" . $uid . ".zip'><img src='img/download-64.png' title=\"{DOWNLOAD_CONFIG_FILES}\" style='padding:8Px;border:1px solid #055447;margin:3px'></a>\n\t\t</center>\n\t\t";
    }
    $html = "\n\t\n\t{$download}\n\t<H3>{events}</H3>\n\t" . ParagrapheTXT("<div style='width:100%;height:200px;overflow:auto'>" . implode("\n", $html_logs) . "</div>");
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
function popup()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $users = new usersMenus();
    $q = new mysql();
    $sql = "SELECT * FROM officials_domains ORDER BY domain";
    writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2>";
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $domains[$ligne["domain"]] = $ligne["domain"];
    }
    $OverWriteRestrictedDomains = 0;
    if ($users->OverWriteRestrictedDomains) {
        $OverWriteRestrictedDomains = 1;
    }
    if ($OverWriteRestrictedDomains == 1) {
        $over = "\n\t\t<hr>\n\t\t<div class=explain>{OverWriteRestrictedDomains_allow_text}</div>\n\t\t<table style='width:99%' class=form>\n\t<tr>\n\t\t<td class=legend>{domain}:</td>\n\t\t<td width=100%>" . Field_text("overwrite-domain", null, "font-size:16px;padding:3px;width:320px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=2 align='right'><hr>" . button("{add}", "AddSubdomainOUOver()") . "</td>\n\t</tr>\n\t</table>\n\t\t";
    }
    $_GET["ou"] = urlencode($_GET["ou"]);
    $domains[null] = "{select}";
    $html = "\n\t<div id='add_subdomain_explain'></div>\n\t<div class=explain >{add_subdomain_explain}</div>\n\t\n\t<table style='width:99%' class=form>\n\t<tr>\n\t\t<td class=legend>{subdomain}:</td>\n\t\t<td width=50%>" . Field_text("subdomain", null, "font-size:16px;padding:3px;width:220px") . "</td>\n\t\t<td style='font-size:16px;padding:3px' width=1%><strong>.</strong></td>\n\t\t<td width=50%>" . Field_array_Hash($domains, "maindomain", null, "style:font-size:16px;padding:3px;") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=4 align='right'><hr>" . button("{add}", "AddSubdomainOU()") . "</td>\n\t</tr>\n\t</table>\n\t{$over}\n\t<script>\n\tvar x_AddSubdomainOU= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tdocument.getElementById('subdomain').innerHTML='';\n\t\tif(results.length>3){alert(results);return;}\n\t\tYahooWin4Hide();\n\t\tLoadAjax('LocalDomainsList','domains.edit.domains.php?LocalDomainList=yes&ou={$_GET["ou"]}');\n\t}\t\t\n\t\t\n\t\tfunction AddSubdomainOU(){\n\t\t\tvar maindomain=document.getElementById('maindomain').value;\n\t\t\tvar subdomain=document.getElementById('subdomain').value;\n\t\t\tif(maindomain.length<3){return;}\n\t\t\tif(subdomain.length<3){return;}\n\t\t\tvar domain=subdomain+'.'+maindomain;\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('AddNewInternetDomain','{$_GET["ou"]}');\n\t\t\tXHR.appendData('AddNewInternetDomainDomainName',domain);\t\n\t\t\tAnimateDiv('add_subdomain_explain');\n\t\t\tXHR.sendAndLoad('domains.edit.domains.php', 'GET',x_AddSubdomainOU);\n\t\t\t\n\t\t}\n\t\t\n\t\tfunction AddSubdomainOUOver(){\n\t\t\tvar maindomain=document.getElementById('overwrite-domain').value;\n\t\t\tif(maindomain.length<3){return;}\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('AddNewInternetDomain','{$_GET["ou"]}');\n\t\t\tXHR.appendData('AddNewInternetDomainDomainName',maindomain);\t\n\t\t\tAnimateDiv('add_subdomain_explain');\n\t\t\tXHR.sendAndLoad('domains.edit.domains.php', 'GET',x_AddSubdomainOU);\t\t\t\n\t\t}\n\n\t</script>\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
function getlist()
{
    $sock = new sockets();
    $res = base64_decode($sock->getFrameWork("cmd.php?etc-hosts-open=yes"));
    writelogs($res, __FUNCTION__, __FILE__, __LINE__);
    $datas = unserialize($res);
    while (list($num, $ligne) = each($datas)) {
        if (preg_match("#^([0-9\\.\\:]+)\\s+(.+?)\\s+(.+?)\$#", $ligne, $re)) {
            $array[] = array("name" => $re[2], "alias" => $re[3], "ip" => $re[1], "md" => md5($ligne));
            continue;
        }
        if (preg_match("#^([0-9\\.\\:]+)\\s+(.+?)\$#", $ligne, $re)) {
            $array[] = array("name" => $re[2], "ip" => $re[1], "md" => md5($ligne));
            continue;
        }
    }
    if (!is_array($array)) {
        return null;
    }
    $html = "<table style='width:98%' class=table_form>\n\t<tr>\n\t\t<th>&nbsp;</th>\n\t\t<th>{ip_address}</th>\n\t\t<th>{servername}</th>\n\t\t<th>{alias}</th>\n\t\t<th>&nbsp;</th>\n\t</tr>\n\t";
    while (list($num, $ligne) = each($array)) {
        $html = $html . "<tr " . CellRollOver() . ">\n\t\t\t<td width=1% nowrap><img src='img/base.gif'></td>\n\t\t\t<td width=1% nowrap>{$ligne["ip"]}</td>\n\t\t\t<td width=60% nowrap>{$ligne["name"]}</td>\n\t\t\t<td width=1% nowrap>{$ligne["alias"]}</td>\n\t\t\t<td width=1% nowrap>" . imgtootltip("ed_delete.gif", "{delete}", "etc_hosts_del('{$ligne["md"]}')") . "</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body("{$html}");
}
function Connect($server, $port, $user, $pass)
{
    writelogs("synchronize {$server}:{$port}", __FUNCTION__, __FILE__, __LINE__);
    $sync = new articaSMTPSync();
    $ldap = new clladp();
    $http = new httpd();
    $array = $sync->GetUsers();
    $field = base64_encode(serialize($array));
    $cred["user"] = $user;
    $cred["pass"] = $pass;
    $curl = new ccurl("https://{$server}:{$port}/exec.smtp.export.users.php");
    $curl->parms["credentials"] = base64_encode(serialize($cred));
    $curl->parms["users"] = $field;
    $curl->parms["local_port"] = $http->https_port;
    $curl->parms["mycred"] = base64_encode(serialize(array($ldap->ldap_admin, $ldap->ldap_password)));
    if (!$curl->get()) {
        writelogs("synchronize {$server}:{$port} failed", __FUNCTION__, __FILE__, __LINE__);
    }
    if (preg_match("#<datas>(.+?)</datas>#is", $curl->data, $re)) {
        $array = unserialize(base64_decode($re[1]));
        $sync->import($array, "{$server}:{$port}");
        $sock = new sockets();
        $sock->getFrameWork("cmd.php?postfix-transport-maps=yes");
    }
}
function main_extensions_bannedextensionslist_list($rule_main = null, $noecho = 0)
{
    $q = new mysql();
    if ($rule_main == null) {
        $rule_main = $_GET["rule_main"];
    }
    $dans = new dansguardian_rules(null, $rule_main);
    writelogs("Loading RuleID={$rule_main}", __FUNCTION__, __FILE__);
    $sql = "SELECT * FROM dansguardian_files WHERE filename='bannedextensionlist' AND RuleID={$rule_main}";
    writelogs("{$sql}", __FUNCTION__, __FILE__);
    $results = $q->QUERY_SQL($sql, "artica_backup");
    $style = CellRollOver();
    $categ = "\n\t<table style='width:99%' class=form>";
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $num = $ligne["ID"];
        $onoff = Field_checkbox("bannedextensionlist_id_{$num}", 1, $ligne["enabled"], "bannedextensionlist_switch('{$num}')");
        $ext = $ligne["pattern"];
        $ext = str_replace('.', '', $ext);
        $img = "img/ext/def_small.gif";
        if (file_exists("img/ext/{$ext}_small.gif")) {
            $img = "img/ext/{$ext}_small.gif";
        }
        $categ = $categ . "<tr {$style}>\n\t\t<td width=1%><IMG SRC='{$img}' id='image_{$num}'></td>\n\t\t<td width=1%>{$onoff}</td>\n\t\t<td width=1% style='font-size:12px'> <strong id='pattern_{$num}'>{$ligne["pattern"]}</strong></td>\n\t\t<td width=98% style='font-size:12px'><strong id='info_{$num}'>{$ligne["infos"]}</strong></td>\n\t\t<td width=1%>" . imgtootltip('ed_delete.gif', '{delete}', "bannedextensionlist_del('{$hostname}','{$rule_main}','{$num}')") . "</td>\n\t\t</tr>\n\t\t";
    }
    $categ = $categ . "</table>";
    $tpl = new templates();
    $categ = $tpl->_ENGINE_parse_body($categ);
    if ($noecho == 1) {
        return $categ;
    }
    echo $categ;
}
function PhotoUploaded()
{
    $tmp_file = $_FILES['photo']['tmp_name'];
    $content_dir = dirname(__FILE__) . "/ressources/conf/upload";
    if (!is_dir($content_dir)) {
        @mkdir($content_dir);
    }
    if (!@is_uploaded_file($tmp_file)) {
        writelogs("PHOTO: error_unable_to_upload_file", __FUNCTION__, __FILE__, __LINE__);
        $GLOBALS["Photo_error"] = '{error_unable_to_upload_file} ' . $tmp_file;
        return;
    }
    $name_file = $_FILES['photo']['name'];
    if (file_exists($content_dir . "/" . $name_file)) {
        @unlink($content_dir . "/" . $name_file);
    }
    if (!move_uploaded_file($tmp_file, $content_dir . "/" . $name_file)) {
        $GLOBALS["Photo_error"] = "{error_unable_to_move_file} : " . $content_dir . "/" . $name_file;
        writelogs("PHOTO: {error_unable_to_move_file} : " . $content_dir . "/" . $name_file, __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $file = $content_dir . "/" . $name_file;
    writelogs("PHOTO: {$file}", __FUNCTION__, __FILE__, __LINE__);
    $jpegPhoto_datas = file_get_contents($file);
    $ad = new external_ad_search();
    if (!$ad->SaveUserPhoto($jpegPhoto_datas, $_POST["DN"])) {
        $GLOBALS["Photo_error"] = $ad->ldap_error;
        return;
    }
}
function main_rules_addcategory_bannedphraselist()
{
    //bannedphraselist
    writelogs("{$_GET["rule_main"]}", __FUNCTION__, __FILE__);
    $dans = new dansguardian_rules($_GET["hostname"], $_GET["rule_main"]);
    $dans->AddCategory_phrase_banned($_GET["DansGuardian_addcategorybannedphraselist"], $_GET["rule_main"]);
}
Exemple #21
0
function page()
{
    $explorer = iconTable('explorer-64.png', '{explorer}', '{explorer_browse_yours_files}', "Loadjs('tree.php')", null, 210, null, 0, true);
    $users = new usersMenus();
    if ($users->SAMBA_INSTALLED) {
        $shareAfolder = iconTable('folder-granted-64.png', '{SHARE_FOLDER}', '{SHARE_A_FOLDER_USER_TEXT}', "Loadjs('share-a-folder.php')", null, 210, null, 0, true);
    }
    if ($users->MLDONKEY_INSTALLED) {
        $ml = new EmuleTelnet();
        if ($ml->UserIsActivated($_SESSION["uid"])) {
            $mldonkey = iconTable('64-emule.png', '{PEER_TO_PEER_NETWORKS}', '{PEER_TO_PEER_NETWORKS_TEXT}', "Loadjs('donkey.php')", null, 210, null, 0, true);
        }
    } else {
        writelogs("MLDONKEY_INSTALLED return false", __FUNCTION__, __FILE__, __LINE__);
    }
    $ct = new user($_SESSION["uid"]);
    writelogs("WebDavUser={$ct->WebDavUser}", __FUNCTION__, __FILE__, __LINE__);
    if ($ct->WebDavUser == 1) {
        $apache = new vhosts();
        print_r($hash);
        $hash = $apache->LoadVhostsType($ct->ou);
        if ($hash["WEBDAV"]) {
            $webdav = iconTable('webdav-64.png', '{WEBDAV_HOWTO}', '{WEBDAV_HOWTO_TEXT}', "Loadjs('webdav.php')", null, 210, null, 0, true);
        }
    }
    $html = "<H1>{storage}:{$_SESSION["ou"]}</H1>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top'>{$explorer}{$shareAfolder}" . storage_icon() . "</td>\n\t\t<td valign='top'>" . Xapian() . "{$mldonkey}{$webdav}</td>\n\t</tr>\n\t</table>\n\t\n\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Exemple #22
0
function PhotoUploaded()
{
    $tmp_file = $_FILES['photo']['tmp_name'];
    $content_dir = dirname(__FILE__) . "/ressources/conf/upload";
    if (!is_dir($content_dir)) {
        @mkdir($content_dir);
    }
    if (!@is_uploaded_file($tmp_file)) {
        writelogs("PHOTO: error_unable_to_upload_file", __FUNCTION__, __FILE__, __LINE__);
        $GLOBALS["Photo_error"] = '{error_unable_to_upload_file} ' . $tmp_file;
        return;
    }
    $name_file = $_FILES['photo']['name'];
    if (file_exists($content_dir . "/" . $name_file)) {
        @unlink($content_dir . "/" . $name_file);
    }
    if (!move_uploaded_file($tmp_file, $content_dir . "/" . $name_file)) {
        $GLOBALS["Photo_error"] = "{error_unable_to_move_file} : " . $content_dir . "/" . $name_file;
        writelogs("PHOTO: {error_unable_to_move_file} : " . $content_dir . "/" . $name_file, __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $file = $content_dir . "/" . $name_file;
    writelogs("PHOTO: {$file}", __FUNCTION__, __FILE__, __LINE__);
    if (isset($_POST["uid"])) {
        $_GET["uid"] = $_POST["uid"];
        $user = new user($_POST["uid"]);
        $jpegPhoto_datas = file_get_contents($file);
        $user->add_user();
        writelogs("PHOTO: Edit: " . strlen($jpegPhoto_datas) . " bytes", __FUNCTION__, __FILE__, __LINE__);
        if (!$user->SaveUserPhoto($jpegPhoto_datas)) {
            $GLOBALS["Photo_error"] = $user->ldap_error;
            return;
        }
        if (is_file($user->thumbnail_path)) {
            unlink($user->thumbnail_path);
        }
        return null;
    }
    if (isset($_POST["employeeNumber"])) {
        $_GET["employeeNumber"] = $_POST["employeeNumber"];
        $user = new contacts($_SESSION["uid"], $_POST["employeeNumber"]);
        $user->jpegPhoto_datas = file_get_contents($file);
        if ($_SESSION["uid"] != -100) {
            $ldap = new clladp();
            $user2 = new user($_SESSION["uid"]);
            $dn = "cn={$user->sn} {$user->givenName},ou={$user2->uid},ou=People,dc={$user2->ou},dc=NAB,{$ldap->suffix}";
            if ($dn == $user->dn) {
                $user->Save();
            } else {
                $tpl = new templates();
                echo $tpl->_ENGINE_parse_body('{ERROR_NO_PRIVS}');
            }
        }
        if (is_file($user->thumbnail_path)) {
            unlink($user->thumbnail_path);
        }
        return null;
    }
}
Exemple #23
0
function checkLogin()
{
    include "ressources/settings.inc";
    $sock = new sockets();
    writelogs("Testing logon....{$_POST["artica_username"]}", __FUNCTION__, __FILE__, __LINE__);
    writelogs("Testing logon.... password:{$_POST["artica_password"]}", __FUNCTION__, __FILE__, __LINE__);
    $FixedLanguage = $sock->GET_INFO("FixedLanguage");
    if ($_SESSION["uid"] != null) {
        echo "location:android.index.php";
        return;
    }
    while (list($index, $value) = each($_SERVER)) {
        $notice[] = "{$index}:{$value}";
    }
    if ($_GLOBAL["ldap_admin"] == null) {
        $tpl = new templates();
        echo $tpl->javascript_parse_text("{ldap_username_corrupt_text}");
        return null;
    }
    $md5submitted = $_POST["artica_password"];
    $md5Manager = md5(trim($_GLOBAL["ldap_password"]));
    if (trim($FixedLanguage) != null) {
        $_POST["lang"] = $FixedLanguage;
    }
    if (trim(strtolower($_POST["artica_username"])) == trim(strtolower($_GLOBAL["ldap_admin"]))) {
        if ($md5Manager != $md5submitted) {
            writelogs("Testing logon.... password:{$_POST["artica_password"]}!==\"{$_GLOBAL["ldap_password"]}\"", __FUNCTION__, __FILE__, __LINE__);
            artica_mysql_events("Failed to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]}", @implode("\n", $notice), "security", "security");
            echo "Bad password";
            return null;
        } else {
            artica_mysql_events("Success to logon on the Artica Web console from {$_SERVER["REMOTE_HOST"]} as SuperAdmin", @implode("\n", $notice), "security", "security");
            //session_start();
            $_SESSION["uid"] = '-100';
            $_SESSION["groupid"] = '-100';
            $_SESSION["passwd"] = $_GLOBAL["ldap_password"];
            $_SESSION["InterfaceType"] = "{APP_ARTICA_ADM}";
            setcookie("artica-language", $_POST["lang"], time() + 172800);
            $_SESSION["detected_lang"] = $_POST["lang"];
            $_SESSION["privileges"]["ArticaGroupPrivileges"] = '
			[AllowAddGroup]="yes"
			[AllowAddUsers]="yes"
			[AllowChangeKav]="yes"
			[AllowChangeKas]="yes"
			[AllowChangeUserPassword]="yes"
			[AllowEditAliases]="yes"
			[AllowEditAsWbl]="yes"
			[AsSystemAdministrator]="yes"
			[AsPostfixAdministrator]="yes"
			[AsArticaAdministrator]="yes"
			';
            $tpl = new templates();
            $sock->getFrameWork("squid.php?clean-catz-cache=yes");
            echo "location:android.index.php";
            exit;
        }
    }
    echo "location:android.logon.php";
}
function query()
{
    $direction = $_GET["direction"];
    $uid = $_SESSION["uid"];
    $email = $_GET["email"];
    $subject = $_GET["subject"];
    $body = $_GET["body"];
    writelogs("found direction={$direction},uid={$uid},email={$email},subject={$subject}", __FUNCTION__, __FILE__);
    $ldap = new clladp();
    $user = new user($uid);
    $back = new backup_query($uid);
    $mymails = $back->sql_mymails;
    if ($body != null) {
        $bodyf = " ,MATCH (`storage`.MessageBody) AGAINST ('{$body}') AS bod";
        $body = " AND MATCH (`storage`.MessageBody) AGAINST ('{$body}')>0";
        $order = " bod DESC,";
    }
    $sql_start = "SELECT `storage`.MessageID,`storage`.zDate,`storage`.subject{$bodyf} FROM `storage`,storage_recipients WHERE \n\t\t`storage`.MessageID=storage_recipients.MessageID ";
    //$sq_direction="OR (`storage`.mailfrom='{$user->mail}')";
    if ($email != null) {
        $email_sql = " AND `storage`.mailfrom LIKE '%{$email}%'";
        if ($direction == null) {
            $sq_direction = "AND (`storage`.mailfrom LIKE '%{$email}%')";
        }
    }
    if ($subject != null) {
        $subject = " AND (`storage`.subject LIKE '%{$subject}%')";
    }
    switch ($direction) {
        case null:
            $sql = "{$sql_start} AND ({$mymails}) {$sq_direction} {$subject} {$body}";
            break;
        case "TO":
            $sql = "{$sql_start} AND ({$mymails}) {$email_sql} {$subject} {$body}";
            break;
        case "FROM":
            $email_sql = " AND (`storage_recipients`.recipient LIKE '%{$email}%')";
            $sql = "{$sql_start} AND (`storage`.mailfrom='{$user->mail}') {$email_sql} {$subject} {$body}";
            break;
    }
    $sql = $sql . " ORDER BY {$order}`storage`.zDate DESC LIMIT 0,50";
    writelogs($sql, __FUNCTION__, __FILE__);
    $s = new mysql();
    $results = $s->QUERY_SQL($sql, "artica_backup");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $arr[$ligne["MessageID"]] = array($ligne["zDate"], $ligne["subject"]);
    }
    if (!is_array($arr)) {
        echo "None...<br><br><code>{$sql}</code>";
        exit;
    }
    $html = "<table style='width:100%'>\n<tr>\n\t<th>{date}</th>\n\t<th>{subject}</th>\n</tr>\n\n";
    while (list($num, $array) = each($arr)) {
        $html = $html . "\n\t<tr " . CellRollOver("ShowBackupMail('{$num}')") . " >\n\t<td nowrap valign='top' style='border-bottom:1px dotted #CCCCCC;padding:3px'>{$array[0]}</td>\n\t<td style='border-bottom:1px dotted #CCCCCC;padding:3px'>{$array[1]}</td>\n\t</tr>\n\t\n\t";
    }
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html . "</table><br><br><code>{$sql}</code>");
}
Exemple #25
0
function rebuild_imapsync(){
	$q=new mysql();
	writelogs("DELETE imapsync table...",__FUNCTION__,__FILE__,__LINE__);
	$sql="DROP TABLE `imapsync`";
	$q->QUERY_SQL($sql,"artica_backup");
	if(!$q->ok){echo "$sql:: $q->mysql_error\n";}
	writelogs("Rebuild tables",__FUNCTION__,__FILE__,__LINE__);
	$q->BuildTables();
	}
function page()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $t = time();
    $sql = "SELECT zDate,not_categorized FROM tables_day ORDER BY zDate";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $xdata[] = $ligne["tdate"];
        $ydata[] = $ligne["not_categorized"];
    }
    $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . ".png";
    $gp = new artica_graphs();
    $gp->width = 880;
    $gp->height = 350;
    $gp->filename = "{$targetedfile}";
    $gp->xdata = $xdata;
    $gp->ydata = $ydata;
    $gp->y_title = null;
    $gp->x_title = $tpl->_ENGINE_parse_body("{days}");
    $gp->title = null;
    $gp->margin0 = true;
    $gp->Fillcolor = "blue@0.9";
    $gp->color = "146497";
    $gp->line_green();
    if (!is_file($targetedfile)) {
        writelogs("Fatal \"{$targetedfile}\" no such file!", __FUNCTION__, __FILE__, __LINE__);
        $targetedfile = "img/kas-graph-no-datas.png";
    }
    $sql = "SELECT zDate,not_categorized FROM tables_day WHERE not_categorized>0 ORDER BY zDate DESC";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>";
    }
    $c = 0;
    $table = null;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $c++;
        $table = $table . "<tr>\n\t\t\t<td style='font-size:14px' width=99%><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.visited.php?day={$ligne["zDate"]}&onlyNot=yes');\" style='font-size:14px;text-decoration:underline'>{$ligne["zDate"]}</a></td>\n\t\t\t<td style='font-size:14px' width=1%><strong>{$ligne["not_categorized"]}</strong></td>\n\t\t</tr>\n\t\t";
        if ($c > 10) {
            $c = 0;
            $tr[] = "<table style='width:20%' class=form><tbody>{$table}</tbody></table>";
            $table = null;
        }
    }
    if ($c > 0) {
        $tr[] = "<table style='width:20%' class=form><tbody>{$table}</tbody></table>";
    }
    $t = time();
    echo $tpl->_ENGINE_parse_body("\n\t<div id='{$t}'>\n\t<div style='font-size:18px'>{not_categorized}/{days}</div>\n\t\n\t<center>\n\t<div style='margin:8px;float-right;width:100%'>" . button("{analyze}", "NoCategorizedAnalyze()") . "</div>\n\t<img src='{$targetedfile}?t=" . time() . "'>\n\t</center>\n\t" . CompileTrGen($tr, 6) . "\n\t</div>\n\t</div>\n\t<script>\n\t\t\n\tvar x_NoCategorizedAnalyze= function (obj) {\n\t\t\tvar tempvalue=obj.responseText;\n\t\t\tif(tempvalue.length>3){alert(tempvalue)};\n\t\t\tif(document.getElementById('squid_stats_consumption')){\n\t    \t\tRefreshTab('squid_stats_consumption');\n\t\t\t}\n\t\t\t\n\t\t\tif(document.getElementById('squid_stats_central')){\n\t    \t\tRefreshTab('squid_stats_central');\n\t\t\t}\t\t\t\n\t\t}\t\n\n\t\tfunction NoCategorizedAnalyze(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('NoCategorizedAnalyze','yes');\n\t\t\tAnimateDiv('{$t}');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_NoCategorizedAnalyze);\n\t\t}\n\t</script>\t\t\n\t\n\t");
}
function SaveForm()
{
    $main = new main_cf();
    while (list($num, $val) = each($_GET)) {
        writelogs("{$num}=\"{$val}\"", __FUNCTION__, __FILE__);
        $main->main_array[$num] = $val;
    }
    $main->save_conf();
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body('{success}');
}
Exemple #28
0
function TEMPLATE_SAVE()
{
    $sql = "UPDATE squid_templates SET `TEMPLATE_DATA`='{$_POST["TEMPLATE_DATA"]}' WHERE `TEMPLATE_NAME`='{$_POST["TEMPLATE_NAME"]}'";
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        writelogs("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?squid-templates=yes");
}
Exemple #29
0
function PostfixLogs()
{
    $sock = new sockets();
    $datas = $sock->getfile('cyrus_events');
    writelogs(strlen($datas) . ' bytes', __FUNCTION__, __FILE__);
    $tbl = explode("\n", $datas);
    $tbl = array_reverse($tbl, TRUE);
    while (list($num, $val) = each($tbl)) {
        $html = $html . "<div style='color:white;margin-bottom:3px;font-size:10px'><code>{$val}</code></div>";
    }
    echo RoundedBlack($html);
}
function showlist()
{
    $q = new mysql_squid_builder();
    $tablesrc = "quotaday_" . date("Ymd");
    $table = "(SELECT SUM(size) as size,ipaddr,familysite,uid,MAC FROM `{$tablesrc}` GROUP BY ipaddr,familysite,uid,MAC) as t";
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $q = new mysql_squid_builder();
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events"));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events"));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (!$q->ok) {
        json_error_show($q->mysql_error, 1);
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error, 1);
    }
    //if(mysql_num_rows($results)==0){$data['rows'][] = array('id' => $ligne[time()],'cell' => array($sql,"", "",""));}
    while ($ligne = mysql_fetch_assoc($results)) {
        $ipaddr = $ligne["ipaddr"];
        $mac = $ligne["MAC"];
        $familysite = $ligne["familysite"];
        $uid = $ligne["uid"];
        $size = FormatBytes($ligne["size"] / 1024);
        $data['rows'][] = array('id' => md5(serialize($ligne)), 'cell' => array("<span style='font-size:14px'>{$uid}</span>", "<span style='font-size:14px'>{$ipaddr}</span>", "<span style='font-size:14px'>{$mac}</span>", "<span style='font-size:14px'>{$familysite}</span>", "<span style='font-size:14px'>{$size}</span>"));
    }
    echo json_encode($data);
}