From 01e2c67a6ac404311a9aebb43e5e3142b7d5321c Mon Sep 17 00:00:00 2001 From: defaultnick01 Date: Sun, 26 Apr 2015 20:31:21 +0200 Subject: [PATCH 1/6] =?UTF-8?q?Pridan=C3=BD=20ping=20pr=C3=ADkaz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dokončiť program --- page_acces_script.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/page_acces_script.php b/page_acces_script.php index 88b9555..4339a89 100644 --- a/page_acces_script.php +++ b/page_acces_script.php @@ -14,4 +14,17 @@ // do premennej $homepage nacitaj obsah stranky $homepage = file_get_contents( $stranky[$nahodne_cislo] ); echo $homepage; +// ping funkcia +function pingAddress($ip){ + $pingresult = shell_exec("start /b ping $ip -n 1"); + $dead = "Request timed out."; + $deadoralive = strpos($dead, $pingresult); + + if ($deadoralive == false){ + echo "The IP address, $ip, is dead"; + } else { + echo "The IP address, $ip, is alive"; + } + +} ?> From 6d2827760e47357890929d8247ab1f85914bc4b6 Mon Sep 17 00:00:00 2001 From: defaultnick01 Date: Mon, 27 Apr 2015 18:31:00 +0200 Subject: [PATCH 2/6] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit prikaz ping - pridaný čoskoro --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1e0370e..7d78236 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ -# page-access-script -example +#Page-Access-Script + +Script generujúci automatické zobrazenia nastaveným stránkam -> script je spúšťaný pomocou serverového cron-a + +Hosting musí podporovať: - php + - cron + +-> podpora ping príkazu bude pridaná čoskoro From c8be129ec296c94dd6e5af7feafd0136b77fe130 Mon Sep 17 00:00:00 2001 From: defaultnick01 Date: Mon, 27 Apr 2015 21:32:20 +0200 Subject: [PATCH 3/6] Update page_acces_script.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit naprogamovaná funkcia ping -otestovať --- page_acces_script.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/page_acces_script.php b/page_acces_script.php index 4339a89..0bec40e 100644 --- a/page_acces_script.php +++ b/page_acces_script.php @@ -14,17 +14,18 @@ // do premennej $homepage nacitaj obsah stranky $homepage = file_get_contents( $stranky[$nahodne_cislo] ); echo $homepage; + // ping funkcia -function pingAddress($ip){ - $pingresult = shell_exec("start /b ping $ip -n 1"); - $dead = "Request timed out."; - $deadoralive = strpos($dead, $pingresult); +function ping($host, $port, $timeout) +{ + $tB = microtime(true); + $fP = fSockOpen($host, $port, $errno, $errstr, $timeout); + if (!$fP) { return "down"; } + $tA = microtime(true); + return round((($tA - $tB) * 1000), 0)." ms"; +} + +//Echoing it will display the ping if the host is up, if not it'll say "down". +echo ping("$stranky", 80, 10); - if ($deadoralive == false){ - echo "The IP address, $ip, is dead"; - } else { - echo "The IP address, $ip, is alive"; - } -} -?> From 40868b7270210a3e9773106e3d9248c43e521587 Mon Sep 17 00:00:00 2001 From: defaultnick01 Date: Mon, 27 Apr 2015 21:43:11 +0200 Subject: [PATCH 4/6] Update page_acces_script.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vylepšenia --- page_acces_script.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/page_acces_script.php b/page_acces_script.php index 0bec40e..22d4994 100644 --- a/page_acces_script.php +++ b/page_acces_script.php @@ -1,8 +1,9 @@ Date: Thu, 30 Apr 2015 06:15:00 +0200 Subject: [PATCH 5/6] Update page_acces_script.php --- page_acces_script.php | 1 + 1 file changed, 1 insertion(+) diff --git a/page_acces_script.php b/page_acces_script.php index 22d4994..69942e0 100644 --- a/page_acces_script.php +++ b/page_acces_script.php @@ -30,3 +30,4 @@ function ping($host, $port, $timeout) echo ping("$stranky", 80, 10); +?> From e0d11f8c45ae9a6a654b3ea04d5b42f1f263ae9c Mon Sep 17 00:00:00 2001 From: defaultnick01 Date: Thu, 30 Apr 2015 06:19:28 +0200 Subject: [PATCH 6/6] Update page_acces_script.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Malá úprava ping scriptu --- page_acces_script.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/page_acces_script.php b/page_acces_script.php index 69942e0..241117b 100644 --- a/page_acces_script.php +++ b/page_acces_script.php @@ -17,17 +17,17 @@ echo $homepage; // ping funkcia -function ping($host, $port, $timeout) -{ - $tB = microtime(true); - $fP = fSockOpen($host, $port, $errno, $errstr, $timeout); - if (!$fP) { return "down"; } - $tA = microtime(true); - return round((($tA - $tB) * 1000), 0)." ms"; +function pingAddress($ip) { + $pingresult = exec("/bin/ping -n 3 $ip", $outcome, $status); + if (0 == $status) { + $status = "alive"; + } else { + $status = "dead"; + } + echo "The IP address, $ip, is ".$status; } -//Echoing it will display the ping if the host is up, if not it'll say "down". -echo ping("$stranky", 80, 10); - +//http://stackoverflow.com/questions/8030789/pinging-an-ip-address-using-php-and-echoing-the-result +pingAddress("127.0.0.1"); ?>