Example #1
0
function disconnect()
{
    $unix = new unix();
    $user = new settings_inc();
    $netbin = $unix->LOCATE_NET_BIN_PATH();
    $kdestroy = $unix->find_program("kdestroy");
    $sock = new sockets();
    $nohup = $unix->find_program("nohup");
    $array = unserialize(base64_decode($sock->GET_INFO("KerbAuthInfos")));
    if (!isset($array["USE_AUTORID"])) {
        $array["USE_AUTORID"] = 1;
    }
    if (!is_numeric($array["USE_AUTORID"])) {
        $array["USE_AUTORID"] = 1;
    }
    $domainUp = strtoupper($array["WINDOWS_DNS_SUFFIX"]);
    $domain_lower = strtolower($array["WINDOWS_DNS_SUFFIX"]);
    $adminpassword = $array["WINDOWS_SERVER_PASS"];
    $adminpassword = $unix->shellEscapeChars($adminpassword);
    $adminpassword = str_replace("'", "", $adminpassword);
    $adminname = $array["WINDOWS_SERVER_ADMIN"];
    $ad_server = $array["WINDOWS_SERVER_NETBIOSNAME"];
    $kdb5_util = $unix->find_program("kdb5_util");
    $function = __FUNCTION__;
    if (!is_file($netbin)) {
        progress_logs(100, "{join_activedirectory_domain}", " net, no such binary");
        return;
    }
    if (!$user->SAMBA_INSTALLED) {
        progress_logs(100, "{join_activedirectory_domain}", " Samba, no such software");
        return;
    }
    build_progress_disconnect("Flush Keytab...", 5);
    exec("{$netbin} ads keytab flush 2>&1", $results);
    build_progress_disconnect("Leave Active Directory...", 10);
    exec("{$netbin} ads leave -U {$adminname}%{$adminpassword} 2>&1", $results);
    build_progress_disconnect("Destroy Kerberos ticket", 10);
    exec("{$kdestroy} 2>&1", $results);
    build_progress_disconnect("Destroy Kerberos ticket", 15);
    system("{$kdb5_util} -r {$domainUp}  -P {$adminpassword} destroy -f");
    build_progress_disconnect("Destroy Kerberos ticket", 20);
    @unlink("/etc/squid3/PROXY.keytab");
    squid_admin_mysql(0, "Active directory disconnected", "An order as been sent to disconnect Active Directory", __FILE__, __LINE__);
    build_progress_disconnect("Stamp to not use Active Directory", 50);
    $sock->SET_INFO("EnableKerbAuth", 0);
    @unlink("/etc/cron.d/artica-ads-watchdog");
    @unlink("/etc/cron.daily/msktutil");
    build_progress_disconnect("Remove the system from Active Directory", 70);
    exec("/usr/share/artica-postfix/bin/artica-install --nsswitch 2>&1", $results);
    build_progress_disconnect("Restarting SMB Engine", 70);
    exec("/etc/init.d/artica-postfix restart samba 2>&1", $results);
    while (list($num, $ligne) = each($results)) {
        echo "Leave......: {$ligne}\n";
        progress_logs(90, "{join_activedirectory_domain}", "Leave......: {$ligne}");
    }
    build_progress_disconnect("{reconfiguring_proxy_service}", 80);
    $php5 = $unix->LOCATE_PHP5_BIN();
    system("{$php5} /usr/share/artica-postfix/exec.squid.php --build --force");
    build_progress_disconnect("{done}", 100);
}
Example #2
0
function import_urls()
{
    $handle = @fopen("/var/log/squid/access.log", "r");
    if (!$handle) {
        echo "Failed to open file\n";
        return;
    }
    while (!feof($handle)) {
        $www = trim(fgets($handle, 4096));
        if (!preg_match("#GET http(.+?)\\s+#", $www, $re)) {
            continue;
        }
        $array["http{$re[1]}"] = true;
        if (count($array) > 500) {
            break;
        }
    }
    while (list($num, $val) = each($array)) {
        $f[] = $num;
    }
    $array = array();
    @mkdir("/etc/siege");
    @file_put_contents("/etc/siege/urls.txt", @implode("\n", $f));
    $f = array();
    build_progress_disconnect(count($f) . " urls saved", 20);
}