Advertisement
kippykip

vixcentral graph data getter test thing

May 27th, 2021
1,084
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.08 KB | None | 0 0
  1. <?php
  2.     //Integral functions
  3.     function GetProxy()
  4.     {      
  5.         $proxy['user'] = 'egyuuyke-dest';
  6.         $proxy['password'] = 'uih8y6ro8r6p';
  7.         $proxy['ip'] = '209.127.191.180';
  8.         $proxy['port'] = '9279';
  9.         $proxy['auth'] = CURLPROXY_HTTP;
  10.         return $proxy;     
  11.     }
  12.     function GetUseragent()
  13.     {
  14.         return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36";
  15.     }
  16.     function GetHeaders()
  17.     {
  18.         srand();
  19.         $headers = array(
  20.         'Connection: keep-alive',
  21.         'Pragma: no-cache',
  22.         'Cache-Control: no-cache',
  23.         'Accept: application/json, text/javascript, */*; q=0.01',
  24.         'DNT: 1',
  25.         'X-Requested-With: XMLHttpRequest',
  26.         'User-Agent: '.GetUseragent(),
  27.         'Referer: http://vixcentral.com/',
  28.         //'Accept-Encoding: gzip, deflate',
  29.         'Accept-Language: en-US,en;q=0.9'
  30.         );
  31.         return $headers;
  32.     }
  33.    
  34.    
  35.     //Returns a full HTML page
  36.     //responsecode if true, just returns whether its a 404 or something
  37.     function Scrape_GetURLContent($url, $usecookies = false, $useproxy = false, $responsecode = false)
  38.     {      
  39.         $ch = @curl_init(); //Init
  40.         if($ch === false){
  41.             return 0; //Failed somehow... uhh
  42.         }
  43.         curl_setopt($ch, CURLOPT_URL, $url);
  44.         curl_setopt($ch, CURLOPT_REFERER, "http://vixcentral.com/");
  45.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  46.         //curl_setopt($ch, CURLOPT_USERAGENT, GetUseragent());
  47.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
  48.         curl_setopt($ch, CURLOPT_MAXREDIRS, 0); //10 directs maximum
  49.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  50.         curl_setopt($ch, CURLOPT_HEADER, $responsecode);
  51.         curl_setopt($ch, CURLOPT_NOBODY, $responsecode);
  52.         curl_setopt($ch, CURLOPT_HTTPHEADER, GetHeaders());
  53.        
  54.         //Enable cookies?
  55.         if($usecookies)
  56.         {
  57.             $cookie = dirname(__FILE__) . "cookies.txt";
  58.             curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
  59.             curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
  60.             curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); // have tried with just the jar, and just the file and both
  61.         }else
  62.         {
  63.             curl_setopt($ch, CURLOPT_COOKIESESSION, FALSE);
  64.         }
  65.        
  66.         //Use a proxy?
  67.         if($useproxy)
  68.         {
  69.             $proxy = GetProxy();       
  70.             @curl_setopt($ch, CURLOPT_PROXY, $proxy['ip'] . ':' . $proxy['port']);
  71.             @curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy['user'] . ':' . $proxy['password']);
  72.             @curl_setopt($ch, CURLOPT_PROXYTYPE, $proxy['auth']);
  73.         }
  74.         //Only return response code?
  75.         if($responsecode)
  76.         {
  77.             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
  78.             curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  79.             @curl_exec($ch);
  80.             $result = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
  81.            
  82.         }else //Return whole page
  83.         {
  84.             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  85.             curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  86.             $result = @curl_exec($ch);
  87.             if(@curl_errno($ch)){   // should be 0
  88.                 return curl_error($ch);
  89.             }
  90.         }
  91.         @curl_close($ch);
  92.         return $result;
  93.     }                                                              
  94.     echo Scrape_GetURLContent('http://vixcentral.com/ajax_update/?_=' . time(), false);
  95.     //echo Scrape_GetURLContent('https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending', true);
  96.     //echo time();
  97. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement