56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
<?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();
|
|
}
|
|
}
|