• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ping函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ping函数的典型用法代码示例。如果您正苦于以下问题:PHP ping函数的具体用法?PHP ping怎么用?PHP ping使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ping函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:lelenaic,项目名称:Monitoring-CLF,代码行数:25,代码来源:fonctions.php


示例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
            }
        }
    }
}
开发者ID:mp84,项目名称:pool,代码行数:29,代码来源:cronjop.php


示例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);
}
开发者ID:aldridged,项目名称:gtg-gts,代码行数:30,代码来源:query_exceede.php


示例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;
 }
开发者ID:no2key,项目名称:MuuCMS,代码行数:58,代码来源:data.php


示例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");
 }
开发者ID:no2key,项目名称:MuuCMS,代码行数:58,代码来源:works.php


示例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";
    }
}
开发者ID:lflores10,项目名称:octa,代码行数:14,代码来源:chat.php


示例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();
开发者ID:psagat,项目名称:plex-server-status,代码行数:14,代码来源:ping_ajax.php


示例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.';
    }
}
开发者ID:ShakataGaNai,项目名称:Network-Status-Page,代码行数:46,代码来源:functions.php


示例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);
//.........这里部分代码省略.........
开发者ID:novozhenets,项目名称:majordomo,代码行数:101,代码来源:pinghosts.class.php


示例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;
}
开发者ID:infercom2,项目名称:rccn,代码行数:22,代码来源:ping.php


示例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";
        }
    }
}
开发者ID:Harvie,项目名称:Programs,代码行数:31,代码来源:ping.php


示例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;
        }
    }
}
开发者ID:alhousseyni,项目名称:gepi,代码行数:93,代码来源:share.inc.php


示例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();
         }
//.........这里部分代码省略.........
开发者ID:no2key,项目名称:MuuCMS,代码行数:101,代码来源:comments.php


示例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:
}
开发者ID:kincki,项目名称:contiki,代码行数:31,代码来源:proxy.php


示例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';
开发者ID:phwelo,项目名称:usercheck,代码行数:14,代码来源:pingtarget.php


示例16: header

<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: origin, x-requested-with, content-type, accept');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
require_once __DIR__ . '/classes/connexion.php';
require_once __DIR__ . '/classes/checkAPI.php';
require_once __DIR__ . '/classes/Sync.php';
$page_level = 0;
if (isset($_REQUEST['api']) && checkAPI($_REQUEST['api'], $page_level)) {
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'GET':
            if (isset($_REQUEST['ping'])) {
                echo json_encode(ping($_REQUEST['ping']));
            } else {
                echo json_encode(get());
            }
            break;
        case 'POST':
            echo add($_REQUEST);
            break;
        case 'PUT':
            update($_REQUEST);
            break;
        case 'DELETE':
            delete($_REQUEST);
            break;
    }
} else {
    http_response_code(403);
}
开发者ID:nawrasg,项目名称:Atlantis,代码行数:31,代码来源:at_ccdevices.php


示例17: 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(processTitle($host['HOSTNAME']));
         } else {
             //web host
             $online = getURL(processTitle($host['HOSTNAME']), 0);
             SaveFile("./cached/host_" . $host['ID'] . '.html', $online);
             if ($host['SEARCH_WORD'] != '' && !is_integer(strpos($online, $host['SEARCH_WORD']))) {
                 $online = 0;
             }
             if ($online) {
                 $online = 1;
             }
         }
         if ($online) {
             $new_status = 1;
         } else {
             $new_status = 2;
         }
         $old_status = $host['STATUS'];
         if ($host['COUNTER_REQUIRED']) {
             $old_status_expected = $host['STATUS_EXPECTED'];
             $host['STATUS_EXPECTED'] = $new_status;
             if ($old_status_expected != $host['STATUS_EXPECTED']) {
                 $host['COUNTER_CURRENT'] = 0;
                 $host['LOG'] = date('Y-m-d H:i:s') . ' tries counter reset (status: ' . $host['STATUS_EXPECTED'] . ')' . "\n" . $host['LOG'];
             } elseif ($host['STATUS'] != $host['STATUS_EXPECTED']) {
                 $host['COUNTER_CURRENT']++;
                 $host['LOG'] = date('Y-m-d H:i:s') . ' tries counter increased to ' . $host['COUNTER_CURRENT'] . ' (status: ' . $host['STATUS_EXPECTED'] . ')' . "\n" . $host['LOG'];
             }
             if ($host['COUNTER_CURRENT'] >= $host['COUNTER_REQUIRED']) {
                 $host['STATUS'] = $host['STATUS_EXPECTED'];
                 $host['COUNTER_CURRENT'] = 0;
             } else {
                 $interval = min($online_interval, $offline_interval, 20);
                 $online_interval = $interval;
                 $offline_interval = $interval;
             }
         } else {
             $host['STATUS'] = $new_status;
             $host['STATUS_EXPECTED'] = $host['STATUS'];
             $host['COUNTER_CURRENT'] = 0;
         }
         $host['CHECK_LATEST'] = date('Y-m-d H:i:s');
         if ($host['LINKED_OBJECT'] != '' && $host['LINKED_PROPERTY'] != '') {
             setGlobal($host['LINKED_OBJECT'] . '.' . $host['LINKED_PROPERTY'], $host['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 != $host['STATUS']) {
             if ($host['STATUS'] == 2) {
                 $host['LOG'] .= date('Y-m-d H:i:s') . ' Host is offline' . "\n";
             } elseif ($host['STATUS'] == 1) {
                 $host['LOG'] .= date('Y-m-d H:i:s') . ' Host is online' . "\n";
             }
             $tmp = explode("\n", $host['LOG']);
             $total = count($tmp);
             if ($total > 50) {
                 $tmp = array_slice($tmp, 0, 50);
                 $host['LOG'] = implode("\n", $tmp);
             }
         }
         SQLUpdate('pinghosts', $host);
         if ($old_status != $host['STATUS'] && $old_status != 0) {
             // do some status change actions
             $run_script_id = 0;
//.........这里部分代码省略.........
开发者ID:cdkisa,项目名称:majordomo,代码行数:101,代码来源:pinghosts.class.php


示例18: str_replace

$message = $data['message']['text'];
if ($userName != "") {
    if (substr($message, 0, 1) == "/") {
        if (true) {
            // For user check
            $cmd = str_replace('@' . BOT_NAME, '', $message);
            $message = strtolower($message);
            logging($cmd);
            $cmd = split(' ', $cmd);
            switch ($cmd[0]) {
                case "/ping":
                    if (intval($chatID) < 0) {
                        break;
                    }
                    if (count($cmd) == 2) {
                        ping($cmd[1]);
                    } else {
                        error(4);
                    }
                    break;
                    /*case "/ping6":
                      if(count($cmd) == 2){
                          ping6($cmd[1]); 
                      }else{
                          error(4);
                      }
                      break;*/
                /*case "/ping6":
                  if(count($cmd) == 2){
                      ping6($cmd[1]); 
                  }else{
开发者ID:HuangJi,项目名称:SITCON-TelegramBot,代码行数:31,代码来源:hook.php


示例19: ping

                ping($array);
                break;
            case 3:
                check_racer($array);
                break;
            case 4:
                clear_all($array);
                break;
            case 5:
                all_plus($array);
                break;
            case 6:
                all_red($array);
                break;
            case 7:
                all_yellow($array);
                break;
            case 8:
                all_green($array);
                break;
            default:
                echo "fuck off";
        }
    } else {
        if ($array['type'] == 2) {
            ping($array);
        } else {
            echo "error";
        }
    }
}
开发者ID:anantanurag,项目名称:Marathon-Tracker,代码行数:31,代码来源:cmd.php


示例20: die

    die($url);
}
if (isset($_GET["multiseed"])) {
    $toplant = (int) $_GET["multiseed"] + 2;
    // 2 extras just in case
    if ($_GET["multiseed"] > 4) {
        die("7:TOOHIGH");
    }
    $db = mysql_connect($dbhost, $dbuname, $dbpasswd);
    mysql_select_db($dbname, $db);
    $query = sprintf("SELECT url FROM trackers WHERE alive = 1 ORDER BY rand() LIMIT %s", quote_smart($toplant));
    // 2 more just in case
    $result = mysql_query($query);
    $urls = array();
    while ($row = mysql_fetch_row($result)) {
        if (ping($row[0])) {
            $urls[] = $row[0];
        }
        if (count($urls) == (int) $_GET["multiseed"]) {
            break;
        }
    }
    mysql_close($db);
    if (count($urls) != (int) $_GET["multiseed"]) {
        die("5:FALSE");
    }
    // or else
    $bdata = "l";
    foreach ($urls as $one) {
        $bdata .= strlen($one) . ":" . $one;
    }
                      

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP pingBlogs函数代码示例发布时间:2022-05-15
下一篇:
PHP piklist函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap