Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $api = [
- 'key' => '7811',
- 'secret' => 'c9b6005389ba8e51e5704d4764ff3c47',
- 'flow_url' => 'URL-1F849-E7037'
- ];
- //* KLO *//
- $my_data = [
- 'phone' => $_POST['phone'],
- 'name' => $_POST['name'],
- 'ip' => $_SERVER['REMOTE_ADDR'],
- 'host' => $_SERVER['HTTP_HOST'],
- 'number' => 'комментарий в клоаку к лидам если нужен'
- ];
- if (!empty($_POST['phone'])) {
- $my_request = file_get_contents('https://fb-trk.info/api/add_lead?' . http_build_query($my_data));
- $my_request = json_decode($my_request);
- $my_id = $my_request->id;
- }
- //* KLO *//
- function send_the_order($post, $api)
- {
- $params = [
- 'flow_url' => $api['flow_url'],
- 'user_phone' => $post['phone'],
- 'user_name' => $post['name'],
- 'other' => $post['other'],
- 'ip' => $_SERVER['REMOTE_ADDR'],
- 'ua' => $_SERVER['HTTP_USER_AGENT'],
- 'api_key' => $api['key'],
- 'sub1' => $post['sub1'],
- 'sub2' => $my_id,
- 'sub3' => $post['sub3'],
- 'sub4' => $post['sub4'],
- 'sub5' => $post['sub5'],
- 'ajax' => 1,
- ];
- $url = 'https://leadrock.com/api/v2/lead/save';
- $trackUrl = $params['flow_url'] . (strpos($params['flow_url'], '?') === false ? '?' : '&') . http_build_query($params);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $trackUrl);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
- $params['track_id'] = curl_exec($ch);
- $params['sign'] = sha1(http_build_query($params) . $api['secret']);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
- $respapi = curl_exec($ch);
- curl_close($ch);
- //* KLO *//
- $upd = ['id' => $my_id, 'response_api' => $respapi];
- file_get_contents('https://fb-trk.info/api/update_lead?'.http_build_query($upd));
- //* KLO *//
- //header('Location: ' . (empty($post['success_page']) ? 'confirm.html' : $post['success_page']));
- require_once('_thankyou/ok.php');
- }
- if (!empty($_POST['phone'])) {
- send_the_order($_REQUEST, $api);
- }
- if (!empty($_GET)) {
- ?>
- <script type="text/javascript">
- window.onload = function() {
- let forms = document.getElementsByTagName("form");
- for(let i=0; i<forms.length; i++) {
- let form = forms[i];
- form.setAttribute('action', form.getAttribute('action') + "?<?php echo http_build_query($_GET)?>");
- form.setAttribute('method', 'post');
- }
- };
- </script>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement