diff options
author | Henry Sudhof <kellanved@phpbb.com> | 2007-12-13 22:23:25 +0000 |
---|---|---|
committer | Henry Sudhof <kellanved@phpbb.com> | 2007-12-13 22:23:25 +0000 |
commit | 3ca0a7cb7616860ac0941f7d3b302f7b318a7fb6 (patch) | |
tree | 556f644d69b46cf677865f20ba4b97e43b2a7ffc /phpBB/includes/functions_user.php | |
parent | ca87f7a2d188f936d57fe8652d2ee6b1e0824da7 (diff) | |
download | forums-3ca0a7cb7616860ac0941f7d3b302f7b318a7fb6.tar forums-3ca0a7cb7616860ac0941f7d3b302f7b318a7fb6.tar.gz forums-3ca0a7cb7616860ac0941f7d3b302f7b318a7fb6.tar.bz2 forums-3ca0a7cb7616860ac0941f7d3b302f7b318a7fb6.tar.xz forums-3ca0a7cb7616860ac0941f7d3b302f7b318a7fb6.zip |
What did you expect? Us slacking off because of a few digg/heise trolls? nah. never!
The show must go on :)
git-svn-id: file:///svn/phpbb/trunk@8280 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r-- | phpBB/includes/functions_user.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index fa7025f2c2..c9921cc6f0 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1261,6 +1261,45 @@ function validate_num($num, $optional = false, $min = 0, $max = 1E99) } /** +* Validate Date +* @param String $string a date in the dd-mm-yyyy format +* @return boolean +*/ +function validate_date($date_string, $optional = false) +{ + $date = explode('-', $date_string); + if ((empty($date) || sizeof($date) != 3) && $optional) + { + return false; + } + else if ($optional) + { + for ($field = 0; $field <= 1; $field++) + { + $date[$field] = (int) $date[$field]; + if (empty($date[$field])) + { + $date[$field] = 1; + } + } + $date[2] = (int) $date[2]; + // assume an arbitrary leap year + if (empty($date[2])) + { + $date[2] = 1980; + } + } + + if (sizeof($date) != 3 || !checkdate($date[1], $date[0], $date[2])) + { + return 'INVALID'; + } + + return false; +} + + +/** * Validate Match * * @return boolean|string Either false if validation succeeded or a string which will be used as the error message (with the variable name appended) |