. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| Server IP : 52.223.31.75 / Your IP : 172.31.6.220 [ Web Server : Apache/2.4.66 () OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux ip-172-31-14-81.eu-central-1.compute.internal 4.14.281-212.502.amzn2.x86_64 #1 SMP Thu May 26 09:52:17 UTC 2022 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE Domains : 4 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/ripara.co/bat/ |
Upload File : |
<?php
function inviaEmail($formType, $sendEmail, $sendMessage, $sendName = "Ripara.co"){
$formConfigFile = file_get_contents("./bat/rd-mailform.config.json");
$formConfig = json_decode($formConfigFile, true);
date_default_timezone_set('Etc/UTC');
try {
require './bat/phpmailer/PHPMailerAutoload.php';
$recipients = $formConfig['recipientEmail'];
preg_match_all("/([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)/", $recipients, $addresses, PREG_OFFSET_CAPTURE);
if (!count($addresses[0])) {
die('MF001');
}
if(!function_exists("getRemoteIPAddress")){
function getRemoteIPAddress() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
return $_SERVER['HTTP_CLIENT_IP'];
} else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
return $_SERVER['REMOTE_ADDR'];
}
}
if (preg_match('/^(127\.|192\.168\.)/', getRemoteIPAddress())) {
die('MF002');
}
$template = file_get_contents('./bat/rd-mailform.tpl');
if (isset($formType)) {
switch ($formType){
case 'contatto':
$subject = 'Messaggio da modulo contatti del sito!';
break;
case 'iscrizione':
$subject = 'Iscrizione al sito Ripara.co!';
break;
case 'ordine':
$subject = 'Nuovo Ordine ricevuto!';
break;
case 'passwordrecovery':
$subject = 'Password di recupero!';
break;
default:
$subject = 'Messaggio dal sito Ripara.co';
break;
}
}else{
die('MF004');
}
if (isset($sendEmail)) {
$template = str_replace(
array("<!-- #{FromState} -->", "<!-- #{FromEmail} -->"),
array("Email:", $sendEmail),
$template);
}
if (isset($sendMessage)) {
$template = str_replace(
array("<!-- #{MessageState} -->", "<!-- #{MessageDescription} -->"),
array("Message:", $sendMessage),
$template);
}
preg_match("/(<!-- #{BeginInfo} -->)(.|\n)+(<!-- #{EndInfo} -->)/", $template, $tmp, PREG_OFFSET_CAPTURE);
foreach ($_POST as $key => $value) {
if ($key != "counter" && $key != "email" && $key != "message" && $key != "form-type" && $key != "g-recaptcha-response" && !empty($value)){
$info = str_replace(
array("<!-- #{BeginInfo} -->", "<!-- #{InfoState} -->", "<!-- #{InfoDescription} -->"),
array("", ucfirst($key) . ':', $value),
$tmp[0][0]);
$template = str_replace("<!-- #{EndInfo} -->", $info, $template);
}
}
$template = str_replace(
array("<!-- #{Subject} -->", "<!-- #{SiteName} -->"),
array($subject, $_SERVER['SERVER_NAME']),
$template);
$mail = new PHPMailer();
if ($formConfig['useSmtp']) {
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
// $mail->Debugoutput = 'logHandler';
$mail->Debugoutput = 'html';
// Set the hostname of the mail server
$mail->Host = $formConfig['host'];
// Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = $formConfig['port'];
// Whether to use SMTP authentication
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
// Username to use for SMTP authentication
$mail->Username = $formConfig['username'];
// Password to use for SMTP authentication
$mail->Password = $formConfig['password'];
/* $mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);*/
}
$mail->From = $addresses[0][0][0];
# Attach file
if (isset($_FILES['file']) &&
$_FILES['file']['error'] == UPLOAD_ERR_OK) {
$mail->AddAttachment($_FILES['file']['tmp_name'],
$_FILES['file']['name']);
}
if (isset($sendName)){
$mail->FromName = $sendName;
}else{
$mail->FromName = "Ripara.co";
}
/* foreach ($addresses[0] as $key => $value) {
$mail->addAddress($value[0]);
}*/
$mail->addAddress($sendEmail);
$mail->CharSet = 'utf-8';
$mail->Subject = $subject;
$mail->MsgHTML($template);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
//die;
die('MF255');
}
// $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
return 'MF000';
} catch (phpmailerException $e) {
die('MF254');
} catch (Exception $e) {
error_log("------------------------------------------------------------------------------------------".$e."------------------------------------------------");
die('MF255');
}
}