Пример #1
0
        die;
        exit;
    }
}
if ($user->AsSquidAdministrator == false) {
    $tpl = new templates();
    echo "alert('" . $tpl->javascript_parse_text("{ERROR_NO_PRIVS}") . "');";
    die;
    exit;
}
if (isset($_GET["purge-js"])) {
    purge_js();
    exit;
}
if (isset($_GET["dns-servers"])) {
    dns_servers();
    exit;
}
if (isset($_GET["items"])) {
    items();
    exit;
}
if (isset($_POST["purge-popup"])) {
    purge();
    exit;
}
page();
function purge_js()
{
    header("content-type: application/x-javascript");
    $page = CurrentPageName();
Пример #2
0
function getipv4fromdns($hostname)
{
    //Make sure hostname is not empty
    if ($hostname != "") {
        //Get DNS Servers
        $dns_servers = dns_servers();
        //Get DNS suffixes
        $suffix = dns_suffix();
        //Make sure DNS server list and suffix list are not empty
        if (!empty($dns_servers)) {
            if (!empty($suffix)) {
                //Explode DNS suffixes
                $suffix_array = explode(',', $suffix);
                //Build array for hostnames with every suffix and without suffix
                foreach ($suffix_array as $suffix) {
                    $hostname_array .= $hostname . $suffix . ",";
                }
            }
            $hostname_array .= $hostname;
            //Explode DNS Servers
            $dns_servers_array = explode(',', $dns_servers);
            //NET DNS2 Resolver with 1 second timeout (default = 5)
            $r = new Net_DNS2_Resolver(array('nameservers' => $dns_servers_array));
            $r->timeout = "1";
            //Loop thru array to make sure every hostname+suffix combination from the array is checked against every DNS Server until (hopefully) a valid response was received
            $success = false;
            $hostname_array = explode(',', $hostname_array);
            foreach ($hostname_array as $hostname) {
                //Try DNS query and catch exceptions from NET_DNS2
                $ipv4 = "";
                try {
                    $result = $r->query($hostname);
                    $success = true;
                    break;
                } catch (Net_DNS2_Exception $e) {
                    $ipv4[0] = "DNS Verification failed! Error: " . $e->getMessage();
                }
            }
            // Loop thru result array to get IP Addresses from result when DNS query succeded
            if ($success) {
                foreach ($result->answer as $rr) {
                    if ($rr->type == 'A' && $r->isIPv4($rr->address)) {
                        $ipv4 = $rr->address . "," . $ipv4;
                    }
                }
                //Trim whitespaces and commas
                $ipv4 = trim($ipv4);
                $ipv4 = rtrim($ipv4, ",");
                //Sort IP Addresses
                $ipv4_array = explode(',', $ipv4);
                natsort($ipv4_array);
                $ipv4 = implode(', ', $ipv4_array);
                //Trim whitespaces and commas again
                $ipv4 = trim($ipv4);
                $ipv4 = rtrim($ipv4, ",");
            } else {
                $ipv4[0] = "Error! Hostname is empty, unreadable or unresolveable!";
                //Give back an error due to hostname error
            }
        } else {
            $ipv4[0] = "Error! No DNS Servers specified under settings!";
            //Give back an error due to missing dns server setting
        }
    } else {
        $ipv4[0] = "Error! Hostname is empty, unreadable or unresolveable!";
        //Give back an error due to hostname error
    }
    return $ipv4;
}
Пример #3
0
    exit;
}
/* Spiros Ioannou 2009-2010 , sivann _at_ gmail.com */
if (isset($_POST['dateformat'])) {
    //if we came from a post (save), update the rack
    $sql = "UPDATE settings set companytitle='" . trim($_POST['companytitle']) . "', dateformat='" . $_POST['dateformat'] . "', currency='" . $_POST['currency'] . "', theme='" . $_POST['theme'] . "', useldap='" . $_POST['useldap'] . "', ldap_server='" . trim($_POST['ldap_server']) . "', ldap_dn='" . trim($_POST['ldap_dn']) . "', ldap_getusers='" . trim($_POST['ldap_getusers']) . "', ldap_getusers_filter='" . trim($_POST['ldap_getusers_filter']) . "', usedns='" . $_POST['usedns'] . "', dns_servers='" . trim($_POST['dns_servers']) . "', dns_suffix='" . trim($_POST['dns_suffix']) . "', dns_autoupdate='" . $_POST['dns_autoupdate'] . "'," . " lang='" . $_POST['lang'] . "', " . " timezone='" . $_POST['timezone'] . "' ";
    db_exec($dbh, $sql);
    //Update DNS Suffixes to include necessary DOT at the beginning of suffix
    $suffix = dns_suffix();
    if (!empty($suffix)) {
        $newsuffix = suffix_dot($suffix);
        $sql = "UPDATE settings set dns_suffix='{$newsuffix}'";
        db_exec($dbh, $sql);
    }
    //Update DNS server list to make sure no unneccessary spaces/commas are in the list
    $dnsservers = dns_servers();
    if (!empty($dnsservers)) {
        $newdnsservers = format_dns_server_list($dnsservers);
        $sql = "UPDATE settings set dns_servers='{$newdnsservers}'";
        db_exec($dbh, $sql);
    }
}
//save pressed
/////////////////////////////
//// display data
$sql = "SELECT * FROM settings";
$sth = $dbh->query($sql);
$settings = $sth->fetchAll(PDO::FETCH_ASSOC);
$settings = $settings[0];
echo "\n<form id='mainform' method=post  action='{$scriptname}?action={$action}' enctype='multipart/form-data'  name='settingsfrm'>\n";
echo "\n<h1>" . t("Settings") . "</h1>\n";
Пример #4
0
	if($user->SQUID_INSTALLED==false){
		if(!$user->WEBSTATS_APPLIANCE){
			$tpl=new templates();
			echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
			die();exit();
		}
	}
	
	if($user->AsSquidAdministrator==false){
		$tpl=new templates();
		echo "alert('". $tpl->javascript_parse_text("{ERROR_NO_PRIVS}")."');";
		die();exit();
	}	
	
	if(isset($_GET["purge-js"])){purge_js();exit;}
	if(isset($_GET["dns-servers"])){dns_servers();exit;}
	if(isset($_GET["items"])){items();exit;}
	if(isset($_POST["purge-popup"])){purge();exit;}

	
page();

function purge_js(){
	header("content-type: application/x-javascript");
	$page=CurrentPageName();
	$tpl=new templates();
	$explain=$tpl->javascript_parse_text("{squid_purge_dns_explain}");
	$dev=$_GET["unlink-disk-js"];
	$t=time();
	$thml="
	var xSave$t= function (obj) {