Google Sitemaps

Started by Davilac, June 05, 2005, 10:17:49 AM

Previous topic - Next topic

[Unknown]

You can add ob_start('ob_sessrewrite'); to the top of the file (after the include) if you want queryless URLs.

For more topics, yes... you cna do that.

-[Unknown]

Goosemoose

I can't get this to work since I'm using mambo and http://www.goosemoose.com/rfc/index.php redirects to the mambo component. Any tricks to get this to work anyways?

DemonicInfluence

What about the boards that guests can't see? Can you make it so that it only is the boards guests see?

coolparth

Hey..Unknown...
Where can i find sitemap.php...The link in the forums isnt working.
Can u post it here ?

desistyle

Quote from: [Unknown] on June 09, 2005, 04:31:59 AM
Untested with SMF 1.0.x.  Upload, test, and give to Google.

Shows the top 20 members, top 20 topics, all boards, and forum only.

-[Unknown]

Hi i uploaded the file on my server it shows like this

http://hamarabollywood.com/forums/sitemap.php

can u tell me why its not working fully please

JayBachatero

It looks good.  That's how its supposed to look.  Just feed the link to google sitemaps website.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

desistyle

Quote from: JayBachatero on November 26, 2005, 09:18:44 PM
It looks good.  That's how its supposed to look.  Just feed the link to google sitemaps website.

isnt it suppose to show all my topics ? like the topic headings and stuff i have 2000 posts isnt that suppose to come just askin ?

JayBachatero

It is possible but, I believe that is against googles TOS.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

desistyle

Quote from: JayBachatero on November 26, 2005, 10:43:03 PM
It is possible but, I believe that is against googles TOS.

oh ok thanks a lot for your help

JayBachatero

Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Davilac

#70
Quote from: JayBachatero on November 26, 2005, 10:43:03 PM
It is possible but, I believe that is against googles TOS.

It's not  ;D

QuoteA Sitemap file can contain no more than 50,000 URLs and be no larger than 10MB when uncompressed. If your Sitemap is larger than this, break it into several smaller Sitemaps. These limits help ensure that your web server is not overloaded by serving large files to Google.
https://www.google.com/webmasters/sitemaps/docs/en/overview.html

Davilac

Quote from: desistyle on November 26, 2005, 09:28:55 PM
Quote from: JayBachatero on November 26, 2005, 09:18:44 PM
It looks good.  That's how its supposed to look.  Just feed the link to google sitemaps website.

isnt it suppose to show all my topics ? like the topic headings and stuff i have 2000 posts isnt that suppose to come just askin ?

I've got what you want. This is working fine for my site. Actually I have this and the other one in this topic, cause you can use as many sitemaps as you want for as many pages you want. You must only modify the variable totaldetopics to fit your forum:

<?php

require_once('SSI.php');

$totaldetopics=5000;

if (
$modSettings['smfVersion'] < '1.1')
ob_start('ob_sessrewrite');

header('Content-Type: text/plain');

echo 
'<?xml version="1.0" encoding="UTF-8"?' '>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">'
;

$request db_query("
SELECT posterTime
FROM 
{$db_prefix}messages
WHERE ID_MSG >= " 
. ($modSettings['maxMsgID'] - 30) . "
ORDER BY ID_MSG DESC
LIMIT 10"
__FILE____LINE__);
$latest_post_times = array(time());
while (
$row mysql_fetch_assoc($request))
$latest_post_times[] = $row['posterTime'];
mysql_free_result($request);

$request db_query("
SELECT ID_BOARD
FROM 
{$db_prefix}boards"__FILE____LINE__);
$boards = array();
while (
$row mysql_fetch_assoc($request))
{
$request2 db_query("
SELECT posterTime
FROM 
{$db_prefix}messages
WHERE ID_BOARD = 
$row[ID_BOARD]. ($modSettings['totalMessages'] > 100000 "
AND ID_MSG >= " 
. ($modSettings['maxMsgID'] * 0.5) : '') . "
ORDER BY ID_MSG DESC
LIMIT 10"
__FILE____LINE__);
$board_post_times = array(time());
while ($row2 mysql_fetch_assoc($request2))
$board_post_times[] = $row2['posterTime'];
mysql_free_result($request2);

$boards[] = array(
'id' => $row['ID_BOARD'],
'times' => $board_post_times,
);
}
mysql_free_result($request);



$request db_query("
SELECT ID_MEMBER
FROM 
{$db_prefix}members
ORDER BY totalTimeLoggedIn DESC
LIMIT 20"
__FILE____LINE__);
$members = array();
while (
$row mysql_fetch_assoc($request))
{
$request2 db_query("
SELECT posterTime
FROM 
{$db_prefix}messages
WHERE ID_MEMBER = 
$row[ID_MEMBER]. ($modSettings['totalMessages'] > 100000 "
AND ID_MSG >= " 
. ($modSettings['maxMsgID'] * 0.5) : '') . "
ORDER BY ID_MSG DESC
LIMIT 10"
__FILE____LINE__);
$member_post_times = array(time());
while ($row2 mysql_fetch_assoc($request2))
$member_post_times[] = $row2['posterTime'];
mysql_free_result($request2);

$members[] = array(
'id' => $row['ID_MEMBER'],
'times' => $member_post_times,
);
}
mysql_free_result($request);

// First, the forum URL.  Highest priority!
echo '
<url>
<loc>'
$scripturl'</loc>
<lastmod>'
posts_max_time($latest_post_times), '</lastmod>
<changefreq>'
posts_to_freq($latest_post_times), '</changefreq>
<priority>1.0</priority>
</url>'
;

// Now the boards!
foreach ($boards as $board)
{
echo '
<url>
<loc>'
$scripturl'/board,'$board['id'], '.0.html</loc>
<lastmod>'
posts_max_time($board['times']), '</lastmod>
<changefreq>'
posts_to_freq($board['times']), '</changefreq>
<priority>'
posts_to_priority(0.8$board['times']), '</priority>
</url>'
;
}

// Popular topics too...

$indice;
for (
$indice=1$indice!=$totaldetopics$indice++)
{
echo '
<url>
<loc>'
$scripturl'/topic,'$indice'.0.html</loc>
<lastmod>'
posts_max_time($topic['times']), '</lastmod>
<changefreq>'
posts_to_freq($board['times']), '</changefreq>
<priority>'
posts_to_priority(0.7$board['times']), '</priority>
</url>'
;
}

// Most active members?
foreach ($members as $member)
{
echo '
<url>
<loc>'
$scripturl'?action=profile;u='$member['id'], '</loc>
<lastmod>'
posts_max_time($member['times']), '</lastmod>
<changefreq>'
posts_to_freq($member['times']), '</changefreq>
<priority>'
posts_to_priority(0.5$board['times']), '</priority>
</url>'
;
}

echo 
'
</urlset>'
;

function 
posts_max_time($post_times)
{
if (empty($post_times) || count($post_times) == 1)
return gmstrftime('%Y-%m-%dT%H:%M:%S+00:00'time() - 3600 24 10);

return gmstrftime('%Y-%m-%dT%H:%M:%S+00:00'max($post_times));
}

function 
posts_to_priority($base$post_times)
{
if (empty($post_times) || count($post_times) == 1)
return sprintf('%1.1f'$base);

$s = (max($post_times) - min($post_times)) / count($post_times);

if ($s 3600 24)
$mod 0.1;
else
$mod 0;

return sprintf('%1.1f'$base $mod);
}

function 
posts_to_freq($post_times)
{
if (empty($post_times) || count($post_times) == 1)
return 'yearly';

$s = (max($post_times) - min($post_times)) / count($post_times);

// Changes more often than every hour.
if ($s 3600)
return 'always';
elseif ($s 3600 12)
return 'hourly';
elseif ($s 3600 24 4)
return 'daily';
else
return 'monthly';
}

?>



desistyle

Quote from: Davilac on November 27, 2005, 03:19:12 AM
Quote from: desistyle on November 26, 2005, 09:28:55 PM
Quote from: JayBachatero on November 26, 2005, 09:18:44 PM
It looks good.  That's how its supposed to look.  Just feed the link to google sitemaps website.

isnt it suppose to show all my topics ? like the topic headings and stuff i have 2000 posts isnt that suppose to come just askin ?

I've got what you want. This is working fine for my site. Actually I have this and the other one in this topic, cause you can use as many sitemaps as you want for as many pages you want. You must only modify the variable totaldetopics to fit your forum:

<?php

require_once('SSI.php');

$totaldetopics=5000;

if (
$modSettings['smfVersion'] < '1.1')
ob_start('ob_sessrewrite');

header('Content-Type: text/plain');

echo 
'<?xml version="1.0" encoding="UTF-8"?' '>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">'
;

$request db_query("
SELECT posterTime
FROM 
{$db_prefix}messages
WHERE ID_MSG >= " 
. ($modSettings['maxMsgID'] - 30) . "
ORDER BY ID_MSG DESC
LIMIT 10"
__FILE____LINE__);
$latest_post_times = array(time());
while (
$row mysql_fetch_assoc($request))
$latest_post_times[] = $row['posterTime'];
mysql_free_result($request);

$request db_query("
SELECT ID_BOARD
FROM 
{$db_prefix}boards"__FILE____LINE__);
$boards = array();
while (
$row mysql_fetch_assoc($request))
{
$request2 db_query("
SELECT posterTime
FROM 
{$db_prefix}messages
WHERE ID_BOARD = 
$row[ID_BOARD]. ($modSettings['totalMessages'] > 100000 "
AND ID_MSG >= " 
. ($modSettings['maxMsgID'] * 0.5) : '') . "
ORDER BY ID_MSG DESC
LIMIT 10"
__FILE____LINE__);
$board_post_times = array(time());
while ($row2 mysql_fetch_assoc($request2))
$board_post_times[] = $row2['posterTime'];
mysql_free_result($request2);

$boards[] = array(
'id' => $row['ID_BOARD'],
'times' => $board_post_times,
);
}
mysql_free_result($request);



$request db_query("
SELECT ID_MEMBER
FROM 
{$db_prefix}members
ORDER BY totalTimeLoggedIn DESC
LIMIT 20"
__FILE____LINE__);
$members = array();
while (
$row mysql_fetch_assoc($request))
{
$request2 db_query("
SELECT posterTime
FROM 
{$db_prefix}messages
WHERE ID_MEMBER = 
$row[ID_MEMBER]. ($modSettings['totalMessages'] > 100000 "
AND ID_MSG >= " 
. ($modSettings['maxMsgID'] * 0.5) : '') . "
ORDER BY ID_MSG DESC
LIMIT 10"
__FILE____LINE__);
$member_post_times = array(time());
while ($row2 mysql_fetch_assoc($request2))
$member_post_times[] = $row2['posterTime'];
mysql_free_result($request2);

$members[] = array(
'id' => $row['ID_MEMBER'],
'times' => $member_post_times,
);
}
mysql_free_result($request);

// First, the forum URL.  Highest priority!
echo '
<url>
<loc>'
$scripturl'</loc>
<lastmod>'
posts_max_time($latest_post_times), '</lastmod>
<changefreq>'
posts_to_freq($latest_post_times), '</changefreq>
<priority>1.0</priority>
</url>'
;

// Now the boards!
foreach ($boards as $board)
{
echo '
<url>
<loc>'
$scripturl'/board,'$board['id'], '.0.html</loc>
<lastmod>'
posts_max_time($board['times']), '</lastmod>
<changefreq>'
posts_to_freq($board['times']), '</changefreq>
<priority>'
posts_to_priority(0.8$board['times']), '</priority>
</url>'
;
}

// Popular topics too...

$indice;
for (
$indice=1$indice!=$totaldetopics$indice++)
{
echo '
<url>
<loc>'
$scripturl'/topic,'$indice'.0.html</loc>
<lastmod>'
posts_max_time($topic['times']), '</lastmod>
<changefreq>'
posts_to_freq($board['times']), '</changefreq>
<priority>'
posts_to_priority(0.7$board['times']), '</priority>
</url>'
;
}

// Most active members?
foreach ($members as $member)
{
echo '
<url>
<loc>'
$scripturl'?action=profile;u='$member['id'], '</loc>
<lastmod>'
posts_max_time($member['times']), '</lastmod>
<changefreq>'
posts_to_freq($member['times']), '</changefreq>
<priority>'
posts_to_priority(0.5$board['times']), '</priority>
</url>'
;
}

echo 
'
</urlset>'
;

function 
posts_max_time($post_times)
{
if (empty($post_times) || count($post_times) == 1)
return gmstrftime('%Y-%m-%dT%H:%M:%S+00:00'time() - 3600 24 10);

return gmstrftime('%Y-%m-%dT%H:%M:%S+00:00'max($post_times));
}

function 
posts_to_priority($base$post_times)
{
if (empty($post_times) || count($post_times) == 1)
return sprintf('%1.1f'$base);

$s = (max($post_times) - min($post_times)) / count($post_times);

if ($s 3600 24)
$mod 0.1;
else
$mod 0;

return sprintf('%1.1f'$base $mod);
}

function 
posts_to_freq($post_times)
{
if (empty($post_times) || count($post_times) == 1)
return 'yearly';

$s = (max($post_times) - min($post_times)) / count($post_times);

// Changes more often than every hour.
if ($s 3600)
return 'always';
elseif ($s 3600 12)
return 'hourly';
elseif ($s 3600 24 4)
return 'daily';
else
return 'monthly';
}

?>




I am lost can u show me where exactly i should modify the code please

Davilac

$totaldetopics=here_the_number_of_topics_of_your_forum;

This, here_the_number_of_topics_of_your_forum, is the number of topics of yor forum. You can see the number of topics of your forum going to your forum's home

desistyle

Quote from: Davilac on November 27, 2005, 12:33:34 PM
$totaldetopics=here_the_number_of_topics_of_your_forum;

This, here_the_number_of_topics_of_your_forum, is the number of topics of yor forum. You can see the number of topics of your forum going to your forum's home


I dont see number of topics here u can see my sitemap.php file sir

<?php

require_once('SSI.php');

if (
$modSettings['smfVersion'] < '1.1')
ob_start('ob_sessrewrite');

header('Content-Type: text/plain');

echo 
'<?xml version="1.0" encoding="UTF-8"?' '>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">'
;

$request db_query("
SELECT posterTime
FROM 
{$db_prefix}messages
WHERE ID_MSG >= " 
. ($modSettings['maxMsgID'] - 30) . "
ORDER BY ID_MSG DESC
LIMIT 10"
__FILE____LINE__);
$latest_post_times = array(time());
while (
$row mysql_fetch_assoc($request))
$latest_post_times[] = $row['posterTime'];
mysql_free_result($request);

$request db_query("
SELECT ID_BOARD
FROM 
{$db_prefix}boards"__FILE____LINE__);
$boards = array();
while (
$row mysql_fetch_assoc($request))
{
$request2 db_query("
SELECT posterTime
FROM 
{$db_prefix}messages
WHERE ID_BOARD = 
$row[ID_BOARD]. ($modSettings['totalMessages'] > 100000 "
AND ID_MSG >= " 
. ($modSettings['maxMsgID'] * 0.5) : '') . "
ORDER BY ID_MSG DESC
LIMIT 10"
__FILE____LINE__);
$board_post_times = array(time());
while ($row2 mysql_fetch_assoc($request2))
$board_post_times[] = $row2['posterTime'];
mysql_free_result($request2);

$boards[] = array(
'id' => $row['ID_BOARD'],
'times' => $board_post_times,
);
}
mysql_free_result($request);

$request db_query("
SELECT ID_TOPIC
FROM 
{$db_prefix}topics
ORDER BY numViews + numReplies DESC
LIMIT 20"
__FILE____LINE__);
$topics = array();
while (
$row mysql_fetch_assoc($request))
{
$request2 db_query("
SELECT posterTime
FROM 
{$db_prefix}messages
WHERE ID_TOPIC = 
$row[ID_TOPIC]
ORDER BY ID_MSG DESC
LIMIT 10"
__FILE____LINE__);
$topic_post_times = array(time());
while ($row2 mysql_fetch_assoc($request2))
$topic_post_times[] = $row2['posterTime'];
mysql_free_result($request2);

$topics[] = array(
'id' => $row['ID_TOPIC'],
'times' => $topic_post_times,
);
}
mysql_free_result($request);

$request db_query("
SELECT ID_MEMBER
FROM 
{$db_prefix}members
ORDER BY totalTimeLoggedIn DESC
LIMIT 20"
__FILE____LINE__);
$members = array();
while (
$row mysql_fetch_assoc($request))
{
$request2 db_query("
SELECT posterTime
FROM 
{$db_prefix}messages
WHERE ID_MEMBER = 
$row[ID_MEMBER]. ($modSettings['totalMessages'] > 100000 "
AND ID_MSG >= " 
. ($modSettings['maxMsgID'] * 0.5) : '') . "
ORDER BY ID_MSG DESC
LIMIT 10"
__FILE____LINE__);
$member_post_times = array(time());
while ($row2 mysql_fetch_assoc($request2))
$member_post_times[] = $row2['posterTime'];
mysql_free_result($request2);

$members[] = array(
'id' => $row['ID_MEMBER'],
'times' => $member_post_times,
);
}
mysql_free_result($request);

// First, the forum URL.  Highest priority!
echo '
<url>
<loc>'
$scripturl'</loc>
<lastmod>'
posts_max_time($latest_post_times), '</lastmod>
<changefreq>'
posts_to_freq($latest_post_times), '</changefreq>
<priority>1.0</priority>
</url>'
;

// Now the boards!
foreach ($boards as $board)
{
echo '
<url>
<loc>'
$scripturl'?board='$board['id'], '.0</loc>
<lastmod>'
posts_max_time($board['times']), '</lastmod>
<changefreq>'
posts_to_freq($board['times']), '</changefreq>
<priority>'
posts_to_priority(0.8$board['times']), '</priority>
</url>'
;
}

// Popular topics too...
foreach ($topics as $topic)
{
echo '
<url>
<loc>'
$scripturl'?topic='$topic['id'], '.0</loc>
<lastmod>'
posts_max_time($topic['times']), '</lastmod>
<changefreq>'
posts_to_freq($topic['times']), '</changefreq>
<priority>'
posts_to_priority(0.7$board['times']), '</priority>
</url>'
;
}

// Most active members?
foreach ($members as $member)
{
echo '
<url>
<loc>'
$scripturl'?action=profile;u='$member['id'], '</loc>
<lastmod>'
posts_max_time($member['times']), '</lastmod>
<changefreq>'
posts_to_freq($member['times']), '</changefreq>
<priority>'
posts_to_priority(0.5$board['times']), '</priority>
</url>'
;
}

echo 
'
</urlset>'
;

function 
posts_max_time($post_times)
{
if (empty($post_times) || count($post_times) == 1)
return gmstrftime('%Y-%m-%dT%H:%M:%S+00:00'time() - 3600 24 10);

return gmstrftime('%Y-%m-%dT%H:%M:%S+00:00'max($post_times));
}

function 
posts_to_priority($base$post_times)
{
if (empty($post_times) || count($post_times) == 1)
return sprintf('%1.1f'$base);

$s = (max($post_times) - min($post_times)) / count($post_times);

if ($s 3600 24)
$mod 0.1;
else
$mod 0;

return sprintf('%1.1f'$base $mod);
}

function 
posts_to_freq($post_times)
{
if (empty($post_times) || count($post_times) == 1)
return 'yearly';

$s = (max($post_times) - min($post_times)) / count($post_times);

// Changes more often than every hour.
if ($s 3600)
return 'always';
elseif ($s 3600 12)
return 'hourly';
elseif ($s 3600 24 4)
return 'daily';
else
return 'monthly';
}

?>

Davilac

You are talking about the official Sitemap, and I'm giving you my own sitemap.

desistyle

Quote from: Davilac on November 27, 2005, 12:43:19 PM
You are talking about the official Sitemap, and I'm giving you my own sitemap.

Wow sir this one works superbbbbbbbbbbbbbbbbb wow too good just one more question sir can it be modified in a way so even the topic title shows ? just wondering and thanks a lot for this one it shows all my posts now :x thanks a lot

Davilac

Of course, but then it won't be a Google Sitemap, but a sitemap, which can help you with the others search engines. But I fear I can't do it for you, PHP is not my language. I'm sure someone here can give us the code to do a query this way

desistyle

Quote from: Davilac on November 27, 2005, 12:56:09 PM
Of course, but then it won't be a Google Sitemap, but a sitemap, which can help you with the others search engines. But I fear I can't do it for you, PHP is not my language. I'm sure someone here can give us the code to do a query this way

Umm thats ok but hey your code is superb it just rocks i see all my post thanks a lot

Davilac

It's nothing especial, just a while. Only note that my sitemaps is for search spider friendly URLs (without ?)

Advertisement: