Skip to content

Commit

Permalink
fixes #939 remove site pinging from core
Browse files Browse the repository at this point in the history
  • Loading branch information
tablatronix committed Oct 14, 2014
1 parent 82315d8 commit 055b11c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 113 deletions.
114 changes: 4 additions & 110 deletions admin/inc/template_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,97 +505,6 @@ function makeIso8601TimeStamp($dateTime) {
return $isoTS;
}

/**
* Ping Sitemaps
*
* @since 3.4
*
* @param string $url_xml XML sitemap
* @return bool
*/
function pingSitemaps($url_xml) {
$status = 0;
$google = 'www.google.com';
$bing = 'www.bing.com';
$ask = 'submissions.ask.com';

// google
if( $fp=@fsockopen($google, 80) ) {

$req = '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 );
}

// bing
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 );
}

// 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 );
}

/**
* LEGACY alias pingSitemaps
* @since 3.0
*/
function pingGoogleSitemaps($url_xml){
return pingSitemaps($url_xml);
}

/**
* File Size
*
Expand Down Expand Up @@ -1420,7 +1329,7 @@ function generate_sitemap() {
getPagesXmlValues(false);
$pagesSorted = subval_sort($pagesArray,'menuStatus');

if (count($pagesSorted) != 0)
if (count($pagesSorted) > 0)
{
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
$xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
Expand Down Expand Up @@ -1462,27 +1371,12 @@ function generate_sitemap() {
$file = GSROOTPATH .GSSITEMAPFILE;
$xml = exec_filter('sitemap',$xml);

XMLsave($xml, $file);
$status = XMLsave($xml, $file);
exec_action('sitemap-aftersave');
}

if (!getDef('GSDONOTPING',true)) {
if (file_exists(GSROOTPATH .GSSITEMAPFILE)){
if( 200 === ($status=pingGoogleSitemaps($SITEURL.GSSITEMAPFILE))) {
#sitemap successfully created & pinged
return true;
} else {
error_log(i18n_r('SITEMAP_ERRORPING'));
return i18n_r('SITEMAP_ERRORPING');
}
} else {
error_log(i18n_r('SITEMAP_ERROR'));
return i18n_r('SITEMAP_ERROR');
}
} else {
#sitemap successfully created - did not ping
return true;
return $status;
}
else return true;
}


Expand Down
3 changes: 0 additions & 3 deletions temp.gsconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
# Turn on debug mode
#define('GSDEBUG', TRUE);

# Ping search engines upon sitemap generation?
define('GSDONOTPING', 1);

# Turn off CSRF protection. Uncomment this if you keep receiving the error message "CSRF error detected..."
#define('GSNOCSRF', TRUE);

Expand Down

0 comments on commit 055b11c

Please sign in to comment.