meannn
Elite Member
- Apr 22, 2009
- 1,908
- 2,771
This is a script that pings your url to ping sites from a file.
When you manually/auto post something to your site, add this code
and this script will automatically pings your post. This function is already on wordpress, however, this is for those who don't use Wordpress.
pingslist.txt
When you manually/auto post something to your site, add this code
and this script will automatically pings your post. This function is already on wordpress, however, this is for those who don't use Wordpress.
PHP:
<?php
//********************************************************
$blogTitle="Page title";
$blogUrl="http://www.yoursite.com/page";
$pingListFile="pinglist.txt";
$showDebugInfo=FALSE;
$replacementCount=0;
$userAgent="pingrpc.php by meannn";
//********************************************************
$fp=fopen($pingListFile,"r");
while ( ! feof( $fp) )
{
$line = trim(fgets( $fp, 4096));
// get the hostname
$host=$line; // Make a copy of $line
$host=preg_replace('/^.*http:\/\//','',$host); // Delete anything before http://
$host=preg_replace('/\/.*$/','',$host); // Delete anything after behind the hostname
// get the path
$path=$line; // Make another copy of $line
$path=preg_replace('/^.*http:\/\/[a-zA-Z0-9\-_\.]*\.[a-zA-Z]{1,3}\//','',$path,-1,$replacementCount); // Delete anything before the path
if(!$replacementCount) $path=''; // if there was no replacement (i.e. no explicit path), act appropiately
if($host) $myList[$host]=$path;
}
$xml= new DOMDocument('1.0');
$xml->formatOutput=true;
$xml->preserveWhiteSpace=false;
$xml->substituteEntities=false;
// Create the xml structure
$methodCall=$xml->appendChild($xml->createElement('methodCall'));
$methodName=$methodCall->appendChild($xml->createElement('methodName'));
$params=$methodCall->appendChild($xml->createElement('params'));
$param[1]=$params->appendChild($xml->createElement('param'));
$value[1]=$param[1]->appendChild($xml->createElement('value'));
$param[2]=$params->appendChild($xml->createElement('param'));
$value[2]=$param[2]->appendChild($xml->createElement('value'));
// Set the node values
$methodName->nodeValue="weblogUpdates.ping";
$value[1]->nodeValue=$blogTitle;
$value[2]->nodeValue=$blogUrl;
$xmlrpcReq = $xml->saveXML(); // Write the document into a string
$xmlrpcLength = strlen( $xmlrpcReq ); // Get the string length.
foreach ( $myList as $host => $path)
{
if($showDebugInfo) echo "";
echo "";
if($showDebugInfo)
{
echo "";
}
// Actually, send ping
if ( $pinghandle = @fsockopen( $host, 80 ) )
{
@fputs( $pinghandle, $httpReq );
while ( ! feof( $pinghandle ) )
{
$pingresponse = @fgets( $pinghandle, 128 );
if($showDebugInfo) echo "";
}
@fclose( $pinghandle );
}
if($showDebugInfo) echo "";
}
?>
pingslist.txt
Code:
http://pastie.org/1948534
Last edited: