First comit

This commit is contained in:
2024-02-23 09:48:44 +01:00
commit 00c63da237
6 changed files with 1017 additions and 0 deletions

View 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();
}
}