note 53975 rejected from function.eregi by betz

From: Date: Sun, 10 Jul 2005 11:54:52 +0000
Subject: note 53975 rejected from function.eregi by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-91732@lists.php.net to get a copy of this message
Note Submitter: liam at sunwise dot co dot uk ---- Anyone tried to use eregi stop anoying people who wreck your site? In english, I am new to PHP but getting better each day. I couldn't block < or > using eregi. My guestbook I made posted all information without a second thought as I had no eregi command to stop this. As a result I lost mysql DB and had hidden files put on my server using a . before the file name! I want to prevent this and share this with everyone as I can't find it anywhere! Problem is tho I only got this far in making it.... <?php $comment = 'comment left by user'; if (eregi ("^(\\<|\\<\\?|\\<\\?php)(*)(\\>|\\?\\>)$", stripslashes(trim($_POST['comment'])))){ $comment = FALSE; $error = 'Your comment is invalid.'; }else{ $comment = $_POST['comment']; } if ($comment && $name && $email){ #Then this would place it in my sql and so on }else{ #if error display on page echo $error; } ?> It only seems to pick up on the php or < tag at the begining I think this is because the pattern dosn't tell it to look for letters/numbers at the beging, as you can get around it by typing information first then proceeding with the php tag. Any ideas are welcome as this sort problem can cost a lot of time. Liam

« previous php.notes (#91732) next »