Topic: need help with SimplePunRewrite mod ...
i am trying to convert SimplePunRewrite mod of thorze to my Megapun foum but i have some problems
since punrewrite 1.0 and PunOOGle were not working with MP then i fond this one
For Demo go here: http://supermag.wsnw.net
here
open footer.php
find
// END SUBST - <pun_include "*">
add after
// SimplyPunRW by Thorze
// It begins with pid recover all ties which require a specific message
$pattern = 'viewtopic.php?pid=<PID>'; // URL Rewriting ?
preg_match_all('#'.str_replace('\<PID\>', '([0-9]+)', preg_quote($pattern, '#')).'#', $tpl_main, $pids);
$pids = array_unique($pids[1]);
if(!empty($pids)) {
// It then recover the id of topics that correspond to different pid
$result = $db->query('SELECT id, topic_id FROM '.$db->prefix.'posts WHERE id='.implode(' OR id=', $pids)) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
message($lang_common['Bad request']);
while ($pid_id = $db->fetch_assoc($result))
{
$adresse[$pid_id['id']] = Array('topic_id' => $pid_id['topic_id']);
if (isset($query))
$query .= ' OR topic_id='.$pid_id['topic_id'];
else
$query = $pid_id['topic_id'];
}
// We recover and then we classify the pid of all posts by all concerned topics
$result = $db->query('SELECT topic_id, id FROM '.$db->prefix.'posts WHERE topic_id='.$query.' ORDER BY posted') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
while ($id_pid = $db->fetch_assoc($result))
$posts[$id_pid['topic_id']][] = $id_pid['id'];
// It looks for pid links in the pid of topics and recover on their positions to calculate their page
foreach ($posts AS $id => $pids)
{
foreach(array_keys($adresse) AS $pid) {
if(($position = array_search($pid, $pids)) !== false)
$adresse[$pid]['p'] = ceil(($position + 1) / $pun_user['disp_posts']);
}
}
// It replaces finally addresses with the addresses by pid unique and direct with the idea of specifying topic page
foreach($adresse AS $pid => $url)
$tpl_main = str_replace(str_replace('<PID>', $pid, $pattern), 'viewtopic.php?id='.$url['topic_id'].'&p='.$url['p'].'', $tpl_main);
}
// It is using this opportunity to turn all? Or p = 1 & p = 1, which also unnecessarily duplicate pages
$tpl_main = preg_replace('#(\?|&)p\=1#', NULL, $tpl_main);
// Function rewrite
function pun_url($str,$more=false) {
if((!isset($more)) || ($more == false)){
$max = 2;
}else{
$max = $more;
}
$str = strtr($str,"A?A???à?â?????O?????ô???EEEEèéêë??II??îïU?UUù?ûü???Cç'`",
"AAAAAAaaaaaaOOOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuyNnCc ");
$str = strtolower($str);
$str = preg_replace('/[^a-z0-9_\.\s]/',' ',$str);
$str = preg_replace('/[^a-z0-9_\s]\./','',trim($str));
$str = str_replace('.',' ',$str);
$str = str_replace('_',' ',$str);
$str = " ".$str." ";
$str = ereg_replace(' .{1,'.$max.'} ', ' ', $str);
$str = ereg_replace(' .{1,'.$max.'} ', ' ', $str);
$rep = array(" quel ", " crois ", " etes ", " quand ", " suis ", " aux "," moi ", " sont ", " quelle ", " quoi ", " mon ", " est ", " plus ", " que ", " vous ", " faites ", " par "," dans "," pour "," pas "," les "," des "," que "," une "," avec "," qui "," sur "," mes ");
$str = str_replace($rep," ",$str);
$str = trim($str);
$str = preg_replace('/[\s]+/','-',$str);
if(count(explode("-", $str)) >= 8){
$max++;
$str = pun_url(str_replace('-',' ',$str),$max);
}
if(!$more){
if((!isset($str)) || ($str == "")){
$str = "punseo";
}
}
return $str;
}
// Rewrite the navbar
$tpl_main = preg_replace('#<a href="index.php#', '<a href="index.html', $tpl_main);
$tpl_main = preg_replace('#<a href="userlist.php#', '<a href="userlist.html', $tpl_main);
$tpl_main = preg_replace('#<a href="search.php#', '<a href="search.html', $tpl_main);
$tpl_main = preg_replace('#<a href="register.php#', '<a href="register.html', $tpl_main);
$tpl_main = preg_replace('#<a href="login.php#', '<a href="login.html', $tpl_main);
$tpl_main = preg_replace('#<a href="login.html\?action=forget#', '<a href="forgot_password.html', $tpl_main);
$tpl_main = preg_replace('#<a href="downloads.php#', '<a href="downloads.html', $tpl_main);
$tpl_main = preg_replace('#<a href="message_list.php#', '<a href="message_list.html', $tpl_main);
// Rewrite of viewforum and we add the name of the forum in the url
$pattern = 'viewforum.php?id=<ID>';
preg_match_all('#'.str_replace('\<ID\>', '([0-9]+)', preg_quote($pattern, '#')).'#', $tpl_main, $out);
$out2 = array_unique($out[1]);
if(!empty($out2))
{
$tabunique2=array_values($out2);
$i=0;
while ($i<count($tabunique2))
{
$id7 = $tabunique2[$i];
$result = $db->query('SELECT id, forum_name FROM '.$db->prefix.'forums WHERE id='.$id7) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
while ($fnom = $db->fetch_assoc($result))
{
$tpl_main = preg_replace('#<a href="viewforum.php\?id='.$fnom['id'].'#', '<a href="f'.$id7.'-'.pun_url($fnom['forum_name']).'.html', $tpl_main);
$tpl_main = preg_replace('#<a href="f([0-9]+)-'.pun_url($fnom['forum_name']).'.html([0-9]+)#', '<a href="f\\1\\2.html', $tpl_main);
$tpl_main = preg_replace('#<a href="f'.$id7.'-'.pun_url($fnom['forum_name']).'.html&p=([0-9]+)#', '<a href="f'.$fnom['id'].'-page\\1-'.pun_url($fnom['forum_name']).'.html', $tpl_main);
}
$i++;
}
}
// Rewrite of viewtopic and adds the title of the post in the url
$pattern = 'viewtopic.php?id=<ID>';
preg_match_all('#'.str_replace('\<ID\>', '([0-9]+)', preg_quote($pattern, '#')).'#', $tpl_main, $out);
$out3 = array_unique($out[1]);
if(!empty($out3))
{
$tabunique3=array_values($out3);
$i=0;
while ($i<count($tabunique3))
{
$id7 = $tabunique3[$i];
$result = $db->query('SELECT id, subject FROM '.$db->prefix.'topics WHERE id='.$id7.'') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
while ($fnom = $db->fetch_assoc($result))
{
$tpl_main = preg_replace('#<a href="viewtopic.php\?id='.$fnom['id'].'#', '<a href="s'.$fnom['id'].'-'.pun_url($fnom['subject']).'.html', $tpl_main);
$tpl_main = preg_replace('#<a href="s([0-9]+)-'.pun_url($fnom['subject']).'.html([0-9]+)#', '<a href="s\\1\\2.html', $tpl_main);
$tpl_main = preg_replace('#<a href="s'.$fnom['id'].'-'.pun_url($fnom['subject']).'.html&p=([0-9]+)#', '<a href="s'.$fnom['id'].'-page\\1-'.pun_url($fnom['subject']).'.html', $tpl_main);
$tpl_main = preg_replace('#<a href="s'.$fnom['id'].'-'.pun_url($fnom['subject']).'.html&action=new#', '<a href="s'.$fnom['id'].'-show-new.html', $tpl_main);
}
$i++;
}
}
// Rewrite profile
$tpl_main = preg_replace('#<a href="profile.php\?id=([0-9]+)#', '<a href="profil-\\1.html', $tpl_main);
// Rewrite links research
$tpl_main = preg_replace('#<a href="search.html\?action=show_24h#', '<a href="search-24-hours.html', $tpl_main);
$tpl_main = preg_replace('#<a href="search.html\?action=show_unanswered#', '<a href="search-unanswered.html', $tpl_main);
$tpl_main = preg_replace('#<a href="search.html\?action=show_subscriptions#', '<a href="show_subscriptions.html', $tpl_main);
$tpl_main = preg_replace('#<a href="search.html\?action=show_new#', '<a href="show_new.html', $tpl_main);
$tpl_main = preg_replace('#<a href="search.html\?action=show_user&user_id=([0-9]+)#', '<a href="messages_by-\\1.html', $tpl_main);
$tpl_main = preg_replace('#<a href="search.html\?search_id=([0-9]+)#', '<a href="search\\1.html', $tpl_main);
$tpl_main = preg_replace('#<a href="search([0-9]+).html&p=([0-9]+)#', '<a href="search\\1-page\\2.html', $tpl_main);
//Divers misc.php
$tpl_main = preg_replace('#<a href="misc.php\?action=rules#', '<a href="rules.html', $tpl_main);
$tpl_main = preg_replace('#<a href="misc.php\?action=markread#', '<a href="mark_read.html', $tpl_main);
and add this to you .htaccess file
RewriteEngine on
RewriteRule ^index.html$ index.php [L]
RewriteRule ^f([0-9]+)-page([0-9]+)-(.*).html$ viewforum.php?id=$1&p=$2 [L]
RewriteRule ^f([0-9]+)(.*)$ viewforum.php?id=$1 [L]
RewriteRule ^s([0-9]+)-page([0-9]+)-(.*).html$ viewtopic.php?id=$1&p=$2 [L]
RewriteRule ^s([0-9]+)-new-messages.html$ viewtopic.php?id=$1&action=new [L]
RewriteRule ^s([0-9]+)(.*)$ viewtopic.php?id=$1 [L]
RewriteRule ^profil-([0-9]+)(.*)$ profile.php?id=$1 [L]
RewriteRule ^register.html$ register.php [L]
RewriteRule ^login.html$ login.php [L]
RewriteRule ^(.*).rss$ extern.php?action=$1&type=rss [L]
RewriteRule ^forum.html$ forum.php [L]
RewriteRule ^message_list.html$ message_list.php [L]
RewriteRule ^contact.html$ contact.php [L]
RewriteRule ^chatbox.html$ chatbox.php [L]
RewriteRule ^online.html$ online.php [L]
RewriteRule ^Links.html$ Links.php [L]
RewriteRule ^gallery.html$ gallery.php [L]
RewriteRule ^downloads.html$ downloads.php [L]
RewriteRule ^forgot_password.html$ login.php?action=forget [L]
RewriteRule ^search.html$ search.php [L]
RewriteRule ^search([0-9]+).html$ search.php?search_id=$1 [L]
RewriteRule ^search([0-9]+)-page([0-9]+).html$ search.php?search_id=$1&p=$2 [L]
RewriteRule ^userlist.html$ userlist.php [L]
RewriteRule ^search-24-hours.html$ search.php?action=show_24h [L]
RewriteRule ^([0-9]+)-my-messages.html$ search.php?action=show_user&user_id=$1 [L]
RewriteRule ^show_subscriptions.html$ search.php?action=show_subscriptions [L]
RewriteRule ^search-unanswered.html$ search.php?action=show_unanswered [L]
RewriteRule ^show_new.html$ search.php?action=show_new [L]
RewriteRule ^messages_by-([0-9]+).html$ search.php?action=show_user&user_id=$1 [L]
RewriteRule ^userlist-pseudo(.*)-group(.*)-sort(.*)-order(.*)-([0-9]+)(.*)$ userlist.php?username=$1&show_group=$2&sort_by=$3&sort_dir=$4&p=$5 [L]
RewriteRule ^rules.html$ misc.php?action=rules [L]
RewriteRule ^mark_read.html$ misc.php?action=markread [L]
and also change the links that are in the nav bars in the option area to this
1 = <a href="forum.html">Forum</a>
3 = <a href="chatbox.html">ChatBox</a>
4 = <a href="gallery.html">Gallery</a>
8 = <a href="Links.html">Links</a>
10 = <a href="contact.html">Contact Us</a>
11 = <a href="online.html">Online</a>
but still all the things are not changed to .html ...
can any one help me with this
i want to change the following
-blog posts
i mean check this to see what to change: http://supermag.wsnw.net/blogs.php
-downloads insided the directory and also directory url
also check this: http://supermag.wsnw.net/downloads.php
-rss that is around every forum
check this page: http://supermag.wsnw.net/forum.html as see all the rss links inside it
-and when i click on my avator in the main page it go to as an old url
check by clicking on avator at the right menu: http://supermag.wsnw.net
-in the online page the users profile links are still old links
check it : http://supermag.wsnw.net/online.html
-and the subforms links are still old php links
look at the subforum links: http://supermag.wsnw.net/forum.html
-arcade mod links ...
look: http://supermag.wsnw.net/arcade.php
-affiliates links also
http://supermag.wsnw.net at the left menu
-also want to change the links of topics and forums from
this:
http://supermag.wsnw.net/f37.html (some urls of forums has this bug ... look at other forum url:
http://supermag.wsnw.net/f56-general-discussions.html
to this
http://supermag.wsnw.net/forum37-web-de … pment.html
and
http://supermag.wsnw.net/s2-how-build-w … cepts.html
to this
http://supermag.wsnw.net/topic2-how-bui … cepts.html
- and if possible to redirect all the old php links to new html links
---------------------------------------------------------------------
i know its alot to ask ... but can some one help ... if you can help with any part of it then that will be appreaciated ...
Thanks