Topic: Punmap - html sitemap with fancy urls UPDATED - final release
Hey mates. This module generates an html sitemap with fancy HTML for SEO purposes. There is no need to go beyond the basic style included as the fancy urls will be used as landing pages from the search engines. Is not likely that a user would browse the archives.
You can see a demo here:
http://shareminer.com/forum/archive
This is vey simple to install. Simply upload these two files to you punbb root directory.
EDIT: final release ready!
All the problems fixed.
I get three warnings on my validations but they simply don't make sense. I should check them up somewhere else.
The last code added its a bit spaggeti code, i was not expecting the default permitions not to be listed in the database, so i had to improvise. Still, in general i think it's simple code.
WARNING: If you are updating this script make shure you update both punmap.php and .htaccess
Smartys, feel free to list this module on punres.
punmap.php
<?php
define('PUN_QUIET_VISIT', 1);
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
$num_links = 100;
function ouptut_html_head($maintitle){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><?php echo $maintitle; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body,h1,h2,h3,h4,h5,h6 {background-color:#fff;color:black;font-family:Verdana;font-size:11px}
h1,h2,h3,h4,h5,h6 {display:inline}
h1{font-size:160%}
h2{font-size:125%}
h3{font-size:120%}
h4{font-size:115%}
h5{font-size:110%}
h6{font-size:105%}
a{text-decoration:none}
a:hover {text-decoration:underline}
a.description{color:black}
</style>
</head>
<body>
<?php
}
function clean_url($text){
$text = ereg_replace("[^A-Za-z\ ]", "", $text);
$text = str_replace (" ","-", $text );
return $text;
}
if (!empty($_GET["forum"])){
$forum_id = intval($_GET["forum"]);
$result13 = $db->query("select read_forum from ".$db->prefix."forum_perms where forum_id=$forum_id and group_id=3 and read_forum=0");
if($db->num_rows($result13)!=0){
echo "permission denied";
exit;
}
$result3 = $db->query("select forum_name from ".$db->prefix."forums where id=$forum_id");
if($db->num_rows($result3)==0){
echo "inexistent or empty forum";
}
else{
//output the html head
$forum_name_array = $db->fetch_assoc($result3);
$displaytitle = $pun_config["o_board_title"]." // ".$forum_name_array["forum_name"];
ouptut_html_head($displaytitle);
//count the posts and paginate if necessary
$result5 = $db->query("select count(*) num_posts from ".$db->prefix."topics where ".$db->prefix."forum_id=$forum_id");
$num_posts_array = $db->fetch_assoc($result5);
$num_posts = $num_posts_array["num_posts"];
if($num_posts > 0){
$paginate = true;
$num_pages = ceil($num_posts/$num_links);
$current_page = intval($_GET["page"]);
if(!isset($current_page) or $current_page < 1 or $current_page > $num_pages){
$current_page = 1;
}
$lower_limit = ($current_page - 1) * $num_links;
$query_suffix = "limit $lower_limit, $num_links";
$page_navigation = "page <br />";
for ($i = 1 ; $i <= $num_pages ; $i++){
$url_stuffing = clean_url($forum_name_array["forum_name"]);
if( $i != $current_page){
$page_navigation .=" <a href=\"".$pun_config['o_base_url']."/$url_stuffing-".$forum_id."-".$i."/\">$i</a>\n";
}
else{
$page_navigation .=" $i";
}
}
}
$result4 = $db->query("select t.id topic_id, t.subject from ".$db->prefix."topics t where t.forum_id=$forum_id order by last_post desc $query_suffix");
//output the topic list
echo "<body>";
echo "<h1>".$forum_name_array["forum_name"]."</h1>";
echo "<ul>";
while( $topic = $db->fetch_assoc($result4) ){
echo "<li>";
$url_stuffing = clean_url($topic["subject"]);
$topic["subject"]= pun_htmlspecialchars($topic["subject"]);
echo "<a href=\"".$pun_config['o_base_url']."/$url_stuffing-".$topic["topic_id"].".htm\">".$topic["subject"]."</a>";
echo "</li>\n";
}
echo "</ul>";
echo $page_navigation;
echo "</body>";
}
}
else{
//get the categories and forums and output them
$result = $db->query("SELECT id cat_id, cat_name from ".$db->prefix."categories order by disp_position");
//check wich forums are not guest readable
$result12 = $db->query("select p.forum_id id from ".$db->prefix."forum_perms p where p.group_id=3 and p.read_forum=0");
while ($row = $db->fetch_assoc($result12)){
$hidden_forums[] = $row["id"];
$hidden_forums_query_suffix = "NOT IN (".implode(", ",$hidden_forums).")";
}
$displaytitle = $pun_config["o_board_title"];
ouptut_html_head($displaytitle);
echo "<h1>".$displaytitle."</h1>\n";
echo "<ul>";
while ($category = $db->fetch_assoc($result)){
$result2 = $db->query("select id forum_id, forum_name, forum_desc from ".$db->prefix."forums f where f.cat_id=".$category["cat_id"]." and f.id $hidden_forums_query_suffix order by f.disp_position");
if ($db->num_rows($result2)>0){
echo "<li><h2>".$category["cat_name"]."</h2></li>\n";
echo "<ul>\n";
while ($forum = $db->fetch_assoc($result2)){
$url_stuffing = clean_url($forum["forum_name"]);
echo "<li><h2><a href=\"".$pun_config['o_base_url']."/".$url_stuffing."-".$forum["forum_id"]."/\">".$forum["forum_name"]."</a></h2><br /><a href=\"".$pun_config['o_base_url']."/".$url_stuffing."-".$forum["forum_id"].".html\" class=\"description\">".$forum["forum_desc"]."</a></li>\n";
}
}
echo "</ul>\n";
}
echo "</ul>\n";
}
echo "</body>";
?>
.htaccess (if you already have an .htaccess in punbb root directory you probably dont need this module at all)
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)-([0-9]*).html viewforum.php?id=$2
RewriteRule ^(.*)-([0-9]*)-([0-9]*)/ punmap.php?forum=$2&page=$3
RewriteRule ^(.*)-([0-9]*)/ punmap.php?forum=$2
RewriteRule ^(.*)-([0-9]*).htm viewtopic.php?id=$2
ReWriteRule archive punmap.php