remove php

This commit is contained in:
sHa
2022-12-01 21:08:47 +02:00
parent a9dc93adee
commit 7e2c206638
8 changed files with 1 additions and 321 deletions

7
.env
View File

@@ -1,7 +0,0 @@
SMTP_SERVER=smtp.mailgun.org
SMTP_USER=site@mg.slavforest.com.ua
SMTP_PASSWORD=bec5494ae5dd629663b3150237e6f361-af6c0cec-6f6edfe8
SMTP_RECEIVER=slavforest@gmail.com
SENDER_NAME='Site form slavforest.com.ua'
SENDER_EMAIL=site@mg.slavforest.com.ua

View File

@@ -1,7 +0,0 @@
SMTP_SERVER=smtp.mailgun.org
SMTP_USER=site@mg.slavforest.com.ua
SMTP_PASSWORD=bec5494ae5dd629663b3150237e6f361-af6c0cec-6f6edfe8
SMTP_RECEIVER=test2@shadoll.com
SENDER_NAME=Site form slavforest.com.ua
SENDER_EMAIL=site@mg.slavforest.com.ua

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
vendor/* vendor/*
composer.lock composer.lock
.vscode/*

View File

@@ -1,8 +0,0 @@
{
"name": "shadoll/slavforest",
"description": "Slav forest site",
"require": {
"vlucas/phpdotenv": "^3.6",
"phpmailer/phpmailer": "^6.1"
}
}

View File

@@ -1,98 +0,0 @@
<?php
//======================================================================
// Variables
//======================================================================
//E-mail address. Enter your email
define("__TO__", "sha@shadoll.work");
//Success message
define('__SUCCESS_MESSAGE__', "Your message has been sent. We will reply soon. Thank you!");
//Error message
define('__ERROR_MESSAGE__', "Your message hasn't been sent. Please try again.");
//Messege when one or more fields are empty
define('__MESSAGE_EMPTY_FIELDS__', "Please fill out all fields");
//======================================================================
// Do not change
//======================================================================
//E-mail validation
function check_email($email){
if(!@eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
return false;
} else {
return true;
}
}
//Send mail
function send_mail($to,$subject,$message,$headers){
if(@mail($to,$subject,$message,$headers)){
echo json_encode(array('info' => 'success', 'msg' => __SUCCESS_MESSAGE__));
} else {
echo json_encode(array('info' => 'error', 'msg' => __ERROR_MESSAGE__));
}
}
//Get data form and send mail
if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['message'])){
$name = $_POST['name'];
$mail = $_POST['email'];
$subjectForm = $_POST['subject'];
$messageForm = $_POST['message'];
if($name == '') {
echo json_encode(array('info' => 'error', 'msg' => "Please enter your name."));
exit();
} else if($mail == '' or check_email($mail) == false){
echo json_encode(array('info' => 'error', 'msg' => "Please enter valid e-mail."));
exit();
} else if($messageForm == ''){
echo json_encode(array('info' => 'error', 'msg' => "Please enter your message."));
exit();
} else {
$to = __TO__;
$subject = $subjectForm . ' ' . $name;
$message = '
<html>
<head>
<title>Mail from '. $name .'</title>
</head>
<body>
<table style="width: 500px; font-family: arial; font-size: 14px;" border="1">
<tr style="height: 32px;">
<th align="right" style="width:150px; padding-right:5px;">Name:</th>
<td align="left" style="padding-left:5px; line-height: 20px;">'. $name .'</td>
</tr>
<tr style="height: 32px;">
<th align="right" style="width:150px; padding-right:5px;">E-mail:</th>
<td align="left" style="padding-left:5px; line-height: 20px;">'. $mail .'</td>
</tr>
<tr style="height: 32px;">
<th align="right" style="width:150px; padding-right:5px;">Subject:</th>
<td align="left" style="padding-left:5px; line-height: 20px;">'. $subjectForm .'</td>
</tr>
<tr style="height: 32px;">
<th align="right" style="width:150px; padding-right:5px;">Message:</th>
<td align="left" style="padding-left:5px; line-height: 20px;">'. $messageForm .'</td>
</tr>
</table>
</body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: ' . $mail . "\r\n";
send_mail($to,$subject,$message,$headers);
}
} else {
echo json_encode(array('info' => 'error', 'msg' => __MESSAGE_EMPTY_FIELDS__));
}

View File

@@ -1,90 +0,0 @@
<?php
$sendfrom = "site@slavforest.com.ua";
$sendto = "sha@shadoll.work; info@slavforest.com.ua";
$subject = "📨 Повідомлення з сайту slavforest.com.ua";
$username = !empty($_POST['name'])?trim(stripslashes($_POST['name'])):'';
$userphone = !empty($_POST['phone'])?trim(stripslashes($_POST['phone'])):'';
$usermail = !empty($_POST['email'])?trim(stripslashes($_POST['email'])):'';
$order = !empty($_POST['order'])?trim(stripslashes($_POST['order'])):'';
$subj = !empty($_POST['subject'])?trim(stripslashes($_POST['subject'])):'';
$message = !empty($_POST['message'])?trim(stripslashes($_POST['message'])):'';
$referer = !empty($_POST['referer'])?trim(stripslashes($_POST['referer'])):'';
$ip = $_SERVER['REMOTE_ADDR']; // the IP address to query
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$ip));
if ($query && $query['status'] == 'success') {
$detect = true;
$country_code = $query['countryCode'];
$country = $query['country'];
$region = $query['regionName'];
$city = $query['city'];
$provider = $query['isp'];
} else {
$detect = false;
}
$headers = "From:".strip_tags($sendfrom)."\r\n";
if (!empty($usermail)) {
$headers .= "Reply-To: ".strip_tags($usermail)."\r\n";
} else {
$headers .= "Reply-To: ".strip_tags($sendto)."\r\n";
}
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;charset=utf-8 \r\n";
$msg = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= '<img src="https://zebnits.com/images/logo_black.png" alt="logo">';
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>".$subject."</h2>\r\n";
$msg .= "<p><strong>Від кого:</strong> ".$username."</p>\r\n";
if (!empty($userphone)) {
$msg .= "<p><strong>Телефон:</strong> ".$userphone."</p>\r\n";
}
if (!empty($usermail)) {
$msg .= "<p><strong>Email:</strong> ".$usermail."</p>\r\n";
}
$msg .= "<hr>\r\n";
if (!empty($subj)) {
$msg .= "<p><strong>Тема:</strong>\r\n".$subj."</p>\r\n";
}
if (!empty($order)) {
$msg .= "<p><strong>Заказ:</strong>\r\n".$order."</p>\r\n";
}
if (!empty($message)) {
$msg .= "<p><strong>Повідомлення:</strong>\r\n".$message."</p>\r\n";
}
$msg .= "<hr>\r\n";
$msg .= "<p><strong>Реферал:</strong> ".$referer."</p>\r\n";
$msg .= "<p><strong>IP-адреса відправника:</strong> ".$ip."</p>\r\n";
if ($detect) {
$msg .= "<p><strong>Провайдер:</strong> ".$provider."</p>\r\n";
$msg .= "<p><strong>Країна:</strong> ".$country." <img style='height:14px; width:auto' src='http://www.geognos.com/api/en/countries/flag/".$country_code.".png'></p>\r\n";
$msg .= "<p><strong>Регіон:</strong> ".$region."</p>\r\n";
$msg .= "<p><strong>Населений пункт:</strong> ".$city."</p>\r\n";
}
$msg .= "</body></html>";
if (empty($username)) {
echo json_encode([
'message'=>'Please enter your name.',
'callback'=>'error',
'focus'=>'name'
]);
} elseif (empty($usermail)) {
echo json_encode([
'message'=>'Please enter valid e-mail.',
'callback'=>'error',
'focus'=>'email'
]);
} else {
$success = @mail($sendto, $subject, $msg, $headers);
echo json_encode([
'html'=>'our message has been sent. We will reply soon. Thank you!',
'target'=>".response",
'callback'=>"message_send"
]);
}

View File

@@ -1,67 +0,0 @@
<?php
require __DIR__.'/sender.php';
$username = !empty($_POST['name'])?trim(stripslashes($_POST['name'])):'';
$userphone = !empty($_POST['phone'])?trim(stripslashes($_POST['phone'])):'';
$usermail = !empty($_POST['email'])?trim(stripslashes($_POST['email'])):'';
$subject = !empty($_POST['subject'])?trim(stripslashes($_POST['subject'])):'';
$message = !empty($_POST['message'])?trim(stripslashes($_POST['message'])):'';
$referer = !empty($_POST['referer'])?trim(stripslashes($_POST['referer'])):'';
if (!empty($_SERVER) && array_key_exists('REMOTE_ADDR', $_SERVER)) {
$ip = $_SERVER['REMOTE_ADDR']; // the IP address to query
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$ip));
if ($query && $query['status'] == 'success') {
$detect = true;
$country_code = $query['countryCode'];
$country = $query['country'];
$region = $query['regionName'];
$city = $query['city'];
$provider = $query['isp'];
} else {
$detect = false;
}
} else {
$ip = 'no IP';
$detect = false;
}
$msg = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= '<img style="height:60px; widht:auto" src="http://slavforest.com.ua/images/logo_w.png" alt="logo">';
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>".$subject."</h2>\r\n";
$msg .= "<p><strong>Від кого:</strong> ".$username."</p>\r\n";
if (!empty($userphone)) {
$msg .= "<p><strong>Телефон:</strong> ".$userphone."</p>\r\n";
}
if (!empty($usermail)) {
$msg .= "<p><strong>Email:</strong> ".$usermail."</p>\r\n";
}
$msg .= "<hr>\r\n";
if (!empty($subj)) {
$msg .= "<p><strong>Тема:</strong>\r\n".$subj."</p>\r\n";
}
if (!empty($message)) {
$msg .= "<p><strong>Повідомлення:</strong>\r\n".$message."</p>\r\n";
}
$msg .= "<hr>\r\n";
$msg .= "<p><strong>Реферал:</strong> ".$referer."</p>\r\n";
$msg .= "<p><strong>IP-адреса відправника:</strong> ".$ip."</p>\r\n";
if ($detect) {
$msg .= "<p><strong>Провайдер:</strong> ".$provider."</p>\r\n";
$msg .= "<p><strong>Країна:</strong> ".$country." <img style='height:14px; width:auto' src='http://www.geognos.com/api/en/countries/flag/".$country_code.".png'></p>\r\n";
$msg .= "<p><strong>Регіон:</strong> ".$region."</p>\r\n";
$msg .= "<p><strong>Населений пункт:</strong> ".$city."</p>\r\n";
}
$msg .= "</body></html>";
$data = (object)[
'name' => $username,
'email' => $usermail,
'subject' => "📨 Повідомлення з сайту slavforest.com.ua",
'body' => $msg,
];
$sender = (new sender)->send($data);

View File

@@ -1,44 +0,0 @@
<?php
require __DIR__.'/vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
class sender
{
public function send($data)
{
$dotenv = \Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = getenv('SMTP_SERVER');
$mail->SMTPAuth = true;
$mail->Username = getenv('SMTP_USER');
$mail->Password = getenv('SMTP_PASSWORD');
$mail->SMTPSecure = 'tls';
$mail->From = getenv('SENDER_EMAIL');
$mail->FromName = getenv('SENDER_NAME');
$mail->addAddress(getenv('SMTP_RECEIVER'));
$mail->isHTML(true);
$mail->Subject = $data->subject;
$mail->Body = $data->body;
$mail->send();
echo 'Message has been sent';
return true;
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
return false;
}
}
}