Current Path : /var/www/html/clients/wodo.e-nk.ru/ |
Current File : /var/www/html/clients/wodo.e-nk.ru/send-request_n.php |
<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php'); if ($_POST['code'] == 'checked') { $to = 'wkexpto@yandex.ru'; $subject = checkValue($_POST['subject']); $message = $subject . ' с сайта ' . $_SERVER['HTTP_HOST'] . '<br><br>'; foreach ($_POST as $key => $value) { if (!in_array($key, array('subject', 'location', 'iblock_id', 'code', 'accept_1', 'accept_2')) && $value != '') { $temp = str_replace('_', ' ', $key) . ': ' . checkValue($value) . '<br>'; $message .= $temp; } } if (checkValue($_POST['iblock_id']) == 39) { CModule::IncludeModule('iblock'); $item = new CIBlockElement; $prop = array(); if ($_FILES['files']) { $files = reArrayFiles($_FILES['files']); $i = 0; foreach ($files as $file) { if ($file['error'] == 0) { $prop[160]["n$i"]['VALUE'] = $file; $i++; } } } $params = array( 'ACTIVE' => 'Y', 'MODIFIED_BY' => 9, 'IBLOCK_ID' => 39, 'NAME' => $subject, 'PREVIEW_TEXT' => $message, 'PREVIEW_TEXT_TYPE' => 'html', 'PROPERTY_VALUES' => $prop ); $id = $item->Add($params); $files = CIBlockElement::GetProperty(39, $id, array(), array('ID' => 160)); $message .= '<br>Файлы<br>'; while ($file = $files->GetNext()) { $href = $_SERVER['HTTP_HOST'] . CFile::GetPath($file['VALUE']); $temp = '<a href="http://' . $href . '">' . $href . '</a><br>'; $message .= $temp; } } $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=utf-8" . "\r\n"; $headers .= "From: <noreply@e-nkama.ru>" . "\r\n"; mail($to, $subject, $message, $headers); if (checkValue($_POST['iblock_id']) == 39) { $to = $_POST['E-mail']; $message = 'Номер вашей заявки: ' . $id; mail($to, $subject, $message, $headers); } $link = mysqli_connect('localhost','onlineCon','','onlineCon'); if(mysqli_connect_errno()) { echo 'Ошибка подключения к базе данных!('.mysqli_connect_errno().'):'.mysqli_connect_error(); exit(); } $sql = mysqli_query ($link,"INSERT INTO Con (id, status, email) VALUES ('NULL', 'Обрабатывается', '".$_POST['E-mail']."')"); session_start(); $_SESSION['res'] = true; header('Location: ' . checkValue($_POST['location'])); } else { header('Location: /'); } function checkValue($value) { return trim(strip_tags($value)); } function reArrayFiles(&$file_post) { $file_array = array(); $file_count = count($file_post['name']); $file_keys = array_keys($file_post); for ($i = 0; $i < $file_count; $i++) { foreach ($file_keys as $key) { $file_array[$i][$key] = $file_post[$key][$i]; } } return $file_array; } ?>