Rabu, 26 Maret 2008

script php (succes)

<?php

function PING($domain){
$starttime = microtime(true);
$file = fsockopen ($domain, 80, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;

if (!$file) $status = -1; // Site is down
else {
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
return $status;
}
?>
<html>
<body bgcolor="#008000">
<?php
$doaminbase = array("www.google.com", "www.yahoo.com", "www.detik.com");
while (list(, $host) = each ($doaminbase)) {
echo "host: $host<br>\n";
$domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
$domainbase = str_replace("http://","",strtolower($domainbase));
}
foreach ($doaminbase as $value) {
echo " <br>\n";
$status = PING($value);
if ($status != -1) echo "<tr><td>Status Domain : http:// $value is ALIVE ($status ms) </td><tr>";
else echo "<tr><td>Status Domain : http:// $value is DOWN</center></td><tr>";
}
?>
</body>
</html>

Selasa, 25 Maret 2008

php ping host

<?php

function PING($domain){
$starttime = microtime(true);
$file = fsockopen ($domain, 80, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;

if (!$file) $status = -1; // Site is down
else {
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
return $status;
}
?>
<html>
<body bgcolor="#008000">
<?php
$doaminbase = array("www.google.com", "www.yahoo.com", "www.detik.com");
reset ($doaminbase);
while (list(, $host) = each ($doaminbase)) {
echo "host: $host<br>\n";
$domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
$domainbase = str_replace("http://","",strtolower($domainbase));
}

foreach ($doaminbase as $value) {
echo "status: $value<br>\n";
$status = PING($value);
if ($status != -1) echo "<tr><td>Status Domain : http:// $domainbase is ALIVE ($status ms) </td><tr>";
else echo "<tr><td>Status Domain : http:// $domainbase is DOWN</center></td><tr>";
}
?>
</body>
</html>

Minggu, 09 Maret 2008

Hasil ruuning php(GAGAL)

host: www.google.com ==>(nama host)
host: www.yahoo.com ==>(nama host)
host: www.detik.com ==>(nama host)
(hasil error)
status: www.google.com

Warning: fsockopen() [function.fsockopen]: unable to connect to :80 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\Program Files\EasyPHP 2.0b1\www\fajar\coba2.php on line 5
Status Domain : http:// is DOWNstatus: www.yahoo.com

Warning: fsockopen() [function.fsockopen]: unable to connect to :80 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\Program Files\EasyPHP 2.0b1\www\fajar\coba2.php on line 5
Status Domain : http:// is DOWNstatus: www.detik.com

Warning: fsockopen() [function.fsockopen]: unable to connect to :80 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\Program Files\EasyPHP 2.0b1\www\fajar\coba2.php on line 5

Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\EasyPHP 2.0b1\www\fajar\coba2.php on line 5

Rabu, 05 Maret 2008

php looping(GAGAL)

<?php

function PING($domain){
$starttime = microtime(true);
$file = fsockopen ($domain, 80, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;

if (!$file) $status = -1; // Site is down
else {
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
return $status;
}
?>
<html>
<body bgcolor="#008000">
<?php
$doaminbase = array("www.google.com", "www.yahoo.com", "www.detik.com");
reset ($doaminbase);
while (list(, $host) = each ($doaminbase)) {
echo "host: $host<br>\n";
$domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
$domainbase = str_replace("http://","",strtolower($domainbase));
}

foreach ($doaminbase as $value) {
echo "status: $value<br>\n";
$status = PING($domainbase);
if ($status != -1) echo "<tr><td>Status Domain : http:// $domainbase is ALIVE ($status ms) </td><tr>";
else echo "<tr><td>Status Domain : http:// $domainbase is DOWN</center></td><tr>";
}
?>
</body>
</html>

php script

ini adalah contoh php script untuk ping ke banyak
host akan tetapi baru menggunakan manual
belum sampai control array dan looping
selengkapnya klik di arsip blog php
<?php

function PING($domain){
$starttime = microtime(true);
$file = fsockopen ($domain, 80, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;

if (!$file) $status = -1; // Site is down
else {
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
return $status;
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>MicroPing domain status checker</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#008000">
<div id="main">
<div id="caption"><font size="20pt" color="#ff0000">Status Domain</font></div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain">
<font size="4pt" color="#00FFFF">host domain :
<table>
<tr><td><input class="text" name="domainname" type="text" size="20" value="www.google.com"></td></tr>
<tr><td><input class="text" name="domainname1" type="text" size="20" value="www.yahoo.com"></td></tr>
<tr><td><input class="text" name="domainname2" type="text" size="20" value="www.detik.com"></td></tr>
<tr><td><input class="text" name="domainname3" type="text" size="20" value="www.friendster.com"></td></tr>
<tr><td><input class="text" name="domainname4" type="text" size="20" value="www.badongo.com"></td></tr>
<tr><td><input class="text" name="domainname5" type="text" size="20" value="www.goal.com"></td></tr>
<tr><td><input class="text" name="domainname6" type="text" size="20" value="www.tunasharapan.info"></td></tr>
<tr><td><input class="text" name="domainname7" type="text" size="20" value="www.youtube.com"></td></tr>
<tr><td><input class="text" name="domainname8" type="text" size="20" value="www.okzone.com" ></td></tr>
<tr><td align="rigt"><br/><input class="text" type="submit" name="submitBtn" value="Ping domain"></td></tr>
</table>
</form>
<?php
if (isset($_POST['submitBtn'])){
$domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
$domainbase = str_replace("http://","",strtolower($domainbase));
?>
<div id="caption">HASIL</div>
<div id="result">
<table width="100%">
<?php
$status = PING($domainbase);
if ($status != -1) echo "<tr><td>Status Domain : http:// $domainbase is ALIVE ($status ms) </td><tr>";
else echo "<tr><td>Status Domain : http:// $domainbase is DOWN</center></td><tr>";
?>
</table>
</div>
<?php
}
?>

<?php
if (isset($_POST['submitBtn'])){
$domainbase1 = (isset($_POST['domainname1'])) ? $_POST['domainname1'] : '';
$domainbase1 = str_replace("http://","",strtolower($domainbase1));
?>
<?php
$status = PING($domainbase);
if ($status != -1) echo "<tr><td>Status Domain : http://$domainbase1 is ALIVE ($status ms)</td><tr>";
else echo "<tr><td>Status Domain : http://$domainbase1 is DOWN</center></td><tr>";
?>
</table>
</div>
<?php
}
?>

<?php
if (isset($_POST['submitBtn'])){
$domainbase2 = (isset($_POST['domainname2'])) ? $_POST['domainname2'] : '';
$domainbase2 = str_replace("http://","",strtolower($domainbase2));
?>
<?php
$status = PING($domainbase);
if ($status != -1) echo "<tr><td>Status Domain : http://$domainbase2 is ALIVE ($status ms)</td><tr>";
else echo "<tr><td>Status Domain : http://$domainbase2 is DOWN</center></td><tr>";
?>
</table>
</div>
<?php
}
?>
<br>
<?php
if (isset($_POST['submitBtn'])){
$domainbase3 = (isset($_POST['domainname3'])) ? $_POST['domainname3'] : '';
$domainbase3 = str_replace("http://","",strtolower($domainbase3));
?>
<?php
$status = PING($domainbase);
if ($status != -1) echo "<tr><td>Status Domain : http://$domainbase3 is ALIVE ($status ms)</td><tr>";
else echo "<tr><td>Status Domain : http://$domainbase3 is DOWN</center></td><tr>";
?>
</table>
</div>
<?php
}
?>
<br>
<?php
if (isset($_POST['submitBtn'])){
$domainbase4 = (isset($_POST['domainname4'])) ? $_POST['domainname4'] : '';
$domainbase4 = str_replace("http://","",strtolower($domainbase4));
?>
<?php
$status = PING($domainbase);
if ($status != -1) echo "<tr><td>Status Domain : http://$domainbase4 is ALIVE ($status ms)</td><tr>";
else echo "<tr><td>Status Domain : http://$domainbase4 is DOWN</center></td><tr>";
?>
</table>
</div>
<?php
}
?>
<br>
<?php
if (isset($_POST['submitBtn'])){
$domainbase5 = (isset($_POST['domainname5'])) ? $_POST['domainname5'] : '';
$domainbase5 = str_replace("http://","",strtolower($domainbase5));
?>
<?php
$status = PING($domainbase);
if ($status != -1) echo "<tr><td>Status Domain : http://$domainbase5 is ALIVE ($status ms)</td><tr>";
else echo "<tr><td>Status Domain : http://$domainbase5 is DOWN</center></td><tr>";
?>
</table>
</div>
<?php
}
?>
<br>
<?php
if (isset($_POST['submitBtn'])){
$domainbase6 = (isset($_POST['domainname6'])) ? $_POST['domainname6'] : '';
$domainbase6 = str_replace("http://","",strtolower($domainbase6));
?>
<?php
$status = PING($domainbase);
if ($status != -1) echo "<tr><td>Status Domain : http://$domainbase6 is ALIVE ($status ms)</td><tr>";
else echo "<tr><td>Status Domain : http://$domainbase6 is DOWN</center></td><tr>";
?>
</table>
</div>
<?php
}
?>
<br>
<?php
if (isset($_POST['submitBtn'])){
$domainbase7 = (isset($_POST['domainname7'])) ? $_POST['domainname7'] : '';
$domainbas74 = str_replace("http://","",strtolower($domainbase7));
?>
<?php
$status = PING($domainbase);
if ($status != -1) echo "<tr><td>Status Domain : http://$domainbase7 is ALIVE ($status ms)</td><tr>";
else echo "<tr><td>Status Domain : http://$domainbase7 is DOWN</center></td><tr>";
?>
</table>
</div>
<?php
}
?>
<br>
<?php
if (isset($_POST['submitBtn'])){
$domainbase8 = (isset($_POST['domainname8'])) ? $_POST['domainname8'] : '';
$domainbase8 = str_replace("http://","",strtolower($domainbase8));
?>
<?php
$status = PING($domainbase);
if ($status != -1) echo "<tr><td>Status Domain : http://$domainbase8 is ALIVE ($status ms)</td><tr>";
else echo "<tr><td>Status Domain : http://$domainbase8 is DOWN</center></td><tr>";
?>
</table>
</div>
<?php
}
?>
</div>
</body>