Author Topic: mode=search is removed from URL when logging in or out  (Read 4789 times)

0 Members and 1 Guest are viewing this topic.

Offline bernd

  • Full Member
  • ***
  • Posts: 214
    • View Profile
mode=search is removed from URL when logging in or out
« on: January 16, 2011, 02:02:09 AM »
4images 1.7.9 - I'm on the details.php via a search result, hence the URL ends with &mode=search. If I now log in (or out) the details.php is reloaded but without the &mode=search.
The same actually happens when you vote for an image that you reached via a search result. I found an ancient post by V@no but that was only for the vote preblem, not for the log in/out issue.

Does anyone have an idea what needs to be changed where to keep the &mode=search when logging in or out?

If you want to test it go to the 4images demo and try it for yourself:
http://demo.4homepages.de/details.php?image_id=54&mode=search&l=english and then vote for the image.

thnx,
b.
« Last Edit: January 23, 2011, 11:35:34 PM by bernd »

Offline bernd

  • Full Member
  • ***
  • Posts: 214
    • View Profile
Re: mode=search is removed from URL when logging in or out
« Reply #1 on: January 23, 2011, 11:36:31 PM »
sorry to bump this but does no-one have a clue?

Offline bernd

  • Full Member
  • ***
  • Posts: 214
    • View Profile
Re: mode=search is removed from URL when logging in or out
« Reply #2 on: February 12, 2011, 02:24:19 PM »
OK, I found it. But I'm not sure if this is really a solution or if I mess something else up.

In global.php find this
$url preg_replace(array("/[?|&]action=[^?|&]*/""/[?|&]mode=[^?|&]*/""/[?|&]".URL_ID."=[^?|&]*/""/[?|&]l=[^?|&]*/""/[&?]+$/"), array(""""""""""), $url);

and replace with this
$url preg_replace(array("/[?|&]action=[^?|&]*/""/[?|&]".URL_ID."=[^?|&]*/""/[?|&]l=[^?|&]*/""/[&?]+$/"), array(""""""""), $url);

As you easily spot the "action", "mode" and a few other things are removed with this regex. I assume that there was a reason for doing so but I don't what it might be. Anyone have an idea?

cheers,
b.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: mode=search is removed from URL when logging in or out
« Reply #3 on: February 12, 2011, 04:44:08 PM »
The best solution would be add the mode into user_loginform.html template.
Insert this code above </form>

Code: [Select]
<?php
global $mode;
?>

        <input type="hidden" name="mode" value="<?=$mode?>" />
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline bernd

  • Full Member
  • ***
  • Posts: 214
    • View Profile
Re: mode=search is removed from URL when logging in or out
« Reply #4 on: February 12, 2011, 05:08:11 PM »
The best solution would be add the mode into user_loginform.html template.
Thanks but nope, does not have any effect. "mode" is in the "HTTP_REFERER" but gets removed by the regex. Adding it to the form does not change anything - it would require further changes to add $mode again to the URL the user is redirected to after logging in. So unless there is a good reason not to do what I did, I'll keep it like this.

cheers,
b.