andreassin
Mitglied
Hallo,
hat jemand eine Idee, wie ich mit PHP heraus bekomme, ob ein externer HTTP-Server läuft?
hat jemand eine Idee, wie ich mit PHP heraus bekomme, ob ein externer HTTP-Server läuft?
Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
<?php
$string = implode('',file('http://www.dieURL.de'));
if(isset($string)) {
// Ok, ist da
do_this();
} else {
// Ist nicht da
do_that();
}
?>
Wird file() nicht auch von allow_url_fopen beeinflusst?Jörg Rißmann hat gesagt.:Einfach mit [phpf]file [/phpf] überprüfen
PHP:<?php $string = implode('',file('http://www.dieURL.de')); if(isset($string)) { // Ok, ist da do_this(); } else { // Ist nicht da do_that(); } ?>
Und meines Wissens nach werden die fopen_wrappers doch von allow_url_fopen beeinflusst.PHP Manual hat gesagt.:Tip: You can use a URL as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename and Appendix M for a list of supported URL protocols.
<?php
readfile("http://www.kde.org");
?>
Warning: readfile() [function.readfile]: URL file-access is disabled in the server configuration in /usr/local/apache/htdocs/test.php on line 2
<html>
<body>
<?php
if ((isset($_POST['startping'])) && (!empty($_POST['host'])) && (!empty($_POST['port'])))
{
$host=$_POST['host'];
$port=$_POST['port'];
$starttime=microtime();
$socket=@fsockopen($host,$port);
$endtime=microtime();
if ($socket!=false)
{
fclose($socket);
list($msec,$sec)=explode(" ",$starttime);
$starttime=(float)$msec+(float)$sec;
list($msec,$sec)=explode(" ",$endtime);
$endtime=(float)$msec+(float)$sec;
$pingtime=($endtime-$starttime)*1000;
echo $host.' ('.$port.'): '.round($pingtime).' ms<br>';
}
else
{
echo 'Port '.$port.' could not be reached on '.$host.'<br>';
}
}
?>
<form method="post" action="ping.php">
Host:<input type="text" name="host" value="localhost"><br>
Port:<input type="text" name="port" value="80"><br>
<input type="submit" name="startping" value="Ping">
</form>
</body>
</html>