Ejemplo n.º 1
0
function sizelimit_save()
{
    $squid = new squidbee();
    $squid->global_conf_array["request_header_max_size"] = $_GET["request_header_max_size"];
    $squid->global_conf_array["request_body_max_size"] = $_GET["request_body_max_size"];
    $squid->global_conf_array["reply_body_max_size"] = $_GET["reply_body_max_size"];
    $squid->SaveToLdap();
}
Ejemplo n.º 2
0
function Save()
{
    $squid = new squidbee();
    $sock = new sockets();
    $sock->SET_INFO("SquidMemoryPoolsLimit", $_POST["SquidMemoryPoolsLimit"]);
    $sock->SET_INFO("SquidMemoryPoolsLimit", $_POST["SquidMemoryPoolsLimit"]);
    if (is_numeric($_POST["cache_mem"])) {
        $squid->global_conf_array["cache_mem"] = trim($_POST["cache_mem"]) . " MB";
    }
    $squid->SaveToLdap(true);
}
Ejemplo n.º 3
0
function max_filedesc()
{
    $squid = new squidbee();
    if ($_POST["max_filedesc"] < 1024) {
        $_POST["max_filedesc"] = 1024;
    }
    $squid->max_filedesc = $_POST["max_filedesc"];
    $squid->SaveToLdap();
    $sock = new sockets();
    $key = base64_encode("fs.file-max");
    $sock->getFrameWork("cmd.php?sysctl-setvalue={$_POST["fs_filemax"]}&key={$key}");
}
Ejemplo n.º 4
0
function save()
{
    $sock = new sockets();
    if ($_POST["SquidBinIpaddr"] == null) {
        $_POST["SquidBinIpaddr"] = "0.0.0.0";
    }
    $sock->SET_INFO("SquidBinIpaddr", $_POST["SquidBinIpaddr"]);
    if (isset($_POST["tcp_outgoing_address"])) {
        $squid = new squidbee();
        $squid->global_conf_array["tcp_outgoing_address"] = $_POST["tcp_outgoing_address"];
        $squid->SaveToLdap(true);
    }
}
function save()
{
    $sock = new sockets();
    $sock->SET_INFO("CacheReplacementPolicy", $_POST["CacheReplacementPolicy"]);
    $sock->SET_INFO("SquidDebugCacheProc", $_POST["SquidDebugCacheProc"]);
    $sock->SET_INFO("ForceWindowsUpdateCaching", $_POST["ForceWindowsUpdateCaching"]);
    $sock->SET_INFO("ProxyDedicateMicrosoftRules", $_POST["ProxyDedicateMicrosoftRules"]);
    $squid = new squidbee();
    $squid->global_conf_array["maximum_object_size"] = $_POST["maximum_object_size"] . " MB";
    $squid->SaveToLdap(true);
    $tpl = new templates();
    echo $tpl->javascript_parse_text("{must_restart_proxy_settings}");
}
function xfiledesc()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $unix = new unix();
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        squid_admin_mysql(0, "Cannot change file descriptors (PID {$pid} already executed)", null, __FILE__, __LINE__);
        die;
    }
    @file_put_contents($pidfile, getmypid());
    $TimePid = $unix->file_time_min($pidTime);
    if ($TimePid < 5) {
        squid_admin_mysql(0, "Cannot change file descriptors ( require 5mn, current {$TimePid}mn)", null, __FILE__, __LINE__);
        die;
    }
    @unlink($pidTime);
    @file_put_contents($pidTime, time());
    $squid = new squidbee();
    $sock = new sockets();
    $sysctl = $unix->find_program("sysctl");
    $t = time();
    if (!is_numeric($squid->max_filedesc)) {
        $squid->max_filedesc = 8192;
    }
    exec("{$sysctl} -n fs.file-max", $results);
    $file_max = intval(trim(@implode("", $results)));
    $file_max_org = $file_max;
    $max_filedesc = intval($squid->max_filedesc);
    if ($max_filedesc == 0) {
        $max_filedesc = 8192;
    }
    $new_max_filedesc = $max_filedesc + 1000;
    echo "Current System: {$file_max}, Proxy {$max_filedesc}\n";
    if ($new_max_filedesc > $file_max - 100) {
        $file_max = $file_max + 1000;
        shell_exec("{$sysctl} -w fs.file-max={$file_max}");
        $unix->sysctl("fs.file-max", $file_max);
    }
    $squid->max_filedesc = $new_max_filedesc;
    $squid->SaveToLdap(true);
    $php = $unix->LOCATE_PHP5_BIN();
    shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
    squid_admin_mysql(0, "Restarting Proxy service to increase file descriptors from {$max_filedesc}/{$file_max_org} to {$new_max_filedesc}/{$file_max}", null, __FILE__, __LINE__);
    shell_exec("/etc/init.d/squid restart --force");
}
function squid_transparent_exe()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $sock = new sockets();
    $squid = new squidbee();
    $WizardProxyTransparent = unserialize($sock->GET_INFO("WizardProxyTransparent"));
    $WizardProxyTransparent = unserialize($sock->GET_INFO("WizardProxyTransparent"));
    $connected_port = intval($WizardProxyTransparent["connected_port"]);
    $transparent_port = intval($WizardProxyTransparent["transparent_port"]);
    $transparent_ssl_port = intval($WizardProxyTransparent["transparent_ssl_port"]);
    $EnableSSLBump = intval($WizardProxyTransparent["EnableSSLBump"]);
    if ($connected_port == 0) {
        build_progress("Fatal connected port unconfigured", 110);
        return;
    }
    if ($transparent_port == 0) {
        build_progress("Fatal Transparent port unconfigured", 110);
        return;
    }
    echo "Connected port........: {$connected_port}\n";
    echo "Transparent port......: {$transparent_port}\n";
    echo "Transparent SSL.......: {$EnableSSLBump}/{$transparent_ssl_port}\n";
    sleep(3);
    build_progress("{reconfigure}", 20);
    $squid = new squidbee();
    $squid->listen_port = $transparent_port;
    $squid->second_listen_port = $connected_port;
    $squid->hasProxyTransparent = 1;
    if ($EnableSSLBump == 1) {
        echo "EnableSquidSSLCRTD ----> 1\n";
        $sock->SET_INFO("EnableSquidSSLCRTD", 1);
        $squid->SSL_BUMP = 1;
        $squid->ssl_port = $transparent_ssl_port;
    }
    build_progress("{saving_parameters}", 20);
    sleep(3);
    $squid->SaveToLdap(true);
    echo "hasProxyTransparent -------> 1\n";
    $sock->SET_INFO("hasProxyTransparent", 1);
    echo "SquidTransparentMixed -----> 1\n";
    $sock->SET_INFO("SquidTransparentMixed", 1);
    build_progress("{building_settings}", 30);
    $php = $unix->LOCATE_PHP5_BIN();
    system("{$php} /usr/share/artica-postfix/exec.squid.php --build --force");
    build_progress("{restarting_service}", 50);
    system("{$php} /usr/share/artica-postfix/exec.squid.watchdog.php --restart --force");
    build_progress("{apply_firewall_rules}", 90);
    system("{$php} /usr/share/artica-postfix/exec.squid.transparent.php --force");
    build_progress("{done}", 100);
}
Ejemplo n.º 8
0
function tests_port($port_id)
{
    $unix = new unix();
    $squid = new squidbee();
    $q = new mysql_squid_builder();
    $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT * FROM proxy_ports WHERE ID={$port_id}"));
    $ssl_bump_line = $squid->ssl_bump_line($ligne["sslcertificate"]);
    $randport = rand(63500, 65535);
    build_progress("{testing_ssl_certificate} ID:{$port_id} {$ligne["sslcertificate"]}", 15);
    $t = time();
    $pid_filename = "/var/run/squid/{$t}.pid";
    $cache_log = "/var/log/squid/cache.{$t}.log";
    $f[] = "coredump_dir\t/var/squid/cache";
    $f[] = "cache_log\t/var/log/squid/cache.log";
    $f[] = "pid_filename\t/var/run/squid/squid.pid";
    $f[] = "cache_effective_user squid";
    $f[] = "http_port 127.0.0.1:{$randport} {$ssl_bump_line}";
    echo " ***********************************************************************\n";
    echo "Using HTTPS port {$ssl_bump_line} Certificate {$ligne["sslcertificate"]}\n";
    echo " ***********************************************************************\n";
    $f[] = "";
    $tmpfile = $unix->FILE_TEMP();
    $squidbin = $unix->LOCATE_SQUID_BIN();
    build_progress("{testing_ssl_certificate} {$ligne["sslcertificate"]}", 20);
    echo "Conf  : {$tmpfile}\n";
    echo "Binary: {$squidbin}\n";
    @file_put_contents($tmpfile, @implode("\n", $f));
    exec("{$squidbin} -f {$tmpfile} -k check 2>&1", $results);
    @unlink($tmpfile);
    while (list($num, $line) = each($results)) {
        echo "Check  : {$line}\n";
        if (preg_match("#FATAL: No valid signing SSL#", $line)) {
            build_progress("{testing_ssl_certificate_failed} {$ligne["sslcertificate"]}", 110);
            $sql = "UPDATE proxy_ports SET sslcertificate='' WHERE ID='{$port_id}'";
            $q->QUERY_SQL($sql);
            return;
        }
    }
    build_progress("{testing_ssl_certificate} {success}", 100);
    // FATAL: No valid signing SSL certificate
}
Ejemplo n.º 9
0
function build()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $oldpid = @file_get_contents($pidfile);
    if ($unix->process_exists($oldpid)) {
        echo "Starting......: c-icap " . __FUNCTION__ . "() already running PID:{$oldpid}\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $cicap = new cicap();
    $cicap->buildconf();
    $squid = new squidbee();
    $conf = $squid->BuildSquidConf();
    $SQUID_CONFIG_PATH = $unix->SQUID_CONFIG_PATH();
    echo "Starting......: c-icap reconfigure squid done...\n";
    @file_put_contents($SQUID_CONFIG_PATH, $conf);
    @mkdir("/usr/etc", 0755, true);
    CicapMagic("/usr/etc/c-icap.magic");
    dbMaintenanceSchedule();
}
Ejemplo n.º 10
0
function ApplyConfig()
{
    $unix = new unix();
    $squid = new squidbee();
    writelogs("->BuildBlockedSites", __FUNCTION__, __FILE__, __LINE__);
    $squid->BuildBlockedSites();
    if (!is_file("/etc/squid3/squid-block.acl")) {
        @file_put_contents("/etc/squid3/squid-block.acl", "");
    }
    $SQUID_CONFIG_PATH = $unix->SQUID_CONFIG_PATH();
    if (!is_file($SQUID_CONFIG_PATH)) {
        writelogs("Unable to stat squid configuration file \"{$SQUID_CONFIG_PATH}\"", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    echo "Starting......: Squid building main configuration done\n";
    $squid = new squidbee();
    $conf = $squid->BuildSquidConf();
    @file_put_contents("/etc/artica-postfix/settings/Daemons/GlobalSquidConf", $conf);
    @file_put_contents($SQUID_CONFIG_PATH, $conf);
    certificate_generate();
}
Ejemplo n.º 11
0
function save()
{
    $squid = new squidbee();
    $sock = new sockets();
    $sock->SET_INFO("DisableTCPEn", $_POST["DisableTCPEn"]);
    $sock->SET_INFO("DisableTCPWindowScaling", $_POST["DisableTCPWindowScaling"]);
    $sock->SET_INFO("SquidUploadTimeouts", $_POST["SquidUploadTimeouts"]);
    unset($_POST["SquidUploadTimeouts"]);
    unset($_POST["DisableTCPEn"]);
    unset($_POST["DisableTCPWindowScaling"]);
    while (list($index, $line) = each($_POST)) {
        $squid->{$index} = $line;
    }
    $squid->SaveToLdap(true);
}
Ejemplo n.º 12
0
function page()
{
    $users = new usersMenus();
    $page = CurrentPageName();
    $tpl = new templates();
    $date = $tpl->_ENGINE_parse_body("{zDate}");
    $description = $tpl->_ENGINE_parse_body("{description}");
    $context = $tpl->_ENGINE_parse_body("{context}");
    $events = $tpl->_ENGINE_parse_body("{events}");
    $empty = $tpl->_ENGINE_parse_body("{empty}");
    $empty_events_text_ask = $tpl->javascript_parse_text("{empty_events_text_ask}");
    $bt_klms_reset_pwd = null;
    $joomlaservername = $tpl->_ENGINE_parse_body("{joomlaservername}");
    $memory = $tpl->_ENGINE_parse_body("{memory}");
    $requests = $tpl->_ENGINE_parse_body("{requests}");
    $member = $tpl->_ENGINE_parse_body("{member}");
    $new_server = $tpl->_ENGINE_parse_body("{new_server}");
    $add_default_www = $tpl->_ENGINE_parse_body("{add_default_www}");
    $delete_freeweb_text = $tpl->javascript_parse_text("{delete_freeweb_text}");
    $delete_freeweb_dnstext = $tpl->javascript_parse_text("{delete_freeweb_dnstext}");
    $WebDavPerUser = $tpl->_ENGINE_parse_body("{WebDavPerUser}");
    $rebuild_items = $tpl->_ENGINE_parse_body("{rebuild_items}");
    $size = $tpl->_ENGINE_parse_body("{size}");
    $help = $tpl->_ENGINE_parse_body("{help}");
    $restore = $tpl->_ENGINE_parse_body("{restore}");
    $status = $tpl->javascript_parse_text("{status}");
    $reset_admin_password = $tpl->javascript_parse_text("{reset_admin_password}");
    $choose_your_zarafa_webserver_type = $tpl->_ENGINE_parse_body("{choose_your_zarafa_webserver_type}");
    $freeweb_compile_background = $tpl->javascript_parse_text("{freeweb_compile_background}");
    $enable = $tpl->javascript_parse_text("{enable}");
    $bt_default_www = "{name: '{$add_default_www}', bclass: 'add', onpress : FreeWebAddDefaultVirtualHost},";
    $bt_webdav = "{name: '{$WebDavPerUser}', bclass: 'add', onpress : FreeWebWebDavPerUsers},";
    $bt_rebuild = "{name: '{$rebuild_items}', bclass: 'Reconf', onpress : RebuildFreeweb},";
    $bt_help = "{name: '{$help}', bclass: 'Help', onpress : HelpSection},";
    $bt_restore = "{name: '{$restore}', bclass: 'Restore', onpress : RestoreSite},";
    $bt_stats = "{name: '{$status}', bclass: 'Network', onpress : ApacheAllstatus},";
    $MAIN_TITLE = null;
    $tablewidth = 874;
    $servername_size = 366;
    $bt_function_add = "AddNewFreeWebServer";
    if ($_GET["force-groupware"] != null) {
        include_once dirname(__FILE__) . "/ressources/class.apache.inc";
        $default_www = null;
        $bt_webdav = null;
        $ach = new vhosts();
        $MAIN_TITLE = "<span style=font-size:18px>" . $tpl->_ENGINE_parse_body("{" . $ach->TEXT_ARRAY[$_GET["force-groupware"]]["TITLE"] . "}") . "</span>";
        if ($_GET["force-groupware"] == "KLMS") {
            $bt_klms_reset_pwd = "{name: '{$reset_admin_password}', bclass: 'Restore', onpress : klmsresetwebpassword},";
        }
    }
    if ($_GET["tabzarafa"] == "yes") {
        $tablewidth = 690;
        $servername_size = 64;
        $bt_webdav = null;
        $bt_default_www = null;
        $bt_function_add = "AddNewFreeWebServerZarafa";
        $bt_restore = null;
    }
    if ($_GET["minimal-tools"] == "yes") {
        $bt_default_www = null;
        $bt_restore = null;
        $bt_webdav = null;
        $bt_help = null;
    }
    if (!$users->APACHE_MOD_STATUS) {
        $bt_stats = null;
    }
    $users = new usersMenus();
    if ($users->SQUID_INSTALLED) {
        $sock = new sockets();
        $SquidActHasReverse = $sock->GET_INFO("SquidActHasReverse");
        if (!is_numeric($SquidActHasReverse)) {
            $SquidActHasReverse = 0;
        }
        $squid = new squidbee();
        if ($squid->isNGnx()) {
            $SquidActHasReverse = 1;
        }
        if ($SquidActHasReverse == 1) {
            $explainSquidActHasReverse = $tpl->_ENGINE_parse_body("<div class=explain style='font-size:14px'>{explain_freewebs_reverse}</div>");
        }
    }
    $t = time();
    $buttons = "\n\tbuttons : [\n\t{name: '<b>{$new_server}</b>', bclass: 'add', onpress : {$bt_function_add}},{$bt_default_www}{$bt_webdav}{$bt_rebuild}{$bt_restore}{$bt_klms_reset_pwd}{$bt_help}{$bt_stats}\n\t\n\t\t],";
    $html = "\n\t{$explainSquidActHasReverse}\n\t<input type='hidden' id='freewebs-table-id' value='freewebs-table-{$t}'>\n\t<table class='freewebs-table-{$t}' style='display: none' id='freewebs-table-{$t}' style='width:100%;margin:-10px'></table>\n<script>\nFreeWebIDMEM='';\n\n\$('#freewebs-table-{$t}').flexigrid({\n\turl: '{$page}?servers-list=yes&t={$t}&force-groupware={$_GET["force-groupware"]}&ForceInstanceZarafaID={$_GET["ForceInstanceZarafaID"]}&t={$t}&tabzarafa={$_GET["tabzarafa"]}',\n\tdataType: 'json',\n\tcolModel : [\n\t\t{display: '&nbsp;', name : 'icon', width : 31, sortable : false, align: 'center'},\n\t\t{display: '{$joomlaservername}', name : 'servername', width :{$servername_size}, sortable : true, align: 'left'},\n\t\t{display: 'compile', name : 'compile', width :80, sortable : false, align: 'center'},\n\t\t{display: '{$enable}', name : 'enabled', width :80, sortable : true, align: 'center'},\n\t\t{display: '{$size}', name : 'DirectorySize', width :80, sortable : true, align: 'center'},\n\t\t{display: '{$memory}', name : 'memory', width :80, sortable : false, align: 'center'},\n\t\t{display: '{$requests}', name : 'requests', width : 72, sortable : false, align: 'center'},\n\t\t{display: 'SSL', name : 'useSSL', width : 31, sortable : true, align: 'center'},\n\t\t{display: 'RESOLV', name : 'resolved_ipaddr', width : 31, sortable : true, align: 'center'},\n\t\t{display: 'DNS', name : 'dns', width : 31, sortable : false, align: 'center'},\n\t\t{display: '{$member}', name : 'member', width : 31, sortable : false, align: 'center'},\n\t\t{display: '&nbsp;', name : 'none1', width : 80, sortable : false, align: 'center'},\n\t],\n\t{$buttons}\n\n\tsearchitems : [\n\t\t{display: '{$joomlaservername}', name : 'servername'},\n\t\t],\n\tsortname: 'servername',\n\tsortorder: 'desc',\n\tusepager: true,\n\ttitle: '{$MAIN_TITLE}',\n\tuseRp: true,\n\trp: 50,\n\tshowTableToggleBtn: false,\n\twidth: '99%',\n\theight: 550,\n\tsingleSelect: true\n\t\n\t});   \n\n\n\tfunction HelpSection(){\n\t\tLoadHelp('freewebs_explain','',false);\n\t}\n\n\tfunction AddNewFreeWebServer(){\n\t\t Loadjs('freeweb.edit.php?hostname=&force-groupware={$_GET["force-groupware"]}&t={$t}')\n\t}\n\t\n\tfunction AddNewFreeWebServerZarafa(){\n\t\tYahooWin('650','{$page}?freeweb-zarafa-choose=yes&t={$t}','{$choose_your_zarafa_webserver_type}');\n\t}\n\t\n\t\n\tfunction ApacheAllstatus(){\n\t\tLoadjs('freeweb.status.php');\n\t}\n\t\n\t\n\tfunction FreeWebWebDavPerUsers(){\n\t\tLoadjs('freeweb.webdavusr.php?t={$t}')\n\t}\n\t\n\tfunction RestoreSite(){\n\t\tLoadjs('freeweb.restoresite.php?t={$t}')\n\t}\n\t\n\tfunction FreeWebsRefreshWebServersList(){\n\t\t\$('#freewebs-table-{$t}').flexReload();\n\t}\n\t\n\t\n\tvar x_EmptyEvents= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);return;}\n\t\t\$('#freewebs-table-{$t}').flexReload();\n\t\t//\$('#grid_list').flexOptions({url: 'newurl/'}); \n\t\t// \$('#fgAllPatients').flexOptions({ query: 'blah=qweqweqwe' }).flexReload();\n\t\t\n\t}\t\n\t\n\tvar x_FreeWebsRebuildvHostsTable= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);return;}\n\t\talert('{$freeweb_compile_background}');\n\t\t\$('#freewebs-table-{$t}').flexReload();\n\t\t//\$('#grid_list').flexOptions({url: 'newurl/'}); \n\t\t// \$('#fgAllPatients').flexOptions({ query: 'blah=qweqweqwe' }).flexReload();\n\t\t}\n\n\t\n\tvar x_klmsresetwebpassword{$t}= function (obj) {\n\t\tvar results=obj.responseText;\n\t\tif(results.length>3){alert(results);return;}\n\t\t\$('#freewebs-table-{$t}').flexReload();\n\t}\t\n\t\n\tvar x_FreeWebDelete=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>10){alert(results);return;}\t\n\t\t\t\$('#row'+FreeWebIDMEM).remove();\n\t\t\tif(document.getElementById('container-www-tabs')){\tRefreshTab('container-www-tabs');}\n\t\t}\t\n\t\t\n\t\tfunction FreeWebDelete(server,dns,md){\n\t\t\tFreeWebIDMEM=md;\n\t\t\tif(confirm('{$delete_freeweb_text}')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tif(dns==1){if(confirm('{$delete_freeweb_dnstext}')){XHR.appendData('delete-dns',1);}else{XHR.appendData('delete-dns',0);}}\n\t\t\t\tXHR.appendData('delete-servername',server);\n    \t\t\tXHR.sendAndLoad('freeweb.php', 'GET',x_FreeWebDelete);\n\t\t\t}\n\t\t}\n\n\tvar x_FreeWebRefresh=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>10){alert(results);return;}\t\n\t\t\t\$('#freewebs-table-{$t}').flexReload();\n\t\t}\t\t\n\t\t\n\t\tfunction FreeWebAddDefaultVirtualHost(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('AddDefaultOne','yes');\n    \t\tXHR.sendAndLoad('freeweb.php', 'POST',x_FreeWebRefresh);\t\t\n\t\t}\n\t\t\n\t\tfunction FreeWeCheckVirtualHost(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('CheckAVailable','yes');\n    \t\tXHR.sendAndLoad('freeweb.php', 'POST',x_FreeWebDelete);\t\t\t\n\t\t}\n\t\t\n\t\tvar x_RebuildFreeweb{$t}=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);}\t\t\t\n\t\t\t\$('#freewebs-table-{$t}').flexReload();\n\t\t}\t\t\t\n\t\t\n\t\tfunction RebuildFreeweb(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('rebuild-items','yes');\n    \t\tXHR.sendAndLoad('freeweb.php', 'GET',x_RebuildFreeweb{$t});\n\t\t\n\t\t}\n\n\t\tfunction klmsresetwebpassword(){\n\t\t  if(confirm('{$reset_admin_password} ?')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tXHR.appendData('klms-reset-password','yes');\n    \t\t\tXHR.sendAndLoad('klms.php', 'POST',x_klmsresetwebpassword{$t});\n    \t\t}\t\t\n\t\t}\n\t\t\n\tfunction FreeWebsRebuildvHostsTable(servername){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('FreeWebsRebuildvHosts',servername);\n\t\tXHR.sendAndLoad('freeweb.edit.php', 'POST',x_FreeWebsRebuildvHostsTable);\n\t}\n\n\n\t\t\n\t\n</script>";
    echo $html;
}
Ejemplo n.º 13
0
function main_rules_apply_conf()
{
    if ($_GET["hostname"] == null) {
        $users = new usersMenus();
        $_GET["hostname"] = $users->hostname;
    }
    $dans = new dansguardian($_GET["hostname"]);
    $dans->SaveSettings();
    if (is_array($dans->Master_rules_index)) {
        while (list($num, $line) = each($dans->Master_rules_index)) {
            $rules = new dansguardian_rules($hostname, $num);
            $rules->SaveConfigFiles();
        }
    }
    $squid = new squidbee();
    $squid->SaveToLdap();
    $squid->SaveToServer();
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body(applysettings("dansguardian", "ApplyDansGuardianSettings('{$_GET["hostname"]}')"));
}
Ejemplo n.º 14
0
function visible_hostname_save()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $squid = new squidbee();
    $hostid = $_POST["hostid"];
    $nodeid = $_POST["nodeid"];
    $visible_hostname = $_POST["visible_hostname"];
    $squid->nodes_names[$hostid] = $visible_hostname;
    $squid->SaveToLdap(true);
    $q = new blackboxes($hostid);
    $q->reconfigure_squid();
}
Ejemplo n.º 15
0
function sargToFile($filePath)
{
    if (!is_file($filePath)) {
        progress("Fatal {$filePath} no such file", 10);
        return;
    }
    $unix = new unix();
    $sarg_bin = $unix->find_program("sarg");
    $linesNumber = $unix->COUNT_LINES_OF_FILE($filePath);
    $basename = basename($filePath);
    progress("Open {$filePath} {$linesNumber} lines", 10);
    $sock = new sockets();
    $SargOutputDir = $sock->GET_INFO("SargOutputDir");
    if ($SargOutputDir == null) {
        $SargOutputDir = "/var/www/html/squid-reports";
    }
    $nice = EXEC_NICE();
    $usersauth = false;
    $t = time();
    $squid = new squidbee();
    if ($squid->is_auth()) {
        $usersauth = true;
    }
    if ($usersauth) {
        events("User authentification enabled");
        $u = " -i ";
    } else {
        events("User authentification disabled");
    }
    $t = time();
    $cmd = "{$nice}{$sarg_bin} {$u}-f /etc/squid3/sarg.conf -l \"{$filePath}\" -o \"{$SargOutputDir}\" -x -z 2>&1";
    progress("Open {$cmd}", 10);
    exec($cmd, $results);
    while (list($index, $line) = each($results)) {
        if (preg_match("#SARG: OPTION:#", $line)) {
            continue;
        }
        events($line);
    }
    if ($basename == "sarg.log") {
        continue;
    }
    $took = $unix->distanceOfTimeInWords($t, time(), true);
    sarg_admin_events("{$basename} generated took: {$took}\n" . @implode("\n", $results), __FUNCTION__, __FILE__, __LINE__, "sarg");
    build_index_page();
}
Ejemplo n.º 16
0
function WCCP_SAVE()
{
    $squid = new squidbee();
    $squid->wccp2_enabled = $_GET["wccp2_enabled"];
    $squid->wccp2_router = $_GET["wccp2_router"];
    $squid->wccp2_forwarding_method = $_GET["wccp2_forwarding_method"];
    $squid->wccp2_return_method = $_GET["wccp2_return_method"];
    $squid->wccp2_assignment_method = $_GET["wccp2_assignment_method"];
    $squid->SaveToLdap();
}
Ejemplo n.º 17
0
function proxy_behavior_save()
{
    $squid = new squidbee();
    $sock = new sockets();
    $exclusive_reverse_proxy = $_POST["exclusive_reverse_proxy"];
    $exclusive_internet_proxy = $_POST["exclusive_internet_proxy"];
    $mixed_mode = $_POST["mixed_mode"];
    if ($exclusive_reverse_proxy == 1) {
        $sock->SET_INFO("SquidActHasReverse", 1);
        $sock->SET_INFO("SquidActHasReverseOnly", 1);
        $sock->SET_INFO("SquidOldHTTPPort", $squid->listen_port);
        $sock->SET_INFO("SquidOldHTTPPort2", $squid->second_listen_port);
        $sock->SET_INFO("SquidOldSSLPort", $squid->ssl_port);
        $squid->listen_port = 80;
        $squid->second_listen_port = 0;
        $squid->ICP_PORT = 0;
        $squid->HTCP_PORT = 0;
        $squid->ssl_port = 443;
        if (!$squid->SaveToLdap()) {
            echo $squid->ldap_error;
            return;
        }
        return;
    }
    if ($exclusive_internet_proxy == 1) {
        $SquidOldHTTPPort = $sock->GET_INFO("SquidOldHTTPPort");
        $SquidOldSSLPort = $sock->GET_INFO("SquidOldSSLPort");
        $SquidOldHTTPPort2 = $sock->GET_INFO("SquidOldHTTPPort2");
        $sock->SET_INFO("SquidActHasReverse", 0);
        $sock->SET_INFO("SquidActHasReverseOnly", 0);
        if (is_numeric($SquidOldHTTPPort)) {
            if ($SquidOldHTTPPort > 0) {
                $squid->listen_port = $SquidOldHTTPPort;
            }
        }
        if (is_numeric($SquidOldHTTPPort2)) {
            if ($SquidOldHTTPPort2 > 0) {
                $squid->second_listen_port = $SquidOldHTTPPort2;
            }
        }
        if (is_numeric($SquidOldSSLPort)) {
            if ($SquidOldSSLPort > 0) {
                $squid->ssl_port = $SquidOldSSLPort;
            }
        }
        if (!$squid->SaveToLdap()) {
            echo $squid->ldap_error;
            return;
        }
        return;
    }
    if ($mixed_mode == 1) {
        $sock->SET_INFO("SquidActHasReverse", 1);
        if ($squid->listen_port != 80) {
            $sock->SET_INFO("SquidOldHTTPPort", $squid->listen_port);
            $sock->SET_INFO("SquidOldHTTPPort2", $squid->second_listen_port);
            $squid->second_listen_port = $squid->listen_port;
            $squid->listen_port = 80;
        }
        if ($squid->ssl_port != 443) {
            $sock->SET_INFO("SquidOldSSLPort", $squid->listen_port);
            $squid->listen_port = 443;
        }
        if (!$squid->SaveToLdap()) {
            echo $squid->ldap_error;
            return;
        }
    }
    $sock = new sockets();
    $sock->getFrameWork("cmd.php?restart-apache-src=yes");
}
Ejemplo n.º 18
0
function delete_cache()
{
    $cachedir = base64_decode($_POST["delete-cache"]);
    $squid = new squidbee();
    unset($squid->cache_list[$cachedir]);
    $sock = new sockets();
    $squid->SaveToLdap(true);
    $squid->SaveToServer(true);
    $sock->getFrameWork("squid.php?remove-cache={$_POST["delete-cache"]}");
}
Ejemplo n.º 19
0
function ApplyConfigSquid()
{
    $user = new usersMenus();
    if (!isset($_GET["hostname"])) {
        $hostname = $user->hostname;
    } else {
        $hostname = $_GET["hostname"];
    }
    $tpl = new templates();
    $prod = "squid_main_settings";
    $users = new usersMenus();
    if ($user->SQUID_INSTALLED == false) {
        echo $tpl->_ENGINE_parse_body(NotInstalled('squid'));
        exit;
    }
    include_once "ressources/class.squid.inc";
    $squid = new squidbee();
    $squid->SaveToLdap();
    $squid->SaveToServer();
    echo $tpl->_ENGINE_parse_body(Success($prod));
}
Ejemplo n.º 20
0
function save()
{
    $squid = new squidbee();
    $squid->forwarded_for = $_POST["forwarded_for"];
    $squid->SaveToLdap(true);
}
Ejemplo n.º 21
0
function parameters_save()
{
    $sock = new sockets();
    $sock->SET_INFO("EnableNginx", $_POST["EnableNginx"]);
    $sock->SET_INFO("SquidReverseDefaultWebSite", $_POST["SquidReverseDefaultWebSite"]);
    $sock->SET_INFO("EnableFreeWeb", $_POST["EnableFreeWeb"]);
    $sock->SET_INFO("EnableArticaInNGINX", $_POST["EnableArticaInNGINX"]);
    $sock->getFrameWork("cmd.php?restart-artica-status=yes");
    $sock->getFrameWork("cmd.php?freeweb-restart=yes");
    $squid = new squidbee();
    $squid->certificate_center = $_POST["certificate_center"];
    $squid->SaveToLdap();
}
Ejemplo n.º 22
0
function whitelist_del()
{
    $sql = "DELETE FROM squid_ssl WHERE ID={$_GET["website_ssl_del"]}";
    $q = new mysql();
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $s = new squidbee();
    $s->SaveToLdap();
}
Ejemplo n.º 23
0
function compile_databases()
{
    $users = new usersMenus();
    $squid = new squidbee();
    $array = $squid->SquidGuardDatabasesStatus();
    $verb = " -d";
    $array = $squid->SquidGuardDatabasesStatus(0);
    if (count($array) > 0) {
        while (list($index, $file) = each($array)) {
            echo "Starting......: squidGuard compiling " . count($array) . " databases\n";
            $file = str_replace(".db", '', $file);
            $textfile = str_replace("/var/lib/squidguard/", "", $file);
            echo "Starting......: squidGuard compiling {$textfile} database " . ($index + 1) . "/" . count($array) . "\n";
            if ($GLOBALS["VERBOSE"]) {
                $verb = " -d";
                echo $users->SQUIDGUARD_BIN_PATH . " {$verb} -C {$file}\n";
            }
            system($users->SQUIDGUARD_BIN_PATH . " -P{$verb} -C {$file}");
        }
    } else {
        echo "Starting......: squidGuard compiling all databases\n";
        if ($GLOBALS["VERBOSE"]) {
            $verb = " -d";
            echo $users->SQUIDGUARD_BIN_PATH . " {$verb} -C all\n";
        }
        system($users->SQUIDGUARD_BIN_PATH . " -P{$verb} -C all");
    }
    $user = GetSquidUser();
    $unix = new unix();
    $chown = $unix->find_program("chown");
    $chmod = $unix->find_program("chmod");
    shell_exec("{$chown} -R {$user} /var/lib/squidguard/*");
    shell_exec("{$chmod} -R 755 /var/lib/squidguard/*");
    system(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.squid.php --build");
    build();
    KillSquidGuardInstances();
}
Ejemplo n.º 24
0
function delete_cache()
{
    $cachedir = base64_decode($_POST["delete-cache"]);
    $squid = new squidbee();
    unset($squid->cache_list[$cachedir]);
    $sock = new sockets();
    $squid->SaveToLdap(true);
    $squid->SaveToServer(true);
}
Ejemplo n.º 25
0
if(posix_getuid()<>0){die("Cannot be used in web server mode\n\n");}
include_once(dirname(__FILE__).'/ressources/class.templates.inc');
include_once(dirname(__FILE__).'/ressources/class.ini.inc');
include_once(dirname(__FILE__).'/ressources/class.main_cf.inc');
include_once(dirname(__FILE__).'/ressources/class.amavis.inc');
include_once(dirname(__FILE__).'/ressources/class.samba.inc');
include_once(dirname(__FILE__).'/ressources/class.squid.inc');

$main=new main_cf();
$main->save_conf();
$main->save_conf_to_server(1);

$amavis=new amavis();
$amavis->Save();
$amavis->SaveToServer();

$samba=new samba();
$samba->SaveToLdap();

$squid=new squidbee();
$squid->SaveToLdap();
$squid->SaveToServer();

system('/etc/init.d/artica-postfix restart postfix');
system('/etc/init.d/artica-postfix restart squid');
system('/etc/init.d/artica-postfix restart samba');
system('/usr/share/artica-postfix/bin/artica-install --cyrus-checkconfig');
system('/etc/init.d/artica-postfix restart imap');
system('/etc/init.d/artica-postfix restart saslauthd');

?>
Ejemplo n.º 26
0
function SQUID_DELETE_CACHE($value)
{
    $value = unserialize(base64_decode($value));
    if (!is_array($value)) {
        send_email_events("Failed to add/modify squid cache (not an array)", null, "CLOUD");
        return true;
    }
    include_once dirname(__FILE__) . '/ressources/class.squid.inc';
    $sock = new sockets();
    $squid = new squidbee();
    unset($squid->cache_list[$value["cache_directory"]]);
    $squid->SaveToLdap();
    $squid->SaveToServer();
    $sock = new sockets();
    $SquidCacheTasks = unserialize(base64_decode($sock->GET_INFO("SquidCacheTask")));
    $SquidCacheTasks[$value["cache_directory"]] = $_GET;
    $sock->SaveConfigFile(base64_encode(serialize($SquidCacheTasks)), "SquidCacheTask");
    $sock->getFrameWork("cmd.php?squid-build-caches=yes");
    send_email_events("Success removing squid cache \"{$value["cache_directory"]}\"", "Squid was scheduled to be reloaded.\n", "CLOUD");
    return true;
}
Ejemplo n.º 27
0
function save(){
	$squid=new squidbee();
	$squid->global_conf_array["cache_mem"]=trim($_POST["cache_mem"])." MB";
	$squid->global_conf_array["read_ahead_gap"]=trim($_POST["read_ahead_gap"])." MB";
	$squid->global_conf_array["maximum_object_size_in_memory"]=trim($_POST["maximum_object_size_in_memory"]);
	$squid->SaveToLdap(true);
}
Ejemplo n.º 28
0
function enable_ftp_restrictions()
{
    $s = new squidbee();
    $s->enable_ftp_restrictions = $_GET["enable_ftp_restrictions"];
    $s->SaveToLdap();
}
Ejemplo n.º 29
0
function build_default_asArtica()
{
    $nginx = new nginx();
    $unix = new unix();
    $squidR = new squidbee();
    $f[] = "server {";
    $f[] = "\tlisten       80;";
    $f[] = "\tserver_name  " . $unix->hostname_g() . ";";
    $f[] = "\tindex     logon.php;";
    $f[] = "\tlocation /nginx_status {";
    $f[] = "\tstub_status on;";
    $f[] = "\terror_log  /var/log/nginx/default.error.log warn;";
    $f[] = "\taccess_log   /var/log/nginx/default.access.log;";
    $f[] = "\tallow all;";
    $f[] = "\t}";
    $f[] = "\tlocation / {";
    $f[] = "\t\troot\t/usr/share/artica-postfix;";
    $f[] = "\t}";
    $f[] = $nginx->php_fpm("logon.php", "/usr/share/artica-postfix", 1);
    $f[] = "}";
    $f[] = "server {";
    $f[] = "\tlisten       443;";
    $f[] = "\tindex     logon.php;";
    $f[] = "\tkeepalive_timeout   70;";
    $f[] = "\terror_log  /var/log/nginx/default.error.log warn;";
    $f[] = "\taccess_log   /var/log/nginx/default.access.log;";
    $f[] = "\tssl on;";
    $f[] = "\t" . $squidR->SaveCertificate($unix->hostname_g(), false, true);
    $f[] = "\tssl_session_timeout  5m;";
    $f[] = "\tssl_protocols  SSLv3 TLSv1;";
    $f[] = "\tssl_ciphers HIGH:!aNULL:!MD5;";
    $f[] = "\tssl_prefer_server_ciphers   on;";
    $f[] = "\tserver_name  " . $unix->hostname_g() . ";";
    $f[] = "\tlocation / {";
    $f[] = "\t\troot\t/usr/share/artica-postfix;";
    $f[] = "\t}";
    $f[] = $nginx->php_fpm("logon.php", "/usr/share/artica-postfix", 1);
    $f[] = "}";
    @file_put_contents("/etc/nginx/conf.d/default.conf", @implode("\n", $f));
    if ($GLOBALS["RELOAD"]) {
        reload(true);
    }
}
Ejemplo n.º 30
0
function time_save(){
	$tpl=new templates();
	if($_GET["time_day"]==null){echo $tpl->_ENGINE_parse_body("{day}: Wrong!\n");exit;}
	$squid=new squidbee();
	$squid->acl_times["time:{$_GET["gpid"]}:{$_GET["ou"]}"][$_GET["time_day"]]="{$_GET["time_hour"]}:{$_GET["time_min"]}-{$_GET["end_time_hour"]}:{$_GET["end_time_min"]}";
	$squid->SaveToLdap();
	echo $tpl->_ENGINE_parse_body("{$_GET["time_hour"]}:{$_GET["time_min"]}-{$_GET["end_time_hour"]}:{$_GET["end_time_min"]}:{success}\n");
	
}