Posts: 3,491
Threads: 106
Joined: Mar 2010
You could try doing as Shawn suggests, remove the pings to ask (and maybe to bing). Instead of deleting those portions of code, you can comment them out:
Edit template_functions.php (function pingGoogleSitemaps), and
Insert this:
just before this
Code: if( $fp=@fsockopen($ask, 80) ) {
and also this
before this:
If you still get the error, remove bing too:
Don't remove that last */ and insert this:
just before this
Code: if( $fp=@fsockopen($bing, 80) ) {
and let's see if it works with google only.
Posts: 260
Threads: 39
Joined: Jun 2014
OK, I did this:
PHP Code: function pingGoogleSitemaps($url_xml) { $status = 0; $google = 'www.google.com'; $bing = 'www.bing.com'; $ask = 'submissions.ask.com'; if( $fp=@fsockopen($google, 80) ) { $req = 'GET /webmasters/tools/ping?sitemap=' . /* old: 'GET /webmasters/sitemaps/ping?sitemap=' . */ urlencode( $url_xml ) . " HTTP/1.1\r\n" . "Host: $google\r\n" . "User-Agent: Mozilla/5.0 (compatible; " . PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" . "Connection: Close\r\n\r\n"; fwrite( $fp, $req ); while( !feof($fp) ) { if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) ) { $status = intval( $m[1] ); break; } } fclose( $fp ); } if( $fp=@fsockopen($bing, 80) ) { $req = 'GET /webmaster/ping.aspx?sitemap=' . urlencode( $url_xml ) . " HTTP/1.1\r\n" . "Host: $bing\r\n" . "User-Agent: Mozilla/5.0 (compatible; " . PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" . "Connection: Close\r\n\r\n"; fwrite( $fp, $req ); while( !feof($fp) ) { if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) ) { $status = intval( $m[1] ); break; } } fclose( $fp ); } /* invalid since 2014: no direct pings to ask.com if( $fp=@fsockopen($ask, 80) ) { $req = 'GET /ping?sitemap=' . urlencode( $url_xml ) . " HTTP/1.1\r\n" . "Host: $ask\r\n" . "User-Agent: Mozilla/5.0 (compatible; " . PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" . "Connection: Close\r\n\r\n"; fwrite( $fp, $req ); while( !feof($fp) ) { if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) ) { $status = intval( $m[1] ); break; } } fclose( $fp ); } */ return( $status );
Google had a slightly different URL, Bing was fine (I tried them manually, they said thank you) and ask.com doesn't offer this function anymore since 2014.
And now I get a wonderful message "4 search engines pinged", which is ridiculous now, but it is green :-)
Thank you!
Posts: 6,266
Threads: 181
Joined: Sep 2011
Good to know
I also noticed that some of these do actually check the value you send them and return 400 errors if you give them bad urls, or localhosts etc.
We also constantly ping which could be rate limited, and start blocking, urls are hard coded, all reasons I removed this from core.
It must be remade as a plugin that utilizes better api calls and a cache, i am planning on making the api caller in core available to plugins for use with any api, not just extend.
Posts: 6,266
Threads: 181
Joined: Sep 2011
bing also says this
We did not receive your sitemap. Please submit it using the following format: http://www.bing.com/ping?sitemap=[your sitemap web address]
Posts: 6,266
Threads: 181
Joined: Sep 2011
Anyone feel free to clean this function up and I will fix it in 3.3.5
it doesn't even do valid response checking, or combine the statuses into a result.
Posts: 260
Threads: 39
Joined: Jun 2014
Hello,
today I updated to 3.3.5 and suddenly the old sitemap problem occured again.
The standard template_functions.php in the 3.3.5 package has a Google URL which is not working any more. This one works:
Code: /**
* Ping Sitemaps
*
* @since 1.0
*
* @param string $url_xml XML sitemap
* @return bool
*/
function pingGoogleSitemaps($url_xml) {
$status = 0;
$google = 'www.google.com';
$bing = 'www.bing.com';
$ask = 'submissions.ask.com';
if( $fp=@fsockopen($google, 80) ) {
$req = 'GET /webmasters/tools/ping?sitemap=' . /* old: 'GET /webmasters/sitemaps/ping?sitemap=' . */
urlencode( $url_xml ) . " HTTP/1.1\r\n" .
"Host: $google\r\n" .
"User-Agent: Mozilla/5.0 (compatible; " .
PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" .
"Connection: Close\r\n\r\n";
fwrite( $fp, $req );
while( !feof($fp) ) {
if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) ) {
$status = intval( $m[1] );
break;
}
}
fclose( $fp );
}
Bye
Hypertexter
Posts: 6,266
Threads: 181
Joined: Sep 2011
Posts: 260
Threads: 39
Joined: Jun 2014
No, I did not... it gave me no error, but bing.com describes another way:
Quote:Pinging Bing Using a HTTP request
If you have an automated system that generates your sitemap, you may find it easier to inform Bing about your sitemap by sending a HTTP request. Using your favorite method to send the request, use the following URL, replacing the example with your sitemap location and URL encoding everything behind the sitemap parameter:
http://www.bing.com/ping?sitemap=http%3A...itemap.xml
This is my code today: (Bing seems to be wrong)
PHP Code: * Ping Sitemaps * * @since 1.0 * * @param string $url_xml XML sitemap * @return bool */ function pingGoogleSitemaps($url_xml) { $status = 0; $google = 'www.google.com'; $bing = 'www.bing.com'; $ask = 'submissions.ask.com'; if( $fp=@fsockopen($google, 80) ) { $req = 'GET /webmasters/tools/ping?sitemap=' . /* old: 'GET /webmasters/sitemaps/ping?sitemap=' . */ urlencode( $url_xml ) . " HTTP/1.1\r\n" . "Host: $google\r\n" . "User-Agent: Mozilla/5.0 (compatible; " . PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" . "Connection: Close\r\n\r\n"; fwrite( $fp, $req ); while( !feof($fp) ) { if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) ) { $status = intval( $m[1] ); break; } } fclose( $fp ); } if( $fp=@fsockopen($bing, 80) ) { $req = 'GET /webmaster/ping.aspx?sitemap=' . urlencode( $url_xml ) . " HTTP/1.1\r\n" . "Host: $bing\r\n" . "User-Agent: Mozilla/5.0 (compatible; " . PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" . "Connection: Close\r\n\r\n"; fwrite( $fp, $req ); while( !feof($fp) ) { if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) ) { $status = intval( $m[1] ); break; } } fclose( $fp ); } /* invalid since 2014: no direct pings to ask.com if( $fp=@fsockopen($ask, 80) ) { $req = 'GET /ping?sitemap=' . urlencode( $url_xml ) . " HTTP/1.1\r\n" . "Host: $ask\r\n" . "User-Agent: Mozilla/5.0 (compatible; " . PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" . "Connection: Close\r\n\r\n"; fwrite( $fp, $req ); while( !feof($fp) ) { if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) ) { $status = intval( $m[1] ); break; } } fclose( $fp ); } */ return( $status ); }
Posts: 6,266
Threads: 181
Joined: Sep 2011
Yeah I noted above that bing was broken also.
So this code is now updated for both ?
Ill add it to 3.3.6 if its all good
I probably still need to change it to check http responses codes, and make sure they are 200 with no error
Posts: 260
Threads: 39
Joined: Jun 2014
OK, I tried this PHP code, but I cannot control it, since I cannot do this: Quote: do valid response checking, or combine the statuses into a result.
PHP Code: /** * Ping Sitemaps * * @since 1.0 * * @param string $url_xml XML sitemap * @return bool */ function pingGoogleSitemaps($url_xml) { $status = 0; $google = 'www.google.com'; $bing = 'www.bing.com'; $ask = 'submissions.ask.com'; if( $fp=@fsockopen($google, 80) ) { $req = 'GET /webmasters/tools/ping?sitemap=' . /* old: 'GET /webmasters/sitemaps/ping?sitemap=' . */ urlencode( $url_xml ) . " HTTP/1.1\r\n" . "Host: $google\r\n" . "User-Agent: Mozilla/5.0 (compatible; " . PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" . "Connection: Close\r\n\r\n"; fwrite( $fp, $req ); while( !feof($fp) ) { if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) ) { $status = intval( $m[1] ); break; } } fclose( $fp ); } if( $fp=@fsockopen($bing, 80) ) { $req = 'GET /ping?sitemap=' . /* old: 'GET /webmaster/ping.aspx?sitemap=' . */ urlencode( $url_xml ) . " HTTP/1.1\r\n" . "Host: $bing\r\n" . "User-Agent: Mozilla/5.0 (compatible; " . PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" . "Connection: Close\r\n\r\n"; fwrite( $fp, $req ); while( !feof($fp) ) { if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) ) { $status = intval( $m[1] ); break; } } fclose( $fp ); } /* invalid since 2014: no direct pings to ask.com if( $fp=@fsockopen($ask, 80) ) { $req = 'GET /ping?sitemap=' . urlencode( $url_xml ) . " HTTP/1.1\r\n" . "Host: $ask\r\n" . "User-Agent: Mozilla/5.0 (compatible; " . PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" . "Connection: Close\r\n\r\n"; fwrite( $fp, $req ); while( !feof($fp) ) { if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) ) { $status = intval( $m[1] ); break; } } fclose( $fp ); } */ return( $status ); }
|