1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Contact Form: Simple keyword and phrase filtering option added.

This commit is contained in:
Cameron
2016-08-28 10:32:10 -07:00
parent 8c52c8aa4e
commit 50fc69a124
4 changed files with 57 additions and 9 deletions

View File

@@ -53,7 +53,33 @@ if (!vartrue($CONTACT_FORM))
if(isset($_POST['send-contactus']))
{
$error = "";
$error = "";
$ignore = false;
// Contact Form Filter -----
$contact_filter = e107::pref('core','contact_filter','');
if(!empty($contact_filter))
{
$tmp = explode("\n", $contact_filter);
if(!empty($tmp))
{
foreach($tmp as $filterItem)
{
if(strpos($_POST['body'], $filterItem)!==false)
{
$ignore = true;
break;
}
}
}
}
// ---------
$sender_name = $tp->toEmail($_POST['author_name'], true,'RAWTEXT');
$sender = check_email($_POST['email_send']);
@@ -108,7 +134,14 @@ if(isset($_POST['send-contactus']))
*/
// No errors - so proceed to email the admin and the user (if selected).
if(empty($error))
if($ignore === true)
{
$ns->tablerender('', "<div class='alert alert-success'>".LANCONTACT_09."</div>"); // ignore and leave them none the wiser.
e107::getDebug()->log("Contact form post ignored");
require_once(FOOTERF);
exit;
}
elseif(empty($error))
{
$body .= "<br /><br />
<table class='table'>
@@ -198,22 +231,23 @@ if(isset($_POST['send-contactus']))
);
$message = e107::getEmail()->sendEmail($send_to, $send_to_name, $eml, false) ? LANCONTACT_09 : LANCONTACT_10;
// $message = (sendemail($send_to,"[".SITENAME."] ".$subject, $body,$send_to_name,$sender,$sender_name)) ? LANCONTACT_09 : LANCONTACT_10;
$message = e107::getEmail()->sendEmail($send_to, $send_to_name, $eml, false) ? LANCONTACT_09 : LANCONTACT_10;
if(isset($pref['contact_emailcopy']) && $pref['contact_emailcopy'] && $email_copy == 1)
{
// $message = (sendemail($send_to,"[".SITENAME."] ".$subject, $body,$send_to_name,$sender,$sender_name)) ? LANCONTACT_09 : LANCONTACT_10;
if(isset($pref['contact_emailcopy']) && $pref['contact_emailcopy'] && $email_copy == 1)
{
require_once(e_HANDLER."mail.php");
sendemail($sender,"[".SITENAME."] ".$subject, $body,ADMIN,$sender,$sender_name);
}
}
$ns->tablerender('', "<div class='alert alert-success'>".$message."</div>");
require_once(FOOTERF);
exit;
}
else
else
{
message_handler("P_ALERT", $error);
}

View File

@@ -501,6 +501,17 @@ $text .= "<fieldset class='e-hideme' id='core-prefs-email'>
<div class='smalltext field-help'>Contact form will only be visible to this userclass group.</div>
</td>
</tr>
<tr>
<td><label for='contact-filter'>".PRFLAN_270."</label></td>
<td>
".$frm->textarea('contact_filter', $pref['contact_filter'], 5, 59, array('size'=>'xxlarge'))."
<div class='smalltext field-help'>".PRFLAN_271."</div>
</td>
</tr>
<tr>
<td><label for='contact-emailcopy'>".PRFLAN_164."</label></td>
<td>";
@@ -517,6 +528,7 @@ $text .= "<fieldset class='e-hideme' id='core-prefs-email'>
</td>
</tr>
</tbody>
</table>
".pref_submit('email')."

View File

@@ -32,6 +32,7 @@
<core name="compress_output">0</core>
<core name="contact_emailcopy">0</core>
<core name="contact_visibility">0</core>
<core name="contact_filter"></core>
<core name="cookie_name">e107cookie</core>
<core name="core-infopanel-default"><![CDATA[array (
0 => 'e-administrator',

View File

@@ -287,4 +287,5 @@ define("PRFLAN_267", "Emailing method");
define("PRFLAN_268", "Frontend Inline-Editing");
define("PRFLAN_269", "Admins with this userclass (and the appropriate admin permissions) will be able to edit html directly via the frontend area.");
define("PRFLAN_270", "Contact Form Filtering");
define("PRFLAN_271", "Ignore form submissions containing these words or phrases. One per line.");