Articles Comments

{ Berbagi, Menulis, Dan Mengajar } Ilmu… » 7. Operating System » Script php arif ptpn-11.com

Script php arif ptpn-11.com

<?

$param = array(
“server” => ‘192.168.11.254’,
“speedy” => ‘180.247.54.151’,
“dns_lokal” => ‘detik.com’,
“ip_lokal” => ‘203.190.241.43’,
“dns_global” => ‘google.com’,
“ip_global” => ‘118.98.36.35’,
);

function getRealIpAddr()
{
if (!empty($_SERVER[‘HTTP_CLIENT_IP’]))   //check ip from share internet
{
$ip=$_SERVER[‘HTTP_CLIENT_IP’];
}
elseif (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’]))   //to check ip is pass from proxy
{
$ip=$_SERVER[‘HTTP_X_FORWARDED_FOR’];
}
else
{
$ip=$_SERVER[‘REMOTE_ADDR’];
}
return $ip;
}

function getproxystat()
{
$output = shell_exec(‘/etc/init.d/squid status’);
if (trim($output) == ‘squid is running.’)
$hasil = true;
else
$hasil = false;

return $hasil;
}

function getbindstat()
{
$output = shell_exec(‘/etc/init.d/bind9 status’);
$result = str_replace(array(“\r\n”, “\r”, “\n”), ” “,$output);
$datapisah = explode(” “,$result);

for($i=0;$i<count($datapisah);$i++)
{
if ($datapisah[$i] == ‘bind9′)
{
$hasilawal = $datapisah[$i];
$hasilawal .= $datapisah[$i+1];
$hasilawal .= $datapisah[$i+2];
break;
}
}

if ($hasilawal == ‘bind9isrunning.’)
$hasil = true;
else
$hasil = false;

return $hasil;
}

function getnmap($param)
{
$eksekusi = ‘nmap -sP ‘.$param;
$output = shell_exec($eksekusi);
$result = str_replace(array(“\r\n”, “\r”, “\n”), ” “,$output);
$datapisah = explode(” “,$result);
for($i=0;$i<count($datapisah);$i++)
{
if ($datapisah[$i] == ‘(1′)
{
$hasilawal = $datapisah[$i];
$hasilawal .= $datapisah[$i+1];
$hasilawal .= $datapisah[$i+2];
break;
}
}
if ($hasilawal == ‘(1hostup)’)
$hasil = true;
else
$hasil = false;

return $hasil;
}

function getdns()
{
$hasilawal = ”;
$hasil = false;
$eksekusi = ‘cat /etc/resolv.conf';
$output = shell_exec($eksekusi);
$result = str_replace(array(“\r\n”, “\r”, “\n”), ” “,$output);
$datapisah = explode(” “,$result);
for($i=0;$i<count($datapisah);$i++)
{
if ($datapisah[$i] == ‘nameserver’)
{
$hasilawal = $datapisah[$i+1];
if (getnmap($hasilawal))
{
$hasil = true;
break;
}
}

}

return $hasil;
}

?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>NetworkCheck v1</title>
<link rel=”stylesheet” type=”text/css” href=”css/theme.css” />
<link rel=”stylesheet” type=”text/css” href=”css/style.css” />
<link rel=”Shortcut Icon” href=”img/icon.png”>
</head>

<body>
<table id=”tablenoborder”>
<tr>
<td colspan=”5″>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>
<div id=”infobox”>
<h3>Your IP</h3>
<div id=”yourip”>
<?echo getRealIpAddr();?>
</div>
</div>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan=”5″>&nbsp;</td>
</tr>
<tr>
<td>
<div id=”infobox”>
<h3>Proxy</h3>
<div id=”text”>
<?
if (getproxystat())
echo ‘<img src=”img/ok.jpg” alt=”ok” height=”50″ width=”50″/>';
else
{
echo ‘<img src=”img/notok.png” alt=”ok” height=”50″ width=”50″/>';
echo ‘<br />';
echo ‘Squid tidak aktif';
}
?>
</div>
</div>
</td>
<td>
<div id=”infobox”>
<h3>Gateway</h3>
<div id=”text”>
<?
if (getnmap($param[‘speedy’]))
echo ‘<img src=”img/ok.jpg” alt=”ok” height=”50″ width=”50″/>';
else
{
echo ‘<img src=”img/notok.png” alt=”ok” height=”50″ width=”50″/>';
echo ‘<br />';
echo ‘Speedy tidak aktif.';
}
?>
</div>
</div>
</td>
<td>
<div id=”infobox”>
<h3>DNS</h3>
<div id=”text”>
<?
if (getdns())
echo ‘<img src=”img/ok.jpg” alt=”ok” height=”50″ width=”50″/>';
else
{
echo ‘<img src=”img/notok.png” alt=”ok” height=”50″ width=”50″/>';
echo ‘<br />';
echo ‘Cek DNS anda.';
}
?>
</div>
</div>
</td>
<td>
<div id=”infobox”>
<h3>IIX</h3>
<div id=”text”>
<?
if (getnmap($param[‘ip_lokal’]) && getnmap($param[‘dns_lokal’]))
echo ‘<img src=”img/ok.jpg” alt=”ok” height=”50″ width=”50″/>';
else
{
echo ‘<img src=”img/notok.png” alt=”ok” height=”50″ width=”50″/>';
echo ‘<br />';
if (getnmap($param[‘ip_lokal’]) == false)
echo ‘Koneksi lokal down. <br />';
if (getnmap($param[‘dns_lokal’]) == false)
echo ‘DNS bermasalah.';
}
?>
</div>
</div>
</td>
<td>
<div id=”infobox”>
<h3>Global</h3>
<div id=”text”>
<?
if (getnmap($param[‘ip_global’]) && getnmap($param[‘dns_global’]))
echo ‘<img src=”img/ok.jpg” alt=”ok” height=”50″ width=”50″/>';
else
{
echo ‘<img src=”img/notok.png” alt=”ok” height=”50″ width=”50″/>';
echo ‘<br />';
if (getnmap($param[‘ip_global’]) == false)
echo ‘Koneksi global down. <br />';
if (getnmap($param[‘dns_global’]) == false)
echo ‘DNS bermasalah.';
}
?>
</div>
</div>
</td>
</tr>
<tr>
<td colspan=”5″>&nbsp;</td>
</tr>
</table>
<p>
Copyright &copy; 2012 Bidang Teknologi Informasi
</p>
</body>
</html>

Filed under: 7. Operating System

Leave a Reply

*

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>