Solved

Foreign GET Query

Posted on 2006-10-23
4
201 Views
Last Modified: 2006-11-18

is there a way to query a foreign php page without cURL like the following pseudo code?

$ip = 'xxx.eee.www.qqq';

$lookup="http://aaa.zzzz.yyyy/country.php?ip='$ip'";


..and have the value stuck inside $lookup?

maybe im off base here, but i thought there was a less involved way than using cURL ...

anyone?
0
Comment
Question by:n8dog
4 Comments
 
LVL 5

Expert Comment

by:daohailam
ID: 17793159
0
 

Author Comment

by:n8dog
ID: 17793690
interesting... got some sample applicable syntax?

0
 
LVL 9

Accepted Solution

by:
tolgaong earned 500 total points
ID: 17794359
first and second method needs allow_url_fopen true as ini set
third method can get all the data although allow url fopen false...
$lookup="http://aaa.zzzz.yyyy/country.php?ip='$ip'";

//FIRST
$firstbuffer="";
$html=fopen($lookup,"rb");
while(!feof($f)){
   $firstbuffer.=fread($f,4096);
}
fclose($f);

//SECOND
$secondbuffer=file_get_contents($loopkup);

//THIRD
if(preg_match("/^http:\/\/([^\/]+)(.*)$/", $lookup, $matches)){
         $response ="";
         $thirbuffer = '';
         $host = $matches[1];
         $uri = $matches[2];

         $request = "GET $uri HTTP/1.0\r\n";
         $request .= "Host: $host\r\n";
         $request .= "User-Agent: Mozilla \r\n";
       $request .= "Connection: close\r\n\r\n";

         if($http = fsockopen($host, 80, $errno, $errstr, 5)){
                fwrite($http, $request);
                $timeout = time() + 5;
                while(time() < $timeout && !feof($http)) {
                    $response .= fgets($http, 4096);
                      }
                list($header, $thirbuffer) = preg_split("/\r?\n\r?\n/", $response, 2);                  
               }
      }
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now