Advertisement
kalinin0080

Untitled

Apr 8th, 2020
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. function getIp()
  4. {
  5.     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  6.         $ip = $_SERVER['HTTP_CLIENT_IP'];
  7.     } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  8.         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  9.     } else {
  10.         $ip = $_SERVER['REMOTE_ADDR'];
  11.     }
  12.     return $ip;
  13. }
  14.  
  15. function apiWebvorkV1NewLead($post, $ip, $offerId, $counter = 0)
  16. {
  17.     $token = '7d4c0905ee1b207f05a83d3846c5fc05'; // Заменяем на свой из кабинета
  18.  
  19.     $url = 'http://api.webvork.com/v1/new-lead?token=' . rawurlencode($token)
  20.         . '&ip=' . rawurlencode($ip)
  21.         . '&offer_id=' . rawurlencode($offerId)
  22.         . '&name=' . rawurlencode($post['name'])
  23.         . '&phone=' . rawurlencode($post['phone'])
  24.         . '&country=' . rawurlencode($post['country']);
  25.  
  26.     $json = file_get_contents($url);
  27.     $data = json_decode($json, 1);
  28.  
  29.     if ($data['status'] != 'ok') {
  30.         if ($counter < 5) {
  31.             sleep(1);
  32.             return apiWebvorkV1NewLead($post, $ip, $offerId, ++$counter);
  33.         } else {
  34.             return false;
  35.         }
  36.     }
  37.  
  38.     if ($data['status'] == 'ok') {
  39.         return true;
  40.     }
  41. }
  42.  
  43. apiWebvorkV1NewLead($_POST, getIp(), 1);
  44.  
  45. header("Location: https://slimbody.website/success.php?fb_pixel=".$_POST['fb_pixel']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement