perfexa Posted April 12, 2011 Share Posted April 12, 2011 Hi all, please bare with me i am a newbie to this forum, i will try my best to provide all clear accurate information where possible, please find a below breakdown, i've had a little help from a user already but as am still getting problems and confused i will take his advise am post it in the right place ! 1) I have the below code and wish to ban specifc words, numbers and emails of my choice. 2) If the users enter a baned word etc either nothing will happen or it will forward them to another page. Please find attached index.php which is full working script of where i wish to add my banned words code too, also please find attached indextest.php containing the working script and code of bannng specfic words that i can't get to work. When i run indextest.php on my linux server the whole page displays perfectly but when you enter a baned or unbaned word and click submit nothing happens at all, so am very confused to where am going wrong. Any kind, helpfull guides to what i'm doing wrong would be highly appriciate as i do want to learn from my mistakes. All the best Steve [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/ Share on other sites More sharing options...
perfexa Posted April 12, 2011 Author Share Posted April 12, 2011 NOTE, these are my errors Notice: Undefined index: do in /var/www/vhosts/facekandi.com/httpdocs/beta/index.php on line 10 Notice: Undefined index: do in /var/www/vhosts/facekandi.com/httpdocs/beta/index.php on line 14 Notice: Undefined index: do in /var/www/vhosts/facekandi.com/httpdocs/beta/index.php on line 36 Notice: Undefined index: do in /var/www/vhosts/facekandi.com/httpdocs/beta/index.php on line 59 Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1200724 Share on other sites More sharing options...
QuickOldCar Posted April 12, 2011 Share Posted April 12, 2011 As for the match of ban words use something like this. <?php $badwords = array( 'monkey', 'banana', 'justin bieber', 'barbara streisant' ); $pattern = implode("|",$badwords); echo "$pattern<br />";//just to see them if(preg_match("/$pattern/i", trim($_POST['ename']))){ echo 'die!'; }else{ echo 'proceed'; } ?> <form action="" method="post"> Name or Email: <input type="text" name="ename" /> <input type="submit" /> </form> As for any includes you got for api's and w/e, nobody can run the same script you are. I did manage to get it connected by excluding some includes, but I had nobody to talk to. Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1200736 Share on other sites More sharing options...
QuickOldCar Posted April 12, 2011 Share Posted April 12, 2011 Use similar to this pattern for "exact" instead of the "if contains" in previous code I did. if(preg_match("/\($pattern\)/i", trim($_POST['ename']))){ Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1200740 Share on other sites More sharing options...
perfexa Posted April 12, 2011 Author Share Posted April 12, 2011 Cheers, but this is where i'm falling down i think after insterting the php code how to i put this code in conjunction with the form code on yours for it to work <?php } else { ?> <form action="index.php?do=start" method="post" > <fieldset style="width: 120; height: 60; font-size: 18px;"> <legend><span class="Facekandi"><font color="#F0F0F0">Enter your Apple Facetime ID</font><font color="#0066FF">*</font></span></legend> <input type="text" name="facetimeid" class="userinput" maxlength="35" size="37" /> </fieldset> <input type="image" src="button.png" class="usersubmit" /> [code] Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1200762 Share on other sites More sharing options...
QuickOldCar Posted April 12, 2011 Share Posted April 12, 2011 I think this should work, just replaced the one line and used your facetimeid value <?php require ('settings.php'); require('functions.php'); session_start(); if ($_GET['do']=='start') { if ($_POST['facetimeid']=='') { header("Location:".SITE_BASE); } else { include('init.php'); } } elseif ($_GET['do']=='random') { // Make sure we have a session, otherwise redirect to homepage if ($_SESSION['CurrentUser']=='') { header("Location:".SITE_BASE); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="tr-TR"> <head> <title>Facekandi for iPhone</title> <base href="<?php print SITE_BASE; ?>/" /> <meta name="keywords" content="facekandi, livecam, webcam, facelette, facetime chat, iphone 4g, facetime, itouch 4g, face chatroom, video chat, world video chat, "> <meta name="description" content="Facekandi is an iPhone and iPad application designed for randomly pairing you with people all over the world. Try it today to chat, engage and have fun in all kinds of ways. "> <link rel="stylesheet" type="text/css" href="style.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width" /> <link href="http://facekandi.com/iphone/favicon.ico" rel="icon" type="image/x-icon" /> </head> <body> <img src="facekandi.png" alt="" width="265" height="39" /> <?php if ($_GET['do']=='start') { $ruser = getRandomUser($_POST['facetimeid']); $ruser=$ruser['UserFacetimeID']; ?> <div class="content"> Great! You can now start a Facetime session with <a href="external://facetime://<?php echo $ruser; ?>"><?php echo $ruser; ?></a>! <br/> <form action="index.php?do=random" method="post" /><input type="image" src="next.png" class="usersubmit" /><p> </p> <p><font color="#C0C0C0">Go social facekandi crazy..</font></p><!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_default_style addthis_32x32_style"> <a class="addthis_button_preferred_1"></a> <a class="addthis_button_preferred_2"></a> <a class="addthis_button_preferred_3"></a> <a class="addthis_button_preferred_4"></a> <a class="addthis_button_compact"></a> </div> <script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=facelette"></script> <!-- AddThis Button END --> <p> </p> </form> </div> <?php } elseif ($_GET['do']=='random') { $ruser = getRandomUser($_SESSION['CurrentUser']); $ruser=$ruser['UserFacetimeID']; ?> <div class="content"> Here's a random Facekandi user for you: <a href="external://facetime://<?php echo $ruser; ?>"><?php echo $ruser; ?></a> <br/> <form action="index.php?do=random" method="post" /><input type="image" src="next.png" class="usersubmit" /><p> </p> <p><font color="#C0C0C0" size="3">Share Facekandi with everyone..</font></p> <!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_default_style addthis_32x32_style"> <a class="addthis_button_preferred_1"></a> <a class="addthis_button_preferred_2"></a> <a class="addthis_button_preferred_3"></a> <a class="addthis_button_preferred_4"></a> <a class="addthis_button_compact"></a> </div> <script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4d8a80540dedf0f0"></script> <!-- AddThis Button END --> <p> </p> <p> </p> <p align="center"></p> <p align="center"> <!--Insert your Adsense code --> <!--Adsense code end--></font></a></p> </form> </div> <?php $badwords = array( 'monkey', 'banana', 'justin bieber', 'barbara streisant' ); $pattern = implode("|",$badwords); if(isset($_POST['submit'])&& !empty($_POST['facetimeid'])){ if(preg_match("/\($pattern\)/i", trim($_POST['facetimeid']))){ echo 'die!'; }else{ echo 'proceed'; } }else{ echo 'fill in some stuff'; } ?> <?php } else { ?> <form action="" method="post"> <input type="text" value="" name="facetimeid" class="userinput" /> <input type="submit" name="submit" value="submit" /></form> <br /> <br /> <p align="left" class="smallprint"><font color="#0066FF">*</font>Your Facetime ID is either your <b> iPhone mobile number</b> or <b>email address</b> you use for Facetime.<br /> <br/> </p> <p align="left" class="smallprint"><font color="#FF3E3E" size="1">Once you exit the Facekandi application your session will terminate from our server</font><br /> <br /> Remember: be safe and most importantly have fun!</p> <p align="left"></p> <?php } ?> </div> <!-- insert your Google Analytics here --> <!-- End of Google Analytics code --> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1200773 Share on other sites More sharing options...
QuickOldCar Posted April 12, 2011 Share Posted April 12, 2011 Your check for the bad word just echoes die or proceed, you would have to place an exit and header redirect, die or w/e if want to actually stop them from using it. Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1200776 Share on other sites More sharing options...
perfexa Posted April 12, 2011 Author Share Posted April 12, 2011 I've just tried it and now i'm getting a HTTP500 error Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1200787 Share on other sites More sharing options...
QuickOldCar Posted April 12, 2011 Share Posted April 12, 2011 Does your original index.php file execute and work properly before the check for preg_match? Maybe your server is down? it is a 500 error Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1200802 Share on other sites More sharing options...
perfexa Posted April 12, 2011 Author Share Posted April 12, 2011 servers not now, everything was working fine before i copieed all the code Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1200814 Share on other sites More sharing options...
QuickOldCar Posted April 12, 2011 Share Posted April 12, 2011 Whenever your server works again try this one. I moved the check for bad words up to the top, is no need to execute the script any further than that if they aren't allowed. Also added a header redirect with a message. This was from your original index.php file <?php require ('settings.php'); require('functions.php'); session_start(); $badwords = array('monkey', 'banana', 'justin bieber', 'barbara streisant' ); $pattern = implode("|",$badwords); if(preg_match("/$pattern/i", trim($_POST['facetimeid']))){ header( "refresh:5;url=index.php" ); echo 'Not allowed, You\'ll be redirected in about 5 secs. If not, click <a href="index.php">here</a>.'; EXIT; } else { if ($_GET['do']=='start') { if ($_POST['facetimeid']=='') { header("Location:".SITE_BASE); } else { include('init.php'); } } elseif ($_GET['do']=='random') { // Make sure we have a session, otherwise redirect to homepage if ($_SESSION['CurrentUser']=='') { header("Location:".SITE_BASE); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="tr-TR"> <head> <title>Facekandi for iPhone</title> <base href="<?php print SITE_BASE; ?>/" /> <meta name="keywords" content="facekandi, livecam, webcam, facelette, facetime chat, iphone 4g, facetime, itouch 4g, face chatroom, video chat, world video chat, "> <meta name="description" content="Facekandi is an iPhone and iPad application designed for randomly pairing you with people all over the world. Try it today to chat, engage and have fun in all kinds of ways. "> <link rel="stylesheet" type="text/css" href="style.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width" /> <link href="http://facekandi.com/iphone/favicon.ico" rel="icon" type="image/x-icon" /> </head> <body> <img src="facekandi.png" alt="" width="265" height="39" /> <?php if ($_GET['do']=='start') { $ruser = getRandomUser($_POST['facetimeid']); $ruser=$ruser['UserFacetimeID']; ?> <div class="content"> Great! You can now start a Facetime session with <a href="external://facetime://<?php echo $ruser; ?>"><?php echo $ruser; ?></a>! <br/> <form action="index.php?do=random" method="post" /><input type="image" src="next.png" class="usersubmit" /><p> </p> <p><font color="#C0C0C0">Go social facekandi crazy..</font></p><!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_default_style addthis_32x32_style"> <a class="addthis_button_preferred_1"></a> <a class="addthis_button_preferred_2"></a> <a class="addthis_button_preferred_3"></a> <a class="addthis_button_preferred_4"></a> <a class="addthis_button_compact"></a> </div> <script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=facelette"></script> <!-- AddThis Button END --> <p> </p> </form> </div> <?php } elseif ($_GET['do']=='random') { $ruser = getRandomUser($_SESSION['CurrentUser']); $ruser=$ruser['UserFacetimeID']; ?> <div class="content"> Here's a random Facekandi user for you: <a href="external://facetime://<?php echo $ruser; ?>"><?php echo $ruser; ?></a> <br/> <form action="index.php?do=random" method="post" /><input type="image" src="next.png" class="usersubmit" /><p> </p> <p><font color="#C0C0C0" size="3">Share Facekandi with everyone..</font></p> <!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_default_style addthis_32x32_style"> <a class="addthis_button_preferred_1"></a> <a class="addthis_button_preferred_2"></a> <a class="addthis_button_preferred_3"></a> <a class="addthis_button_preferred_4"></a> <a class="addthis_button_compact"></a> </div> <script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4d8a80540dedf0f0"></script> <!-- AddThis Button END --> <p> </p> <p> </p> <p align="center"></p> <p align="center"> <!--Insert your Adsense code --> <!--Adsense code end--></font></a></p> </form> </div> <?php } else { ?> <form action="index.php?do=start" method="post" > <fieldset style="width: 120; height: 60; font-size: 18px;"> <legend><span class="Facekandi"><font color="#F0F0F0">Enter your Apple Facetime ID</font><font color="#0066FF">*</font></span></legend> <input type="text" name="facetimeid" class="userinput" maxlength="35" size="37" /> </fieldset> <input type="image" src="button.png" class="usersubmit" /> <br /> <br /> <p align="left" class="smallprint"><font color="#0066FF">*</font>Your Facetime ID is either your <b> iPhone mobile number</b> or <b>email address</b> you use for Facetime.<br /> <br/> </p> <p align="left" class="smallprint"><font color="#FF3E3E" size="1">Once you exit the Facekandi application your session will terminate from our server</font><br /> <br /> Remember: be safe and most importantly have fun!</p> <p align="left"></p> </form> <?php } } ?> </div> <!-- insert your Google Analytics here --> <!-- End of Google Analytics code --> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1200867 Share on other sites More sharing options...
perfexa Posted April 13, 2011 Author Share Posted April 13, 2011 Hi QuickOldCar Sorry i ment to say my server was never down, the server is still working fine, i've tried both codes you modified and everytime i upload and try it i get a HTTP500 error and when i replace it with the unmodified (normal) code it works fine. Any ideas Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1201053 Share on other sites More sharing options...
QuickOldCar Posted April 13, 2011 Share Posted April 13, 2011 I don't know why it's doing that. I can run the code on my server if i eliminate the includes and the first if statement regarding the api. Could it be your copy/paste is converting the quotes? Try using notepad2 http://sourceforge.net/projects/notepad2/ Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1201133 Share on other sites More sharing options...
perfexa Posted April 13, 2011 Author Share Posted April 13, 2011 I've got no idea either its weird, i just copy and paste into dreamweaver save as php and upload then HTTP500 What do you think is the best way forward? Quote Link to comment https://forums.phpfreaks.com/topic/233513-ban-words-number-and-emails-in-a-text-area/#findComment-1201203 Share on other sites More sharing options...
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.