Externer HTTP Server

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();
    }
?>
 
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();
    }
?>
Wird file() nicht auch von allow_url_fopen beeinflusst?
Also wenn allow_url_fopen off ist, dann duerfte file() auf per HTTP nicht klappen, meiner Meinung nach.
 
Ich hab im Manual das hier gefunden:
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.
Und meines Wissens nach werden die fopen_wrappers doch von allow_url_fopen beeinflusst.

Naja, mal testen.

Nachtrag:

Test-Code:
PHP:
<?php
readfile("http://www.kde.org");
?>

Test-Ergebnis:
Warning: readfile() [function.readfile]: URL file-access is disabled in the server configuration in /usr/local/apache/htdocs/test.php on line 2
 
Zuletzt bearbeitet:
Hier mal ein Happen Code den ich vor einer Weile geschraubt hab...

ping.php
PHP:
<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>
 
Zurück