wcf.regNote.message
|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 |
$feed_url="http://tunertreff.de/news/newsupload/news.xml";
ini_set('default_socket_timeout',25); //15 Sekunden Timeout
if ($fp = @fsockopen($feed_url,80))
{
fwrite($fp,'HEAD '.$feed_url.' HTTP/1.1'."\r\n".'Host: '.$feed_url."\r\n\r\n"); //Header ohne Content anfordern
$http_status = fgets($fp);
fclose($fp);
}
if (strstr($http_status,'200'))
{ echo "TRUE"; } else { echo "FALSE"; }
|
|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php
function urlfind($link){
if($link) {
$file = @fopen ($link, "r");
}
if($file){
return true;
fclose($file);
}
else {
return false;
}
}
$link = "http://www.php.net";
if(urlfind($link)){
echo $link." existiert und ist erreichbar";
}
else {
echo $link." existiert nicht oder ist nicht erreichbar";
}
?>
|
|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
<?
// cache a (http) fopen - with cache-timeout.
function cached_fopen($file, $file_mode, $timeout_seconds = 600, $cache_path = "/tmp"){
$debug=false;
clearstatcache();
$cache_filename=$cache_path . "/" . urlencode($file) .".cached";
if ($debug) { print "local_cache creation_time =" . @filemtime($cache_filename) . " actual time = " . time() . " timeout = " . $timeout_seconds ."<p>";}
if ( ( @file_exists($cache_filename ) and ( ( @filemtime($cache_filename) + $timeout_seconds) > ( time() ) ) ) ){
// ok, file is already cached and young enouth
if ($debug) { print "using cached file ($cache_filename) <p>";}
}
else
{
if ($debug) { print "cacheing file ($file) to local ($cache_filename)<p>";}
// cache file from net to local
$f = fopen($file,"r");
$f2 = fopen($cache_filename,"w+");
while ($r=fread($f,8192) ) {
fwrite($f2,$r);
}
fclose($f2);
fclose($f);
}
// ok, point to (fresh) cached file
$handle = fopen($cache_filename, $file_mode);
return $handle;
}
?>
usage:
<?
$handle = cached_fopen("http://example.com/show?xy","r",600)
?>
|
|
|
PHP Source code |
1 |
fwrite($fp,'HEAD '.$feed_url.' HTTP/1.1'."\r\n".'Host: '.$feed_url."\r\n\r\n"); //Header ohne Content anfordern
|
|
|
PHP Source code |
1 |
fwrite($fp,"GET $feed_url\r\n\r\n"); //Header ohne Content anfordern
|




|
|
PHP Source code |
1 2 |
$url = "http://www.irgendneseite.de/mit/pfad/wie/du/willst.html";
$request = "GET $url HTTP/1.0 \r\n\r\n";
|



.|
|
Source code |
1 2 |
HEAD /der/Pfad/was/du/willst/ HTTP/1.1 Host: www.deinhost.de |

This post has been edited 1 times, last edit by "Ephraim" (Jun 29th 2004, 2:35pm)
|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$feed_path="/news/newsupload/news.xml";
$feed_host = "tunertreff.de";
ini_set('default_socket_timeout',25); //15 Sekunden Timeout
if ($fp = @fsockopen($feed_url,80))
{
fwrite($fp,"GET $feed_path HTTP/1.1\r\nHost: $feed_host\r\n\r\n");
$http_status = fgets($fp);
fclose($fp);
}
if (strstr($http_status,'200'))
{ echo "TRUE"; } else { echo "FALSE"; }
|

|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$feed_url="http://tunertreff.de/news/newsupload/news.xml";
$feed_url_path="/news/newsupload/news.xml";
$feed_url_host="http://tunertreff.de";
ini_set('default_socket_timeout',25); //15 Sekunden Timeout
if ($fp = @fsockopen($feed_url,80))
{
fwrite($fp,'HEAD '.$feed_url_path.' HTTP/1.1'."\r\n".'Host: '.$feed_url_host.' '."\r\n\r\n"); //Header ohne Content anfordern
$http_status = fgets($fp);
fclose($fp);
}
if (strstr($http_status,'200')) { echo "TRUE"; } else { echo "FALSE"; }
|
|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php
function checkurl($url,$timeout) {
$url_host=explode(str_replace("http://","",$url),"/");
$url_host=$url_host[0];
$url_path=str_replace($url_host,"",(str_replace("http://","",$url));
if(!$timeout) $timeout=15;
ini_set('default_socket_timeout',$timeout); //15 Sekunden Timeout
if ($fp = @fsockopen($url_host,80)) {
fwrite($fp,"HEAD $url_path HTTP/1.1\r\nHost: $url_host\r\n\r\n"); //Header ohne Content anfordern
$http_status = fgets($fp);
fclose($fp);
}
return (strstr($http_status,'200'));
}
?>
|
|
|
PHP Source code |
1 |
include("checkurl.inc");
|
|
|
PHP Source code |
1 2 3 4 5 |
if(checkurl("http://www.coder-board.info/index.php",20)) {
echo "Coder-Board läuft";
} else {
echo "Coder-Board is down";
}
|

|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
<?
/**********************************************************************/
// CheckUrl
/**********************************************************************/
//
// IN:
// $url Beliebiege Url
// $timeout Timeout in Sekunden nach dem der Verbindungsversuch
// aufgegeben werden soll.
// $debug wenn 1 dann gibt die funktion ein paar debug meldungen aus.
//
// created: Ephraim@coder-board.info 29.06.04
// idee: webmaster@coder-board.info
/**********************************************************************/
function CheckUrl($url, $timeout=25, $debug=0) {
$arrurl = Array();
$http_status = "";
if($url == "") return false;
// zerlegung der url in die bestandteile protokoll, host, pfad
preg_match("/([hH][tT]{2}[pP][sS]{0,1}:\/\/){0,1}([^\/]*)(\/{0,1}.*)$/", $url, $arrurl);
if($debug) { print_r($arrurl); }
ini_set('default_socket_timeout', $timeout);
// socket verbindung aufbauen
if ($fp = @fsockopen($arrurl['2'],80))
{
// wenn kein Pfad gegeben nehmen wir einen einfachen /
$arrurl['3'] = ($arrurl['3'] == "" ? "/" : $arrurl['3']);
// HTTP request absetzen
fwrite($fp,"HEAD ".$arrurl['3']." HTTP/1.1\r\nHost: ".$arrurl['2']."\r\n\r\n"); //Header ohne Content anfordern
// erste zeile von return holen
$http_status = fgets($fp);
// socket verbindung schliessen
fclose($fp);
}
if($debug) { echo "\nHttp Status: $http_status\n"; }
// kommt ein HTTP/1.1 200 OK zurück wurde die seite gefunden
return strstr($http_status, "200");
}
if(isset($_REQUEST['url'])) {
// Url check
echo "<html><head><title>CheckUrl: ".$_REQUEST['url']."</title></head><body><center>CheckUrl: ".$_REQUEST['url']."</center><pre>";
echo (CheckUrl($_REQUEST[url], 25, 1) ? "TRUE" : "FALSE");
echo "</pre><body></html>";
}
else {
// form für die eingabe
?>
<html>
<head><title>Which Url yoou wanna check?</title></head>
<body>
<center><form method="post" action="checkurl.php"><input name="url" /><br /><input type="submit" value="Check" /></form></center>
</body>
</html>
<? } ?>
|

... sowas könnten wir eig. in die datenbank packen dann haben wir auch mal was da was man downloaden kann.