FEJL: '.$pingUrl.' er ikke en url
';
}
//forbered url til fsocket løsning i tilfælde af cURL ikke er hjemme
$host = $urlDele['host']; //host
$port = (isset($urlDele['port']) ? $urlDele['port'] : 80); //port?
$sti = (isset($urlDele['path']) ? $urlDele['path'] : '/'); //sti
$sti.= (isset($urlDele['query']) ? '?' . $urlDele['query'] : ''); //querystring
//xml kald
$xmlRequest =''."\n";
$xmlRequest.=''."\n";
$xmlRequest.='weblogUpdates.ping'."\n";
$xmlRequest.=''."\n";
$xmlRequest.=''.htmlspecialchars($blogName).''."\n";
$xmlRequest.='' . htmlspecialchars($blogUrl) . ''."\n";
$xmlRequest.=''."\n";
$xmlRequest.='';
//hvis curl er installeret
if (function_exists('curl_init')) {
//curl kald
$cPing = curl_init(); //start curl
//curl options
curl_setopt($cPing,CURLOPT_URL,$pingUrl);
curl_setopt($cPing,CURLOPT_RETURNTRANSFER,1);
curl_setopt($cPing,CURLOPT_HTTPHEADER,array('Content-Type: text/xml'));
curl_setopt($cPing, CURLOPT_POST,1);
curl_setopt($cPing,CURLOPT_POSTFIELDS,$xmlRequest);
curl_setopt($cPing, CURLOPT_TIMEOUT, $timeout);
$responseContent = curl_exec($cPing); //udfør kald
$responseCode = curl_getinfo($cPing); //hent header info
$responseCode = $responseCode['http_code'];
curl_close($cPing); //luk curl
} else {
//old school fsock
if (!$fp = @fsockopen($host, $port, $errno, $errstr, $timeout)) { //hvis vi ikke kan skabe forbindelse til url
return 'FEJL: '.$pingUrl.' kunne ikke kontaktes
';
} else {
$responseCode='';
}
socket_set_timeout($fp, $timeout); //sæt timeout
//opbyg vores kald
$request = "POST $sti HTTP/1.0\r\n" .
"Host: $host\r\n" .
"Content-Type: text/xml\r\n" .
"Content-Length: " . strlen($xmlRequest) . "\r\n" .
"\r\n" .
$xmlRequest;
//send data
fputs($fp, $request);
//hent svar ud
$responseContent = '';
while (!feof($fp)) {
$responseContent .= fgets($fp, 1024);
}
fclose($fp);
}
//håndter svar
preg_match('#message\s*(\s*)?([^]*)(\s*)?#i', $responseContent, $msg);
preg_match('#flerror\s*(\s*)?([^]*)(\s*)?#i', $responseContent, $msg2);
if ($responseCode != 200 && !stristr($responseContent,'200 OK')) {
return 'FEJL: kunne ikke kontaktes
';
} else if($msg2[2]==1) {
return 'Der opstod en fejl: '.$msg[2].'
';
} else {
return ' - PING OK
';
}
}
// Array med ping urls
$pingUrls = array(
'http://blogbot.dk/io/xml-rpc.php',
'http://rpc.weblogs.com/RPC2',
'http://overskrift.dk/ping/',
'http://rpc.twingly.com/',
'http://blogsearch.google.com/ping/RPC2',
'http://rpc.technorati.com/rpc/ping',
'http://ping.feedburner.com',
'http://api.moreover.com/ping',
'http://api.my.yahoo.com/RPC2',
'http://api.my.yahoo.com/rss/ping',
'http://bblog.com/ping.php',
'http://blog.goo.ne.jp/XMLRPC',
'http://ping.bitacoras.com',
'http://ping.bloggers.jp/rpc/',
'http://ping.myblog.jp',
'http://ping.syndic8.com/xmlrpc.php',
'http://ping.weblogalot.com/rpc.php',
'http://pingoat.com/goat/RPC2',
'http://rpc.icerocket.com:10080/',
'http://rpc.pingomatic.com/',
'http://topicexchange.com/RPC2',
'http://www.bitacoles.net/ping.php',
'http://www.blogdigger.com/RPC2',
'http://www.blogpeople.net/servlet/weblogUpdates',
'http://www.blogsnow.com/ping',
'http://www.overskrift.dk/ping/',
'http://www.popdex.com/addsite.php',
'http://wasalive.com/ping/',
'http://xping.pubsub.com/ping/'
);
foreach ($pingUrls as $pingUrl) {
echo 'Pinger: '.$pingUrl;
flush();
echo blogPing($blogUrl,$blogName,$pingUrl);
}
?>