<?php // phpinfo();
$program = "GetHeaders()";
$version = "v0.0.2f-2g.2m"; // Current source code on iMac or Vega.
include('MyFuncations.php'); // Include the fuctions that are needed to make this page work.
SendHeaders();
CheckForToDos($QueryString);
if (substr($QueryString,0,7)=="domain=") { $source = substr($QueryString,7); }
if (@$_GET["*"] != "") { $get = $_GET["*"]; header("Location: $phpself?$get"); }
?><!DOCTYPE html>
<html lang="en">
<head>
<?php include('GoogleAnalytics.php'); ?>
<title><?php echo $program; ?> - Get webserver HTTP Headers @ NetworkStuff.Net</title>
<?php include('head-for-bootstrap_fa.php'); ?>
<link rel="stylesheet" href="/Site.css">
<style>
b { color: purple; font-size:1em; font-weight: 400; }
tt { color: silver; font-size:1em; font-weight: 100; background-color: aliceblue; }
address { color: green; }
address > a { color: blue; }
</style>
</head>
<body>
<?php
include('header.php');
?>
<div class="container-fluid">
<h1><?php echo $program; ?>
<kbd style="font-size:12px">// <?php echo "Version: $version"; ?></kbd></h1>
<?php
// GetHeaders.php // ## Master stored on on Vega, Wi?? & the iMac. ##
if($source=="") { $source = @$_GET['url']; }
// view-source
if($source=="") { $source = @$_SERVER["QUERY_STRING"]; }
if($source=="sourcecode") { show_source(@$_SERVER["SCRIPT_FILENAME"]); exit; }
$https = @$_SERVER['HTTPS'];
if (($https == true)&&($https != "off")) { $Lscheme = "https"; }
else { $Lscheme = "http"; }
$url = "$Lscheme://www.google.com/"; // = "http://att.com/";
$url = "http://localhost/"; // = "http://rndpswd.com/";
// = "http://securerandompassword.com/";
if(strpos($source, 'https') === 0)
{ $url = $source;
// echo "\n\t<h2 style='color:green'>$source</h2>\n\t\t";
}
else{
if(strpos($source, 'http') === 0)
{ $url = $source;
// echo "\n\t<h2 style='color:purple'>$source</h2>\n\t\t";
}
else{
if($source!="")
{ $url = "http://".$source;
// echo "\t\t<h2 style='color:orange'>$source</h2>\n";
}
else
{
// echo "\n\t<h2 style='color:teal'>$url</h2>\n\t\t";
}
}
}
echo "\t\t<form style='float:right' method='GET'>\n\t\t\t<label for='*'>?:</label>\n";
echo "\t\t\t<input type='text' id='DomainGH' name='domain' value='$source'> \n";
echo "\t\t\t<input type='submit' value='Submit'>\n";
echo "\t\t</form>\n";
$SSLStatus = sslinfo($url);
// print_r($SSLStatus);
$URLhost = parse_url($url, PHP_URL_HOST); // will return 'sub.domain.tld'.
$URLhostip = gethostbyname($URLhost);
// echo "URLhost:$URLhost<br>URLhostip=$URLhostip"; exit;
$URLscheme = parse_url($url, PHP_URL_SCHEME); // will return 'http' OR 'https'.
stream_context_set_default( [ // Fixed SSL issues with 7425.net, but not 7425.com
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar",
),
'ssl' => [
'capture_peer_cert' => true,
'verify_peer' => true,
'verify_peer_name' => false,
],
]);
// if ($URLhost!=$URLhostip) { $HTTPheaders = get_headers($url,1); }
$HTTPheaders = get_headers($url,1);
// echo $url;
// var_dump($HTTPheaders);
/*
$context = stream_context_create( [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
]);
print_r(get_headers($url, 0, $context));
*/
// $HTTPheaders= @get_headers($url,1);
$i = -1;
$result = array();
if (!empty($HTTPheaders)) {$HeaderCounter = sizeof($HTTPheaders);} // Was w/ [0] after sizeof($HTTPheaders)
else { $HeaderCounter=0; }
echo "\t\t<h3><a href='$URLscheme://$URLhost' target='_BLANK'>";
if($SSLStatus[0]==true) { $color="info"; } else { $color="warning"; }
if ($URLscheme=="https") {
echo "<i class='text-success'>$URLscheme://</i>";
} else {
$color="danger";
echo "<i class='text-warning'>$URLscheme://</i>";
}
echo "$URLhost <sup><i class=\"fas fa-external-link-alt text-info\"></i></sup></a>";
if ($URLscheme=="https") { if($SSLStatus[0]==true) { $color="success"; }
echo " <sup><i class='fas fa-lock text-$color' title='".$SSLStatus[1]."'></i>"; }
else { if($SSLStatus[0]==true) { $color="primary"; }
echo " <sup><i class='fas fa-unlock text-$color' title='".$SSLStatus[1]."'></i>"; }
echo "\n\t\t\t= $URLhostip</h3>\n";
if ($URLhost==$URLhostip)
{
if (filter_var($URLhostip, FILTER_VALIDATE_IP)) {
echo("$URLhostip is a valid IP address");
} else {
echo("$URLhostip is not a valid IP address");
echo "\n<div class=\"alert alert-warning\"><strong>No IP Adddress</strong> - Seems like there was <i>no</i> <code>DNS</code> records found.</div>";
}
}
else{}
echo "\t\tChecking...<br>\n";
// echo "<pre>"; print_r($HTTPheaders); echo "</pre>[".sizeof($HTTPheaders)."]";
if($HeaderCounter != 0) {
// echo "<pre>"; print_r($HTTPheaders); echo "</pre>";
$x=0; $cx=0;
foreach ($HTTPheaders as $key=>$value) {
$result[$key] = $value;
if (is_array($value)) { $value0 = current($value);
// echo "here[$x]:$key/";print_r($value);
}
else { $value0 = $value; }
if (is_numeric($key)) {
++$i;
if ($i==0) { $requrlwas = $url; }
else { $requrlwas = $HTTPheaders["Location"]; // [$i-1];
if (is_array($requrlwas)) { $requrlwas = $requrlwas[$i-1]; }
}
// echo $key,$i; exit;
echo "\t\t<i>Connection</i>: <b>$key ($i) @ <a href=?domain=$requrlwas>$requrlwas</a></b> = <tt style='color:green'>$value</tt><br>\n";
foreach ($result as $key123=>$value123) {
if ((is_array($value123)) && (isset($value123[$key]))) {
if( ($key123=="Location") || ($key123=="location") ) {
echo "\t\t • <b>$key123</b> <i class=\"fas fa-forward\"></i> = <tt><a href=$value123[$key]
target=\"redirect\">$value123[$key]<i class=\"fas fa-external-link-alt text-info\"></i></a></tt><br>\n";
}
else{ echo "\t\t · <b>$key123</b> = <tt>$value123[$key]</tt><br>\n"; }
}
}
// echo "<pre style='color:green'>";print_r($result);echo"</pre>";
}
else{ if( ($key=="Location") || ($key=="location") )
{ echo "\t\t • <b>$key</b> <i class=\"fas fa-forward\"></i> = <tt>
<a href=$value0 target=\"redirect\">$value0<i class=\"fas fa-external-link-alt text-info\"></i></a></tt><br>\n";
}
else
{ echo "\t\t ↝ <b>$key</b> = <tt>$value0</tt>";
if($key=="Date") { date_default_timezone_set('America/Los_Angeles'); echo " = ".date(DATE_RFC2822); }
echo "<br>\n";
}
}
$x++;
}
// echo "<pre>";print_r($result);echo "</pre>";
}
else
{
echo "<br><br><div class=\"alert alert-danger\"><strong>Problem!</strong> Got no <code>headers</code> or reply from server.</div>\n";
}
$lookupLink = $Lscheme . '://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo "\t\t<address>Link: <a href=$lookupLink target=_SELF>$lookupLink</a> (".($i+1)." connections required)</address>\n";
?>
</div>
<hr>
<?php include('copyright.php'); ?>
<?php
$remoteaddr = @$_SERVER['REMOTE_ADDR'];
$localaddr = @$_SERVER['LOCAL_ADDR'];
$https = @$_SERVER['HTTPS'];
include('footer.php');
?>
</body></html>