本文整理汇总了PHP中ping函数的典型用法代码示例。如果您正苦于以下问题:PHP ping函数的具体用法?PHP ping怎么用?PHP ping使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ping函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
function test($serviceId)
{
$tableau = Connexion::query('select url,port,texte,trl from services where id=\'' . $serviceId . '\'');
$url = $tableau[0][0];
$port = $tableau[0][1];
$texte = $tableau[0][2];
$ping = ping($url, $port, $texte, $tableau[0][3]);
$date = date('Y-m-d');
$heure = date('H:i:s');
$trl = $ping[2];
$etat = $ping[0] == true ? 1 : 0;
$codeHttp = strlen($ping[1]) != 3 ? '500' : $ping[1];
Connexion::exec('insert into tests (service_id,date,heure,trl,etat,codeHttp) values (\'' . $serviceId . '\',\'' . $date . '\',\'' . $heure . '\',\'' . $trl . '\',\'' . $etat . '\',\'' . $codeHttp . '\')');
if ($ping[0] == false or $trl * 1000 > $tableau[0][3] or $codeHttp != '200') {
$res = false;
} else {
$res = true;
validation($serviceId, $date, $heure);
}
if ($res == false) {
notif($serviceId, $date, $heure);
erreur($serviceId, $date, $heure);
}
return $res;
}
示例2: update_geraete
function update_geraete()
{
//UPDATE geraete SET zeitEin = $timestamp WHERE id = 1"
$defaultIP = "0.0.0.0";
//$sqlbefehl = "SELECT id,ip,zeitEin FROM `devices` WHERE ip NOT like '" . $defaultIP . "'";
$sqlbefehl = "SELECT id,ip,zeitEin,zeitHeute FROM `devices` WHERE ip NOT like '" . $defaultIP . "' AND ip NOT like ''";
//SELECT id,ip,zeitEin FROM `devices` WHERE ip NOT like '0.0.0.0' AND ip NOT like ''
$sql = query($sqlbefehl);
//var_dump($sql);
while ($row = fetch($sql)) {
//var_dump($row);
$result = ping($row['ip']);
//var_dump($result);
if ($result) {
if ($row['zeitEin'] == "0") {
$sql1 = query("UPDATE devices SET zeitEin = '" . time() . "' WHERE id = '" . $row['id'] . "'");
// update Zeit Ein heute
}
} else {
if ($row['zeitEin'] != "0") {
$zeitHeute = time() - $row['zeitEin'];
var_dump($zeitHeute);
$sql2 = query("UPDATE devices SET zeitHeute = '" . $zeitHeute . "' WHERE id = '" . $row['id'] . "'");
$sql1 = query("UPDATE devices SET zeitEin = '0' WHERE id = '" . $row['id'] . "'");
//update Zeit Ein heute
}
}
}
}
示例3: statusping
function statusping($host)
{
$pingtime = 0;
$avgpingtime = 0;
$packetloss = 0;
for ($i = 1; $i <= 10; $i++) {
$pingtime = ping($host, 2);
if ($pingtime == FALSE) {
$packetloss++;
} else {
$avgpingtime += $pingtime;
}
}
if ($packetloss == 10) {
$avgpingtime = 0;
} else {
$avgpingtime = round($avgpingtime / (10 - $packetloss) * 1000);
}
if ($packetloss > 5) {
$status = 40002;
} else {
if ($packetloss > 2 || $avgpingtime > 1000) {
$status = 40001;
} else {
$status = 40000;
}
}
$packetloss *= 10;
return array($status, $avgpingtime, $packetloss);
}
示例4: proccess
public function proccess($data = NULL, $validations = FALSE)
{
if (is_array($validations)) {
foreach ($validations as $field => $validation) {
if ($validation === "required") {
if (!POST($field)) {
$field = $this->rename($field);
return array("error" => getAlert("{$field} is required"));
}
} elseif ($validation === "email?") {
if (!isEmail(POST($field))) {
return array("error" => getAlert("{$field} is not a valid email"));
}
} elseif ($validation === "injection?") {
if (isInjection(POST($field))) {
return array("error" => getAlert("SQL/HTML injection attempt blocked"));
}
} elseif ($validation === "spam?") {
if (isSPAM(POST($field))) {
return array("error" => getAlert("SPAM prohibited"));
}
} elseif ($validation === "vulgar?") {
if (isVulgar(POST($field))) {
return array("error" => getAlert("Your {$field} is very vulgar"));
}
} elseif ($validation === "ping") {
if (!ping(POST($field))) {
return array("error" => getAlert("Invalid URL"));
}
} elseif (is_string($validation) and substr($validation, 0, 6) === "length") {
$count = (int) substr($validation, 7, 8);
$count = $count > 0 ? $count : 6;
if (strlen(POST($field)) < $count) {
return array("error" => getAlert("{$field} must have at least {$count} characters"));
}
} elseif (isset($field["exists"]) and isset($this->table) and POST("save")) {
if (is_array($validation)) {
$exists = $this->Db->findBy($validation);
if ($exists) {
return array("error" => getAlert("The record already exists"));
}
}
}
}
}
if (is_null($data)) {
$data = array();
}
$POST = POST(TRUE);
foreach ($POST as $field => $value) {
if (!in_array($field, $this->ignore)) {
if (!isset($data[$this->rename($field)])) {
$data[$this->rename($field)] = decode(filter($value, "escape"));
}
}
}
return $data;
}
示例5: editOrSave
private function editOrSave($action)
{
if (!POST("title")) {
return getAlert("You need to write a title");
} elseif (!POST("description")) {
return getAlert("You need to write a description");
} elseif (!ping(POST("URL"))) {
return getAlert("Invalid URL");
} elseif (FILES("image", "name") === "" and $action === "save") {
return getAlert("Selected image");
} elseif (FILES("preview1", "name") === "" and $action === "save") {
return getAlert("Selected preview");
} elseif (FILES("preview2", "name") === "" and $action === "save") {
return getAlert("Selected preview");
}
if (FILES("image", "name") !== "") {
$upload = $this->upload("image");
if ($upload) {
$this->image = $upload;
} else {
return $this->error;
}
} else {
if ($action === "edit") {
$this->image = "";
}
}
if (FILES("preview1", "name") !== "") {
$upload = $this->upload("preview1");
if ($upload) {
$this->preview1 = $upload;
} else {
return $this->error;
}
} else {
if ($action === "edit") {
$this->preview1 = "";
}
}
if (FILES("preview2", "name") !== "") {
$upload = $this->upload("preview2");
if ($upload) {
$this->preview2 = $upload;
} else {
return $this->error;
}
} else {
if ($action === "edit") {
$this->preview2 = "";
}
}
$this->ID = POST("ID_Work");
$this->title = POST("title", "decode", "escape");
$this->nice = nice($this->title);
$this->description = POST("description");
$this->URL = POST("URL");
$this->state = POST("state");
}
示例6: getTypeC
function getTypeC()
{
global $_GET;
if (!$_GET["ECOMM"]) {
if (ping() == "logout") {
header('Content-type: application/json');
echo '{"die":"ok"}';
exit(0);
}
return "ERP";
} else {
return "ECOMMERCE";
}
}
示例7: Ini_Set
<!DOCTYPE html>
<?php
Ini_Set('display_errors', true);
include "functions.php";
?>
<html lang="en">
<script>
// Enable bootstrap tooltips
$(function ()
{ $("[rel=tooltip]").tooltip();
});
</script>
<?php
echo ping();
示例8: sabSpeedAdjuster
function sabSpeedAdjuster()
{
global $sabnzbd_ip;
global $sabnzbd_port;
global $sabnzbd_api;
global $sabnabdSpeedLimitMax;
global $sabnzbdSpeedLimitMin;
// Set how high ping we want to hit before throttling
global $ping_throttle;
// Check the current ping
$avgPing = ping();
// Get SABnzbd XML
$sabnzbdXML = simplexml_load_file('http://' . $sabnzbd_ip . ':' . $sabnzbd_port . '/api?mode=queue&start=START&limit=LIMIT&output=xml&apikey=' . $sabnzbd_api);
// Get current SAB speed limit
$sabSpeedLimitCurrent = $sabnzbdXML->speedlimit;
// Check to see if SAB is downloading
if ($sabnzbdXML->status == 'Downloading') {
// If it is downloading and ping is over X value, slow it down
if ($avgPing > $ping_throttle) {
if ($sabSpeedLimitCurrent > $sabnzbdSpeedLimitMin) {
// Reduce speed by 256KBps
echo 'Ping is over ' . $ping_throttle;
echo '<br>';
echo 'Slowing down SAB';
$sabSpeedLimitSet = $sabSpeedLimitCurrent - 256;
shell_exec('curl "http://' . $sabnzbd_ip . ':' . $sabnzbd_port . '/api?mode=config&name=speedlimit&value=' . $sabSpeedLimitSet . '&apikey=' . $sabnzbd_api . '"');
} else {
echo 'Ping is over ' . $ping_throttle . ' but SAB cannot slow down anymore';
}
} elseif ($avgPing . 9 < $ping_throttle) {
if ($sabSpeedLimitCurrent < $sabnabdSpeedLimitMax) {
// Increase speed by 256KBps
echo 'SAB is downloading and ping is ' . ($avgPing . 9) . ' so increasing download speed.';
$sabSpeedLimitSet = $sabSpeedLimitCurrent + 256;
shell_exec('curl "http://' . $sabnzbd_ip . ':' . $sabnzbd_port . '/api?mode=config&name=speedlimit&value=' . $sabSpeedLimitSet . '&apikey=' . $sabnzbd_api . '"');
} else {
echo 'SAB is downloading. Ping is low enough but we are at global download speed limit.';
}
} else {
echo 'SAB is downloading. Ping is ok but not low enough to speed up SAB.';
}
} else {
// do nothing,
echo 'SAB is not downloading.';
}
}
示例9: checkAllHosts
/**
* Title
*
* Description
*
* @access public
*/
function checkAllHosts($limit=1000) {
// ping hosts
$pings=SQLSelect("SELECT * FROM pinghosts WHERE CHECK_NEXT<=NOW() ORDER BY CHECK_NEXT LIMIT ".$limit);
$total=count($pings);
for($i=0;$i<$total;$i++) {
$host=$pings[$i];
echo "Checking ".$host['HOSTNAME']."\n";
$online_interval=$host['ONLINE_INTERVAL'];
if (!$online_interval) {
$online_interval=60;
}
$offline_interval=$host['OFFLINE_INTERVAL'];
if (!$offline_interval) {
$offline_interval=$online_interval;
}
if ($host['STATUS']=='1') {
$host['CHECK_NEXT']=date('Y-m-d H:i:s', time()+$online_interval);
} else {
$host['CHECK_NEXT']=date('Y-m-d H:i:s', time()+$offline_interval);
}
SQLUpdate('pinghosts', $host);
$online=0;
// checking
if (!$host['TYPE']) {
//ping host
$online=ping($host['HOSTNAME']);
} else {
//web host
$online=file_get_contents($host['HOSTNAME']);
SaveFile("./cached/host_".$host['ID'].'.html', $online);
if ($host['SEARCH_WORD']!='' && !is_integer(strpos($online, $host['SEARCH_WORD']))) {
$online=0;
}
if ($online) {
$online=1;
}
}
$old_status=$host['STATUS'];
if ($online) {
$new_status=1;
} else {
$new_status=2;
}
$host['CHECK_LATEST']=date('Y-m-d H:i:s');
$host['STATUS']=$new_status;
if ($host['STATUS']=='1') {
$host['CHECK_NEXT']=date('Y-m-d H:i:s', time()+$online_interval);
} else {
$host['CHECK_NEXT']=date('Y-m-d H:i:s', time()+$offline_interval);
}
if ($old_status!=$new_status) {
if ($new_status==2) {
$host['LOG']=date('Y-m-d H:i:s').' Host is offline'."\n".$host['LOG'];
} elseif ($new_status==1) {
$host['LOG']=date('Y-m-d H:i:s').' Host is online'."\n".$host['LOG'];
}
}
SQLUpdate('pinghosts', $host);
if ($old_status!=$new_status && $old_status!=0) {
// do some status change actions
$run_script_id=0;
$run_code='';
if ($old_status==2 && $new_status==1) {
// got online
if ($host['SCRIPT_ID_ONLINE']) {
$run_script_id=$host['SCRIPT_ID_ONLINE'];
} elseif ($host['CODE_ONLINE']) {
$run_code=$host['CODE_ONLINE'];
}
} elseif ($old_status==1 && $new_status==2) {
// got offline
if ($host['SCRIPT_ID_OFFLINE']) {
$run_script_id=$host['SCRIPT_ID_OFFLINE'];
} elseif ($host['CODE_OFFLINE']) {
$run_code=$host['CODE_OFFLINE'];
}
}
if ($run_script_id) {
//run script
runScript($run_script_id);
} elseif ($run_code) {
//run code
eval($run_code);
//.........这里部分代码省略.........
示例10: ping
<?php
// starting point for tests to devices
// future: icinga, mtr, jitter etc....
if (!empty($_GET['ip'])) {
$ip = $_GET['ip'];
$pingReply = ping($ip);
if ($pingReply) {
$reply = "up";
} else {
$reply = "down";
}
} else {
$ip = null;
}
echo $reply;
// functions to play with
function ping($host)
{
exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
return $rval === 0;
}
示例11: fopen
if ($c == "\n") {
// && ($c == "\r") //May be later on oher systems
return $t;
} else {
$t = $t . $c;
}
}
return $t;
}
//READLINE END
//Code
//echo (ping ("192.168.2.1"));
$fp = fopen("hosts.txt", "r+");
//host list file (hosts separated by newline, ends with two empty lines)
$fhost = "EMPTY";
while ($fhost != "") {
$ping = "";
$fhost = trim(readline($fp));
if ($fhost != "") {
echo "HOST: " . $fhost;
try {
$ping = ping($fhost);
} catch (string $err) {
}
if ($ping != "" && $ping > "0") {
echo " - UP PING: " . $ping . " sec.\n";
} else {
echo " - TIMED OUT\n";
}
}
}
示例12: checkAccess
/**
* Vérifie que la page est bien accessible par l'utilisateur
*
* @global string
* @return boolean TRUE si la page est accessible, FALSE sinon
* @see tentative_intrusion()
*/
function checkAccess()
{
global $gepiPath;
global $mysqli;
if (!preg_match("/mon_compte.php/", $_SERVER['SCRIPT_NAME'])) {
if (isset($_SESSION['statut']) && $_SESSION['statut'] != "administrateur" && getSettingAOui('MailValideRequis' . ucfirst($_SESSION['statut']))) {
$debug_test_mail = "n";
if ($debug_test_mail == "y") {
$f = fopen("/tmp/debug_check_mail.txt", "a+");
fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " checkAccess(): depuis " . $_SERVER['SCRIPT_NAME'] . "\n");
fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " checkAccess(): Avant le test check_mail().\n");
fclose($f);
}
$ping_host = getSettingValue('ping_host');
if ($ping_host == "") {
//$ping_host="www.google.fr";
$ping_host = "173.194.40.183";
}
$redir_saisie_mail_requise = "n";
//if((!isset($_SESSION['email']))||(!check_mail($_SESSION['email']))) {
if (!isset($_SESSION['email'])) {
$redir_saisie_mail_requise = "y";
if ($debug_test_mail == "y") {
$f = fopen("/tmp/debug_check_mail.txt", "a+");
fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " \$_SESSION['email'] est vide.\n");
fclose($f);
}
} elseif (getSettingAOui('MailValideRequisCheckDNS') && ping($ping_host, 80, 3) != "down") {
if ($debug_test_mail == "y") {
$f = fopen("/tmp/debug_check_mail.txt", "a+");
fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " Avant le test checkdnsrr...\n");
fclose($f);
}
if (!check_mail($_SESSION['email'], 'checkdnsrr', 'y')) {
$redir_saisie_mail_requise = "y";
if ($debug_test_mail == "y") {
$f = fopen("/tmp/debug_check_mail.txt", "a+");
fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " Le test checkdnsrr a échoué.\n");
fclose($f);
}
}
} elseif (!check_mail($_SESSION['email'])) {
if ($debug_test_mail == "y") {
$f = fopen("/tmp/debug_check_mail.txt", "a+");
fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " Le check_mail() a échoué.\n");
fclose($f);
}
$redir_saisie_mail_requise = "y";
}
if ($redir_saisie_mail_requise == "y") {
if ($debug_test_mail == "y") {
$f = fopen("/tmp/debug_check_mail.txt", "a+");
if (!isset($_SESSION['email'])) {
fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " checkAccess(): Après le test check_mail() qui n'a pas été effectué : \$_SESSION['email'] n'est pas initialisé.\n");
} else {
fwrite($f, strftime("%Y-%m-%d %H:%M:%S") . " checkAccess(): Après le test check_mail() qui a échoué sur '" . $_SESSION['email'] . "'.\n");
}
fclose($f);
}
header("Location: {$gepiPath}/utilisateurs/mon_compte.php?saisie_mail_requise=yes");
//getSettingValue('sso_url_portail')
die;
}
}
}
$url = parse_url($_SERVER['SCRIPT_NAME']);
if (mb_substr($url['path'], 0, mb_strlen($gepiPath)) != $gepiPath) {
tentative_intrusion(2, "Tentative d'accès avec modification sauvage de gepiPath");
return FALSE;
} else {
if ($_SESSION["statut"] == 'autre') {
$sql = "SELECT autorisation\n\t\t\t\t\tFROM droits_speciaux\n\t\t\t\t\tWHERE nom_fichier = '" . mb_substr($url['path'], mb_strlen($gepiPath)) . "'\n\t\t\t\t\tAND id_statut = '" . $_SESSION['statut_special_id'] . "'\n\t\t\t\t\tAND autorisation='V'";
} else {
$sql = "SELECT " . $_SESSION['statut'] . " AS autorisation\n\t\t\t\t\tFROM droits\n\t\t\t\t\tWHERE id = '" . mb_substr($url['path'], mb_strlen($gepiPath)) . "'\n\t\t\t\t\tAND " . $_SESSION['statut'] . "='V';";
}
$resultat = mysqli_query($mysqli, $sql);
$nb_lignes = $resultat->num_rows;
$resultat->close();
if ($nb_lignes > 0) {
return TRUE;
} else {
tentative_intrusion(1, "Tentative d'accès à un fichier sans avoir les droits nécessaires");
return FALSE;
}
}
}
示例13: saveComments
public function saveComments()
{
$this->ID_Application = POST("ID_Application");
$this->ID_Record = POST("ID_Record");
$this->comment = POST("comment", "clean", FALSE);
$this->email = POST("email");
$this->website = POST("website");
$this->name = SESSION("ZanUser") ? NULL : POST("name");
$this->username = SESSION("ZanUser") ? SESSION("ZanUser") : NULL;
$this->ID_User = SESSION("ZanUserID") ? (int) SESSION("ZanUserID") : 0;
$this->state = "Active";
$this->date1 = now(4);
$this->date2 = now(2);
$this->year = date("Y");
$this->month = date("m");
$this->day = date("d");
$this->URL = POST("URL");
if ($this->ID_Application === "3") {
if ($this->comment === NULL) {
return getAlert("Empty Comment");
}
if (isSPAM($this->comment) === TRUE) {
return getAlert("STOP, SPAM");
}
if (isVulgar($this->comment) === TRUE) {
return getAlert("STOP, The Comment is Vulgar");
}
if (isInjection($this->comment) === TRUE) {
return getAlert("STOP, Injection");
} else {
cleanHTML($this->comment);
}
if ($this->ID_User > 0) {
$this->Db->table($this->table);
$repost = $this->Db->findBySQL("Comment = '{$this->comment}' AND Year = '{$this->year}' AND Month = '{$this->month}' AND Day = '{$this->day}' AND Name = '{$this->name}'");
if (is_array($repost)) {
return getAlert("This Comment has been posted yet");
}
$fields = "ID_User, Username, Comment, Start_Date, Text_Date, Year, Month, Day, State";
$values = "'{$this->ID_User}', '{$this->username}', '{$this->comment}', '{$this->date1}', '{$this->date2}', '{$this->year}', '{$this->month}', '{$this->day}', '{$this->state}'";
$this->Db->table($this->table, $fields);
$this->Db->values($values);
$this->insertID1 = $this->Db->save();
$fields = "ID_Application, ID_Comment";
$values = "'3', '{$this->insertID1}'";
$this->Db->table("comments2applications", $fields);
$this->Db->values($values);
$this->insertID2 = $this->Db->save();
$fields = "ID_Comment2Application, ID_Record";
$values = "'{$this->insertID2}', '{$this->ID_Record}'";
$this->Db->table("comments2records", $fields);
$this->Db->values($values);
$this->insertID3 = $this->Db->save();
} else {
$this->Db->table($this->table);
$repost = $this->Db->findBySQL("ID_User = '{$this->ID_User}' AND Comment = '{$this->comment}' AND Year = '{$this->year}' AND Month = '{$this->month}' AND Day = '{$this->day}'");
if (is_array($repost)) {
return getAlert("This Comment has been posted yet");
}
if ($this->name === NULL) {
return getAlert("Empty Name");
}
if (isVulgar($this->name) === TRUE) {
return getAlert("STOP, Vulgar Name");
}
if (isInjection($this->name) === TRUE) {
return getAlert("STOP, Injection");
} else {
cleanHTML($this->comment);
}
if ($this->email === NULL) {
return getAlert("Empty Email");
}
if (isEmail($this->email) === FALSE) {
return getAlert("Invalid Email");
}
if (isset($this->website) and ping($this->website) === FALSE) {
if (isInjection($this->website) === TRUE) {
return getAlert("STOP, Injection");
} else {
cleanHTML($this->website);
}
return getAlert("Invalid Website");
}
$fields = "ID_User, Comment, Start_Date, Text_Date, Year, Month, Day, Name, Email, Website, State";
$values = "'{$this->ID_User}', '{$this->comment}', '{$this->date1}', '{$this->date2}', '{$this->year}', '{$this->month}', '{$this->day}', '{$this->name}', '{$this->email}', '{$this->website}', '{$this->state}'";
$this->Db->table($this->table, $fields);
$this->Db->values($values);
$this->insertID1 = $this->Db->save();
$fields = "ID_Application, ID_Comment";
$values = "'3', '{$this->insertID1}'";
$this->Db->table("comments2applications", $fields);
$this->Db->values($values);
$this->insertID2 = $this->Db->save();
$fields = "ID_Comment2Application, ID_Record";
$values = "'{$this->insertID2}', '{$this->ID_Record}'";
$this->Db->table("comments2records", $fields);
$this->Db->values($values);
$this->insertID3 = $this->Db->save();
}
//.........这里部分代码省略.........
示例14: ping
echo "{\n\"address\":\"" . $ligne["address"] . "\",\n\"type\":\"" . $ligne["type"] . "\",\n\"state\":\"" . $ligne["state"] . "\",\n\"groupe\":\"" . $ligne["groupe"] . "\"\n}";
}
echo "]\n";
break;
case "ping":
if ($address != "*") {
ping($address);
exit(0);
}
Emma_connection();
$sql = mysql_query("SELECT * FROM log ORDER BY address");
$precedent = "";
while ($ligne = mysql_fetch_array($sql)) {
if ($ligne["address"] != $precedent) {
$precedent = $ligne["address"];
if (ping($ligne["address"])) {
$tmp = mysql_query("SELECT * FROM network WHERE address='" . $ligne["address"] . "'");
$tmp = mysql_fetch_array($tmp);
if ($tmp) {
mysql_query("UPDATE network SET state='Connected' WHERE id='{$tmp['address']}'");
} else {
mysql_query("INSERT INTO network (address, type, state, groupe)\n\t\t\t\t\t\t\tVALUES('" . $ligne["address"] . "','','Connected','')");
}
} else {
mysql_query("DELETE FROM network WHERE address='" . $ligne["address"] . "'");
}
}
}
break;
default:
}
示例15: ping
<?php
/* our simple php ping function */
function ping($host)
{
exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
return $rval === 0;
}
/* check if the host is up
$host can also be an ip address */
$host = '10.4.12.16';
$up = ping($host);
/* optionally display either a red or green image to signify the server status */
echo $up ? 'up' : 'down';