Jump to content

Recommended Posts

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]

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

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.

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]

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&#39;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>

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&#39;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>

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

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/

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.