[ABD] Google sitemap mod

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Locked
jhaskins
Registered User
Posts: 32
Joined: Wed Apr 17, 2002 10:20 pm
Contact:

[ABD] Google sitemap mod

Post by jhaskins » Sun Jun 05, 2005 7:27 pm

This is a simple little mod to generate a listing of your forum's topics in Google's sitemap xml format (anyone not familiar with this should see http://www.google.com/webmasters/sitema ... n/faq.html).

Note: this just generates the sitemap, it doesn't submit it. That must be done manually.

download here

Suggestions/comments/constructive criticism always welcomed.

mighty b
Registered User
Posts: 34
Joined: Mon Mar 15, 2004 8:32 pm

Post by mighty b » Mon Jun 06, 2005 12:35 am

this is just what i have been looking for. Thanks!

Il give it a try and post my results

Uchiha Nick
Registered User
Posts: 424
Joined: Wed Jul 14, 2004 12:13 pm
Contact:

Post by Uchiha Nick » Mon Jun 06, 2005 12:43 am

could you give us a explanation of how it works? ive read it on google, dont really understand it tho oO

Jugulator
Registered User
Posts: 52
Joined: Fri Jul 30, 2004 3:58 pm
Location: [RO]-Constanta
Contact:

Post by Jugulator » Mon Jun 06, 2005 11:33 am

In http://patch/forum/sitemap.php appear only

Code: Select all

<urlset>
-
	<url>
<loc>http://patch/forum</loc>
<lastmod/>
<changefreq>always</changefreq>
</url>
</urlset>
It is not display any link!
In pending

jozomannen
Registered User
Posts: 172
Joined: Sun Jul 25, 2004 9:17 pm

Post by jozomannen » Mon Jun 06, 2005 3:03 pm

It's not working for me either, same as yours Jugulator.
Image
Questions regarding this? PM me!

User avatar
ewelin
Registered User
Posts: 262
Joined: Fri May 21, 2004 2:13 pm
Location: MA, USA
Contact:

Post by ewelin » Mon Jun 06, 2005 7:47 pm


jhaskins
Registered User
Posts: 32
Joined: Wed Apr 17, 2002 10:20 pm
Contact:

Post by jhaskins » Mon Jun 06, 2005 10:47 pm

Sorry I wasn't able to get to this sooner. After checking over the files, I realized that part of the problem was that I included the wrong template file. :( I've updated the file on my site with the right one.

Before you use this, you will have to open "sitemap.php" and set $forumids to the forums you want included. I've also fixed one minor issue that turned up & updated the instructions to include a list of the variables that control various config options & what each one is for.

Finally, I've addded a couple new features:
*Set priority for announcements & sticky topics (each can be set seprately)
*Locked topics have <changefreq> set to never (who's gonna reply if it's locked?)

download link

demo

tomythius
Registered User
Posts: 74
Joined: Sat May 28, 2005 3:05 pm
Location: Queniborough - Leicester - UK
Contact:

Post by tomythius » Mon Jun 06, 2005 11:21 pm

I love this mod!
And there I was messing around in the shell with python...
Godsend, well done!
All I'd like to see (and these are suggestions, not demands!) would be a gzip option, and the option to sort by most recent. I tried changing the SQL to do the latter, but got in a tangle :?.
Good luck with this.

PS How would I set this as a cron job? I've never needed one before...
Tom says so, QED.

khisanthax
Registered User
Posts: 443
Joined: Sun Mar 02, 2003 1:49 am

Post by khisanthax » Mon Jun 06, 2005 11:53 pm

can I run this script using a cron job??

User avatar
MHobbit
Former Team Member
Posts: 4761
Joined: Thu Mar 18, 2004 5:32 pm
Location: There and Back Again

Post by MHobbit » Mon Jun 06, 2005 11:56 pm

khisanthax wrote: can I run this script using a cron job??


Why would you want to? It doesn't automatically submit your sitemap to Google. Also, it doesn't create static XML files AFAIK.
Former phpBB MOD Team member
No private support is offered.
"There’s too many things to get done, and I’m running out of days..."

tomythius
Registered User
Posts: 74
Joined: Sat May 28, 2005 3:05 pm
Location: Queniborough - Leicester - UK
Contact:

Post by tomythius » Tue Jun 07, 2005 12:01 am

MennoniteHobbit wrote: Why would you want to? It doesn't automatically submit your sitemap to Google. Also, it doesn't create static XML files AFAIK.

Thanks MennoniteHobbit, was having a moment...
I think google auto-retrieves it regularly once submitted as well, doesn't it?
Tom says so, QED.

jhaskins
Registered User
Posts: 32
Joined: Wed Apr 17, 2002 10:20 pm
Contact:

Post by jhaskins » Tue Jun 07, 2005 12:30 am

Regarding compression: I've added compression to the sitemap for my forums using ob_gzhandler & I'm waiting for google to reindex it to see if they send the header needed to trigger it.

Regarding auto submission/cron jobs: If you want to resubmit your sitemap on a regular basis or don't wan't to manually submit it for some reason, you can use the script below:

Code: Select all

<?php
//based heavily on the fsockopen() example from php.net
$sitemap="http://www.yoursite.com/forums/sitemap.php";
$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
if (!$fp) {
   echo "$errstr ($errno)<br />\n";
} else {
   $out = "GET /webmasters/sitemaps/ping?sitemap=".urlencode($sitemap)." HTTP/1.1\r\n";
   $out .= "Host: www.google.com\r\n";
   $out .= "Connection: Close\r\n\r\n";

   fwrite($fp, $out);
   while (!feof($fp)) {
       $response .= fgets($fp, 128);
   }
   fclose($fp);
   if(preg_match("/200\sOK/", $response))
   		{
		print "Sitemap submitted sucessfully.";
		}
	else
		{
		print "Problem submitting sitemap: \n $response";
		}
}
?> 
Note that you should set $sitemap to the full url to your sitemap.php file.

Regarding sort by most recent: This could get ugly :). The way I coded this, it gets the topics in groups to keep large boards from causing load problems. Unfortunatly, I didn't give much thought to sorting when I came up with this :oops:. I'll see what I can come up with & post back when I have something.

ridinhighspeeds
Registered User
Posts: 105
Joined: Tue Jan 25, 2005 1:53 am
Location: MA
Contact:

Post by ridinhighspeeds » Tue Jun 07, 2005 3:36 am

Great work with this mod!!

Heres a demo from my site.

tomythius
Registered User
Posts: 74
Joined: Sat May 28, 2005 3:05 pm
Location: Queniborough - Leicester - UK
Contact:

Post by tomythius » Tue Jun 07, 2005 10:43 am

Mine now sits in the folder above my phpbb root, in the real root of my whole site.
A few hardcoded lines in the template means that my static pages are included in the same map.
DEMO
Tom says so, QED.

ridinhighspeeds
Registered User
Posts: 105
Joined: Tue Jan 25, 2005 1:53 am
Location: MA
Contact:

Post by ridinhighspeeds » Tue Jun 07, 2005 10:56 am

Only one problem with mine...Google rejected it because of the dates. Heres an example of mine with the date. Anyway to fix this??

<url>
<loc>http://defendingthetruth.com/viewtopic.php?t=3</loc>
<lastmod>2005-05-06T02:25:10-07:00</lastmod>
<changefreq>always</changefreq>
<priority>0.5</priority>
</url>

I think Google wants it like this

Example: 2005-05-06T02:25:10+08:00

http://www.google.com/schemas/sitemap/0.84/sitemap.xsd

Locked

Return to “[2.0.x] MODs in Development”