| | |
| | | |
| | | // Validate domain part |
| | | if (preg_match('/^\[((IPv6:[0-9a-f:.]+)|([0-9.]+))\]$/i', $domain_part, $matches)) { |
| | | return self::ip_check(preg_replace('/^IPv6:/i', '', $matches[1])); // valid IPv4 or IPv6 address |
| | | return self::check_ip(preg_replace('/^IPv6:/i', '', $matches[1])); // valid IPv4 or IPv6 address |
| | | } |
| | | else { |
| | | // If not an IP address |
| | |
| | | * |
| | | * @return bool True if the address is valid |
| | | */ |
| | | public static function ip_check($ip) |
| | | public static function check_ip($ip) |
| | | { |
| | | // IPv6, but there's no build-in IPv6 support |
| | | if (strpos($ip, ':') !== false && !defined('AF_INET6')) { |
| | |
| | | public static function check_referer() |
| | | { |
| | | $uri = parse_url($_SERVER['REQUEST_URI']); |
| | | $referer = parse_url(rcube_request_header('Referer')); |
| | | return $referer['host'] == rcube_request_header('Host') && $referer['path'] == $uri['path']; |
| | | $referer = parse_url(self::request_header('Referer')); |
| | | return $referer['host'] == self::request_header('Host') && $referer['path'] == $uri['path']; |
| | | } |
| | | |
| | | |
| | |
| | | static $html_encode_arr = false; |
| | | static $js_rep_table = false; |
| | | static $xml_rep_table = false; |
| | | |
| | | if (!is_string($str)) { |
| | | $str = strval($str); |
| | | } |
| | | |
| | | // encode for HTML output |
| | | if ($enctype == 'html') { |
| | |
| | | } |
| | | |
| | | $out = strtr($str, $encode_arr); |
| | | |
| | | // avoid douple quotation of & |
| | | $out = preg_replace('/&([A-Za-z]{2,6}|#[0-9]{2,4});/', '&\\1;', $out); |
| | | |
| | | return $newlines ? nl2br($out) : $out; |
| | | } |
| | |
| | | // %s - domain name after the '@' from e-mail address provided at login screen. Returns FALSE if an invalid email is provided |
| | | if (strpos($name, '%s') !== false) { |
| | | $user_email = self::get_input_value('_user', self::INPUT_POST); |
| | | $user_email = rcube_utils::idn_convert($user_email, true); |
| | | $user_email = self::idn_convert($user_email, true); |
| | | $matches = preg_match('/(.*)@([a-z0-9\.\-\[\]\:]+)/i', $user_email, $s); |
| | | if ($matches < 1 || filter_var($s[1]."@".$s[2], FILTER_VALIDATE_EMAIL) === false) { |
| | | return false; |