I know, just something to keep in mind. Great work on what has been done thus far. If I knew a lick of php I'd lend a hand, but instead I just sit back and give ideas while development is in progress by those of you who have a clue. Thanks again, btw.
Google have provided us with the ping address so at the end we need to add a ping (untested) $google_url = 'http://www.google.com/webmasters/sitemaps/ping?sitemap='; $ping_url = rawurlencode($google_url . $base. $file); $churl = @fopen($ping_url,'r'); if (!$churl) mail($technicalemail, 'Google ping failed', date('Y-m-d H:i')); Code (markup): $technicalemail is defined in config.php Sarah
Ok, got it set up and ready to test but because the file name has changed I'll wait for Google to take it manually first. I like that you've added the gzip! Sarah
Thanks for the ping part sarahk, I'll add it. Im thinking about doing a major rewrite to make it scale better.
The idea is awesome and works well but the problem is some of us have Mod Rewrite installed and the sitemaps shows our old URLS. The concept is pretty much the same as the threads instead of showthread.php?t=# are as thread#.html and same format for the posts but with showpost of course. Would it be possible to show us how to use mod rewrite URLS as well. Thanks
Hello, i added some things and i share the additions, upload did not work... added, links to archive, links to member profiles, and ping to google like above Bernhard <?php // base url of the forum with trailing slash, table prefix if any, $base = 'http://help.berberber.com/'; $prefix = ''; // home page if different than the base url for the forum $home = 'http://help.berberber.com/'; // the var string for forum display // if your url is forumdisplay.php?f=73 then this would be f= $forumq = 'f='; // the var string for your thread display // if your url is showthread.php?t=872 then is t= $threadq = 't='; // the var string for your member display // if your url is member.php?u=872 then is t= $memberq = 'u='; // url text file name make it writable!!! $file = 'sitemap.xml.gz'; // new line character \r\n for widnows \n for unix $nl = "\n"; // forum priority , tread priority, member priority, change frequency tread and forum see the sitemaps dcumentation $fpriority = "0.8"; $tpriority = '1.0'; $mpriority = '0.1'; $fchange ='daily' ; $tchange ='weekly'; $mchange ='monthly'; // base and forum base change and priority $bchange ='hourly'; $bpriority = '1.0'; // change to the path to config.php require 'includes/config.php'; // end variabless function mysql2date($dateformatstring, $mysqlstring, $use_b2configmonthsdays = 1) { global $month, $weekday, $month_abbrev, $weekday_abbrev; $m = $mysqlstring; if (empty($m)) { return false; } $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4)); if (!empty($month) && !empty($weekday) && $use_b2configmonthsdays) { $datemonth = $month[date('m', $i)]; $datemonth_abbrev = $month_abbrev[$datemonth]; $dateweekday = $weekday[date('w', $i)]; $dateweekday_abbrev = $weekday_abbrev[$dateweekday]; $dateformatstring = ' '.$dateformatstring; $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring); $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring); $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring); $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring); $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1); } $j = @date($dateformatstring, $i); if (!$j) { // for debug purposes // echo $i." ".$mysqlstring; } return $j; } $basestr = " $bchange $bpriority"; $fstr = " $fchange $fpriority"; $tstr = " $tchange $tpriority"; $connection = mysql_connect($servername, $dbusername, $dbpassword ) or die("Database is down please try again"); $db = mysql_select_db($dbname, $connection) or die ("NO DATABASE" ); //$handle = fopen("$file", "w"); $a = date('Y-m-d\TH:i:s\Z'); $handle = gzopen($file, 'w9'); gzwrite( $handle, '<?xml version="1.0" encoding="UTF-8"?>'."\n"); gzwrite( $handle, "<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd\"> <url> <loc>{$home}</loc> <lastmod>".$a."</lastmod> <changefreq>{$bchange}</changefreq> <priority>{$bpriority}</priority> </url>\n <url> <loc>{$base}</loc> <lastmod>".$a."</lastmod> <changefreq>{$bchange}</changefreq> <priority>{$bpriority}</priority> </url>\n"); $forums = $prefix."forum"; $treads = $prefix."thread"; $members = $prefix."user"; $fquery = "SELECT forumid, lastpost FROM $forums"; $results = mysql_query($fquery) or DIE("$fquery" ); $num_rows = mysql_num_rows($results); for ( $i = 0; $i < $num_rows; $i++) { $row = mysql_fetch_row($results); $url = $base."forumdisplay.php?".$forumq.$row[0]; $url2 = $base."archive/index.php/f-".$row[0].".html"; $txt = "<url> <loc>{$url}</loc> <changefreq>{$fchange}</changefreq> <priority>{$fpriority}</priority> </url>\n <url> <loc>{$url2}</loc> <changefreq>{$fchange}</changefreq> <priority>{$fpriority}</priority> </url>\n"; gzwrite($handle, $txt); } // <lastmod>".mysql2date('Y-m-d\TH:i:s\Z', $row[1], false)."</lastmod> $tquery = "SELECT threadid, lastpost FROM $treads"; $results = mysql_query($tquery) or DIE("$tquery" ); $num_rows = mysql_num_rows($results); for ( $i = 0; $i < $num_rows; $i++) { $row = mysql_fetch_row($results); // print_r($row); $url = $base."showthread.php?".$threadq.$row[0]; $url2 = $base."archive/index.php/t-".$row[0].".html"; $txt = "<url> <loc>{$url}</loc> <changefreq>{$tchange}</changefreq> <priority>{$tpriority}</priority> </url>\n <url> <loc>{$url2}</loc> <changefreq>{$tchange}</changefreq> <priority>{$tpriority}</priority> </url>\n"; gzwrite($handle, $txt); } //<lastmod>".mysql2date('Y-m-d\TH:i:s\Z', $row[1], false)."</lastmod> $tquery = "SELECT userid FROM $members"; $results = mysql_query($tquery) or DIE("$tquery" ); $num_rows = mysql_num_rows($results); for ( $i = 0; $i < $num_rows; $i++) { $row = mysql_fetch_row($results); // print_r($row); $url = $base."member.php?".$memberq.$row[0]; $txt = "<url> <loc>{$url}</loc> <changefreq>{$mchange}</changefreq> <priority>{$mpriority}</priority> </url>\n"; gzwrite($handle, $txt); } gzwrite($handle, "</urlset>\n"); gzclose($handle); $google_url = 'http://www.google.com/webmasters/sitemaps/ping?sitemap='; $ping_url = rawurlencode($google_url . $base. $file); $churl = @fopen($ping_url,'r'); if (!$churl) mail($technicalemail, 'Google ping failed', date('Y-m-d H:i')); header("Location: {$file}"); exit; ?> PHP:
Well done, berberber. Anyway to do any checks to see if you have more than 50,000 urls to make a second site map (and possibly more). This would greatly benefit those of us with large forums.
It pings google to let them know a new map is up. It does this so you don't have to manually submit the site map when changes are made to it.
Any idea why everytime I change the file to the new code you all keep posting I get the text of the file and not an XML showing when I goto the page? If I try a refresh it still shows a text of the links. If I close the window and reopen it and view the page again it works fine. Also the sitemap.xml.gz file, if I dont chmod it 666 it wont work. Can google still grab it?
I just got an email saying the ping failed... Subject: Google ping failed From: Nobody 2005-06-15 03:43
you are redirected to the created file, to not be you can remove that header("Location: {$file}"); PHP: concerning ping, i am not sure it actualyworks, i heard servers are pretty busy yes, 666 shouldnt be a problem, to see if it worked well, submit uour sitemap on googles sites, it will say you how it worked
Can you show me the links exactly? I might be able to help. Sorry I haven't replied in a while this tread wasn't comming up for me
I'm planning on it but I wont have time until next month to work on this, Does anyone know fi the tables stay the same with vb 3.5 or they change?
hey i uploaded this script and change my forum address and etc... but when i enter link i get this error Warning: main(/public_html/forum/includes/config.php): failed to open stream: No such file or directory in /home/xturkx/public_html/deneme/vbsitemap-035.php on line 28 Warning: main(/public_html/forum/includes/config.php): failed to open stream: No such file or directory in /home/xturkx/public_html/deneme/vbsitemap-035.php on line 28 Fatal error: main(): Failed opening required '/public_html/forum/includes/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xturkx/public_html/deneme/vbsitemap-035.php on line 28 what is the reason of this? also this script's address is : http://www.xturkx.com/deneme/vbsitemap-035.php
Make sure you edit this line: // change to the path to config.php require 'forums/includes/config.php'; Code (markup): No begining /