Author Topic: [Pre-mod] Redirect back to url after login  (Read 11612 times)

0 Members and 1 Guest are viewing this topic.

Offline BartAfterDark

  • Hero Member
  • *****
  • Posts: 520
    • View Profile
[Pre-mod] Redirect back to url after login
« on: February 20, 2006, 05:28:39 PM »
*BETA*
Addon for http://www.4homepages.de/forum/index.php?topic=7062.0 ([MOD] Information if Guest follows direct link to an image/category)

Hey.
If a user view a picture they do not have access to and they tries to login, they get send back to /index.php
But this redirects them back to the image (at least I think it does)

Open login.php
Find:
Code: [Select]
  $user_name = trim($HTTP_POST_VARS['user_name']);
  $user_password = trim($HTTP_POST_VARS['user_password']);
  $auto_login = (isset($HTTP_POST_VARS['auto_login']) && $HTTP_POST_VARS['auto_login'] == 1) ? 1 : 0;

  if ($site_sess->login($user_name, $user_password, $auto_login)) {
    if (!ereg("index.php", $url) && !ereg("login.php", $url) && !ereg("register.php", $url) && !ereg("member.php", $url)) {
      header("Location: ".$site_sess->url($url, "&"));
    }
    else {
      header("Location: ".$site_sess->url(ROOT_PATH."index.php", "&"));
    }
  }
  else {
    $error = $lang['invalid_login'];
Replace with:
Code: [Select]
  $user_name = trim($HTTP_POST_VARS['user_name']);
  $user_password = trim($HTTP_POST_VARS['user_password']);
  $auto_login = (isset($HTTP_POST_VARS['auto_login']) && $HTTP_POST_VARS['auto_login'] == 1) ? 1 : 0;

  if ($site_sess->login($user_name, $user_password, $auto_login)) {
    if (!ereg("index.php", $url) && !ereg("login.php", $url) && !ereg("register.php", $url) && !ereg("member.php", $url)) {
      header("Location: ".$site_sess->url($url, "&"));
    }
    else {
      header("Location: ".$site_sess->url($url, "&"));
    }
  }
  else {
    $error = $lang['invalid_login'];
but I have one problem with it. As soon I use this: http://www.4homepages.de/forum/index.php?topic=6729.msg57268#msg57268 ([Mod] Search Engine Friendly URLs aka Short URLs)
And View a picture I don't have access to and tries to login from that page It redirects me to a blank /login.php page. (with no code at all) I'm going to put up a temp install, so you guys can see for your self.

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: [Pre-mod] Redirect back to url after login
« Reply #1 on: February 21, 2006, 01:12:15 AM »
Sorry to tell you that, but it will not work just like that...
4images is using "HTTP_REFERER" value. So, unless your browser (or other privacy control software/antivirus/firewall) is blocking referal pages, 4images should redirect you to the image you were trying to access before login.

And your changes are equal to removing what is in red:[qcode]    if (!ereg("index.php", $url) && !ereg("login.php", $url) && !ereg("register.php", $url) && !ereg("member.php", $url)) {
      header("Location: ".$site_sess->url($url, "&"));
    }
    else {
      header("Location: ".$site_sess->url($url, "&"));
    }
[/qcode]
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 tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [Pre-mod] Redirect back to url after login
« Reply #2 on: September 08, 2006, 08:26:59 AM »
After changing the provider we have the problem that after a login on the detail-page
you are redirected to the index.php. Could this be caused by the new server?

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: [Pre-mod] Redirect back to url after login
« Reply #3 on: September 08, 2006, 02:40:48 PM »
it could be, but probably its the client side...if referer page blocked, you'll get redirect to index.php
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)