note 50296 added to function.str-replace
| From: | dambkruckAThotmaildotcom at osu1 dot php dot net | Date: | Thu, 24 Feb 2005 03:37:11 +0000 |
| Subject: | note 50296 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85461@lists.php.net to get a copy of this message | ||
I'm not sure that this is the right place, but I believe that it is useful for the accents
problem. I just wrote and tested this script because I'm using a variable from $_GET to open a
text file and I do not want to allow anyone to go searching thru my folders by entering ../ (or
other malicious stuff that I don't know about). Anyway, this function returns true if the
string passed to it is only made up of letters (upper/lower case) or numbers.
<?PHP
//-------------------------------------------------------------------
//allowed chars from 48-57,65-90,97-122 AKA 0-9, A-Z, a-z
//-------------------------------------------------------------------
function isAlphaNumeric($checkThisString){
$result = true;
$i=0;
while($i<strlen($checkThisString) && $result){
$char = substr($checkThisString,$i,1);
$charNum = ord($char);
if( !(($charNum>47 && $charNum < 58) || ($charNum>64 && $charNum < 91)
|| ($charNum>96 && $charNum < 123)) )
$result = false;
$i++;
}
return $result;
}
?>
cheers,
Adam F-K
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50296
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50296&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50296&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50296&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50296&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50296&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50296&report=yes
Search -- http://master.php.net/manage/user-notes.php