PHP Scripts for HTTP Viewer Packages

This PHP script is designed to emulate a browser to show you what browser is used to read from the server. HTTP Viewer is able to show you the full server response of a web resource with any one of the Apache request methods. It features for finding server redirect’s, viewing source code or examing questionable websites.

 

 

<?php

# COPYRIGHT
# HTTP Viewer (c) 2010 Scott Connell
# Redistribution without permission is forbidden.
# Source http://www.scottconnell.com
# Last Updated 12/26/2010
#
# SET VARIABLES ########################

# Change the header path, and footer path,
# to your full directory path if neccessary.

$header_path = "header.php";
$footer_path = "footer.php";

# END SETTING VARIABLES #################

if(!function_exists("fsockopen"))
{
$title = "Whoops! - Function Disabled";
include_once($header_path);

print <<<ENDHTM
<p>Your server has the PHP function (fsockopen) disabled! You will not be able to run this program.</p>
ENDHTM
;

exit(include_once($footer_path));
}

function printForm()
{
global $www,$options;

$action = $_SERVER["PHP_SELF"];
$action = str_replace("index.php","", $action);

print <<<ENDHTM

<form method="post" action="$action">

<p>http:// <input type="text" name="www" value="$www"/></p>

<p>Method <select name="methods">
ENDHTM
;

foreach($options as $o)
{
print "<option value=\"$o\">$o</option>\n";
}

print <<<ENDHTM
</select></p>
<p><input type="submit" value="Submit"/></p>
</form>

ENDHTM
;
}

function fetchURL($m)
{
global $domain;

$theArray = parse_url($domain);

$theProtocol = $theArray["scheme"];
$theHost   = $theArray["host"];
$thePort   = $theArray["port"];
$theUser   = $theArray["user"];
$thePass   = $theArray["pass"];
$thePath   = $theArray["path"];
$theQuery  = $theArray["query"];
$theFragment = $theArray["fragment"];

if(!$thePort)
{
$thePort  = "80";
}
if(!$thePath)
{
$thePath    = "/";
}

$thePage = $thePath . ($theQuery?"?":"") . $theQuery;

$open_socket = @fsockopen($theHost, $thePort, $errno, $errstr, 30);

 if($open_socket)
 {
 $message .= $m ." ". $thePage . " HTTP/1.1\r\n";
 $message .= "Host: $theHost\r\n";
 $message .= "Connection: close\r\n\r\n";

 fputs($open_socket, "$message\n");

 while ($read_text = fgets($open_socket, 4096))
 {
 $response .= htmlspecialchars($read_text, ENT_QUOTES);
 }

 return $response;
 }
}

$options = array('HEAD','GET','POST','OPTIONS','TRACE','BASELINE_CONTROL','CHECKIN','CHECKOUT','CONNECT','COPY','DELETE','INVALID','LABEL','LOCK','MERGE','MKACTIVITY','MKCOL','MKWORKSPACE','MOVE','PATCH','PROPFIND','PROPPATCH','PUT','REPORT','UNCHECKOUT','UNLOCK','UPDATE','VERSION_CONTROL');

if($_REQUEST['www'])
{
$domain = strtolower($_REQUEST['www']);
$xArray = @parse_url($domain);

 if(!$xArray["scheme"])
 {
 $domain = "http://" . $domain;
 $xArray = @parse_url($domain);
 }

 $xProtocol = $xArray["scheme"];
 $xHost   = $xArray["host"];
 $xPort   = $xArray["port"];
 $xUser   = $xArray["user"];
 $xPass   = $xArray["pass"];
 $xPath   = $xArray["path"];
 $xQuery  = $xArray["query"];
 $xFragment = $xArray["fragment"];

 $domain = $xProtocol ."://". $xHost . $xPath . ($xQuery?"?":"") . $xQuery;
 $www = $xHost . $xPath . ($xQuery?"?":"") . $xQuery;

 setcookie("URL", strtolower($www), time()+(60*60*24*30), "/"); // 30 days

 $title = "HTTP Viewer - Emulate a browser with this page sniffer.";
 include_once($header_path);

 if(!$fp = @fsockopen($xHost, 80, $errno, $errstr, 30))
 {
 $host = $xArray["host"];
 printForm();
 print "<p><span class=\"bold\">ERROR</span> Could not connect to $host</p>\n";
 exit(include_once($footer_path));
 }
 else
 {
 $result = fetchURL($_REQUEST['methods']);
 printForm();
 print "<h4>". $_REQUEST['methods'] ." Request</h4>\n";
 print "<pre>$result</pre>\n\n";
 }
}
else
{
$title = "HTTP Viewer - Emulate a browser with this page sniffer.";
include_once($header_path);

 if(isset($_COOKIE['URL']))
 {
 $www = $_COOKIE['URL'];
 }

printForm();
}

?>

<?php

include_once($footer_path);

?>

&amp;nbsp;

&amp;nbsp;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>