Exemple #1
0
function CategorizeAWebSite($www, $category)
{
    $md5 = md5($www . $category);
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $uuid = $GLOBALS["UUID"];
    $category_table = $q->category_transform_name($category);
    $sql_add = "INSERT IGNORE INTO categorize (zmd5,zDate,category,pattern,uuid) VALUES('{$md5}',NOW(),'{$category}','{$www}','{$uuid}')";
    $sql_add2 = "INSERT IGNORE INTO category_{$category_table} (zmd5,zDate,category,pattern,uuid) VALUES('{$md5}',NOW(),'{$category}','{$www}','{$uuid}')";
    $q->QUERY_SQL($sql_add);
    if (!$q->ok) {
        echo $q->mysql_error . "\n{$sql_add}\n";
        return false;
    }
    $q->QUERY_SQL($sql_add2);
    if (!$q->ok) {
        echo $q->mysql_error . "\n{$sql_add2}\n";
        return false;
    }
    $categories = $q->GET_CATEGORIES($www, true);
    if ($categories != null) {
        $sql = "UPDATE visited_sites SET category='{$categories}' WHERE sitename='{$www}'";
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            echo $q->mysql_error . "\n{$sql}\n";
            return false;
        }
    }
}
Exemple #2
0
function popup()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
    if ($SquidPerformance > 1) {
        echo $tpl->_ENGINE_parse_body(FATAL_ERROR_SHOW_128("{artica_statistics_disabled}"));
        return;
    }
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $type = $tpl->_ENGINE_parse_body("{type}");
    $browsers = $tpl->_ENGINE_parse_body("{browsers}");
    $items = $tpl->_ENGINE_parse_body("{items}");
    $add = $tpl->_ENGINE_parse_body("{add}");
    $delete_group_ask = $tpl->javascript_parse_text("{inputbox delete group}");
    $title = $tpl->javascript_parse_text("{browsers}");
    $t = time();
    $table_width = 630;
    $table_height = 450;
    $buttons = "buttons : [\n\t{name: '{$new_group}', bclass: 'add', onpress : AddGroup},\n\t\t],\t";
    $buttons = null;
    $html = $tpl->_ENGINE_parse_body("") . "\n\t<table class='table-{$t}' style='display: none' id='table-{$t}' style='width:99%'></table>\n<script>\n\$(document).ready(function(){\n\$('#table-{$t}').flexigrid({\n\turl: '{$page}?list=yes',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$browsers}', name : 'pattern', width : 904, sortable : true, align: 'left'},\n\t\t{display: '{$add}', name : 'pattern', width : 81, sortable : false, align: 'center'},\n\t\t\n\t\t\n\t],\n\n\tsearchitems : [\n\t\t{display: '{$browsers}', name : 'pattern'},\n\t\t],\n\tsortname: 'pattern',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '<span style=font-size:18px>{$title}</span>',\n\tuseRp: true,\n\trp: 15,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: {$table_height},\n\tsingleSelect: true\n\t\n\t});   \n});\n</script>\n\t";
    echo $html;
}
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 #4
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 reconstruct()
{
    $database = $_POST["reconstruct"];
    $tpl = new templates();
    if ($database == "squidlogs") {
        $q = new mysql_squid_builder();
        $q->CheckTables();
        echo $tpl->javascript_parse_text("{success}");
        return;
    }
    $q = new mysql();
    $q->BuildTables();
    echo $tpl->javascript_parse_text("{success}");
}
function repair_table_days()
{
    $q = new mysql_squid_builder();
    echo "Delete table tables_day\n";
    $q->DELETE_TABLE("tables_day");
    echo "Check databases...\n";
    $q->CheckTables();
    $array = $q->LIST_TABLES_dansguardian_events();
    while (list($tablename, $none) = each($array)) {
        echo $tablename . "\n";
        $time = $q->TIME_FROM_DANSGUARDIAN_EVENTS_TABLE($tablename);
        $date = date("Y-m-d", $time);
        $q->QUERY_SQL("INSERT IGNORE INTO tables_day (tablename,zDate) VALUES ('{$tablename}','{$date}')");
    }
}
function myhome1()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $ip = $_SERVER["REMOTE_ADDR"];
    $you_need_to_update_your_ip_address = $tpl->_ENGINE_parse_body("{you_need_to_update_your_ip_address}");
    $update_your_ip_address = $tpl->_ENGINE_parse_body("{update_your_ip_address}");
    $q = new mysql_squid_builder();
    $tcip = new networking();
    $tcp_array = $tcip->ALL_IPS_GET_ARRAY();
    $prefix = "http";
    $port = $_SERVER["SERVER_PORT"];
    if ($_SERVER["HTTPS"] == "on") {
        $prefix = "https";
    }
    if ($port == "80" or $port == "443") {
        $port = null;
    } else {
        $port = ":{$port}";
    }
    $orignaluri = "{$prefix}://{$_SERVER["SERVER_NAME"]}{$port}";
    $q->QUERY_SQL("UPDATE usersisp SET wwwname='{$orignaluri}' WHERE userid='{$_SESSION["uid"]}'");
    if (strpos(" {$q->mysql_error}", "Unknown column") > 0) {
        $q->CheckTables();
        echo "<script>\n\t\tLoadAjax('myhome1','{$page}?myhome1=yes');\n\t\t</script>";
    }
    if (!$q->ok) {
        echo "<strong style='color:#D20404'>{$q->mysql_error}</strong>";
    }
    $sql = "SELECT publicip,wwwname FROM usersisp WHERE userid='{$_SESSION["uid"]}'";
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql));
    if ($ligne["publicip"] != null) {
        $hostname = gethostbyaddr($ip);
        if ($tcp_array[$ligne["publicip"]] != null) {
            $hostname = null;
            $hostname = "<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t<td width=1%><img src='img/warning-panneau-32.png'>\n\t\t\t<td><strong style='color:#D20404'>\n\t\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:UpdatePublicIPBox();\" style='font-size:12px;text-decoration:underline;color:#D20404'>\n\t\t\t\t\t{$you_need_to_update_your_ip_address}</a>\n\t\t\t\t</td>\n\t\t\t\t\n\t\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t\t";
        }
    } else {
        $hostname = "<table style='width:100%'>\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/warning-panneau-32.png'>\n\t\t\t<td><strong style='color:#D20404'>\n\t\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:UpdatePublicIP();\" style='font-size:12px;text-decoration:underline;color:#D20404'>\n\t\t\t\t\t{$you_need_to_update_your_ip_address}</a>\n\t\t\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t\t";
    }
    $html = "\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{public_ip}:</td>\n\t\t<td><strong style='font-size:14px'><a href=\"javascript:blur();\" OnClick=\"javascript:UpdatePublicIPBox();\" style='font-size:14px;text-decoration:underline;'>{$ligne["publicip"]}</a></td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{hostname}:</td>\n\t\t<td><strong style='font-size:14px'>{$hostname}</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{howto}:</ \n\t\n\t\n\t</table>\n\t\n\t<script>\n\t\tvar x_UpdatePublicIP= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);}\n\t\t\tLoadAjax('myhome1','{$page}?myhome1=yes');\n\t\t\t}\t\t\n\t\n\t\n\t\tfunction UpdatePublicIP(){\t\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('update-public-ip','yes');\n\t\t\tAnimateDiv('myhome1');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_UpdatePublicIP);\t\t\n\t\t}\n\t\t\n\t\tfunction UpdatePublicIPBox(){\n\t\t\tYahooWin2('445','{$page}?UpdatePublicIPBox=yes','{$update_your_ip_address}');\n\t\t}\n\t\t\n\t\tLoadAjax('myhome2','{$page}?myhome2=yes');\n\t\t\n\t</script>\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}
function popup()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $mac = $tpl->javascript_parse_text("{MAC}");
    $enabled = $tpl->javascript_parse_text("{enabled}");
    $pattern = $tpl->javascript_parse_text("{pattern}");
    $hostname = $tpl->javascript_parse_text("{hostname}");
    $Apply = $tpl->javascript_parse_text("{apply}");
    $description = $tpl->javascript_parse_text("{description} / {allowed}");
    $title = $tpl->javascript_parse_text("{members}: {internet_access_restrictions}");
    $t = time();
    $table_width = 630;
    $table_height = 450;
    $buttons = "buttons : [\n\t{name: '{$Apply}', bclass: 'Apply', onpress : Apply{$t}},\n\t\t],\t";
    $html = $tpl->_ENGINE_parse_body("") . "\n\t<table class='table-{$t}' style='display: none' id='table-{$t}' style='width:99%'></table>\n<script>\n\$(document).ready(function(){\n\$('#table-{$t}').flexigrid({\n\turl: '{$page}?list=yes&t={$t}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$mac}', name : 'MAC', width : 152, sortable : true, align: 'left'},\n\t\t{display: '{$hostname}', name : 'hostname', width : 315, sortable : false, align: 'left'},\n\t\t{display: '{$description}', name : 'description', width : 452, sortable : false, align: 'left'},\n\t\t{display: '{$enabled}', name : 'enabled', width : 54, sortable : false, align: 'left'},\n\t\t{display: '&nbsp;', name : 'delete', width : 60, sortable : false, align: 'left'},\n\t\t\n\t\t\n\t\t\n\t],\n\n\tsearchitems : [\n\t\t{display: '{$mac}', name : 'MAC'},\n\t\t],\n\tsortname: 'MAC',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '<span style=font-size:18px>{$title}</span>',\n\tuseRp: true,\n\trp: 15,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: {$table_height},\n\tsingleSelect: true\n\t\n\t});   \n});\n\nvar xRtResProxyEnable= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\t\$('#table-{$t}').flexReload();\n\t}\n\nfunction BlksProxyDelete(pattern){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('delete-pattern',pattern);\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('squid.hosts.blks.php', 'POST',xBlksProxyDelete);\n}\n\n\nfunction Apply{$t}(){\n\tLoadjs('squid.computer.access.progress.php');\n}\n\n\n\nfunction RtResProxyEnable(pattern,id){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById(id).checked){XHR.appendData('enabled',1);}else{XHR.appendData('enabled',0);}\n\t\tXHR.appendData('enable-pattern',pattern);\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('{$page}', 'POST',xRtResProxyEnable);\n}\n</script>\n\t";
    echo $html;
}
function popup()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $type = $tpl->javascript_parse_text("{type}");
    $browsers = $tpl->javascript_parse_text("{browsers}");
    $pattern = $tpl->javascript_parse_text("{pattern}");
    $items = $tpl->javascript_parse_text("{items}");
    $add = $tpl->javascript_parse_text("{add}");
    $description = $tpl->javascript_parse_text("{description}");
    $title = $tpl->javascript_parse_text("{blocked_members}");
    $t = time();
    $table_width = 630;
    $table_height = 450;
    $buttons = "buttons : [\n\t{name: '{$new_group}', bclass: 'add', onpress : AddGroup},\n\t\t],\t";
    $buttons = null;
    $html = $tpl->_ENGINE_parse_body("") . "\n\t<table class='table-{$t}' style='display: none' id='table-{$t}' style='width:99%'></table>\n<script>\n\$(document).ready(function(){\n\$('#table-{$t}').flexigrid({\n\turl: '{$page}?list=yes',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$type}', name : 'PatternType', width : 231, sortable : true, align: 'left'},\n\t\t{display: '{$pattern}', name : 'pattern', width : 231, sortable : false, align: 'left'},\n\t\t{display: '{$description}', name : 'description', width : 231, sortable : false, align: 'left'},\n\t\t{display: '&nbsp;', name : 'enable', width : 60, sortable : false, align: 'left'},\n\t\t{display: '&nbsp;', name : 'delete', width : 60, sortable : false, align: 'left'},\n\t\t\n\t\t\n\t\t\n\t],\n\n\tsearchitems : [\n\t\t{display: '{$pattern}', name : 'pattern'},\n\t\t],\n\tsortname: 'pattern',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '<span style=font-size:18px>{$title}</span>',\n\tuseRp: true,\n\trp: 15,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: {$table_height},\n\tsingleSelect: true\n\t\n\t});   \n});\n\n\tvar xBlksProxyDelete= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\t\$('#table-{$t}').flexReload();\n\t}\n\nfunction BlksProxyDelete(pattern){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('delete-pattern',pattern);\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('squid.hosts.blks.php', 'POST',xBlksProxyDelete);\n}\n\n\n\nfunction BlksProxyEnable(pattern,id){\n\t\tvar XHR = new XHRConnection();\n\t\tif(document.getElementById(id).checked){XHR.appendData('enabled',1);}else{XHR.appendData('enabled',0);}\n\t\tXHR.appendData('enable-pattern',pattern);\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('squid.hosts.blks.php', 'POST');\n}\n</script>\n\t";
    echo $html;
}
function main_table()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $type = $tpl->_ENGINE_parse_body("{type}");
    $ipaddr = $tpl->_ENGINE_parse_body("{ipaddr}");
    $sitename = $tpl->_ENGINE_parse_body("{websites}");
    $uid = $tpl->_ENGINE_parse_body("{member}");
    $MAC = $tpl->javascript_parse_text("{MAC}");
    $size = $tpl->javascript_parse_text("{size}");
    $title = $tpl->javascript_parse_text("{realtime_flow} {members} {today} {time}:" . date("H") . "h");
    $t = time();
    $table_width = 630;
    $table_height = 450;
    $buttons = "buttons : [\n{name: '{$new_group}', bclass: 'add', onpress : AddGroup},\n],\t";
    $buttons = null;
    $html = $tpl->_ENGINE_parse_body("") . "\n<table class='table-{$t}' style='display: none' id='table-{$t}' style='width:99%'></table>\n<script>\n\$(document).ready(function(){\n\t\t\$('#table-{$t}').flexigrid({\n\t\turl: '{$page}?list=yes',\n\t\tdataType: 'json',\n\t\tcolModel : [\n\t\t{display: '{$sitename}', name : 'sitename', width : 230, sortable : true, align: 'left'},\n\t\t{display: '{$ipaddr}', name : 'ipaddr', width : 120, sortable : true, align: 'left'},\n\t\t{display: '{$uid}', name : 'uid', width : 230, sortable : true, align: 'left'},\n\t\t{display: '{$MAC}', name : 'MAC', width : 230, sortable : true, align: 'left'},\n\t\t{display: '{$size}', name : 'size', width : 150, sortable : true, align: 'right'},\n\n\n\t\t],\n\n\t\tsearchitems : [\n\t\t{display: '{$ipaddr}', name : 'ipaddr'},\n\t\t{display: '{$uid}', name : 'uid'},\n\t\t{display: '{$MAC}', name : 'MAC'},\n\t\t],\n\t\tsortname: 'size',\n\t\tsortorder: 'desc',\n\t\tusepager: true,\n\t\ttitle: '<span style=font-size:18px>{$title}</span>',\n\t\tuseRp: true,\n\t\trp: 15,\n\t\tshowTableToggleBtn: false,\n\t\twidth: '99%',\n\t\theight: {$table_height},\n\t\tsingleSelect: true\n\n});\n});\n</script>\n";
    echo $html;
}
function popup()
{
    $page = CurrentPageName();
    $sock = new sockets();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $tOrg = $_GET["t"];
    $t = $_GET["tt"];
    $mainrule = $_GET["mainrule"];
    $rule = $tpl->_ENGINE_parse_body("{rule}");
    $new_rule = $tpl->_ENGINE_parse_body("{new_rule}");
    $groups = $tpl->_ENGINE_parse_body("{proxy_objects}");
    $delete_rule_ask = $tpl->javascript_parse_text("{delete_rule_ask}");
    $period = $tpl->javascript_parse_text("{period}");
    $budget = $tpl->_ENGINE_parse_body("{budget}");
    $enabled = $tpl->javascript_parse_text("{enabled}");
    $delete = $tpl->javascript_parse_text("{delete}");
    $tt = time();
    $html = "\n\t\t<table class='table-{$tt}' style='display: none' id='table-{$tt}' style='width:99%'></table>\n\t\t<script>\n\t\tvar DeleteSquidAclGroupTemp{$tt}=0;\n\t\t\$(document).ready(function(){\n\t\t\$('#table-{$tt}').flexigrid({\n\t\turl: '{$page}?sessions-rules-list=yes&t={$t}&tOrg={$tOrg}&mainrule={$mainrule}&tt={$tt}',\n\t\tdataType: 'json',\n\t\tcolModel : [\n\t\t{display: '{$rule}', name : 'rulename', width : 300, sortable : true, align: 'left'},\n\t\t{display: '{$budget}', name : 'budget', width : 76, sortable : true, align: 'left'},\n\t\t{display: '{$period}', name : 'period', width : 76, sortable : true, align: 'left'},\n\t\t{display: '{$enabled}', name : 'enabled', width : 31, sortable : true, align: 'center'},\n\t\t{display: '{$delete}', name : 'del', width : 31, sortable : false, align: 'center'},\n\t\t],\n\t\tbuttons : [\n\t\t{name: '{$new_rule}', bclass: 'add', onpress : AddSessionRule{$tt}},\n\t\t],\n\t\tsearchitems : [\n\t\t{display: '{$rule}', name : 'QuotaName'},\n\t\t],\n\t\tsortname: 'ID',\n\t\tsortorder: 'desc',\n\t\tusepager: true,\n\t\ttitle: '',\n\t\tuseRp: true,\n\t\trp: 15,\n\t\tshowTableToggleBtn: false,\n\t\twidth: 600,\n\t\theight: 450,\n\t\tsingleSelect: true\n\t\n\t});\n\t});\n\tfunction AddSessionRule{$tt}() {\n\t\tLoadjs('{$page}?session-rule-js=yes&ID=-1&t={$t}&tOrg={$tOrg}&tt={$tt}&mainrule={$mainrule}');\n\t\n\t}\n\t\n\tvar x_DeleteSquidAclRule{$tt}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\t\$('#rowacl'+DeleteSquidAclGroupTemp{$tt}).remove();\n\t\t\$('#table-{$tOrg}').flexReload();\n\t\t\$('#table-{$t}').flexReload();\t\t\n\t}\n\tvar x_EnableDisableAclRule{$tt}= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\t\$('#table-{$tOrg}').flexReload();\n\t\t\$('#table-{$t}').flexReload();\n\t\t\$('#table-{$tt}').flexReload();\n\t}\t\n\t\n\n\tfunction DeleteSessionRule{$tt}(ID){\n\t\tDeleteSquidAclGroupTemp{$tt}\n\t\tif(confirm('{$delete_rule_ask} :'+ID)){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('acl-rule-delete', ID);\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_DeleteSquidAclRule{$tt});\t\n\t\t\t\n\t\t\t}\n\t\n\t}\n\t\n\tfunction EnableDisableSessionRule{$tt}(ID){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('acl-rule-enable', ID);\n\t\tif(document.getElementById('sessionid_'+ID).checked){XHR.appendData('enable', '1');}else{XHR.appendData('enable', '0');}\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_EnableDisableAclRule{$tt});\n\t}\n\t\n\t\n\t\n\t\n\t</script>\n\t\n\t";
    echo $html;
}
function page()
{
    $ID = $_GET["ID"];
    $page = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $type = $tpl->_ENGINE_parse_body("{type}");
    $description = $tpl->_ENGINE_parse_body("{description}");
    $new_group = $tpl->_ENGINE_parse_body("{new_proxy_object}");
    $items = $tpl->_ENGINE_parse_body("{items}");
    $delete_group_ask = $tpl->javascript_parse_text("{inputbox delete group}");
    $wpad = null;
    if (isset($_GET["wpad"])) {
        $wpad = "&wpad=yes";
    }
    $t = time();
    $buttons = "\n\tbuttons : [\n\t{name: '<strong style=font-size:18px>{$new_group}</strong>', bclass: 'add', onpress : AddGroup{$t}},\n\t],";
    $html = $tpl->_ENGINE_parse_body("") . "\n\t<input type='hidden' id='TABLE_BROWSE_ACL_GROUPS_ID' value='table-{$t}'>\n\t<table class='table-{$t}' style='display: none' id='table-{$t}' style='width:99%'></table>\n<script>\nvar DeleteSquidAclGroupTemp=0;\n\$(document).ready(function(){\n\$('#table-{$t}').flexigrid({\n\turl: '{$page}?groups-list=yes&callback={$_GET["callback"]}&t={$t}&FilterType={$_GET["FilterType"]}{$wpad}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '{$description}', name : 'GroupName', width : 277, sortable : true, align: 'left'},\n\t\t{display: '{$time}', name : 'GroupType', width : 119, sortable : true, align: 'left'},\n\t\t{display: '{$items}', name : 'items', width : 67, sortable : false, align: 'center'},\n\t\t{display: '', name : 'none3', width : 31, sortable : false, align: 'left'},\n\t\t\n\t],\n\t{$buttons}\n\tsearchitems : [\n\t\t{display: '{$description}', name : 'GroupName'},\n\t\t],\n\tsortname: 'GroupName',\n\tsortorder: 'asc',\n\tusepager: true,\n\ttitle: '',\n\tuseRp: true,\n\trp: 15,\n\tshowTableToggleBtn: false,\n\twidth: 570,\n\theight: 350,\n\tsingleSelect: true\n\t\n\t});   \n});\nfunction AddGroup{$t}() {\n\tLoadjs('squid.acls.groups.php?AddGroup-js=yes&ID=-1&table-acls-t={$t}&FilterType={$_GET["FilterType"]}&callback={$_GET["callback"]}{$wpad}');\n\t\n}\t\n\nfunction RefreshSquidGroupTable(){\n\n\tif(document.getElementById('GLOBAL_SSL_CENTER_ID')){\n\t\t\$('#'+document.getElementById('GLOBAL_SSL_CENTER_ID').value).flexReload();\n\t}\n\tif(document.getElementById('SSL_RULES_GROUPS_ID')){\n\t\t\$('#'+document.getElementById('SSL_RULES_GROUPS_ID').value).flexReload();\n\t}\t\n\t\n\tif(document.getElementById('flexRT-refresh-1')){ \n\t\t\$('#'+document.getElementById('flexRT-refresh-1').value).flexReload();\n\t}\n\t\n\t\$('#table-{$t}').flexReload();\n\t\n}\n\n\n\tvar x_DeleteSquidAclGroup= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\tif(document.getElementById('main_filter_rule_edit')){RefreshTab('main_filter_rule_edit');}\n\t\tif(document.getElementById('main_dansguardian_tabs')){RefreshTab('main_dansguardian_tabs');}\n\t\t\$('#rowtime'+TimeRuleIDTemp).remove();\n\t}\n\t\n\tvar x_EnableDisableGroup= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\t\n\t\t\n\t}\t\n\t\n\tfunction DeleteSquidAclGroup(ID){\n\t\tDeleteSquidAclGroupTemp=ID;\n\t\tif(confirm('{$delete_group_ask} :'+ID)){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('DeleteGroup', 'yes');\n\t\t\tXHR.appendData('ID', ID);\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_DeleteSquidAclGroup);\n\t\t}  \t\t\n\t}\n\n\tvar x_DeleteSquidAclGroup= function (obj) {\n\t\tvar res=obj.responseText;\n\t\tif(res.length>3){alert(res);return;}\n\t\t\$('#rowgroup'+DeleteSquidAclGroupTemp).remove();\n\t}\n\t\n\tfunction EnableDisableGroup(ID){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('EnableGroup', 'yes');\n\t\tXHR.appendData('ID', ID);\n\t\tif(document.getElementById('groupid_'+ID).checked){XHR.appendData('enable', '1');}else{XHR.appendData('enable', '0');}\n\t\tXHR.sendAndLoad('{$page}', 'POST',x_EnableDisableGroup);  \t\t\n\t}\t\t\n\t\n\t\n\n\t\n</script>\n\t\n\t";
    echo $html;
}
function rebuild_tables(){
	$q=new mysql_squid_builder();
	$q->QUERY_SQL("DROP TABLE `wpad_rules`");
	$q->QUERY_SQL("DROP TABLE `wpad_sources_link`");
	$q->QUERY_SQL("DROP TABLE `wpad_white_link`");
	$q->QUERY_SQL("DROP TABLE `wpad_destination`");
	$q->CheckTables(null,true);
	
}
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 report_new_save()
{
    $q = new mysql_squid_builder();
    $q->CheckTables(null, true);
    $zmd5 = md5(time());
    $_POST["report_new"] = mysql_escape_string2($_POST["report_new"]);
    $q->QUERY_SQL("INSERT IGNORE INTO squid_reports (report_name,zmd5) VALUES ('{$_POST["report_new"]}','{$zmd5}')");
    if (!$q->ok) {
        echo $q->mysql_error;
    }
}
Exemple #17
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 hosts(){
	$tpl=new templates();
	$MyPage=CurrentPageName();
	$q=new mysql_squid_builder();
	
	$t=$_GET["t"];
	$search='%';
	$table="dnsmasq_blacklist";
	
	
	$page=1;
	$FORCE_FILTER=null;
	
	$total=0;
	
	
	if(isset($_POST["sortname"])){if($_POST["sortname"]<>null){$ORDER="ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";}}
	if(isset($_POST['page'])) {$page = $_POST['page'];}
	
	$searchstring=string_to_flexquery();
	
	if($searchstring<>null){
		$sql="SELECT COUNT(*) as TCOUNT FROM $table WHERE 1 $FORCE_FILTER $searchstring";
		$ligne=mysql_fetch_array($q->QUERY_SQL($sql));
		$total = $ligne["TCOUNT"];
	
	}else{
		$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 data}");
	
	$data = array();
	$data['page'] = $page;
	$data['total'] = $total;
	$data['rows'] = array();
	
	if(!$q->ok){
		if(strpos($q->mysql_error, "doesn't exist")>0){$q->CheckTables();$results = $q->QUERY_SQL($sql);}
	}
		
	if(!$q->ok){	json_error_show($q->mysql_error."<br>$sql");}
	if(mysql_num_rows($results)==0){json_error_show("no data");}
	
	$fontsize="16";
	
	while ($ligne = mysql_fetch_assoc($results)) {
		$color="black";
		$delete=imgsimple("delete-32.png",null,"Loadjs('$MyPage?delete-host-js=yes&ID={$ligne["ID"]}&t=$t&tt={$_GET["tt"]}')");
	
		
		
		$hostname=$ligne["hostname"];
		
	
	$data['rows'][] = array(
			'id' => $ligne['ID'],
			'cell' => array(
					"<span style='font-size:{$fontsize}px;font-weight:bold;color:$color'>$hostname</a><br><i style='font-size:12px'>&nbsp;$grouptype</i></span>",
					"<span style='font-size:{$fontsize}px;font-weight:normal;color:$color'>$delete</span>",)
	);
	}
	
	
	echo json_encode($data);
	
	}
function start($xtime = 0)
{
    $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";
    if ($GLOBALS["VERBOSE"]) {
        echo "Timefile = {$timefile}\n";
    }
    $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 (!$GLOBALS["SCHEDULED"]) {
            if ($timeexec < 2880) {
                return;
            }
        }
        $mypid = getmypid();
        @file_put_contents($pidfile, $mypid);
    }
    @unlink($timefile);
    @file_put_contents($timefile, time());
    build_progress("Starting refreshing...", 10);
    $sql = "SELECT tablename, familyday,DATE_FORMAT(zDate,'%Y%m%d') AS `suffix` FROM tables_day \n\t\t\tWHERE familyday=0 AND DAY(zDate)<DAY(NOW()) AND YEAR(zDate) = YEAR(NOW()) AND MONTH(zDate) = MONTH(NOW())";
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo mysql_num_rows($results) . " rows\n";
    }
    $c = 0;
    $Max = mysql_num_rows($results);
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $worktable = "{$ligne["suffix"]}_visited";
        $SourceTable = "{$ligne["suffix"]}_hour";
        $desttable = "{$ligne["suffix"]}_family";
        $c++;
        $prc = $c / $Max * 100;
        $prc = round($prc);
        if ($prc > 80) {
            $prc = 80;
        }
        build_progress("Checking ...{$worktable} {$desttable}", $prc);
        if (!$q->TABLE_EXISTS($worktable)) {
            if (!$q->TABLE_EXISTS($SourceTable)) {
                $q->QUERY_SQL("UPDATE tables_day SET familyday=1 WHERE tablename='{$ligne["tablename"]}'");
                continue;
            }
            if (!repair_visited_from_sources_table($SourceTable, $worktable)) {
                continue;
            }
        }
        if (!perform($worktable, $desttable)) {
            continue;
        }
        $q->QUERY_SQL("UPDATE tables_day SET familyday=1 WHERE tablename='{$ligne["tablename"]}'");
    }
    build_progress("Calculating master table", 80);
    CONDENSED();
    build_progress("Done", 100);
}
function container_list()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $search = '%';
    $table = "squid_storelogs";
    $page = 1;
    $ORDER = "ORDER BY ID DESC";
    $sock = new sockets();
    $t = $_GET["t"];
    if (!$q->TABLE_EXISTS($table)) {
        $q->CheckTables();
    }
    $total = 0;
    if ($q->COUNT_ROWS($table, $database) == 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"] = "*" . $_POST["query"] . "*";
        $_POST["query"] = str_replace("**", "*", $_POST["query"]);
        $_POST["query"] = str_replace("**", "*", $_POST["query"]);
        $_POST["query"] = str_replace("*", "%", $_POST["query"]);
        $search = $_POST["query"];
        $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')";
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        if (!$q->ok) {
            json_error_show($q->mysql_error);
        }
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        if (!$q->ok) {
            json_error_show($q->mysql_error);
        }
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    if ($OnlyEnabled) {
        $limitSql = null;
    }
    $sql = "SELECT `ID`,`filename`,`fileext`,`filesize`,`Compressedsize`,`filetime` FROM `{$table}` WHERE 1 {$searchstring} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error);
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $events = "&nbsp;";
        $md5 = md5(serialize($ligne) . $t);
        $span = "<span style='font-size:16px'>";
        $delete = imgtootltip("delete-24.png", "{delete} {$ligne['ID']}", "LogsCsvDelte{$t}('{$ligne['ID']}','{$md5}')");
        $jsEdit = "Loadjs('{$MyPage}?Rotate-js=yes&ID={$ligne['taskid']}&t={$t}');";
        $jstask = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$jsEdit}\"\r\n\t\t style='font-size:16px;font-weight:bold;color:{$color};text-decoration:underline'>";
        $jslloop = "Loadjs('{$MyPage}?log-js=yes&filename={$ligne['filename']}&t={$t}&ID={$ligne['ID']}');";
        $view = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$jslloop}\"\r\n\t\t style='font-size:16px;font-weight:bold;color:{$color};text-decoration:underline'>";
        if ($ligne["filesize"] > 1024) {
            $ligne["filesize"] = FormatBytes($ligne["filesize"] / 1024);
        } else {
            $ligne["filesize"] = $ligne["filesize"] . " Bytes";
        }
        if ($ligne["Compressedsize"] > 1024) {
            $ligne["Compressedsize"] = FormatBytes($ligne["Compressedsize"] / 1024);
        } else {
            $ligne["Compressedsize"] = $ligne["Compressedsize"] . " Bytes";
        }
        $time = strtotime($ligne['filetime']);
        $distance = distanceOfTimeInWords($time, time(), false);
        $img = "ext/unknown_small.gif";
        if (is_file("img/ext/{$ligne["fileext"]}_small.gif")) {
            $img = "ext/{$ligne["fileext"]}_small.gif";
        }
        $distance = $tpl->javascript_parse_text($distance);
        $data['rows'][] = array('id' => $md5, 'cell' => array("{$span}{$view}{$ligne['filetime']}</a></span>", "{$span}{$view}{$distance}</a></span>", "{$span}{$view}{$ligne["filename"]}</a></span>", "<img src='img/{$img}'>", "{$span}{$ligne["filesize"]}</a></span>", "{$span}{$ligne["Compressedsize"]}</a></span>", $delete));
    }
    echo json_encode($data);
}
function rewrite_rule_settings_save()
{
    $_POST["rulename"] = addslashes($_POST["rulename"]);
    $ID = $_POST["ID"];
    if ($ID == 0) {
        $sql = "INSERT INTO webfilters_rewriterules (enabled,rulename) VALUES('{$_POST["enabled"]}','{$_POST["rulename"]}');";
    } else {
        $sql = "UPDATE webfilters_rewriterules SET enabled={$_POST["enabled"]},rulename='{$_POST["rulename"]}' WHERE ID='{$_POST["ID"]}'";
    }
    $q = new mysql_squid_builder();
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        $q->CheckTables();
        $q->QUERY_SQL($sql);
    }
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("webfilter.php?compile-rules=yes");
}
function charter_save()
{
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $ID = $_POST["ID"];
    unset($_POST["ID"]);
    if (isset($_POST["ChartContent"])) {
        $_POST["ChartContent"] = url_decode_special_tool($_POST["ChartContent"]);
        $_POST["ChartContent"] = stripslashes($_POST["ChartContent"]);
    }
    if (isset($_POST["ChartHeaders"])) {
        $_POST["ChartHeaders"] = url_decode_special_tool($_POST["ChartHeaders"]);
        $_POST["ChartHeaders"] = stripslashes($_POST["ChartHeaders"]);
    }
    if (isset($_POST["TextIntro"])) {
        $_POST["TextIntro"] = url_decode_special_tool($_POST["TextIntro"]);
        $_POST["TextIntro"] = stripslashes($_POST["TextIntro"]);
    }
    if (isset($_POST["TextButton"])) {
        $_POST["TextButton"] = url_decode_special_tool($_POST["TextButton"]);
        $_POST["TextButton"] = stripslashes($_POST["TextButton"]);
    }
    while (list($key, $value) = each($_POST)) {
        $fields[] = "`{$key}`";
        $values[] = "'" . mysql_escape_string2($value) . "'";
        $edit[] = "`{$key}`='" . mysql_escape_string2($value) . "'";
    }
    if ($ID > 0) {
        $sql = "UPDATE itcharters SET " . @implode(",", $edit) . " WHERE ID='{$ID}'";
    } else {
        $sql = "INSERT IGNORE INTO itcharters (" . @implode(",", $fields) . ") VALUES (" . @implode(",", $values) . ")";
    }
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("squid.php?squid-k-reconfigure=yes");
}
function websites_save()
{
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $numS = $q->COUNT_ROWS("webtests");
    $f = explode("\n", $_POST["websites-add"]);
    while (list($num, $www) = each($f)) {
        $www = trim(strtolower($www));
        if (preg_match("#http:\\/\\/(.+)#", $www, $re)) {
            $www = $re[1];
        }
        writelogs("{$www}", __FUNCTION__, __FILE__, __LINE__);
        $www = str_replace("www.", "", $www);
        if (strpos($www, "/") > 0) {
            $www = substr($www, 0, strpos($www, "/"));
        }
        $d[] = $www;
    }
    if (count($d) == 0) {
        return;
    }
    while (list($num, $www) = each($d)) {
        $www = trim($www);
        if (trim($www) == null) {
            continue;
        }
        if (strpos($www, ",") > 0) {
            continue;
        }
        if (strpos($www, " ") > 0) {
            continue;
        }
        if (strpos($www, ":") > 0) {
            continue;
        }
        if (strpos($www, "%") > 0) {
            continue;
        }
        if (trim($www) == null) {
            continue;
        }
        $qA[] = "('{$www}')";
    }
    if (count($qA) > 0) {
        $q->QUERY_SQL("INSERT IGNORE INTO webtests (sitename) VALUES " . @implode(",", $qA));
        if (!$q->ok) {
            if (strpos($q->mysql_error, "doesn't exist") > 0) {
                $q->CheckTables();
            }
            $q->QUERY_SQL("INSERT IGNORE INTO webtests (sitename) VALUES " . @implode(",", $qA));
            if (!$q->ok) {
                echo $q->mysql_error;
            }
        }
    }
    $num2 = $q->COUNT_ROWS("webtests");
    $tot = $num2 - $numS;
    echo $tpl->javascript_parse_text("{$tot} {added_websites}");
    $sock = new sockets();
    $sock->getFrameWork("squid.php?categorize-tests=yes");
}
Exemple #24
0
function parseTemplate_LocalDB_receive()
{
    session_start();
    include_once dirname(__FILE__) . "/ressources/class.sockets.inc";
    include_once dirname(__FILE__) . "/ressources/class.mysql.inc";
    include_once dirname(__FILE__) . "/ressources/class.page.builder.inc";
    include_once dirname(__FILE__) . "/ressources/class.templates.inc";
    include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php";
    include_once dirname(__FILE__) . "/ressources/class.ldap.inc";
    include_once dirname(__FILE__) . "/ressources/class.user.inc";
    $user = new user($_POST["USERNAME"]);
    if ($_POST["password"] != md5($user->password)) {
        $tpl = new templates();
        echo $tpl->javascript_parse_text("{failed}: {wrong_password}");
        die;
    }
    $privs = new privileges($user->uid);
    $privileges_array = $privs->privs;
    if ($privileges_array["AllowDansGuardianBanned"] != "yes") {
        $tpl = new templates();
        echo $tpl->javascript_parse_text("{failed}: {ERROR_NO_PRIVS}");
        return;
    }
    //AllowDansGuardianBanned
    $Whitehost = $_POST["Whitehost"];
    $CLIENT = $_POST["CLIENT"];
    $MEMBER = $_POST["USERNAME"];
    $md5 = md5("{$CLIENT}{$Whitehost}{$MEMBER}");
    $sql = "INSERT IGNORE INTO webfilters_usersasks (zmd5,ipaddr,sitename,uid) \n\tVALUES ('{$md5}','{$CLIENT}','{$Whitehost}','{$MEMBER}')";
    $q = new mysql_squid_builder();
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        if (strpos($q->mysql_error, "doesn't exist") > 0) {
            $q->CheckTables();
            $q->QUERY_SQL($sql);
        }
    }
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body("{success_restart_query_in_few_seconds}");
    $sock = new sockets();
    $sock->getFrameWork("squid.php?build-smooth=yes");
}
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 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);
}
Exemple #27
0
function PaseUdfdbGuard()
{
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $count = 0;
    $total = 0;
    $tableblock = date('Ymd') . "_blocked";
    $PREFIX = "INSERT INTO `{$tableblock}` (client,website,category,rulename,public_ip) VALUES";
    events_tail("PaseUdfdbGuard:: parsing /var/log/artica-postfix/ufdbguard-queue Line: " . __LINE__);
    foreach (glob("/var/log/artica-postfix/ufdbguard-queue/*.sql") as $filename) {
        events_tail("dansguardian-stats:: parsing {$filename} Line: " . __LINE__);
        $content = @file_get_contents($filename);
        if ($content == null) {
            events_tail("PaseUdfdbGuard:: Fatal {$filename} is empty !");
            @unlink($filename);
        }
        $f[] = $content;
        @unlink($filename);
        $count++;
        $total++;
        if ($count > 500) {
            events_tail("PaseUdfdbGuard:: {$count} -> send to mysql");
            $count = 0;
            $q = new mysql_squid_builder();
            $sql = $PREFIX . " " . @implode(",", $f);
            $f = array();
            $q->QUERY_SQL($sql);
            if (!$q->ok) {
                @file_put_contents("/var/log/artica-postfix/ufdbguard-queue/" . md5($sql) . "error", $sql);
                events_tail("PaseUdfdbGuard:: Fatal {$q->mysql_error}");
                writelogs($q->mysql_error . "\n", $sql, __FILE__, __LINE__);
            }
            $sql = null;
            continue;
        }
    }
    if (count($f) > 0) {
        $q = new mysql_squid_builder();
        $sql = $PREFIX . " " . @implode(",", $f);
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            @file_put_contents("/var/log/artica-postfix/ufdbguard-queue/" . md5($sql) . "error", $sql);
            events_tail("PaseUdfdbGuard:: Fatal {$q->mysql_error}");
        }
        $sql = null;
    }
    events_tail("PaseUdfdbGuard:: {$total} files.");
}
Exemple #28
0
function popup(){
	
	$page=CurrentPageName();
	$tpl=new templates();
	
	$sock=new sockets();
	$SquidPerformance=intval($sock->GET_INFO("SquidPerformance"));
	if($SquidPerformance>1){
		echo $tpl->_ENGINE_parse_body(FATAL_WARNING_SHOW_128("{artica_statistics_disabled}"));
		return;
	}
	
	$q=new mysql_squid_builder();	
	$q->CheckTables();
	$type=$tpl->_ENGINE_parse_body("{type}");
	$browsers=$tpl->_ENGINE_parse_body("{browsers}");
	
	$items=$tpl->_ENGINE_parse_body("{items}");
	$add=$tpl->_ENGINE_parse_body("{add}");
	$delete_group_ask=$tpl->javascript_parse_text("{inputbox delete group}");
	$title=$tpl->javascript_parse_text("{browsers}");
	$t=time();		
	$table_width=630;
	$table_height=450;

	$buttons="buttons : [
	{name: '$new_group', bclass: 'add', onpress : AddGroup},
		],	";
	$buttons=null;
	
	$html=$tpl->_ENGINE_parse_body("")."
	<table class='table-$t' style='display: none' id='table-$t' style='width:99%'></table>
<script>
$(document).ready(function(){
$('#table-$t').flexigrid({
	url: '$page?list=yes',
	dataType: 'json',
	colModel : [
		{display: '$browsers', name : 'pattern', width : 904, sortable : true, align: 'left'},
		{display: '$add', name : 'pattern', width : 81, sortable : false, align: 'center'},
		
		
	],

	searchitems : [
		{display: '$browsers', name : 'pattern'},
		],
	sortname: 'pattern',
	sortorder: 'asc',
	usepager: true,
	title: '<span style=font-size:18px>$title</span>',
	useRp: true,
	rp: 15,
	showTableToggleBtn: false,
	width: '99%',
	height: $table_height,
	singleSelect: true
	
	});   
});
</script>
	";
	echo $html;	

}
Exemple #29
0
function hosts()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $t = $_GET["t"];
    $search = '%';
    $table = "dnsmasq_records";
    $page = 1;
    $FORCE_FILTER = null;
    $total = 0;
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS("dnsmasq_records");
    }
    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 data}");
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        if (strpos($q->mysql_error, "doesn't exist") > 0) {
            $q->CheckTables();
            $results = $q->QUERY_SQL($sql);
        }
    }
    if (!$q->ok) {
        json_error_show($q->mysql_error . "<br>{$sql}");
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data");
    }
    $fontsize = "16";
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $delete = imgsimple("delete-32.png", null, "Loadjs('{$MyPage}?delete-host-js=yes&ID={$ligne["ID"]}&t={$t}&tt={$_GET["tt"]}')");
        $editjs = "<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:Loadjs('{$MyPage}?host-js=yes&ID={$ligne["ID"]}&t={$t}',true);\"\n\t\tstyle='font-size:{$fontsize}px;font-weight:bold;color:{$color};text-decoration:underline'>";
        $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(ID) as tcount FROM dnsmasq_cname WHERE recordid='{$ligne["ID"]}'"));
        $hostname = $ligne["hostname"];
        $ipaddr = $ligne["ipaddr"];
        $Items = $ligne2["tcount"];
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:bold;color:{$color}'>{$editjs}{$hostname}</a><br><i style='font-size:12px'>&nbsp;{$grouptype}</i></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$ipaddr}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$Items}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
function categories_list()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    if (!is_numeric($_GET["TimeID"])) {
        $_GET["TimeID"] = 0;
    }
    $search = '%';
    $table = "webfilters_categories_caches";
    $page = 1;
    $ORDER = "ORDER BY categorykey ASC";
    $FORCE_FILTER = null;
    $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 usersisp_blkcatz";
    $results = $q->QUERY_SQL($sql);
    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}";
    if ($_POST["query"] != null) {
        $_POST["query"] = "*{$_POST["query"]}*";
        $_POST["query"] = str_replace("**", "*", $_POST["query"]);
        $_POST["query"] = str_replace("**", "*", $_POST["query"]);
        $_POST["query"] = str_replace("*", "%", $_POST["query"]);
        $search = $_POST["query"];
        $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')";
        $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) {
            json_error_show($q->mysql_error);
        }
        $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) {
            json_error_show($q->mysql_error);
        }
        $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) {
        json_error_show($q->mysql_error);
    }
    $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, "", "", ""));
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($ligne["picture"] == null) {
            $ligne["picture"] = "20-categories-personnal.png";
        }
        $img = "img/{$ligne["picture"]}";
        $val = 0;
        $zmd5 = md5($ligne['categorykey']);
        if ($cats[$ligne['categorykey']]) {
            $val = 1;
        }
        $disable = Field_checkbox($zmd5, 1, $val, "EnableDisableForceCategory('{$ligne['categorykey']}','{$zmd5}')");
        $data['rows'][] = array('id' => $ligne['categorykey'], 'cell' => array("<img src='{$img}'>", "{$js}{$ligne['categorykey']}</a>", $ligne['description'], $disable));
    }
    echo json_encode($data);
}