Skapa en fil och chmoda till 666 eller 777 blablabla... döp den till vhosts.txt
Sen skapar ni en fil vid namn vhost-list.php och lägger följande kod i den filen:
Code: Select all
<?php
/*
* Erik T. Söderström (c) 1999-2003 erik@freebsd.se
* All rights reserved.
* --------------------------------------------------------------------------------
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice and the produced output informing the user of the initial
* developer, this list of conditions and the following disclaimer.
* 2. Initial developer will be notified by e-mail about
* modified distributions which developed from this sourcecode.
*
*
* THIS SOURCCODE IS PROVIDED BY Erik Söderström AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Erik Soderstrom OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* --------------------------------------------------------------------------------
* (having that crap said, we can start explaining the content)
*
* VHost-list 1.1
* This file creates an array of 50 IP's (205.217.179.100 to 205.217.179.150)
* It then checks to see what hostname the IP's resolve into, and then
* check what IP the hostnames resolve back to. If the hostname resolves
* back to the originating IP, the vhost is considered to be online.
* The script is pretty much self-explanitory.
*
* If you want to replace the 205.217.179.100 to 205.217.179.150 array, you can simply delete
* the for-loop and replace it with, for example:
* $ipvect[] = "213.134.122.156";
* $ipvect[] = "194.47.143.4";
* $ipvect[] = "216.136.204.21";
*
* If you dont want the resolved hostname-output to be longer than "X" number of characters,
* you can set it with the $chrlength variable.
*
* Oh yeah, you can cron it too, so if you would like the vhost list to update
* every six hours, you would go like this:
* 0 0,6,12,18 * * * wget -q -O /dev/null http://yourserver/vhost-list.php?update=1
*
* Check out my webpage for more scripts and things that might be interresting:
* http://erik.freebsd.se
*
*/
?>
<html><head><title>VHost-list</title>
<?php echo "<!--\n\n\n\n\n\n\n\n\n\n\n\n\t\t|\n\t\t|\n\t\t| VHost-list 1.1\n\t\t|\n\t\t| (c)" . date("Y") . " Erik T. Söderström\n\t\t|\n\t\t| http://erik.freebsd.se\n\t\t|\n\t\t|\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n-->"; ?>
<style type="text/css">
<!--
body {
margin-left: 10px;
margin-right: 0px;
margin-width: 0px;
margin-height: 0px;
margin-top: 5px;
margin-bottom: 0px;
background: #e1e1e1;
}
font {
font-family : verdana, Arial, Helvetica, sans-serif;
font-size : 8pt;
cursor : default;
color : #000000;
font-weight: smaller;
}
font.green {
font-family : verdana, Arial, Helvetica, sans-serif;
font-size : 8pt;
cursor : default;
color : green;
font-weight: smaller;
}
font.red {
font-family : verdana, Arial, Helvetica, sans-serif;
font-size : 8pt;
cursor : default;
color : red;
font-weight: smaller;
}
font.bold {
font-weight : bold;
font-size : 11px;
font-family : Verdana, Geneva, Arial;
color : #000000;
text-decoration : none;
cursor : default;
}
a:link {
color: #000000;
}
a:visited {
color: #000000;
}
a:active {
color: #ffffff;
}
a:hover {
color: #0000ff;
}
}
-->
</style>
</head>
<body><font>
<font class="bold">&&Virtual hosts</font>&<font>(<a href="?update=1" target="_self">update list</a>)</font><br /><br />
<table cellspacing="0" cellpadding="0"><tr><td valign="top"><font class="bold">STATUS:</font></td><td width="25"></td><td valign="top" width="25"><font class="bold">IP:</font></td><td valign="top" width="25">&</td><td valign="top"><font class="bold">DOMAIN:</font></td></tr>
<?php
set_time_limit("600"); // Set the number of seconds we are allowed to resolve hostnames before the script expires.
$output = ""; // Set $output to nothing, so we are sure that the $vhosts_file doesnt get filled with unwanted data before the content is replaced with whats generated if $update is set to 1.
$update = $_GET['update']; // Check if we should update the list of vhosts.
$vhosts_file = "vhosts.txt"; // Name of the file that the static output should be saved in. A relative or absolute path can be specified. Set permissions to 666 or 777 for this file.
$colors = array('#ffffff', '#e1e1e1'); // Colors to be looped in the table. The first table row has #ffffff and the second #e1e1e1 for example.
$chrlimit = "false"; // Set this to "true" if you want to limit the allowed number of characters allowed in the hostname output.
$chrlength = 80; // The allowed number of characters in the hostname output. This is only implied if $chrlimit is set to "true".
$ipserie = "205.217.179."; // The starting IP serie. The forumla looks like $ipserie.$startip looped to $ipserie.$endip, which would create a loop from 205.217.179.100 to 205.217.179.150.
$startip = 100; // Starting IP, like 205.217.179.$startip (which would be 205.217.179.100 in this case)
$endip = 150; // Ending IP, like 205.217.179.$endip (which would be 205.217.179.150 in this case).
function writefile($filename, $data, $mode) {
$fp = fopen($filename, $mode);
fwrite($fp, $data);
fclose($fp);
}
if($update==1) {
$endip++; // Adds 1 to $endip, so that if $endip is 150, it becomes 151. This is so that the for-loop will go through 0 to 150, instead of 0 to 149.
for($i=$startip; $i<$endip; $i++) { // Delete this for loop and add $ipvect[] = "your.desired.ip.number"; (if you dont have a constant sequence of IP-numbers).
$ipvect[] = $ipserie . $i;
}
writefile($vhosts_file,"", "w"); // Empty the vhosts-file from any prior content.
for($i=0; $i<count($ipvect); $i++) {
$ip = $ipvect[$i];
$hostname = @gethostbyaddr($ip);
$iprev = @gethostbyname($hostname);
if($hostname == $ip) {
$hostname = "This IP is not reversed.";
$status = "<font class=\"red\">DOWN</font>";
} else {
if($iprev != $ip) {
$status = "<font class=\"red\">DOWN</font>";
} else {
if($iprev == $ip) { $status = "<font class=\"green\">UP</font>";
} else { $status = "ERROR"; }
}
}
if ($chrlimit=="true") {
if (strlen($hostname) > $chrlength) $hostname=substr($hostname, 0, $chrlength)."...";
}
$output = "<tr bgcolor=\"".$colors[$i % 2]."\"><td valign=\"top\">$status</td><td width=\"25\"></td><td valign=\"top\" width=\"25\"><font>$ip</font></td><td valign=\"top\" width=\"25\">&</td><td valign=\"top\"><font>$hostname</font></td></tr>\n";
echo $output;
writefile($vhosts_file, $output, "a");
}
} else {
include($vhosts_file);
}
?>
</table>
</font></body></html>
Adios.