Example #1
0
function PROXY()
{
    $ini = new Bs_IniHandler();
    $sock = new sockets();
    $ini->loadString($sock->GET_INFO("ArticaProxySettings"));
    $ArticaProxyServerEnabled = $ini->_params["PROXY"]["ArticaProxyServerEnabled"];
    $ArticaProxyServerName = $ini->_params["PROXY"]["ArticaProxyServerName"];
    $ArticaProxyServerPort = $ini->_params["PROXY"]["ArticaProxyServerPort"];
    $ArticaProxyServerUsername = $ini->_params["PROXY"]["ArticaProxyServerUsername"];
    $ArticaProxyServerUserPassword = $ini->_params["PROXY"]["ArticaProxyServerUserPassword"];
    $ArticaCompiledProxyUri = $ini->_params["PROXY"]["ArticaCompiledProxyUri"];
    if (trim($ArticaProxyServerEnabled) != "yes") {
        PROXY_DELETE();
        return;
    }
    if (trim($ArticaProxyServerName == null)) {
        PROXY_DELETE();
        return;
    }
    if (trim($ArticaProxyServerPort == null)) {
        $ArticaProxyServerPort = 80;
    }
    if (!is_numeric($ArticaProxyServerPort)) {
        $ArticaProxyServerPort = 80;
    }
    if ($ArticaProxyServerUsername != null) {
        $pattern = "{$ArticaProxyServerUsername}";
        if ($ArticaProxyServerUserPassword != null) {
            $pattern = $pattern . ":{$ArticaProxyServerUserPassword}";
        }
        $pattern = $pattern . "@";
    }
    echo "Starting......: " . date("H:i:s") . " Using proxy {$ArticaProxyServerName}:{$ArticaProxyServerPort}\n";
    $proxypattern = "http://{$pattern}{$ArticaProxyServerName}:{$ArticaProxyServerPort}";
    $f = explode("\n", @file_get_contents("/etc/environment"));
    while (list($key, $line) = each($f)) {
        if (preg_match("#^HTTP_PROXY#i", $line)) {
            unset($f[$key]);
        }
    }
    $f[] = "http_proxy={$proxypattern}";
    if (is_dir("/etc/profile.d")) {
        $t[] = "#!/bin/sh";
        $t[] = "HTTP_PROXY={$proxypattern}";
        $t[] = "for i in NEWSPOST_PROXY NEWSREPLY_PROXY NEWS_PROXY WAIS_PROXY SNEWSREPLY_PROXY FINGER_PROXY HTTPS_PROXY FTP_PROXY CSO_PROXY SNEWSPOST_PROXY NNTP_PROXY GOPHER_PROXY SNEWS_PROXY; do";
        $t[] = "export \$i=\$HTTP_PROXY; done";
        $t[] = "unset i";
        @file_put_contents("/etc/profile.d/proxy-mycompany.sh", @implode("\n", $t));
        @chmod("/etc/profile.d/proxy-mycompany.sh", 0755);
    }
    @file_put_contents("/root/.wgetrc", @implode("\n", $f));
    @file_put_contents("/etc/profile.local", @implode("\n", $f));
    @file_put_contents("/etc/environment", @implode("\n", $f));
    if (is_dir("/etc/apt/apt.conf.d")) {
        echo "Starting......: " . date("H:i:s") . " Using proxy with apt-get, apt-mirror...\n";
        @file_put_contents("/etc/apt/apt.conf.d/proxy", "Acquire::http::Proxy \"{$proxypattern}\";");
    }
}
Example #2
0
function PROXY()
{
    $ini = new Bs_IniHandler();
    $sock = new sockets();
    $ini->loadString($sock->GET_INFO("ArticaProxySettings"));
    $ArticaProxyServerEnabled = $ini->_params["PROXY"]["ArticaProxyServerEnabled"];
    $ArticaProxyServerName = $ini->_params["PROXY"]["ArticaProxyServerName"];
    $ArticaProxyServerPort = $ini->_params["PROXY"]["ArticaProxyServerPort"];
    $ArticaProxyServerUsername = $ini->_params["PROXY"]["ArticaProxyServerUsername"];
    $ArticaProxyServerUserPassword = $ini->_params["PROXY"]["ArticaProxyServerUserPassword"];
    $ArticaCompiledProxyUri = $ini->_params["PROXY"]["ArticaCompiledProxyUri"];
    if (trim($ArticaProxyServerEnabled) != "yes") {
        PROXY_DELETE();
        return;
    }
    if (trim($ArticaProxyServerName == null)) {
        PROXY_DELETE();
        return;
    }
    if (trim($ArticaProxyServerPort == null)) {
        $ArticaProxyServerPort = 80;
    }
    if (!is_numeric($ArticaProxyServerPort)) {
        $ArticaProxyServerPort = 80;
    }
    if ($ArticaProxyServerUsername != null) {
        $pattern = "{$ArticaProxyServerUsername}";
        if ($ArticaProxyServerUserPassword != null) {
            $pattern = $pattern . ":{$ArticaProxyServerUserPassword}";
        }
        $pattern = $pattern . "@";
    }
    echo "Starting......: Using proxy {$ArticaProxyServerName}:{$ArticaProxyServerPort}\n";
    $proxypattern = "http://{$pattern}{$ArticaProxyServerName}:{$ArticaProxyServerPort}";
    $f = explode("\n", @file_get_contents("/etc/environment"));
    while (list($key, $line) = each($f)) {
        if (preg_match("#^HTTP_PROXY#i", $line)) {
            unset($f[$key]);
        }
    }
    $f[] = "http_proxy={$proxypattern}";
    @file_put_contents("/etc/environment", @implode("\n", $f));
    if (is_dir("/etc/apt/apt.conf.d")) {
        echo "Starting......: Using proxy with apt-get, apt-mirror...\n";
        @file_put_contents("/etc/apt/apt.conf.d/proxy", "Acquire::http::Proxy \"{$proxypattern}\";");
    }
}