4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: bernd on January 16, 2011, 02:02:09 AM

Title: mode=search is removed from URL when logging in or out
Post by: bernd 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 (http://www.4homepages.de/forum/index.php?topic=5880.0) 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.
Title: Re: mode=search is removed from URL when logging in or out
Post by: bernd on January 23, 2011, 11:36:31 PM
sorry to bump this but does no-one have a clue?
Title: Re: mode=search is removed from URL when logging in or out
Post by: bernd 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.
Title: Re: mode=search is removed from URL when logging in or out
Post by: V@no 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?>" />
Title: Re: mode=search is removed from URL when logging in or out
Post by: bernd 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.