[solved] Optimizing use of real phpBB URLs...
 
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.   printer-friendly view    phpMiX.org Forum Index -> mxBB Modules -> mxBB Module: mx_forum (beta team)
View previous topic :: View next topic  
Author Message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Fri Jul 09, 2004 12:32 am    Post subject: [solved] Optimizing use of real phpBB URLs... Reply with quote

I still don't like the links with the form of index.php?page=xx when that is not necessary, since they will be redirected anyway once the phpBB script receives the request.

Let me explain it better, using an example:

As you can see in this site, all links to viewtopic.php?t=xx are converted to index.php?page=nn,t=xx.

Ok, that's what we wanted since now viewtopic.php is a Portal Block. Perfect!

However, imagine I'm running this mode of operation for a while and posting references to my topics all around (hey, read what x is saying here, and the like...). I'll post links in the form of index.php?page=nn,t=xx, just because that is all I can see. For instance, try to create a link to this topic using the old form (viewtopic.php?t=xx).

Now, suddenly I decide to remove the use of viewtopic.php as a Block (for whatever reason) falling back as standalone phpBB Script.

What will happen then? All people trying to follow a link I posted in the form of index.php?page=nn,t=xx will see unknown results, because viewtopic block does not exist and that page is probably removed or reused with other blocks.

I hope you may understand what I'm trying to mean.

Well, well. I'm going to add some checks to generate links in the form of index.php?page=nn,t=xx ONLY when necessary.

That is, it will only be necessary for phpBB scripts that need to process forms. I have not been able to correctly redirect POST requests (those sent by FORMs). Problem here is POST variables are lost at redirection time. This is not the case for GET variables. These are passed within the URL itself and that is something the redirection code deals with perfectly now.

As an example of redirection with GET variables:
http://www.example.com/index.php?page=213&t=198
http://forums.example.com/viewtopic.php?t=198
...both URLs point to the same page. However, the second will be processed at phpBB2 folder by the Hook MOD (remember?) and redirected to the portal page.

As an example of redirection with POST variables:
Well, try to use the QuickSearch form on the left column. It will try to POST the request at phpBB2/search.php (use view source and look at the form code if you don't believe me Smile ). This is because the QuickSearch block is part of another module which does not know if we're using mx_forum module or not (same thing could happen with other examples). However, the Hook MOD waiting at that end will redirect that request to the portal page where search block lives ...loosing whatever you entered in the text field of the QuickSearch form.

So... be prepared for some changes here. Wink

Additionally, if I'm able to find a way to deal with POST variables with the redirection logic, that will be perfect since there will be no need to convert any URL. That means a lot of simplification while applying the MODs when porting phpBB scripts. Most of the problem will be solved then by the redirection logic itself.

Though, I'm not sure how to deal with POST variables. No warranties here. It's time for a brainstorming at my end... Rolling Eyes

Does that mean it doesn't worth trying to test the current released alpha?
Nope. While it seems somehow complex the change will no impact current implementation. The "method" will remain the same. So any time spent giving current alpha release a try is still very good and (sorry to insist in this) any feedback on the documentation is much appreciated.

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Fri Jul 09, 2004 3:44 am    Post subject: Re: Optimizing use of real phpBB URLs... Reply with quote

Ok, the above problem has been solved for all phpBB Scripts that doesn't use FORMs. These are the following:

faq.php, index.php, memberlist.php, viewforum.php, viewonline.php and viewtopic.php.

As you'll notice now in this site, none of the links to above phpBB Scripts are transformed. Then all the work is done at phpBB side by the Hook MOD. It will simply redirect all requests to the corresponding Portal Page.

So... main problem is solved. Now we can easilly get links to our topic as always.

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Fri Jul 09, 2004 3:58 am    Post subject: Re: Optimizing use of real phpBB URLs... Reply with quote

Now it's time to deal with those scripts using FORMs... there should be a way for the Hook MOD to catch all POST variables and pass them safely to the other side (the portal page).

Well, catch all POST variables is easy, by reading the $_POST array.

The question is... How to pass these variables from phpBB side (the Hook) to the Portal side (the Block)?

By the Hook I mean the forum_hack.php script being included to phpbb/common.php. That is something executed at phpBB side.

By the Block I mean the forum_hack.php script being included on top of all phpBB Scripts ported as Portal Blocks. That is something executed at Portal side.

I'm thinking about this solution:
a) The Hook reads the $_POST array and saves anything there as a $_SESSION variable, then performs the redirection.
b) The Block reads the $_SESSION array and saves all post variables previously stored back to the $_POST array.

Problem with this approach is it requires the PHP session engine working correctly.

Does anyone see any problem with this?

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Fri Jul 09, 2004 4:22 pm    Post subject: Re: Optimizing use of real phpBB URLs... Reply with quote

markus_petrux wrote:
I'm thinking about this solution:
a) The Hook reads the $_POST array and saves anything there as a $_SESSION variable, then performs the redirection.
b) The Block reads the $_SESSION array and saves all post variables previously stored back to the $_POST array.

For some reason I'm unable to pass on POST vars through SESSION vars. This approach does not want to work. Sad

I have also tried to redirect with POSTs using JavaScript, using this code:
Code:
   $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n".
         '<html><head>'."\n".
         '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'."\n".
         '<title>Redirect</title>'."\n".
         '<style type="text/css">'."\n".
         'body {'."\n".
         "\t".'color:#000000; background-color:#FFFFFF;'."\n".
         '}'."\n".
         'input {'."\n".
         "\t".'color:#000000; background-color:#FFFFFF; border-color:#000000; font:normal 11px Verdana, Helvetica, sans-serif;'."\n".
         '}'."\n".
         '</style>'."\n".
         '</head>'."\n".
         '<body onload="redirect.submit();">'."\n";
   $html .= '<form name="redirect" method="post" action="'.$portal_url.'">'."\n";
   foreach( $HTTP_POST_VARS as $key => $val )
   {
      $html .= '<input type="hidden" name="'.$key.'" value="'.stripslashes($val).'" />'."\n";
   }
   $html .= '<div align="center">If your browser does not support javascript please click '.
         '<input type="submit" value="HERE" /> to be redirected</div>'."\n";
   $html .= '</form>'."\n";
   $html .= '</body></html>';
   echo $html;

But result is terrible annoying, since the "if your browser does not support javascript..." message is displayed on the browser for a while AND it adds that page to the browser's history.
So... JavaScript POSTs redirection discarded. Sad

I have also tried to redirect via sockets, using a function based on this code:
http://www.php.net/source.php?url=/include/posttohost.inc
All I get is a 403 Forbidden HTTP Error. That means it depends on the Hosting features, which mine are too restricted.
So... socket redirection discarded !!! Sad

Arrow What does it mean then?
Unless another idea arises, all URLs to phpBB Scripts depending on POST variables should be transformed.

That's how mx_forum v0.1.0 already works.

So the only change you will see in next Alpha release is related to phpBB Scripts depending on GET variables exclusively (as noted in previous posts).

That's all... for now.

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Fri Jul 09, 2004 4:24 pm    Post subject: Re: Optimizing use of real phpBB URLs... Reply with quote

Changed status of this issue to CLOSED.


+

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Fri Jul 09, 2004 8:29 pm    Post subject: Re: [re-opened] Optimizing use of real phpBB URLs... Reply with quote

ejem... further investigations revealed the POST->SESSION->redirect->SESSION->POST method as explained above have worked in another installation. That's very good news since it seems possible then, however...

...same code tested in this site fails! Sad

Why Question .....it seems I should still investigate this further.


Arrow New Issue Status: re-opened Confused

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Sat Jul 10, 2004 2:32 pm    Post subject: Re: [re-opened] Optimizing use of real phpBB URLs... Reply with quote

More news...

I got it working! Smile

However, it works ONLY when cookies are enabled. Sad

At this moment, when cookies are disabled, the SESSION variables are lost during the redirection.

Strange, because it should work, as far as the SID is passed as a GET variable in the URL.

I should still investigate what's going on...

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Sun Jul 11, 2004 5:55 am    Post subject: Re: [re-opened] Optimizing use of real phpBB URLs... Reply with quote

markus_petrux wrote:
Strange, because it should work, as far as the SID is passed as a GET variable in the URL.

I should still investigate what's going on...

Bingo !!! Smile Smile Smile

I got it! Smile Smile Smile


I was trying to pass on to the redirected URL the sid as generated by phpBB append_sid function, which indeed appends the phpBB sid when cookies are disabled.

Problem is phpBB sids are NOT the same thing as PHP session ids, which is the thing required when using SESSION vars.

Solution was to create a new append_PHPSESSID function similar to append_sid. So now, redirection URLs go with the PHPSESSID appended when cookies are disabled.

Also I have found that for PHP 4.3.3+ session_start() may generate warnings if session is already started, so now all session functions called by forum_hack.php go prefixed with he magic @ code, which avoids any warnings.

And all that seem to work!!! ...this site now runs the new redirection code. Try to use the QuickSearch block (example used in previous posts) and tell me if that works or not. Try to do it disabling cookies too, if you wish. Try to post something, and tell me if that works. hmmm... if that fails, you can also contact me via MX site.


So... I'm going to update the status of this issue to solved. Smile

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Haplo
Apprentice
Apprentice


Joined: 19 Oct 2003
Posts: 10

PostPosted: Wed Jul 28, 2004 10:46 pm    Post subject: Re: [solved] Optimizing use of real phpBB URLs... Reply with quote

...and when may this cool addon be public...hate those page= links
 
 
_________________

___________________________________
The MX-Portal Project:
www.mx-system.com
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Thu Jul 29, 2004 12:02 pm    Post subject: Re: [solved] Optimizing use of real phpBB URLs... Reply with quote

This is alpha code, Haplo.

Latest changes in code are not ready to release (even another alpha). First, I want to explore the technique with more phpBB MODs. This is why I'm now compiling a preMOD'd phpBB pack.

Note the format of the final product is still unknown to me. So, it's somehow useless release anything that could be changed in its basic implementation in short time.

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Haplo
Apprentice
Apprentice


Joined: 19 Oct 2003
Posts: 10

PostPosted: Thu Jul 29, 2004 10:03 pm    Post subject: Re: [solved] Optimizing use of real phpBB URLs... Reply with quote

sure...no problem...i got excited thats all Wink
 
 
_________________

___________________________________
The MX-Portal Project:
www.mx-system.com
 
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.   printer-friendly view    phpMiX.org Forum Index -> mxBB Modules -> mxBB Module: mx_forum (beta team) All times are GMT + 1 Hour
 
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum