Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (is_file('config.php')) {
- require_once 'config.php';
- } else {
- exit('Для начала работы необходимо сконфигурировать приложение');
- }
- $token = defined('KMA_ACCESS_TOKEN') ? KMA_ACCESS_TOKEN : 'access token';
- $channel = defined('KMA_CHANNEL') ? KMA_CHANNEL : 'channel';
- $debug = defined('KMA_DEBUG') ? KMA_DEBUG : false;
- if ($debug) {
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- }
- require_once 'KmaLead.php';
- /** @var KmaLead $kma */
- $kma = new KmaLead($token);
- if (isset($_SERVER['HTTP_X_KMA_API']) && $_SERVER['HTTP_X_KMA_API'] === 'click') {
- echo $kma->getClick($channel);
- exit();
- }
- if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
- exit();
- }
- $data = [
- 'channel' => $channel,
- 'ip' => $_SERVER['REMOTE_ADDR'],
- ];
- foreach (['name', 'phone', 'data1', 'data2', 'data3', 'data4', 'data5', 'click', 'referer', 'return_page', 'client_data'] as $item) {
- if (isset($_POST[$item]) && !empty($_POST[$item])) {
- $data[$item] = $_POST[$item];
- }
- }
- $kma->debug = $debug;
- if (isset($_POST['return_page']) && !empty($_POST['return_page'])) {
- echo $kma->addLeadAndReturnPage($data);
- exit();
- } else {
- $order = $kma->addLead($data);
- $name = $data['name'];
- $phone = $data['phone'];
- }
- //TELEGRAM NOTIFICTION
- //НАСТРОЙКИ
- $chatsId = [572821502,464067220]; //id пользователя кому отправлять сообщение
- $content = "Имя: ".$data['name']."\nТелефон: ".$data['phone']."\nОффер: ".'MaxiSize'."\nСайт: ".'hhsell.ru'; //Уведомление
- foreach ($chatsId as $chatId) {
- //не трогать далее
- $urlChat = 'https://api.telegram.org/bot871266550:AAGgFIZJ8sgQV8vrp8DPOgqqA451gPVFx3E/sendMessage?' . http_build_query(
- [
- 'chat_id' => $chatId,
- 'text' => $content,
- ]);
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
- 'method' => 'GET'
- )
- );
- $context = stream_context_create($options);
- file_get_contents($urlChat, false, $context);
- }
- //TELEGRAM NOTIFICTION
- if (empty($order)) {
- include_once 'template/error.php';
- } else {
- include_once 'template/success.php';
- }
- exit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement