All pastes #811538 Raw Edit

Something

public text v1 · immutable
·published 2007-12-11 00:42 UTC
rendered paste body
<?php
$host = "www.whatismyip.org";
$port = 80;
$path = "/";

$response = "";

$fp = fsockopen($host, $port, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    $out = "GET $path HTTP/1.1\r\n";
    $out .= "Host: $host\r\n";
    $out .= "Connection: Close\r\n\r\n";

    fwrite($fp, $out);
    while (!feof($fp)) {
        $response .= fgets($fp, 128);
    }
    fclose($fp);

    $data = explode("\r\n\r\n", $response, 2);
    $ip = $data[1];
}
?>