[MODDB] Login Redirection Suite

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Locked
phantomk
Registered User
Posts: 1039
Joined: Wed Apr 14, 2004 5:32 am
Location: Canada Eh?
Name: Daniel Lee
Contact:

[MODDB] Login Redirection Suite

Post by phantomk »

Released MOD can be found here: http://www.phpbb.com/phpBB/viewtopic.php?t=329684

Login Redirection Suite
(Current Version - 1.0.0, Released September 22, 2005)

Login Redirection Suite adds a redirection variable to the login link(s) and form(s).

August 18, 2005
Login Redirection Suite version 0.0.1-b

August 22, 2005
Login Redirection Suite version 1.0.0 - Submitted to MOD DB

Without further hesitation, here it is:

Login Redirection Suite version 1.0.0

Demo Site
Username: test
Password: test
Last edited by phantomk on Sat Oct 29, 2005 5:09 am, edited 4 times in total.

linuxoverwindows
Registered User
Posts: 82
Joined: Sun Feb 01, 2004 2:50 am
Location: Las Cruces, NM.
Contact:

made the changes

Post by linuxoverwindows »

i made all the changes from your script, but im still directed to the login page when you hit logout from my home page or any other page. i guess it really isnt a big deal, i just think it would be kind of cool. to recap: im using your code from this post in the modified files...

i also use:

Code: Select all

<?php
//
// add this code to the top of pages
//
define('IN_PHPBB', true);
$phpbb_root_path = $docroot.'/phpBB/';  // Change this to the path of where your phpBB is located.
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

// session id check
if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
{
        $sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
}
else
{
        $sid = '';
}

?>
this one:

Code: Select all

<?php
$phpself = $_SERVER[PHP_SELF];
$querystr = $_SERVER["QUERY_STRING"];
//
// Generate logged in/logged out status
//
if ( $userdata['session_logged_in'] )
{
   $u_login_logout = append_sid('/phpBB/login.'.$phpEx.'?logout=true&sid=' . $userdata['session_id']);
   $l_login_logout = $lang['Logout'] . ' [ ' . $userdata['username'] . ' ]';
}
else
{
   $u_login_logout = append_sid('/phpBB/login.'.$phpEx);
   $l_login_logout = $lang['Login'];
}
echo '<form method="post" action="'.$u_login_logout.'">';
echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
//
// Login box
//
if ( !$userdata['session_logged_in'] )
{
echo '<tr>
   <td class="row1" align="center" valign="middle" height="28"><span class="gensmall">
      Username: <input class="post" type="text" name="username" size="10" />&nbsp;&nbsp;&nbsp;
      Password: <input class="post" type="password" name="password" size="10" maxlength="32" />&nbsp;&nbsp;&nbsp;&nbsp;
      Login automatically each visit <input class="text" type="checkbox" name="autologin" />&nbsp;&nbsp;&nbsp;<input type="submit" name="login" value="Login" />&nbsp;&nbsp;&nbsp;
      <a href="/phpBB/profile.php?mode=register">Register</a></p>
   </span> </td>
</tr>';
}
else
{
echo '<tr>
   <td class="row1" valign="middle" height="28"><a href="'.$u_login_logout.'">'.$l_login_logout.'</a></td>
</tr>';
}
echo '</table>';
if ($querystr) { echo '<input type="hidden" name="redirect" value="..'.$phpself.'?'.$querystr.'">'; } else { echo '<input type="hidden" name="redirect" value="..'.$phpself.'">'; }
echo '</form>';
?>
and this to close the session:

Code: Select all

<?php

// add to the end of pages
// Close our DB connection.
//
$db->sql_close();

exit;

?>
maybe the new mod means i need to modify your other code...
of course i use some variables as you can see such as $docroot and such but that dont matter...
-rw-r--r-- 1 root root 69 Mar 12 00:00 core
http://www.yougetalife.com
mushroom mushroom

phantomk
Registered User
Posts: 1039
Joined: Wed Apr 14, 2004 5:32 am
Location: Canada Eh?
Name: Daniel Lee
Contact:

Post by phantomk »

Your trying to do something completely different from what the mod does to your forum. You are trying to add a login form to your "other" site abd be redirected to that part of your site, which is outside of the phpBB directory. For what you want to do it wil require more modifications and fine tuneing.

This is meant for the forum only.

linuxoverwindows
Registered User
Posts: 82
Joined: Sun Feb 01, 2004 2:50 am
Location: Las Cruces, NM.
Contact:

ok, i was sidetracked...

Post by linuxoverwindows »

ok, i thought it was added as a supplement to our previous conversation...

mostly, what i wouldnt mind is a logout button, like how the login sends variables that put it into logged in state... maybe if i make a submit that clears the logged in state... i wonder, if you just clear the $userdata['session_logged_in'] variable, if that is plenty?
the other variables should clear out in suit i would think, upon refreshing the page or clicking a link to the next page... hmmm...
-rw-r--r-- 1 root root 69 Mar 12 00:00 core
http://www.yougetalife.com
mushroom mushroom

linuxoverwindows
Registered User
Posts: 82
Joined: Sun Feb 01, 2004 2:50 am
Location: Las Cruces, NM.
Contact:

ok got it...

Post by linuxoverwindows »

i modified the logout anchor... its now a submit button...

Code: Select all

//
// Login box
//
if ( !$userdata['session_logged_in'] )
{
echo '<tr>
   <td class="row1" align="center" valign="middle"><span class="gensmall">
      Username: <input class="post" type="text" name="username" size="10" />&nbsp;&nbsp;&nbsp;
      Password: <input class="post" type="password" name="password" size="10" maxlength="32" />&nbsp;&nbsp;&nbsp;&nbsp;
      Login automatically each visit <input class="text" type="checkbox" name="autologin" />&nbsp;&nbsp;&nbsp;<input type="submit" name="login" value="Login" />&nbsp;&nbsp;&nbsp;
      <a href="/phpBB/profile.php?mode=register">Register</a>
   </span> </td>
</tr>';
}
else
{
echo '<tr>';
echo '<td class="row1" valign="middle"><span class="gensmall"><input type="submit" name="logout" value="Logout" /></span></td>';
// echo '<td class="row1" valign="middle"><a href="'.$u_login_logout.'">'.$l_login_logout.'</a></td>';
echo '</tr>';
}
echo '</table>';
if ($querystr) { echo '<div><input type="hidden" name="redirect" value="..'.$phpself.'?'.$querystr.'"></div>'; } else { echo '<div><input type="hidden" name="redirect" value="..'.$phpself.'"></div>'; }
echo '</form>';
?>
in the above, you see where i // out the old line with an a tag and replaced it with a submit button that sends logout to the login script and does the legwork for me. now it makes a little button and when you logout, it stays on the same page and just presents a login form. and i had to add div tags elsewhere to make the code html 4.01 strict.
-rw-r--r-- 1 root root 69 Mar 12 00:00 core
http://www.yougetalife.com
mushroom mushroom

phantomk
Registered User
Posts: 1039
Joined: Wed Apr 14, 2004 5:32 am
Location: Canada Eh?
Name: Daniel Lee
Contact:

Re: made the changes

Post by phantomk »

Code: Select all

<?php
//
// add this code to the top of pages
//
define('IN_PHPBB', true);
$phpbb_root_path = $docroot.'/phpBB/';  // Change this to the path of where your phpBB is located.
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

?>

Code: Select all

<?php
//
// Extract the query variables from the url
//
parse_str($_SERVER["QUERY_STRING"], $outputs);

foreach ($outputs as $var => $string)
{
	//
	// Remove the sid variable from the url
	//
	if ($string != $outputs['sid'])
	{
		$query_vars[] = $var . '=' . $string;
	}
}

//
// Don't whine if thier is an error, any urls that don't have query's
//
@$queryVars = implode("&", $query_vars);

//
// Put the url back together
//
$redirect = (!empty($_SERVER["QUERY_STRING"])) ?  '..' . $_SERVER[PHP_SELF] . '?' . $queryVars : '..' . $_SERVER[PHP_SELF];

//
// Generate logged in/logged out status
//
if ( $userdata['session_logged_in'] )
{
	$u_login_logout = 'login.' . $phpEx . '?logout=true&redirect=\'' . $redirect . '\'&sid=' . $userdata['session_id'];
	$l_login_logout = $lang['Logout'] . ' [ ' . $userdata['username'] . ' ]';
}
else
{
	$u_login_logout = 'login.' . $phpEx . '?redirect=\'' . $redirect . '\'';
	$l_login_logout = $lang['Login'];
}

$u_login_logout = append_sid($phpbb_root_path . $u_login_logout);

//
// Login box
//
if ( !$userdata['session_logged_in'] )
{
	echo '<form method="post" action="' . append_sid($phpbb_root_path . "login." . $phpEx) . '">';
	echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
	echo '<tr>';
	echo '<td class="row1" align="center" valign="middle" height="28"><span class="gensmall">';
	echo 'Username: <input class="post" type="text" name="username" size="10" />&nbsp;&nbsp;&nbsp;';
	echo 'Password: <input class="post" type="password" name="password" size="10" maxlength="32" />&nbsp;&nbsp;&nbsp;&nbsp;';
	echo 'Login automatically each visit <input class="text" type="checkbox" name="autologin" />&nbsp;&nbsp;&nbsp;<input type="submit" name="login" value="Login" />&nbsp;&nbsp;&nbsp;';
	echo '<a href="' . append_sid($phpbb_root_path . "profile." . $phpEx . "?mode=register") . '">Register</a></p>';
	echo '</span></td>';
	echo '</tr>';
	echo '</table>';
	echo '<input type="hidden" name="redirect" value="' . $redirect . '">';
	echo '</form>';
}
else
{
	echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
	echo '<tr>';
	echo '<td class="row1" valign="middle" height="28"><a href="' . $u_login_logout . '">' . $l_login_logout . '</a></td>';
	echo '</tr>';
	echo '</table>';
}

?>

Code: Select all

<?php

// add to the end of pages
// Close our DB connection.
//
$db->sql_close();

exit;

?>

afterlife_69
I've Been Banned!
Posts: 630
Joined: Tue Nov 30, 2004 10:35 am

Post by afterlife_69 »

its already there, you just put a hidden form field like this:

Code: Select all

<input type="hidden" name="redirect" value="{U_HOME}" />
we do it on GamerzVault.com

phantomk
Registered User
Posts: 1039
Joined: Wed Apr 14, 2004 5:32 am
Location: Canada Eh?
Name: Daniel Lee
Contact:

Post by phantomk »

afterlife_69 wrote: its already there, you just put a hidden form field like this:

Code: Select all

<input type="hidden" name="redirect" value="{U_HOME}" />
we do it on GamerzVault.com

??

phantomk
Registered User
Posts: 1039
Joined: Wed Apr 14, 2004 5:32 am
Location: Canada Eh?
Name: Daniel Lee
Contact:

Post by phantomk »

Mod Updated to 1.0.0 and has been submitted to the MOD DB and is awaiting approval.

phantomk
Registered User
Posts: 1039
Joined: Wed Apr 14, 2004 5:32 am
Location: Canada Eh?
Name: Daniel Lee
Contact:

Post by phantomk »

Small fix in install file

OPEN
includes/page_header.php

FIND

Code: Select all

$u_login_logout = 'login.' . $phpEx . '?redirect=\'./' . $phpbb_root_path . $redirect . '\'';
REPLACE WITH

Code: Select all

$u_login_logout = 'login.' . $phpEx . '?redirect=\'' . $phpbb_root_path . $redirect . '\'';

saaiberke
Registered User
Posts: 1126
Joined: Wed Jul 20, 2005 8:13 am
Location: Gent/Belgium
Contact:

Post by saaiberke »

I installed the Olympus style login screen but with your directives for this mod it doesn't work out, my login.php and page_header.php are already modded :-(

Although it would be a great mod for my board. :-(

Grtz,

Nic

phantomk
Registered User
Posts: 1039
Joined: Wed Apr 14, 2004 5:32 am
Location: Canada Eh?
Name: Daniel Lee
Contact:

Post by phantomk »

Mod validated, thanks Mod Team.

Locked

Return to “[2.0.x] MODs in Development”