import subprocess
curl = subprocess.Popen( ["curl", "-o", "test.txt", "https://toster.ru", "-A", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"], stdout=subprocess.PIPE ).communicate()
echo json_encode(array('data' => $data));
break;
case 'feedback':
$name = filter($_POST['name']) ?? '';
$phone = filter($_POST['phone']) ?? '';
$email = filter($_POST['email']) ?? '';
$msg = filter($_POST['msg']) ?? '';
if (strlen($name) > 0 && strlen($phone))
{
$text = 'Имя: ' . $name . "\n";
$text .= 'Телефон: ' . $phone . "\n";
$text .= 'E-mail: ' . $email . "\n";
mail($mail, 'сайт - ' . $msg, $text, "From: no-reply@site.ru\r\nContent-type: text/plain; charset=utf-8\r\n");
echo json_encode(array('data' => 'ok'));
}
else
{
echo json_encode(array('data' => 'error'));
}
break;
<script type="text/javascript">
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
$('.feedback-button').click(function ()
{
var name = $('#form-name').val();
var phone = $('#form-phone').val();
var email = $('#form-email').val();
var type = $(this).attr('id');
if (name.length > 0 && phone.length > 0)
{
$.ajax(
{
url: '/netcat/ajax.php?action=feedback',
method: 'post',
data: {name: name, phone: phone, email: email, msg: window.appFeedbackMsg},
cache: false,
success: function (json)
{
if (json.data == 'ok')
{
$('#form-name').val('');
$('#form-phone').val('');
$('#form-email').val('');
$('.feedback-form-row').fadeOut(150);
alert('Ваше сообщение отправлено!');
yaCounter38233635.reachGoal('zavka');
}
}
});
}
else
{
alert('Все поля обязательны к заполнению!');
}
});
</script>