Nicholas Posted January 15, 2010 Posted January 15, 2010 hi, you know in mailbox... where can i put this to stop advertising and swear words? hopefully ive done it right... if not can someone correct it for me? sorry about swear words btw... if(!preg_match('~(.?).(http|www|.com|.co.uk|.info|.co.cc|fuck|nob|fanny|vagina|dick|.net|bitch|gay|shit)~i', $_POST['message'])) { print "Sorry, we dont allow advertising or swear words... [url='index.php']> Go Back <[/url]"; } else { yes i made them lines myself from scratch lol, and im not a good coder really still beginner so not 100% sure its correct... where can i put that text? which function and where? i tried putting it in the (function mail_send) part but cant figure it out where to put it to prevent well that lol. Quote
Nicholas Posted January 15, 2010 Author Posted January 15, 2010 ahh figured it out... sorry about the post... knew ill figure it out once i done this post... function mail_send() { global $db,$ir,$c,$userid,$h; $subj=str_replace(array("\n"),array(" "),strip_tags($_POST['subject'])); $msg=str_replace(array("\n"),array(" "),strip_tags($_POST['message'])); if(!preg_match('~(.?).(http|www|.com|.co.uk|.info|.co.cc|fuck|nob|fanny|vagina|dick|.net|bitch|gay|shit)~i', $_POST['message'])) { print "Sorry, we dont allow advertising or swear words... [url='index.php']> Go Back <[/url]"; $h->endpage(); exit; } Quote
Nicholas Posted January 15, 2010 Author Posted January 15, 2010 damn wait that dont work... can anyone help me? this is my sending function? can someone add that preg thing in for me to make it work? function mail_send() { global $db,$ir,$c,$userid,$h; $subj=str_replace(array("\n"),array(" "),strip_tags($_POST['subject'])); $msg=str_replace(array("\n"),array(" "),strip_tags($_POST['message'])); if($_POST['user1'] && $_POST['user2']) { die("Please do not select a contact AND enter a username, only do one. [url='mailbox.php']> Back[/url]"); } if(!$_POST['user1'] && !$_POST['user2']) { die("You must select a contact or enter a username. [url='mailbox.php']> Back <[/url]"); } $codes = array( ':)', ';)', ':o', ':D', ':s', ':(', 'angry', 'kissy', 'clapping', 'drool', 'crying', 'hyper', 'newbie', 'rolleyes', 'shock', 'thumbsup', ':P', 'yawn', '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', ); $images = array( '[img=smilies/smile.gif]', '[img=smilies/wink.gif]', '[img=smilies/shock.gif]', '[img=smilies/happy.gif]', '[img=smilies/confused.gif]', '[img=smilies/sad.gif]', '[img=smilies/angry.gif]', '[img=smilies/kissy.gif]', '[img=smilies/clapping.gif]', '[img=smilies/drool.gif]', '[img=smilies/cry1.gif]', '[img=smilies/hyper.gif]', '[img=smilies/newbie.gif]', '[img=smilies/rolleye.gif]', '[img=smilies/shock.gif]', '[img=smilies/thumbsup.gif]', '[img=smilies/tongue.gif]', '[img=smilies/yawn.gif]', '[b]', '[/b]', '[i]', '[/i]', '<u>', '</u>', ); $newmsg = str_replace($codes, $images, $msg); $to=($_POST['user1']) ? $_POST['user1'] : $_POST['user2']; $q=$db->query("SELECT userid FROM users WHERE username='{$to}'"); if($db->num_rows($q)==0) { die("<font color=white>You cannot send mail to nonexistant users. [url='mailbox.php']> <font color=white>Back[/url]"); } $to=$db->fetch_single($q); $db->query("INSERT INTO mail VALUES ('',0,$userid,$to,unix_timestamp(),'$subj','$msg')"); $db->query("UPDATE users SET new_mail=new_mail+1 WHERE userid={$to}"); print "<font color=white>Message sent. [url='mailbox.php']> <font color=white>Back[/url]"; } Quote
seanybob Posted January 15, 2010 Posted January 15, 2010 function mail_send() { global $db,$ir,$c,$userid,$h; $subj=str_replace(array("\n"),array(" "),strip_tags($_POST['subject'])); $msg=str_replace(array("\n"),array(" "),strip_tags($_POST['message'])); if($_POST['user1'] && $_POST['user2']) { die("Please do not select a contact AND enter a username, only do one. [url='mailbox.php']> Back[/url]"); } if(!$_POST['user1'] && !$_POST['user2']) { die("You must select a contact or enter a username. [url='mailbox.php']> Back <[/url]"); } $codes = array( ':)', ';)', ':o', ':D', ':s', ':(', 'angry', 'kissy', 'clapping', 'drool', 'crying', 'hyper', 'newbie', 'rolleyes', 'shock', 'thumbsup', ':P', 'yawn', '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', ); $images = array( '[img=smilies/smile.gif]', '[img=smilies/wink.gif]', '[img=smilies/shock.gif]', '[img=smilies/happy.gif]', '[img=smilies/confused.gif]', '[img=smilies/sad.gif]', '[img=smilies/angry.gif]', '[img=smilies/kissy.gif]', '[img=smilies/clapping.gif]', '[img=smilies/drool.gif]', '[img=smilies/cry1.gif]', '[img=smilies/hyper.gif]', '[img=smilies/newbie.gif]', '[img=smilies/rolleye.gif]', '[img=smilies/shock.gif]', '[img=smilies/thumbsup.gif]', '[img=smilies/tongue.gif]', '[img=smilies/yawn.gif]', '[b]', '[/b]', '[i]', '[/i]', '<u>', '</u>', ); $newmsg = str_replace($codes, $images, $msg); if(!preg_match('~(.?).(http|www|.com|.co.uk|.info|.co.cc|fuck|nob|fanny|vagina|dick|.net|bitch|gay|shit)~i', $newmsg)) { die("Sorry, we dont allow advertising or swear words... [url='index.php']> Go Back <[/url]"); } $to=($_POST['user1']) ? $_POST['user1'] : $_POST['user2']; $q=$db->query("SELECT userid FROM users WHERE username='{$to}'"); if($db->num_rows($q)==0) { die("<font color=white>You cannot send mail to nonexistant users. [url='mailbox.php']> <font color=white>Back[/url]"); } $to=$db->fetch_single($q); $db->query("INSERT INTO mail VALUES ('',0,$userid,$to,unix_timestamp(),'$subj','$newmsg')"); $db->query("UPDATE users SET new_mail=new_mail+1 WHERE userid={$to}"); print "<font color=white>Message sent. [url='mailbox.php']> <font color=white>Back[/url]"; } Fixed. I crudely just made it die... but that'll work. Quote
Zeggy Posted January 15, 2010 Posted January 15, 2010 I think your regular expression is wrong. It will only match text like ahttp, bshit, ccnob, etc. Try this: /(((http|www).+)|(.+(\.com|\.co.uk|\.info|\.co\.cc|\.net))|.*(fuck|nob|fanny|vagina|dick|bitch|gay|shit).*)/i This will match words that begin with http or www, end in .com/.co.uk/etc or any words that contain swear words (even doorknob or snob will trigger because it contains nob, so watch out which words you put in here). Quote
Nicholas Posted January 15, 2010 Author Posted January 15, 2010 function mail_send() { global $db,$ir,$c,$userid,$h; $subj=str_replace(array("\n"),array(" "),strip_tags($_POST['subject'])); $msg=str_replace(array("\n"),array(" "),strip_tags($_POST['message'])); if($_POST['user1'] && $_POST['user2']) { die("Please do not select a contact AND enter a username, only do one. > Back"); } if(!$_POST['user1'] && !$_POST['user2']) { die("You must select a contact or enter a username. > Back <"); } $codes = array( ':)', ';)', ':o', ':D', ':s', ':(', 'angry', 'kissy', 'clapping', 'drool', 'crying', 'hyper', 'newbie', 'rolleyes', 'shock', 'thumbsup', ':P', 'yawn', '', '', '', '', '', '', ); $images = array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '<u>', '</u>', ); $newmsg = str_replace($codes, $images, $msg); if(!preg_match('~(.?).(http|www|.com|.co.uk|.info|.co.cc|fuck|nob|fanny|vagina|dick|.net|bitch|gay|shit)~i', $newmsg)) { die("Sorry, we dont allow advertising or swear words... > Go Back <"); } $to=($_POST['user1']) ? $_POST['user1'] : $_POST['user2']; $q=$db->query("SELECT userid FROM users WHERE username='{$to}'"); if($db->num_rows($q)==0) { die("<font color=white>You cannot send mail to nonexistant users. > <font color=white>Back"); } $to=$db->fetch_single($q); $db->query("INSERT INTO mail VALUES ('',0,$userid,$to,unix_timestamp(),'$subj','$newmsg')"); $db->query("UPDATE users SET new_mail=new_mail+1 WHERE userid={$to}"); print "<font color=white>Message sent. > <font color=white>Back"; } Fixed. I crudely just made it die... but that'll work. doesnt work :( just says Sorry, we dont allow advertising or swear words... > Go Back < when i typed "test" and then tried to send it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.