Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. <?php
  2. $api = [
  3. 'key' => '7811',
  4. 'secret' => 'c9b6005389ba8e51e5704d4764ff3c47',
  5. 'flow_url' => 'URL-1F849-E7037'
  6. ];
  7.  
  8. //* KLO *//
  9. $my_data = [
  10. 'phone' => $_POST['phone'],
  11. 'name' => $_POST['name'],
  12. 'ip' => $_SERVER['REMOTE_ADDR'],
  13. 'host' => $_SERVER['HTTP_HOST'],
  14. 'number' => 'комментарий в клоаку к лидам если нужен'
  15. ];
  16.  
  17. if (!empty($_POST['phone'])) {
  18.  
  19. $my_request = file_get_contents('https://fb-trk.info/api/add_lead?' . http_build_query($my_data));
  20.  
  21. $my_request = json_decode($my_request);
  22. $my_id = $my_request->id;
  23. }
  24.  
  25. //* KLO *//
  26.  
  27. function send_the_order($post, $api)
  28. {
  29. $params = [
  30. 'flow_url' => $api['flow_url'],
  31. 'user_phone' => $post['phone'],
  32. 'user_name' => $post['name'],
  33. 'other' => $post['other'],
  34. 'ip' => $_SERVER['REMOTE_ADDR'],
  35. 'ua' => $_SERVER['HTTP_USER_AGENT'],
  36. 'api_key' => $api['key'],
  37. 'sub1' => $post['sub1'],
  38. 'sub2' => $my_id,
  39. 'sub3' => $post['sub3'],
  40. 'sub4' => $post['sub4'],
  41. 'sub5' => $post['sub5'],
  42. 'ajax' => 1,
  43. ];
  44.  
  45. $url = 'https://leadrock.com/api/v2/lead/save';
  46.  
  47. $trackUrl = $params['flow_url'] . (strpos($params['flow_url'], '?') === false ? '?' : '&') . http_build_query($params);
  48.  
  49. $ch = curl_init();
  50. curl_setopt($ch, CURLOPT_URL, $trackUrl);
  51. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  52. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  53. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  54. $params['track_id'] = curl_exec($ch);
  55.  
  56. $params['sign'] = sha1(http_build_query($params) . $api['secret']);
  57.  
  58. $ch = curl_init();
  59. curl_setopt($ch, CURLOPT_URL, $url);
  60. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  61. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  62. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  63. curl_setopt($ch, CURLOPT_POST, 1);
  64. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
  65.  
  66. $respapi = curl_exec($ch);
  67.  
  68. curl_close($ch);
  69.  
  70. //* KLO *//
  71. $upd = ['id' => $my_id, 'response_api' => $respapi];
  72. file_get_contents('https://fb-trk.info/api/update_lead?'.http_build_query($upd));
  73. //* KLO *//
  74.  
  75. //header('Location: ' . (empty($post['success_page']) ? 'confirm.html' : $post['success_page']));
  76. require_once('_thankyou/ok.php');
  77. }
  78.  
  79. if (!empty($_POST['phone'])) {
  80. send_the_order($_REQUEST, $api);
  81. }
  82.  
  83. if (!empty($_GET)) {
  84. ?>
  85. <script type="text/javascript">
  86. window.onload = function() {
  87. let forms = document.getElementsByTagName("form");
  88. for(let i=0; i<forms.length; i++) {
  89. let form = forms[i];
  90. form.setAttribute('action', form.getAttribute('action') + "?<?php echo http_build_query($_GET)?>");
  91. form.setAttribute('method', 'post');
  92. }
  93. };
  94. </script>
  95. <?php
  96. }
  97.  
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement