From d2db3f75bce2f824d5a9d19c0323a934a3e77167 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Thu, 17 Apr 2003 17:00:33 +0000 Subject: Some change-arounds ... hopefully not introducing problems ... git-svn-id: file:///svn/phpbb/trunk@3870 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_user.php | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'phpBB/includes/functions_user.php') diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index d6dd83e723..40eaaf2cfc 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -19,6 +19,46 @@ * ***************************************************************************/ +// Does supplementary validation of optional profile fields. This +// expects common stuff like trim() and strip_tags() to have already +// been run. Params are passed by-ref, so we can set them to the empty +// string if they fail. +function validate_optional_fields(&$icq, &$aim, &$msnm, &$yim, &$website, &$location, &$occupation, &$interests, &$sig) +{ + $check_var_length = array('aim', 'msnm', 'yim', 'location', 'occupation', 'interests', 'sig'); + + for($i = 0; $i < count($check_var_length); $i++) + { + if (strlen($$check_var_length[$i]) < 2) + { + $$check_var_length[$i] = ''; + } + } + + // ICQ number has to be only numbers. + if (!preg_match('/^[0-9]+$/', $icq)) + { + $icq = ''; + } + + // website has to start with http://, followed by something with length at least 3 that + // contains at least one dot. + if ($website != '') + { + if (!preg_match('#^http[s]?:\/\/#i', $website)) + { + $website = 'http://' . $website; + } + + if (!preg_match('#^http[s]?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $website)) + { + $website = ''; + } + } + + return; +} + // Handles manipulation of user data. Primary used in registration // and user profile manipulation class userdata extends user -- cgit v1.2.1