diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2007-09-21 15:00:40 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2007-09-21 15:00:40 +0000 |
commit | 69d29e9282e0fcdbcac0017acea8aaa942ee2623 (patch) | |
tree | 0e1df725fcc84bdae0e76fb20ed99aa86be91d7a /phpBB/includes/functions.php | |
parent | 529980ab79094234eda8e6d796a3e0736c1c00cc (diff) | |
download | forums-69d29e9282e0fcdbcac0017acea8aaa942ee2623.tar forums-69d29e9282e0fcdbcac0017acea8aaa942ee2623.tar.gz forums-69d29e9282e0fcdbcac0017acea8aaa942ee2623.tar.bz2 forums-69d29e9282e0fcdbcac0017acea8aaa942ee2623.tar.xz forums-69d29e9282e0fcdbcac0017acea8aaa942ee2623.zip |
put expressions for ip validation into our get_preg_ function.
git-svn-id: file:///svn/phpbb/trunk@8094 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3742d89475..cb2631d7b5 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3414,7 +3414,7 @@ function get_backtrace() /** * This function returns a regular expression pattern for commonly used expressions * Use with / as delimiter for email mode and # for url modes -* mode can be: email|bbcode_htm|url|url_inline|www_url|www_url_inline|relative_url|relative_url_inline +* mode can be: email|bbcode_htm|url|url_inline|www_url|www_url_inline|relative_url|relative_url_inline|ipv4|ipv6 */ function get_preg_expression($mode) { @@ -3435,6 +3435,17 @@ function get_preg_expression($mode) ); break; + // Whoa these look impressive! + // The code to generate the following two regular expressions which match valid IPv4/IPv6 addresses + // can be found in the develop directory + case 'ipv4': + return '#^(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$#'; + break; + + case 'ipv6': + return '#^(?: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