1 (edited by SuperMAG 2008-03-01 14:47)

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

MyFootballCafe.com  is Now Online!

Re: need help with SimplePunRewrite mod ...

what

MyFootballCafe.com  is Now Online!

3

Re: need help with SimplePunRewrite mod ...

Then it wouldn't be anymore SimpleRewrite... smile

What u have to do is to adapt url_rewriting in 1.3 for 1.2 branch.
Which means changing ALL the links (call a function for rewrite them) and code a complete .htaccess

This takes a long time (and modifies all the php files).

Re: need help with SimplePunRewrite mod ...

Mpok wrote:

Then it wouldn't be anymore SimpleRewrite... smile

What u have to do is to adapt url_rewriting in 1.3 for 1.2 branch.
Which means changing ALL the links (call a function for rewrite them) and code a complete .htaccess

This takes a long time (and modifies all the php files).

i know about the 1.3 type to url rewrite ... but my url rewrite is more simpiler and edit only footer.php and .htaccess and the code is also simple ... look at it if u are a coder .. i am not thats why i dont know how to code it if even it is simple ..

thanks

MyFootballCafe.com  is Now Online!

Re: need help with SimplePunRewrite mod ...

any one

MyFootballCafe.com  is Now Online!

Re: need help with SimplePunRewrite mod ...

ok i chagnged my mind ... lets do it step by step ...

first step .... i want to correct things in the main page i . e www.sportstv.co.cc

here is main page problems ...

1- the title of the evey news is still lead to the old link ... i mean
http://img209.imageshack.us/img209/1608/bug1le5.jpg

i know where the problem is but dont know how to solve it ....
in index.php find this:

            <td style="border: 0px; padding: 0px 10px 7px 7px;"><span class="news-icon"><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><?php echo $cur_post['subject']; ?></a></span></td>

so what i change in that code ...

MyFootballCafe.com  is Now Online!

7

Re: need help with SimplePunRewrite mod ...

I second this, I need to figure out how to get that news link on the frontpage to rewrite, and get the profile correctly rewritten.

Re: need help with SimplePunRewrite mod ...

xsdmx wrote:

I second this, I need to figure out how to get that news link on the frontpage to rewrite, and get the profile correctly rewritten.

i already found out that ... just need to change the code in the above post to make it post the SEF url

MyFootballCafe.com  is Now Online!

Re: need help with SimplePunRewrite mod ...

i fixed a few problems after 3 hrs of working on it ... but there are fiew major things that i cant understand ....

1- the redriects in viewtopic.php

+ these are two codes which needs to be changed ...

redirect(PUN_ROOT.'viewtopic.php?id='.$id, $lang_topic_rating['Topic rating increased']);
redirect(PUN_ROOT.'viewtopic.php?id='.$id, $lang_topic_rating['Topic rating decreased']);

what should i change these two codes so that it redirects to the sef url topic

+ when some one post a topic or post or delete a post or edit a post it redirects to the old urls ... how can i change that .. if any thing is required like edit.php file or delete.php file or post.php file then tell me i am ready ...

2- the most hardist bugs ... in forum.php .. the subforums urls are old urls while others are changed .. how can i change that ....

PLEASE SOME ONE HELP .... THANKS IN ADVANCE

MyFootballCafe.com  is Now Online!

10

Re: need help with SimplePunRewrite mod ...

SuperMag, how did you get "Re: hea guys .... sorry about..." working with Megapun? on the forums.php?

Also, cansomeone help us out with the index page?

11 (edited by SuperMAG 2008-03-25 23:04)

Re: need help with SimplePunRewrite mod ...

xsdmx wrote:

SuperMag, how did you get "Re: hea guys .... sorry about..." working with Megapun? on the forums.php?

oh you mean Last post's subject on forum index: http://wiki.punres.org/Last_post%27s_su … orum_index

and guys can some one help me with this pllease:

SuperMAG wrote:

i fixed a few problems after 3 hrs of working on it ... but there are fiew major things that i cant understand ....

1- the redriects in viewtopic.php

+ these are two codes which needs to be changed ...

redirect(PUN_ROOT.'viewtopic.php?id='.$id, $lang_topic_rating['Topic rating increased']);
redirect(PUN_ROOT.'viewtopic.php?id='.$id, $lang_topic_rating['Topic rating decreased']);

what should i change these two codes so that it redirects to the sef url topic

+ when some one post a topic or post or delete a post or edit a post it redirects to the old urls ... how can i change that .. if any thing is required like edit.php file or delete.php file or post.php file then tell me i am ready ...

2- the most hardist bugs ... in forum.php .. the subforums urls are old urls while others are changed .. how can i change that ....

PLEASE SOME ONE HELP .... THANKS IN ADVANCE

MyFootballCafe.com  is Now Online!

12

Re: need help with SimplePunRewrite mod ...

http://wiki.punres.org/Last_post%27s_su … orum_index

For some reason that won't work on Megapun.

Re: need help with SimplePunRewrite mod ...

what is ur site and the latest version of megapun (megapun 5) has it ... updated your forum

MyFootballCafe.com  is Now Online!

14

Re: need help with SimplePunRewrite mod ...

http://reviewstash.com

Ah, I see, I can't really update since I've changed so much and stripped so much code out. I'll poke around the code though.

15

Re: need help with SimplePunRewrite mod ...

<mode "non-constructive, but tho.." on> wink
If u want to have a full rewrite mod, just take it from PunBB 1.3, and put it on 1.2 branch.
It DOES work perfectly, as the implementation of url_rewriting is pretty good in 1.3 (thx devs, maybe just a little lack of localization's possibility in sef_friendly() function..).
It's a far better way (IMO) that trying to deal with old mods (which were good as the time they have been published, but now out of date).
</mode>

Re: need help with SimplePunRewrite mod ...

Mpok wrote:

<mode "non-constructive, but tho.." on> wink
If u want to have a full rewrite mod, just take it from PunBB 1.3, and put it on 1.2 branch.
It DOES work perfectly, as the implementation of url_rewriting is pretty good in 1.3 (thx devs, maybe just a little lack of localization's possibility in sef_friendly() function..).
It's a far better way (IMO) that trying to deal with old mods (which were good as the time they have been published, but now out of date).
</mode>

well the 1.3 is still in construction and it will be impossible to convert my old forum to 1.3 and there are no extensions of 1.3 right now ... at lease some one make a subforum extension ....


but cammon how much time it will take ... 10 15 min for a person who knows php ....

so can some one help me before i get mad and tell every one how bad punbb community is ... oohhhh ... i asking this 100 times ..

MyFootballCafe.com  is Now Online!

17 (edited by Mpok 2008-03-26 02:50)

Re: need help with SimplePunRewrite mod ...

SuperMAG wrote:

well the 1.3 is still in construction and it will be impossible to convert my old forum to 1.3 and there are no extensions of 1.3 right now ... at lease some one make a subforum extension ....

but cammon how much time it will take ... 10 15 min for a person who knows php ....

1.3 is true beta, but url scheme (AND functions associated) were (almost) finished at least nine months ago (and maybe more)...
Have migrated my own 1.2.x forum with full url_rewriting at these times.

But SORRY : NO, IT DOESN'T TAKE 10-15 MINS (!!!)
The fact of knowing php or not doesn't matter, it's pretty easy (no trick involved), but IT DOES takes time..
What u have to do : change ALL (i mean ALL) links in ALL (i mean ALL php files) files in order to use a function which will rewrite the link (take a look at 1.3 files if u don't see precisely..).
So, it's EASY... but IT TAKES TIME (as ALL files are concerned).
(refer to corresponding 'SimplePunRewrite' subject, it has NOTHING to be in common, SimpleRewrite was a tip, what i'm talking about is a real url_rewriting...).

But maybe the best choice (if u can..) is : just wait 1.3 and migrate, u will have it without effort.. wink

Re: need help with SimplePunRewrite mod ...

Mpok wrote:
SuperMAG wrote:

well the 1.3 is still in construction and it will be impossible to convert my old forum to 1.3 and there are no extensions of 1.3 right now ... at lease some one make a subforum extension ....

but cammon how much time it will take ... 10 15 min for a person who knows php ....

1.3 is true beta, but url scheme (AND functions associated) were (almost) finished at least nine months ago (and maybe more)...
Have migrated my own 1.2.x forum with full url_rewriting at these times.

But SORRY : NO, IT DOESN'T TAKE 10-15 MINS (!!!)
The fact of knowing php or not doesn't matter, it's pretty easy (no trick involved), but IT DOES takes time..
What u have to do : change ALL (i mean ALL) links in ALL (i mean ALL php files) files in order to use a function which will rewrite the link (take a look at 1.3 files if u don't see precisely..).
So, it's EASY... but IT TAKES TIME (as ALL files are concerned).
(refer to corresponding 'SimplePunRewrite' subject, it has NOTHING to be in common, SimpleRewrite was a tip, what i'm talking about is a real url_rewriting...).

But maybe the best choice (if u can..) is : just wait 1.3 and migrate, u will have it without effort.. wink

i know i should wait but what happen to all the urls in the search engines now ...

i dont want all the things to be rewriten ... just these final things ....

and i mean final .. no more no little :

1- correct the Headline of the News in portal page ...
2- in the forum.php the subforums links are old links and also some of the forums have stupid links like:
http://www.sportstv.co.cc/f24.html
it is this inside the forums
Index » (TV Softwares / P2P Softwares) » Sopcast
http://www.sportstv.co.cc/f24-softwares … wares.html
3- correct the redirection problems when you add a topic or add a post or edit a topic or increase a topic karma or topic rating

thats three only i can get you where to change things to be corrected but i dont know what to change ...

my links are like this:
http://www.sportstv.co.cc/s197-sopcast.html (topic link)
http://www.sportstv.co.cc/s197-sopcast.html#p329 (post link)
http://www.sportstv.co.cc/f24-softwares … wares.html (forum link)

so finally can any one help ... mpok if u know php may be u help with these three

MyFootballCafe.com  is Now Online!

19

Re: need help with SimplePunRewrite mod ...

You obsess way too much over what your links look like. Most things, including search engines, don't honestly care what they look like.

And, as Mpok stated above, and has been said since day one when you broached this subject, the matter is not a simple one, no matter how much you may think it is. I would be very surprised if anyone does this work for you, unless you actually pay them to do so.

Re: need help with SimplePunRewrite mod ...

MattF wrote:

You obsess way too much over what your links look like. Most things, including search engines, don't honestly care what they look like.

And, as Mpok stated above, and has been said since day one when you broached this subject, the matter is not a simple one, no matter how much you may think it is. I would be very surprised if anyone does this work for you, unless you actually pay them to do so.

ok how much may some one want for this

MyFootballCafe.com  is Now Online!