Hi everyone,
Here is a simple ping script to inform search engines that your sitemap has been updated. Save the following as scripts/ping.php
<?php
require("../includes/common.php");
$host = "www.example.com";
$sitemap = "http://".$host.$config_baseHREF."sitemap.php";
$pings = array();
$pings[] = "http://www.google.com/webmasters/sitemaps/ping?sitemap=%SITEMAP%";
$pings[] = "http://www.bing.com/ping?sitemap=%SITEMAP%";
// add any additional search engine PING URLs here
foreach($pings as $ping)
{
$ping = str_replace("%SITEMAP%",$sitemap,$ping);
file_get_contents($ping);
}
?>
To add additional search engines simply add entries to the $pings array where indicated, using the placeholder %SITEMAP% at the position within the ping URL that should contain your full sitemap URL, for example:
$pings[] = "http://www.example.com/ping_us?url=%SITEMAP%
ping.php can then be included in your CRON job. In most cases, multiple commands can be included in the same CRON job using semi-colon separation, for example, if your existing command is:
cd /home/example/public_html/scripts/;/usr/bin/php cron.php
...then to include ping.php, use:
cd /home/example/public_html/scripts/;/usr/bin/php cron.php;/usr/bin/php ping.php
Cheers!
David
--
PriceTapestry.com
Bob L.
Thanks David,
It didn't dawn on me you wrote this mod per my request until I seen technoarenasol post.
Probably because you sent the link in an email after I had done a search here for one and couldn't find any.
Works like a charm.
Great work David, and support.
Have a great weekend..
Is it possible to ping from the a browser url to the scripts folder or you have to use the cron?
Hi,
Password protection isn't included in the above example so you could browse directly to /scripts/ping.php
Cheers,
David.
--
PriceTapestry.com
Bob L.
I don't know if Bing has changed something or not.
But as of late, Bing has not showed the sitemaps has been submitted from this script.
The last submission dates are only showing where I have logged in and submitted them.
Just thought I'd give a heads up here.
Hello Bob,
Thanks for that! bing.com's ping URL has indeed changed. I have updated the above script accordingly, for your reference, line 6 was previously:
http://www.bing.com/webmaster/ping.aspx?siteMap=%SITEMAP%
...but is now just:
http://www.bing.com/ping?sitemap=%SITEMAP%
Cheers,
David.
--
PriceTapestry.com
Bob L.
Thank you, David,
Great support is always appreciated.
Hi David
Is it possible to run this directly after a full import rather than via cron.
As we import all fortnightly (via cron) I thought it could be useful if this ran automatically at the end of the import rather than setting up many more cron jobs. I'm using the import all to temp table mod.
Chris
Hi Chris,
Sure - if you could let me know what CRON command you're currently using, i'll show you how to append the call to this script to your current command - no need to set-up a new cron job...
Cheers,
David.
--
PriceTapestry.com
Hi David
The CRON command is as follows:
wget -O /dev/null http://USERNAME:PASSWORD@www.DOMAIN/scripts/cron.php?password=PASSWORD
Thanks
Chris
Hello Chris,
As you're using wget, the best thing to do will be to include ping.php at the end of your cron.php
Before you can do this, first edit scripts/ping.php and where you have this code at line 2:
require("../includes/common.php");
...REPLACE with:
require_once("../includes/common.php");
With that in place, you can edit your scripts/cron.php and at the very end of the script, on the line before the closing PHP tag add this code:
require("ping.php");
Cheers,
David.
--
PriceTapestry.com
Hello David,
When we have multiply sites how should we apply ping for the rest than the main website?
Cheers
Steve
Hi Steve,
I notice that you currently have a scripts/ping.php file that you are calling directly from scripts/ping.php by this code at line 156:
require("ping.php");
That can remain in place for the master website, but since ping.php can run standalone, what I would suggest is adding to your CRON command line calls to ping.php in your other installations, so if your current CRON command line was:
cd /home/example/public_html/scripts/;
/usr/bin/php cron.php;
Then add to the command line:
cd /home/example/public_html/site2/scripts/;
/usr/bin/php ping.php;
cd /home/example/public_html/site3/scripts/;
/usr/bin/php ping.php;
Note that all the above are on a single command line, only separated into new lines for clarity. Separate commands in a single job are separated by semi-colon...
Cheers,
David.
--
PriceTapestry.com
Thank you very much David,
Fast and accurate support.
Cheers
Steve
technoarenasol
Thank David..Very useful script...