note 53975 added to function.eregi
| From: | liam at sunwise dot co dot uk | Date: | Sun, 19 Jun 2005 17:48:48 +0000 |
| Subject: | note 53975 added to function.eregi | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90655@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/function.eregi.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53975
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53975&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53975&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53975&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53975&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+53975&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53975&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53975&report=yes
Search -- http://master.php.net/manage/user-notes.php