Blame view

mail.php 1.15 KB
80576aee7   Дмитрий Типикин   Интеграция верстк...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  <?php
  	require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
  	CModule::IncludeModule("iblock");
  	header('Content-type: application/json');
  
  	if($_REQUEST['send_form'] == 'Y') {
  
  		$el = new CIBlockElement;
  		$PROP = [];
  		$PROP[16] = strip_tags($_REQUEST['phone']);
  		$PROP[17] = strip_tags($_REQUEST['email']);
  		$PROP[18] = strip_tags($_REQUEST['company']);
  
  		$name = 'Сообщение от ' . strip_tags($_REQUEST['first_name']) . ' за ' . date('d.m.Y H:i:s');
  
  		$arLoadProductArray = [
  			'IBLOCK_ID' => IBID_FEEDBACK,
  			'PROPERTY_VALUES' => $PROP,
  			'NAME' => $name,
  			'PREVIEW_TEXT' => strip_tags($_REQUEST['comment']),
  			'ACTIVE' => 'Y',
  		];
  
  		if ($PRODUCT_ID = $el->Add($arLoadProductArray)) {
  			$to_send = [];
  			$to_send['AUTHOR_EMAIL'] = strip_tags($_REQUEST['email']);
  			$to_send['AUTHOR'] = strip_tags($_REQUEST['first_name']);
  			$to_send['PHONE'] = strip_tags($_REQUEST['phone']);
  			$to_send['COMPANY'] = strip_tags($_REQUEST['company']);
  			$to_send['TEXT'] = strip_tags($_REQUEST['comment']);
  
  			CEvent::SendImmediate ('FEEDBACK_FORM', SITE_ID, $to_send);
  		} else {
  			echo 'Error: ' . $el->LAST_ERROR;
  		}
  	}