减少垃圾邮件的提交

时间:2019-03-16 05:04:05

标签: javascript html smarty

我的网站上有一个表格,该表格提供了我的广告客户与其潜在客户之间的联系方式,很遗憾,有很多垃圾邮件发送给我的广告客户,我需要设法阻止它们。由于大多数垃圾邮件都包含大量文本内容,因此我希望将其设置为如果包含140个单词或更多,则会向我发送邮件以确认它不是垃圾邮件。

此表单会自动发送给我的广告客户,因此我需要一种基于消息部分中的单词数来覆盖发送表单的方法。

我不确定如何将其实现到下面的smarty contact.php文件中。

if (!empty($_POST)) {
$go = TRUE;
//they have submitted the form//
if (!empty($_POST['name']) && !empty($_POST['fromemail']) && !empty($_POST['message']) && $go == TRUE) {
//data has been filled
$name = Filter::no_html($_POST['name']);
$from = Filter::no_html($_POST['fromemail']);
$start_dt = Filter::no_html($_POST['start_dt']);
$end_dt = Filter::no_html($_POST['end_dt']);
$comments = Filter::no_html($_POST['message']);
$validate - > isEmpty($name, LANG_JAVASCRIPT_PLEASE_ENTER.
" ".LANG_YOUR_NAME);
$validate - > isEmpty($from, LANG_JAVASCRIPT_PLEASE_ENTER.
" ".LANG_YOUR_EMAIL);
$validate - > isSingleEmail($from, LANG_JAVASCRIPT_PLEASE_ENTER_EMAIL);
$validate - > isEmpty($comments, LANG_JAVASCRIPT_PLEASE_ENTER.
" ".LANG_YOUR_MESSAGE);
$modules - > call_hook('contact_owner_submit', ''); // Call any module functions
$id = (int) @$_POST['ownerid'];
$vehicle = (int) @$_POST['listingid'];

if ($validate - > isError()) {
$errors = $validate - > getErrorList();

$errorText = "<b>The operation could not be performed because one or more error(s) occurred.</b> <p> Please resubmit the form after making the following changes:</p>";
$errorText. = "<ol>";
foreach($errors as $e) {
$errorText. = "<li>".$e['msg'].
                "</li>";
}
$errorText. = "</ol>";
$class_tpl - > assign('msg', $errorText);

//assign the vars back
foreach($_POST as $item => $k) //@TODO remove if these being assigned twice
{
$class_tpl - > assign(Filter::special_chars($item), Filter::special_chars($k));
}

$class_tpl - > assign('title', $title);
$class_tpl - > assign('name', Filter::special_chars($_POST['name']));
$class_tpl - > assign('fromemail', Filter::special_chars($_POST['fromemail']));
$class_tpl - > assign('message', Filter::special_chars($_POST['message']));
$class_tpl - > assign('start_dt', Filter::special_chars($_POST['start_dt']));
$class_tpl - > assign('end_dt', Filter::special_chars($_POST['end_dt']));
$class_tpl - > assign('lid', Filter::special_chars($_POST['listingid']));
$class_tpl - > assign('owner', Filter::special_chars($_POST['ownerid']));
$class_tpl - > assign('body', 'contact/contactowner.tpl');
} else {
//update the replied count
$sSQL = "UPDATE ".PREFIX.
"listings SET repliedcount=repliedcount+1 WHERE id=".Filter::mysql_quote($vehicle);
$db - > query($sSQL);

//now get the user information
$sSQL = "SELECT firstname, lastname, email,username FROM ".PREFIX.
"users WHERE id=".Filter::mysql_quote($id);
$result = $db - > query($sSQL);
$rs = $result - > fetch();
$to_first_name = $rs['firstname'];
$to_last_name = $rs['lastname'];
$to = $rs['email'];
$to_username = $rs['username'];

//now the vehicle information
$sSQL = "SELECT id,title FROM ".PREFIX.
"listings WHERE id=".Filter::mysql_quote($vehicle);
$result = $db - > query($sSQL);
$rs = $result - > fetch();
$vehicle = $rs['id'];
$ltitle = $rs['title'];
$sitetitle = $title;

$vars['listing_url'] = $modules - > call_hook('listing_url', $rs);
if ($vars['listing_url'] == '') {
$vars['listing_url'] = URL.
"/viewlisting.php?view=".$vehicle;
}

$vars['name'] = $name;
$vars['email'] = $to;
$vars['fromemail'] = $from;
$vars['name'] = $name;
$vars['comments'] = $comments;
$vars['start_dt'] = $start_dt;
$vars['end_dt'] = $end_dt;
$vars['sitetitle'] = $sitetitle;
$vars['to_first_name'] = $to_first_name;
$vars['to_last_name'] = $to_last_name;
$vars['to_username'] = $to_username;
$content = "contactowner.tpl";
$msg = $Mailer - > sendMail($to, $content, $vars);

if ($msg == TRUE) {
$class_tpl - > assign('pPageContent', LANG_CONTACT_SUCCESS_BODY);
$class_tpl - > assign('body', 'content.tpl');
} else {
$class_tpl - > assign('title', LANG_ERROR);
$class_tpl - > assign('pPageContent', $msg);
$class_tpl - > assign('body', 'content.tpl');
}
$class_tpl - > display('layout.tpl');
die();

}
} else {
//show the form again
$class_tpl - > assign('title', $title);
$class_tpl - > assign('name', Filter::special_chars($_POST['name']));
$class_tpl - > assign('fromemail', Filter::special_chars($_POST['fromemail']));
$class_tpl - > assign('message', Filter::special_chars($_POST['message']));
$class_tpl - > assign('start_dt', Filter::special_chars($_POST['start_dt']));
$class_tpl - > assign('end_dt', Filter::special_chars($_POST['end_dt']));
$class_tpl - > assign('lid', (int) $_POST['listingid']);
$class_tpl - > assign('owner', (int) $_POST['ownerid']);
$class_tpl - > assign('body', 'contact/contactowner.tpl');
}
} else {
$class_tpl - > assign('title', $title);
$class_tpl - > assign('name', Filter::special_chars($_REQUEST['name']));
$class_tpl - > assign('fromemail', Filter::special_chars($_REQUEST['fromemail']));
$class_tpl - > assign('message', Filter::special_chars($_REQUEST['message']));
$class_tpl - > assign('start_dt', Filter::special_chars($_REQUEST['start_dt']));
$class_tpl - > assign('end_dt', Filter::special_chars($_REQUEST['end_dt']));
$class_tpl - > assign('lid', (int) $_REQUEST['listingid']);
$class_tpl - > assign('owner', (int) $_REQUEST['ownerid']);
$class_tpl - > assign('body', 'contact/contactowner.tpl');
}
$class_tpl - > display('layout.tpl');

0 个答案:

没有答案