First comit
This commit is contained in:
55
override/controllers/front/ContactController.php
Normal file
55
override/controllers/front/ContactController.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
class ContactController extends ContactControllerCore
|
||||
{
|
||||
public function postProcess()
|
||||
{
|
||||
session_start();
|
||||
$filename = _PS_ROOT_DIR_ . 'banned.txt';
|
||||
|
||||
if (Tools::isSubmit('submitMessage')) {
|
||||
|
||||
$message = Tools::getValue('message');
|
||||
$from = Tools::getValue('from');
|
||||
|
||||
if (file_exists($filename)) {
|
||||
|
||||
$banned_in_email = array();
|
||||
$banned_content = ['email marketing'];
|
||||
$target = Context::getContext()->link->getPageLink('contact');
|
||||
|
||||
try {
|
||||
$file = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $filename);
|
||||
$file = new SplFileObject($file);
|
||||
} catch (LogicException $exception) {
|
||||
die('SplFileObject : ' . $exception->getMessage());
|
||||
}
|
||||
while ($file->valid()) {
|
||||
$line = $file->fgets();
|
||||
array_push($banned_in_email, trim($line));
|
||||
}
|
||||
$file = null;
|
||||
|
||||
$_SESSION["bannedctc"] = "notbanned";
|
||||
|
||||
foreach ($banned_in_email as $string) {
|
||||
|
||||
if (strstr($from, $string)) {
|
||||
//$this->errors[] = Tools::displayError('This email address is not allowed');
|
||||
$_SESSION["bannedctc"] = "banned";
|
||||
Tools::redirectAdmin($target);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($banned_content as $string) {
|
||||
if (strstr($message, $string)) {
|
||||
//$this->errors[] = Tools::displayError('Invalid Content');
|
||||
$_SESSION["bannedctc"] = "banned";
|
||||
Tools::redirectAdmin($target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo $_SESSION["bannedctc"];
|
||||
parent::postProcess();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user