rendered paste body
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<!--
|
| Copyright PakShells , me@pexi.net
|
|
-->
<HEAD>
<TITLE> PakShells Communications vhost checker </TITLE>
<META NAME="Author" CONTENT="Pekka Pesola,pexi,pex">
<META NAME="Keywords" CONTENT="Vhost checker script">
<META NAME="Description" CONTENT="Check working vhosts in real time">
</HEAD>
<BODY>
<style type="text/css">
#table1 {
border: 0px solid red;
color: black;
}
.td1 {
font-family: Verdana;
font-size: 10;
border: 1px solid black;
background-color: #96CDCD;
text-align: center
}
.td2 {
font-family: Verdana;
font-size: 10;
border: 1px solid black;
background-color: #B4CDCD;
text-align: center;
}
</style>
<br>
<table id=table1 width=30% align="center">
<tr><td class=td2><b>PakShells Communications</b></td></tr>
</table>
<br>
<table id=table1 width=30% align="center">
<tr><td class=td1>Checking started, please be patient.</td></tr>
</table>
<br>
<?php
/*
status.php
vhost status checker script BASIC EDITION
NOTE: THIS SCRIPT USES SYSCALLS SO YOU NEED THOSE ENABLED
*/
if ($ipfile == ip.txt)
$tid="1";
$down="0";
$up="0";
$count=0;
while ($i < 50) {
echo "<!-- FORCE STREAM -->\n";
$i++;
}
if ( ! $ips=file("$ipfile")) {
echo "error opening $ipfile";
die();
}
$ip=trim($ip);
$time_start=time();
foreach ($ips as $ip) {
$count++;
if ($tid == 1) {
$tid="2";
}else{
$tid="1";
}
//sleep(1); //slow things down a bit to get accurate results
$do=exec("ping -c1 -q $ip 2>&1",$output,$err);
if (preg_match("/(.*)100%(.*)/",$output[3],$o)) {
$status="down";
$fcolor="red";
$down++;
$pingdown="TRUE";
}elseif ($output[3] == "") {
$status="down";
$fcolor="red";
$down++;
$pingdown="TRUE";
}else{
$status="up";
$fcolor="green";
}
$do=exec("host $ip",$output1);
$pieces=explode(" ",$output1[0]);
$ptr=$pieces[4];
$ptr=rtrim($ptr, ".");
$ip=trim($ip);
if ($ptr == "3(NXDOMAIN)") {
$ptr="Cant find PTR record for this ip.";
}else{
$do=exec("host $ptr",$output2);
$pieces1=explode(" ",$output2[0]);
$arecord=$pieces1[3];
$arecord=trim($arecord);
if ($pingdown == "TRUE") {
$ptr="Does not respond to ping";
$status="down";
$fcolor="red";
}
if ($arecord != $ip && $pingdown != "TRUE") {
$ptr="$ip resolves to $ptr, but $ptr does not resolve back";
$status="down";
$fcolor="red";
$down++;
}elseif ($pingdown != "TRUE" && $arecord = $ip) {
$status="up";
$fcolor="green";
$up++;
}
}
?>
<table id=table1 align="center" width=65%>
<tr><td class="td<?=$tid?>" align=center width=20%><?=$ip?></td><td class="td<?=$tid?>" align=center><?=$ptr?></td><td
class="td<?=$tid?>" align=center width=10%><font color="<?=$fcolor?>"><?=$status?></font></td></tr>
</table>
<?php
unset($output1,$err,$output,$output2,$pingdown);
flush();
}// foreach
$time_end = time();
$time=$time_end - $time_start;
?>
<br>
<table id=table1 align="center" width=25%>
<tr><td class=td1>Check completed in:</td><td class=td1 width=15%><b><?=$time?></b> seconds</td></tr>
<tr><td class=td2>Number of working vhosts:</td><td class=td2><b><?=$up?></b></td></tr>
<tr><td class=td1>Number of non-working vhosts:</td><td class=td1><b><?=$down?></b></td></tr>
<tr><td class=td2>Total vhosts:</td><td class=td2><b><?=$count?></b></td></tr>
</table>
<br>
<table id=table1 align="center" width=35%>
<tr>
<td class=td1>Copyright: PakShells </td>
</tr>
<tr>
<td class=td2>Contact bullet@cyber.net.pk if you need custom php/bash scripts.</td>
</tr>
</table>
</BODY>
</HTML>