<?php
//include class
include('ping.class.php');
//Instantiation of Class
$pingdom = new PingDom;
/*function ping
parameters: it's an array or string that included host address, port and etc.
mode: it's mode of checking your destination host. included ('ping','status_check','equal','not_equal')
timeout: it's number of timeout and integer. Default: 1 , For Example: 3
$paramaters = array('host'=>'http://www.google.com','value'=>'site is alive');
$pingdom->ping($parameters,'equal',3);
*/
/*Array For Paramteres to check status of website
host: IP or Host address of destination.
port: Port of destination server. (optional)
*/
$paramaters_check_status1 = array('host'=>'http://www.google.com','port'=>'80');
if($pingdom->ping($paramaters_check_status1,'status_check')){
echo 'alive';
}else{
echo 'dead';
}
echo '<br />------------------<br />';
$paramaters_check_status2 = array('host'=>'http://www.google.com:80');
if($pingdom->ping($paramaters_check_status2,'status_check')){
echo 'alive';
}else{
echo 'dead';
}
echo '<br />------------------<br />';
/*Array For Parameters to search for value in website
host: IP or Host address of destination. for example : http://www.google.com , http://192.168.1.1 , http://www.google.com:80
value: exact value should search for in website. For example: "site is alive"
port: Port of destination server. (optional) for example: 80, 8080
*/
$paramaters_search_for_included = array('host'=>'http://www.google.com','value'=>'site is alive');
if($pingdom->ping($paramaters_search_for_included,'equal')){
echo 'alive';
}else{
echo 'dead';
}
echo '<br />------------------<br />';
/*Array For Parameters to search for value that is not included in website
host: IP or Host address of destination. for example : http://www.google.com , http://192.168.1.1 , http://www.google.com:80
value: exact value should search for in website. For example: "site is dead"
port: Port of destination server. (optional) for example: 80, 8080
*/
$paramaters_search_for_not_included = array('host'=>'http://www.google.com','value'=>'site is dead');
if($pingdom->ping($paramaters_search_for_not_included,'not_equal')){
echo 'alive';
}else{
echo 'dead';
}
echo '<br />------------------<br />';
// ****Direct use specific of class*****
$host = 'http://www.google.com';
$value = 'search';
if($pingdom->equal_check($host,$value,$timeout=1,$port=80)){
echo 'alive';
}else{
echo 'dead';
}
echo '<br />------------------<br />';
$host = 'http://www.google.com';
$value = 'Database connection error';
if($pingdom->not_equal_check($host,$value,$timeout=1,$port=80)){
echo 'alive';
}else{
echo 'dead';
}
echo '<br />------------------<br />';
$host = '192.168.1.101';
$value = 'Database connection error';
if($pingdom->check_ping($host,$timeout=1)){
echo 'alive';
}else{
echo 'dead';
}
?>
|