/dev/null 2>&1
*/
function gh($url){
$encabezados = @get_headers($url);
if (preg_match("|200|", $encabezados[0])) {
echo "ok 200
";
} elseif(preg_match("|404|", $encabezados[0])) {
echo "no existe 404";
}elseif(preg_match("|500|", $encabezados[0])) {
echo "error 500";
}
echo $encabezados[0]."
";
echo $encabezados[1]."
";
echo $encabezados[2]."
";
echo $encabezados[3]."
";
echo $encabezados[4]."
";
echo $encabezados[5]."
";
echo $encabezados[6]."
";
echo $encabezados[7]."
";
echo $encabezados[8]."
";
}
//gh("http://citaslegalizaciones.mppre.gob.ve/principal/inicio");
function telegram($text){
$token = "487061354:AAGKgHsJXbQthgLPpbNr8S2cuDaUeCocDAs";
$chat_id = "9991075";
//$text = "El sistema abrio";
$url ="https://api.telegram.org/bot".$token."/sendMessage?chat_id=".$chat_id."&text=".$text;
$ch = curl_init($url);
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Accept: application/json'),
CURLOPT_SSL_VERIFYPEER => false,
);
// Setting curl options
curl_setopt_array( $ch, $options );
// Getting results
$response = curl_exec($ch); // Getting jSON result string
// Cerrar el recurso cURL y liberar recursos del sistema
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
}
function ping($url){
$cmd = 'tcping -n 2 '. $url .' | find "open" /c';
$output = shell_exec($cmd);
return $output;
}
$domain = "contribuyente.seniat.gob.ve";
$ip = gethostbyname($domain);
echo $ip;
echo "
";
//$ip = '162.252.57.82';
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $ip);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Petición HEAD
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$content = curl_exec($ch);
if (!curl_errno($ch)) {
$info = curl_getinfo($ch);
print_r("\nSe recibió respuesta " . $info['http_code'] . ' en ' . $info['total_time'] . " segundos \n");
$file = fopen("log.txt", "r");
while(!feof($file)) { $texto = fgets($file); }
if ($texto == "bien"){
echo "Igual";
}else{
$file = fopen("log.txt", "w");
fwrite($file, "bien");
fclose($file);
telegram('Sirve la pagina '.$domain);
}
fclose($file);
} else {
print_r("\nError en petición: " . curl_error($ch) . "\n");
$file = fopen("log.txt", "r");
while(!feof($file)) { $texto = fgets($file); }
if ($texto == "error"){
echo "Igual";
}else{
$file = fopen("log.txt", "w");
fwrite($file, "error");
fclose($file);
telegram('No sirve la pagina '.$domain);
}
//fclose($file);
}
curl_close($ch);
} else {
print_r("\nDirección IP no válida: " . $ip . "\n");
}
/* */
?>