Esempio n. 1
0
function validateIPv6($IP)
{
    // fast exit for localhost
    if (strlen($IP) < 3) {
        return $IP == '::';
    }
    // Check if part is in IPv4 format
    if (strpos($IP, '.')) {
        $lastcolon = strrpos($IP, ':');
        if (!($lastcolon && validateIPv4(substr($IP, $lastcolon + 1)))) {
            return false;
        }
        // replace IPv4 part with dummy
        $IP = substr($IP, 0, $lastcolon) . ':0:0';
    }
    // check uncompressed
    if (strpos($IP, '::') === false) {
        return preg_match('/^(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}$/i', $IP);
    }
    // check colon-count for compressed format
    if (substr_count($IP, ':') < 8) {
        return preg_match('/^(?::|(?:[a-f0-9]{1,4}:)+):(?:(?:[a-f0-9]{1,4}:)*[a-f0-9]{1,4})?$/i', $IP);
    }
    return false;
}
Esempio n. 2
0
         $Err_email = true;
     }
 } else {
     $Err_email = true;
 }
 if (isset($_REQUEST["pass"])) {
     if (check_pass($_REQUEST["email"], $_REQUEST["pass"])) {
         $Err_pass = false;
     } else {
         $Err_pass = true;
     }
 } else {
     $Err_pass = true;
 }
 if (isset($_REQUEST["ip"])) {
     if (validateIPv4($_REQUEST["ip"]) || validateIPv6($_REQUEST["ip"])) {
         $Err_ip = false;
     } else {
         $Err_ip = true;
     }
 } else {
     $Err_ip = true;
 }
 if (isset($_REQUEST["name"])) {
     if (check_computer($_REQUEST["name"], $_REQUEST["email"])) {
         $Err_name = false;
     } else {
         $Err_name = true;
     }
 } else {
     $Err_name = true;