Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Extra contact_us.php Protection


MJP

Recommended Posts

I've installed this contribution which looks great but unfortunately it's not working for me. I get no errors but typing in any filter keyword such as "china" still allows the message to be sent. Install is pretty easy so I don't think I messed that up. Or maybe I did!

Any thoughts what could be wrong? Thanks!

 

 

Here is my contact_us.php file:

<?php


 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTACT_US);

 $error = false;
 if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) {
  $name = preg_replace ('/([\x80-\xff])/se','',$name);
if( strlen($name) < 3 ) {
	$messageStack->add('contact_us', 'Enter Your Name Please');
	$error = true;
}
$email_address = tep_db_prepare_input($HTTP_POST_VARS['email']);
  $enquiry = strip_tags($enquiry);
$enquiry = preg_replace ('/([\x80-\xff])/se','',$enquiry);
if( strlen($enquiry) < 10 ) {
	$messageStack->add('contact_us', 'Please enter a Message to Submit Your Message');
	$error = true;
}
if( strlen($enquiry) > 350 ) {
	$messageStack->add('contact_us', 'Please shorten your message and use only necessary detail.');
	$error = true;
}

$patterns = array("china", "fuck", "travel", "viagara");
$regex = '/(' .implode('|', $patterns) .')/i';
if (preg_match($regex, $enquiry)){
$messageStack->add('contact_us', 'Not interested in your spam, thank you.');
$error = true;
}

if (tep_validate_email($email_address)) {
  tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address);
	if(SEND_CONTACT_US_RESPONSE=='true')

  tep_mail($name, $email_address, CONTACT_US_RESPONSE_EMAIL_SUBJECT, CONTACT_US_RESPONSE_EMAIL_TEXT."\n\n-------------------------Your Message:\n".$enquiry, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);



  tep_redirect(tep_href_link(FILENAME_CONTACT_US, 'action=success'));
} else {
  $error = true;

  $messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
}
 }

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONTACT_US));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="images/spacer.gif" alt="" height="20" width="375" border="0">

</td>
</tr>
</table><!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //--><table width="80" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td background="images/leftshadow1.jpg"><img src="images/spacer.gif" alt="" height="32" width="25" border="0"></td>
			<td>
<table width="750" border="0" cellspacing="0" cellpadding="0" align="center" background="images/lightlinenbkg.jpg">

		<tr>
			<td background="images/lbstorebottom.jpg"><img src="images/spacer.gif" alt="" height="10" width="37" border="0"></td>
			<td valign="top">
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
</table></td>
<!-- body_text //-->
<td width="100%" valign="top"><?php echo tep_draw_form('contact_us', tep_href_link(FILENAME_CONTACT_US, 'action=send')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_contact_us.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
   <?php
 if ($messageStack->size('contact_us') > 0) {
?>
  <tr>
	<td><?php echo $messageStack->output('contact_us'); ?></td>
  </tr>
<?php
 }
?>
  <?php
 if ($messageStack->size('contact') > 0) {
?>
  <tr>
	<td><?php echo $messageStack->output('contact'); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 }

 if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) {
?>

Link to comment
Share on other sites

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...