Exemple #1
0
 function VerifyHost($hosts = '')
 {
     if (!$hosts) {
         return TRUE;
     }
     $allowedlist = explode(',', $hosts);
     $isin = FALSE;
     foreach ($allowedlist as $value) {
         $net = '';
         $mask = '';
         if (strpos($value, '/') === FALSE) {
             $net = $value;
         } else {
             list($net, $mask) = explode('/', $value);
         }
         $net = trim($net);
         $mask = trim($mask);
         if ($mask == '') {
             $mask = '255.255.255.255';
         } elseif (is_numeric($mask)) {
             $mask = prefix2mask($mask);
         }
         if (isipinstrict($this->ip, $net, $mask)) {
             return TRUE;
         }
     }
     return FALSE;
 }
Exemple #2
0
    foreach ($allowedlist as $value) {
        $net = '';
        $mask = '';
        if (strpos($value, '/') === FALSE) {
            $net = $value;
        } else {
            list($net, $mask) = explode('/', $value);
        }
        $net = trim($net);
        $mask = trim($mask);
        if ($mask == '') {
            $mask = '255.255.255.255';
        } elseif (is_numeric($mask)) {
            $mask = prefix2mask($mask);
        }
        if (isipinstrict($ipaddr, $net, $mask)) {
            $isin = TRUE;
            break;
        }
    }
    if (!$isin) {
        header('HTTP/1.1 403 Forbidden');
        echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
		<HTML><HEAD>
		<TITLE>403 Forbidden</TITLE>
		</HEAD><BODY>
		<H1>Forbidden</H1>
		You don\'t have permission to access ' . $_SERVER['REQUEST_URI'] . '
		on this server.<P>
		<HR>
		' . $_SERVER['SERVER_SIGNATURE'] . '