[BETA] BartVB SiteMap Generator

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!
Scam Warning
User avatar
3Di
Former Team Member
Posts: 16032
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by 3Di »

Well done, now I can follow just a thread.. the one I was interested to. :geek:
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! 🚀
BartVB
Consultant
Consultant
Posts: 1288
Joined: Thu Aug 02, 2001 1:32 pm
Location: The Netherlands
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by BartVB »

I'm hoping that someone (Joshua2100 perhaps?) will adopt my changes in his mod. Again; I have no intention of forking Joshua's mod, the changes have been posted posted only to improve on his work.
I Hate oversized sigs and Love Penguins :D
User avatar
Joshua2100
Registered User
Posts: 67
Joined: Sun Nov 18, 2007 1:14 am
Location: Australia
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by Joshua2100 »

You did all the things i was to lazy/didn't know how to do.. :D

Good work
BartVB
Consultant
Consultant
Posts: 1288
Joined: Thu Aug 02, 2001 1:32 pm
Location: The Netherlands
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by BartVB »

So now all you need to do is copy/paste my code into your mod and update the admin page and language files :P
I Hate oversized sigs and Love Penguins :D
User avatar
UncleVIBES
Registered User
Posts: 64
Joined: Sat Jun 09, 2007 5:08 am
Location: France
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by UncleVIBES »

if seo mod is installed change the first lines of includes/sitemap_functions php to these lines to get only valid url clean. (from phpbb-seo.com advise)

Code: Select all

<?php 
/** 
*
* @package phpBB3
* @version $Id: sitemap_functions.php 2007-11-26 Joshua2100 $
* @copyright (c) 2007 Joshua www.commexcomputers.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

if (!defined('IN_PHPBB'))
{
	exit;
}
// www.phpBB-SEO.com SEO TOOLKIT BEGIN 
if (empty($phpbb_seo) ) { 
   require_once($phpbb_root_path . 'phpbb_seo/phpbb_seo_class.'.$phpEx); 
   $phpbb_seo = new phpbb_seo(); 
} 
// www.phpBB-SEO.com SEO TOOLKIT END
// start
function clean_for_xml($string) 
{ 
   // www.phpBB-SEO.com SEO TOOLKIT BEGIN 
   global $phpbb_seo; 
   return $phpbb_seo->format_url($string); 
   // www.phpBB-SEO.com SEO TOOLKIT END 
}
User avatar
Highway of Life
Former Team Member
Posts: 6048
Joined: Wed Feb 02, 2005 5:41 pm
Location: Seattle, WA
Name: David Lewis
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by Highway of Life »

BartVB wrote:I'm hoping that someone (Joshua2100 perhaps?) will adopt my changes in his mod. Again; I have no intention of forking Joshua's mod, the changes have been posted posted only to improve on his work.
No problem, much of the discussion turned to relation to the changes you posted, so I had to split the topic... give the word and I’ll lock the topic if you wish. :)
The phpBB Weekly Podcast - Discussing the developments of phpBB4 and beyond.

New to phpBB3? Want to learn about programing?
Visit phpBB Academy at StarTrekGuide to learn how.
User avatar
Dogs and things
Registered User
Posts: 2114
Joined: Fri Sep 01, 2006 9:04 am
Location: Spain
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by Dogs and things »

Bart took Joshua´s MOD a step further in the right direction and shortened the TODO list.

It would be nice if someone continues developing this MOD into a finished version of a perfect sitemap generator tool now that it has come this close.
For phpBB2 support visit phpBB2refugees.
fabiomaticus
Registered User
Posts: 134
Joined: Tue May 08, 2007 11:56 am
Location: Taranto - ITALY
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by fabiomaticus »

When i click "RUN NOW" in sitemap generator it appaer "Unable to open sitemap_forums.xml for writing"

Why?
fabiomaticus
Registered User
Posts: 134
Joined: Tue May 08, 2007 11:56 am
Location: Taranto - ITALY
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by fabiomaticus »

UncleVIBES wrote:if seo mod is installed change the first lines of includes/sitemap_functions php to these lines to get only valid url clean. (from phpbb-seo.com advise)

Code: Select all

<?php 
/** 
*
* @package phpBB3
* @version $Id: sitemap_functions.php 2007-11-26 Joshua2100 $
* @copyright (c) 2007 Joshua www.commexcomputers.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

if (!defined('IN_PHPBB'))
{
	exit;
}
// www.phpBB-SEO.com SEO TOOLKIT BEGIN 
if (empty($phpbb_seo) ) { 
   require_once($phpbb_root_path . 'phpbb_seo/phpbb_seo_class.'.$phpEx); 
   $phpbb_seo = new phpbb_seo(); 
} 
// www.phpBB-SEO.com SEO TOOLKIT END
// start
function clean_for_xml($string) 
{ 
   // www.phpBB-SEO.com SEO TOOLKIT BEGIN 
   global $phpbb_seo; 
   return $phpbb_seo->format_url($string); 
   // www.phpBB-SEO.com SEO TOOLKIT END 
}
I have replaced this but this is my sitemap_forums.xml http://www.500forum.it/forum/sitemaps/s ... forums.xml
User avatar
UncleVIBES
Registered User
Posts: 64
Joined: Sat Jun 09, 2007 5:08 am
Location: France
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by UncleVIBES »

check mine: http://www.mixvibes.dj/index_sitemap.htlm or forum_sitemap.html or topics_sitemaps.html produced by the sitemap mod. All of them do the job!
only the root path for seo is added & function clean_for_xml modified
this is the full file sitemap_functions.php in case of ?

Code: Select all

<?php 
/** 
*
* @package phpBB3
* @version $Id: sitemap_functions.php 2007-11-26 Joshua2100 $
* @copyright (c) 2007 Joshua http://www.commexcomputers.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

if (!defined('IN_PHPBB'))
{
	exit;
}
// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN 
if (empty($phpbb_seo) ) { 
   require_once($phpbb_root_path . 'phpbb_seo/phpbb_seo_class.'.$phpEx); 
   $phpbb_seo = new phpbb_seo(); 
} 
// http://www.phpBB-SEO.com SEO TOOLKIT END
// start
function clean_for_xml($string) 
{ 
   // http://www.phpBB-SEO.com SEO TOOLKIT BEGIN 
   global $phpbb_seo; 
   return $phpbb_seo->format_url($string); 
   // http://www.phpBB-SEO.com SEO TOOLKIT END 
}
function write_map($xmlcontent, $type, $zipped) 
{
	global $phpbb_root_path, $user;

	$xml = '<?xml version="1.0" encoding="UTF-8"?>'."\r\n";
	$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\r\n";
	$xml .= $xmlcontent;
	$xml .= '</urlset>';
	
	$xmlindex = '<?xml version="1.0" encoding="UTF-8"?>
   				<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
				.$xmlcontent.'
				</sitemapindex>';
				
	switch($type)
	{
	case 'forum':
		$filename = $phpbb_root_path . 'forum_sitemap.xml';
		$contents = $xml;
	break;
	case 'topic':
		$filename = $phpbb_root_path . 'topic_sitemap.xml';
		$contents = $xml;
	break;
	case 'index':
		$filename = $phpbb_root_path . 'sitemap_index.xml';
		$contents = $xmlindex;
	break;
	}
	if (is_writable($filename.'.gz') && ($zipped == true)) 
	{
		$zp = gzopen($filename.'.gz', "w9");
		gzwrite($zp, $contents);
		gzclose($zp);
	}
	elseif (is_writable($filename)) 
	{
		$fp = fopen($filename, "w");
		fwrite($fp, $contents);
		fclose($fp);
	}
	else
	{
		return $error = true;
	}
}

function topic_map($seomod) 
{
	global $db, $user;
	
	$t_xml = null;
	
	$sql = 'SELECT topic_id, topic_title, topic_last_post_time FROM '. TOPICS_TABLE;
	$result = $db->sql_query($sql);
	
	while ($data = $db->sql_fetchrow($result)) 
	{
		$lastpost = $user->format_date($data['topic_last_post_time'], "Y-m-d");
		$t_xml .= '<url>'."\r\n";
		
		if ($seomod == true) 
		{
			$topicname = clean_url($data['topic_title']);
			$topicname = clean_for_xml($topicname);
			$t_xml .= '<loc>'.FORUM_DOMAIN_ROOT.$topicname.'-t'.$data['topic_id'].'.html</loc>'."\r\n";
		} 
		else 
		{
			$t_xml .= '<loc>'.FORUM_DOMAIN_ROOT.'viewtopic.php?t='.$data['topic_id'].'</loc>'."\r\n";
		}
		$t_xml .= '<lastmod>'.$lastpost.'</lastmod>'."\r\n";
		$t_xml .= '<changefreq>daily</changefreq>'."\r\n";
		$t_xml .= '<priority>0.5</priority>'."\r\n";
		$t_xml .= '</url>'."\r\n";
	}		
	return $t_xml;
}

function forum_map($seomod) 
{
	global $db;
	
	$f_xml = null;
	
	$sql = 'SELECT forum_id, forum_name FROM '. FORUMS_TABLE;
	$result = $db->sql_query($sql);
	
	while ($data = $db->sql_fetchrow($result)) 
	{
		$f_xml .= '<url>'."\r\n";
		if ($seomod == true) 
		{
			$forumname = clean_url($data['forum_name']);
			$forumname = clean_for_xml($forumname);
			$f_xml .= '<loc>'.FORUM_DOMAIN_ROOT.$forumname.'-f'.$data['forum_id'].'.html</loc>'."\r\n";
		} 
		else 
		{
			$f_xml .= '<loc>'.FORUM_DOMAIN_ROOT.'viewforum.php?f='.$data['forum_id'].'</loc>'."\r\n";
		}
		
		$f_xml .= '<changefreq>daily</changefreq>'."\r\n";
		$f_xml .= '<priority>0.5</priority>'."\r\n";
		
		$f_xml .= '</url>'."\r\n";
	}
	return $f_xml;
}

function map_index() {
	$indfiles = array('topic_sitemap.xml', 'forum_sitemap.xml');
	$data = current($indfiles);
	$i_xml = '<sitemap><loc>'.FORUM_DOMAIN_ROOT.$data.'</loc></sitemap>';
	while ($data = next($indfiles)) 
	{	
	$i_xml .= '<sitemap><loc>'.FORUM_DOMAIN_ROOT.$data.'</loc></sitemap>';
	}
	return $i_xml;
}

function pinggooglesitemaps($url_xml)
// @author     J de Silva  <giddomains@gmail.com>
// @link       http://www.gidnetwork.com/b-54.html  PHP function to ping Google Sitemaps
{
	global $user;
	$status = 0;
	$google = 'www.google.com';
	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 );
	}
	if ($status != '200') 
	{
		trigger_error($user->lang['MAP_GOOGLE_PING'] . '<br />' . $status . $user->lang['PING_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING);
	}
}
?>
fabiomaticus
Registered User
Posts: 134
Joined: Tue May 08, 2007 11:56 am
Location: Taranto - ITALY
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by fabiomaticus »

This is my sitemap_fuction in includes

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id: sitemap_functions.php 2007-11-26 Joshua2100 $
* @copyright (c) 2007 Joshua http://www.commexcomputers.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

if (!defined('IN_PHPBB'))
{
   exit;
}
// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
if (empty($phpbb_seo) ) {
   require_once($phpbb_root_path . 'phpbb_seo/phpbb_seo_class.'.$phpEx);
   $phpbb_seo = new phpbb_seo();
}
// http://www.phpBB-SEO.com SEO TOOLKIT END
// start
function clean_for_xml($string)
{
   // http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
   global $phpbb_seo;
   return $phpbb_seo->format_url($string);
   // http://www.phpBB-SEO.com SEO TOOLKIT END
}
function write_map($xmlcontent, $type, $zipped)
{
   global $phpbb_root_path, $user;

   $xml = '<?xml version="1.0" encoding="UTF-8"?>'."\r\n";
   $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\r\n";
   $xml .= $xmlcontent;
   $xml .= '</urlset>';
   
   $xmlindex = '<?xml version="1.0" encoding="UTF-8"?>
               <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
            .$xmlcontent.'
            </sitemapindex>';
            
   switch($type)
   {
   case 'forum':
      $filename = $phpbb_root_path . 'forum_sitemap.xml';
      $contents = $xml;
   break;
   case 'topic':
      $filename = $phpbb_root_path . 'topic_sitemap.xml';
      $contents = $xml;
   break;
   case 'index':
      $filename = $phpbb_root_path . 'sitemap_index.xml';
      $contents = $xmlindex;
   break;
   }
   if (is_writable($filename.'.gz') && ($zipped == true))
   {
      $zp = gzopen($filename.'.gz', "w9");
      gzwrite($zp, $contents);
      gzclose($zp);
   }
   elseif (is_writable($filename))
   {
      $fp = fopen($filename, "w");
      fwrite($fp, $contents);
      fclose($fp);
   }
   else
   {
      return $error = true;
   }
}

function topic_map($seomod)
{
   global $db, $user;
   
   $t_xml = null;
   
   $sql = 'SELECT topic_id, topic_title, topic_last_post_time FROM '. TOPICS_TABLE;
   $result = $db->sql_query($sql);
   
   while ($data = $db->sql_fetchrow($result))
   {
      $lastpost = $user->format_date($data['topic_last_post_time'], "Y-m-d");
      $t_xml .= '<url>'."\r\n";
      
      if ($seomod == true)
      {
         $topicname = clean_url($data['topic_title']);
         $topicname = clean_for_xml($topicname);
         $t_xml .= '<loc>'.FORUM_DOMAIN_ROOT.$topicname.'-t'.$data['topic_id'].'.html</loc>'."\r\n";
      }
      else
      {
         $t_xml .= '<loc>'.FORUM_DOMAIN_ROOT.'viewtopic.php?t='.$data['topic_id'].'</loc>'."\r\n";
      }
      $t_xml .= '<lastmod>'.$lastpost.'</lastmod>'."\r\n";
      $t_xml .= '<changefreq>daily</changefreq>'."\r\n";
      $t_xml .= '<priority>0.5</priority>'."\r\n";
      $t_xml .= '</url>'."\r\n";
   }      
   return $t_xml;
}

function forum_map($seomod)
{
   global $db;
   
   $f_xml = null;
   
   $sql = 'SELECT forum_id, forum_name FROM '. FORUMS_TABLE;
   $result = $db->sql_query($sql);
   
   while ($data = $db->sql_fetchrow($result))
   {
      $f_xml .= '<url>'."\r\n";
      if ($seomod == true)
      {
         $forumname = clean_url($data['forum_name']);
         $forumname = clean_for_xml($forumname);
         $f_xml .= '<loc>'.FORUM_DOMAIN_ROOT.$forumname.'-f'.$data['forum_id'].'.html</loc>'."\r\n";
      }
      else
      {
         $f_xml .= '<loc>'.FORUM_DOMAIN_ROOT.'viewforum.php?f='.$data['forum_id'].'</loc>'."\r\n";
      }
      
      $f_xml .= '<changefreq>daily</changefreq>'."\r\n";
      $f_xml .= '<priority>0.5</priority>'."\r\n";
      
      $f_xml .= '</url>'."\r\n";
   }
   return $f_xml;
}

function map_index() {
   $indfiles = array('topic_sitemap.xml', 'forum_sitemap.xml');
   $data = current($indfiles);
   $i_xml = '<sitemap><loc>'.FORUM_DOMAIN_ROOT.$data.'</loc></sitemap>';
   while ($data = next($indfiles))
   {   
   $i_xml .= '<sitemap><loc>'.FORUM_DOMAIN_ROOT.$data.'</loc></sitemap>';
   }
   return $i_xml;
}

function pinggooglesitemaps($url_xml)
// @author     J de Silva  <giddomains@gmail.com>
// @link       http://www.gidnetwork.com/b-54.html  PHP function to ping Google Sitemaps
{
   global $user;
   $status = 0;
   $google = 'www.google.com';
   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 );
   }
   if ($status != '200')
   {
      trigger_error($user->lang['MAP_GOOGLE_PING'] . '<br />' . $status . $user->lang['PING_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING);
   }
}
?>
When i click RUN NOW, i have blank page!
User avatar
Joshua2100
Registered User
Posts: 67
Joined: Sun Nov 18, 2007 1:14 am
Location: Australia
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by Joshua2100 »

that code edit won't work with this mod... because the way it generates the maps is totally different.
User avatar
UncleVIBES
Registered User
Posts: 64
Joined: Sat Jun 09, 2007 5:08 am
Location: France
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by UncleVIBES »

Why is it working for me? I feel alone.
User avatar
NeoID
Registered User
Posts: 406
Joined: Mon Jun 06, 2005 10:12 pm
Location: Norway
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by NeoID »

Where are these files in the package (VB2)?

Code: Select all

Copy: root/forum_sitemap.xml 
To: forum_sitemap.xml 

Copy: root/topic_sitemap.xml 
To: topic_sitemap.xml 

Copy: root/sitemap_index.xml 
To: sitemap_index.xml 

Copy: root/forum_sitemap.xml.gz 
To: forum_sitemap.xml.gz 

Copy: root/topic_sitemap.xml.gz 
To: topic_sitemap.xml.gz 

Copy: root/sitemap_index.xml.gz 
To: sitemap_index.xml.gz 
Norsk Anime Forum
http://www.AnimeNord.com
BartVB
Consultant
Consultant
Posts: 1288
Joined: Thu Aug 02, 2001 1:32 pm
Location: The Netherlands
Contact:

Re: [BETA] BartVB SiteMap Generator

Post by BartVB »

Those files aren't included (or needed). I just haven't updated the .xml file :)
I Hate oversized sigs and Love Penguins :D
Locked

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