note 50296 deleted from function.str-replace by bjori

From: Date: Sun, 26 Mar 2006 22:25:53 +0000
Subject: note 50296 deleted from function.str-replace by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106677@lists.php.net to get a copy of this message
Note Submitter: dambkruck AT hotmail dot com ---- 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

« previous php.notes (#106677) next »