Last active
August 29, 2015 14:10
-
-
Save Neolot/f002e0b0b26520047d76 to your computer and use it in GitHub Desktop.
Обработка данных и отправка служебного письма для Forma Email Logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Служебное письмо на [email protected] | |
include_once($_SERVER['DOCUMENT_ROOT'].'/path_to_file/tokki.php'); | |
$formdata = array( | |
'name' => $data['name'], | |
'phone' => $data['phone'], | |
'email' => $data['email'], | |
'message' => $data['message'], | |
'prim' => $data['some_data'], | |
); | |
tokki_sendEmail(tokki_prepareData($formdata, $subject), $subject); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tokki_getVisitorData() { | |
date_default_timezone_set('Europe/Moscow'); | |
$campaign_data = array(); | |
$sourcedata = str_replace('|', '&', $_COOKIE['sbjs_first']); | |
parse_str($sourcedata, $sbjs); | |
$campaign_data['date'] = date('d.m.Y'); | |
$campaign_data['time'] = date('H:i:s'); | |
$campaign_data['typ'] = $sbjs['typ']; | |
$campaign_data['src'] = $sbjs['src']; | |
$campaign_data['mdm'] = $sbjs['mdm']; | |
$campaign_data['cmp'] = $sbjs['cmp']; | |
$campaign_data['cnt'] = $sbjs['cnt']; | |
$campaign_data['trm'] = urldecode($sbjs['trm']); | |
return $campaign_data; | |
} | |
function tokki_prepareData($formdata, $subject) { | |
$campaign_data = tokki_getVisitorData(); | |
$data['subject'] = $subject; | |
$data = array_merge((array)$campaign_data, $data, (array)$formdata); | |
return json_encode($data); | |
} | |
function tokki_sendEmail($message, $subject) { | |
$hostname = $_SERVER['SERVER_NAME']; | |
$mailto = '[email protected]'; | |
$from = "$hostname <noreply@$hostname>"; | |
$headers = "From: $from\r\n"; | |
$headers.= "MIME-Version: 1.0\r\n"; | |
$headers.= "Content-Type: text/plain; charset=utf-8\r\n"; | |
$headers.= "X-Priority: 1\r\n"; | |
mail($mailto, $subject, $message, $headers); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment