Register for your free account! | Forgot your password?

Go Back   elitepvpers › Other Online Games › Browsergames › DarkOrbit
You last visited: Today at 22:15

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Php webgrabber

Discussion on Php webgrabber within the DarkOrbit forum part of the Browsergames category.

Reply
 
Old   #1
 
UND3RW0RLD's Avatar
 
elite*gold: 1
Join Date: Jun 2011
Posts: 1,465
Received Thanks: 1,065
Php webgrabber

Hey here is a little toy. If you want to piss off bp you can mirror their loginpage. This saves you much time, because you get their updates instantly

PHP Code:
function getWebContents($url)
{
  
$parse = parse_url($url);
  if(!
$parse || !isset($parse['host'])) 
  {
    return 
false;
  }

  
$host = $parse['host'];
  
$port = isset($parse['port']) ? $parse['port'] : ($parse['scheme'] == 'http' ? 80 : 443);
  
$pfad = isset($parse['path']) ? $parse['path'] : '/';
  
  if (isset(
$parse['query']))
  {
    
$query = array();
    
$parse['query'] = explode("&",urldecode($parse['query']));
    foreach (
$parse['query'] as $entry)
    {
      
$entry = explode("=",$entry);
      
$query[] = $entry[0]."=".urlencode($entry[1]);
    }
    
$parse['query'] = implode("&",$query);
  }
    
  
$ConnectionHandle = @fsockopen(($port != 443 ? $host : 'ssl://' . $host), $port, $errno, $errstr, 2);
  
  if(!
$ConnectionHandle) {
    return 
false;
  }
  
  
$request   = array();  
  
$request[] = "GET ".$pfad.(isset($parse['query'])?"?".$parse['query']:"")." HTTP/1.1";
  
$request[] = "Host: ".$host;
  
$request[] = "User-Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
  
$request[] = "Accept: text/html,text/plain";
  
$request[] = "Accept-Language: en-us,en;q=0.5";
  
$request[] = "Accept-Encoding: deflate";
  
$request[] = "Accept-Charset: ISO-8859-1";
  
$request[] = "Connection: close";
  
  
$request = implode("\r\n",$request)."\r\n\r\n";
  
  
fputs ($ConnectionHandle, $request);

  
$retr = "";
  while (!
feof($ConnectionHandle)) 
  {
    
$retr .= fgets($ConnectionHandle, 128);
  }  
  
  
fclose($ConnectionHandle);

  
$pos = strpos($retr, "\r\n\r\n");
  
$header = substr($retr, 0, $pos); 
  
$header = explode("\r\n", $header);
    
  
$status = explode(" ",$header[0]);
    
  
$http = $status[0];
  unset(
$status[0]);
  unset(
$header[0]);
    
  
$h = array();
  
$h[$http] = implode(" ",$status);  
    
  foreach(
$header as $i)
  {
    
$i = explode(":",$i);
    
$h[trim($i[0])] = trim($i[1]);
  } 
  
  
$content = substr($retr, $pos + 4);
  
  
$content = str_replace(array("ö", "ä", "ü", "ß", "Ö",  "Ä", "Ü", "é", "Â"),
           array(
"ö", "ä", "ü",  "ß", "Ö", "Ä", "Ü","é"), 
           
$content);
  
  return array(
"header" => $h, "content" => $content);
} 
this generates an output like: (example google)
Code:
array(2) {
  ["header"]=>
  array(8) {
    ["HTTP/1.0"]=>
    string(6) "200 OK"
    ["Date"]=>
    string(19) "Mo, 17 Nov 2014 19"
    ["Expires"]=>
    string(2) "-1"
    ["Cache-Control"]=>
    string(18) "private, max-age=0"
    ["Content-Type"]=>
    string(24) "text/html; charset=UTF-8"
    ["Set-Cookie"]=>
    string(164) "NID=51=R3n-Ek-42HTVUVUk7a4xm3VQA1p-TAt5ZRPCabzgiAAEJt1xcpay84rooJHsy8yGK1n5dg-ULoCsLKYqFHJjddtQRkC63aPXV-zS1AFgYmLGkgLDVaekiox0QsLF9Zhz; expires=Sat, 07-Apr-2015 19"
    ["Server"]=>
    string(3) "gws"
    ["X-XSS-Protection"]=>
    string(13) "1; mode=block"
  }
  ["content"]=>
  string(29765) "<!doctype html><html>... (ripped)"
}
if you call it like:
PHP Code:
$data = getWebContents("http://www.google.de"); 
PHP Code:
echo $data["content"]; 
to handle forms you can use str_replace. This ofc forces you to make own processingpages like "takesignup".

or if you want to mirror pages like "choosefaction" too you have to extend the array $request with
PHP Code:
// vBulletin-board-default setting
$request[] = "Cookie: bblastvisit=0; bblastactivity=0"; 
the possibities to use this script are endless not only for dark orbit.
UND3RW0RLD is offline  
Thanks
1 User
Old   #2

 
Luffa's Avatar
 
elite*gold: 61
Join Date: Oct 2010
Posts: 1,188
Received Thanks: 2,403
i should not comment on anything at epvp.
But awesome job

Best Regards
Luffa is offline  
Thanks
3 Users
Reply




All times are GMT +1. The time now is 22:15.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.