Regarding about user integration

Started by Rune-Cpsv.info, December 28, 2011, 06:18:51 AM

Previous topic - Next topic

Rune-Cpsv.info

Hello, i have integrate my forum users with my site members but i do not get it that when i tried logging in an account in the forum, it will lead to my site instead of the forum... so... please help me...

I also added ssi_login()/ssi_logout() functions to my site.
Visit us at http://rune-cpsv.info


Andre N

Try setting $_SESSION['login_url'] and $_SESSION['logout_url'] to be the url you want people redirected to after login/logout. Set the session variable first, then call ssi_login() (or logout)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Rune-Cpsv.info

Yes, i make the page call
<?php
require_once('community/SSI.php');
$_SESSION['login_url']='http://rune-cpsv.info/donate.php'.$_SERVER['PHP_SELF'];
$_SESSION['logout_url']='http://rune-cpsv.info/donate.php'.$_SERVER['PHP_SELF'];
?>

which i forgot to add in the post but yet, i still have the same problem.
Visit us at http://rune-cpsv.info


Rune-Cpsv.info

Another problem is that why it can't redirect back to a page like www.domain.com/page.php instead they will got www.domain.com?
So there will be 2 problems need to be solved in total.
Visit us at http://rune-cpsv.info


Andre N

Have you tried using the url as a parameter of the function, like:

ssi_login($redirect_url);


From looking at the SSI script it looks like that's just going to set the $_SESSION['login_url'] variable that you already set, but it doesn't hurt to try.

You could also try calling loadSession() before the login call just to make sure you are using SMF's session.

If that doesn't work, i'd start probing /Sources/LogInOut.php in the function Login2() to find out if the $_SESSION variable is set there or not...

I don't understand your second problem, you should be able to redirect anywhere
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Rune-Cpsv.info

Quote from: andre nickatina on December 30, 2011, 06:26:44 PM
Have you tried using the url as a parameter of the function, like:

ssi_login($redirect_url);


From looking at the SSI script it looks like that's just going to set the $_SESSION['login_url'] variable that you already set, but it doesn't hurt to try.

You could also try calling loadSession() before the login call just to make sure you are using SMF's session.

If that doesn't work, i'd start probing /Sources/LogInOut.php in the function Login2() to find out if the $_SESSION variable is set there or not...

I don't understand your second problem, you should be able to redirect anywhere
hi i tried ssi_login($redirect_url);, yet it still redirect my page to my home page.
If i add load session before the call of the login form and ssi_login($redirect_url);, it will give me error.
Visit us at http://rune-cpsv.info


Rune-Cpsv.info

Visit us at http://rune-cpsv.info


Andre N

ok ok, try this:
set $_SESSION['old_url'] to be the url you want to redirect to before calling ssi_login()
I think this might do it :)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Rune-Cpsv.info

Visit us at http://rune-cpsv.info


Rune-Cpsv.info

All my page with the log in form, after log in, my page will redirect to my home page, basically, what i am testing is my other page instead of my forum log in form.
When i tried my other page called : donate.php to log in an account, it will redirect me to my index.php page.
So try to help me fix this first.. thanks
Visit us at http://rune-cpsv.info


Andre N

Ok, sounds like you are just setting the SESSION variables in another session that SMF won't have access to.

Try setting the path in a cookie, and then in your /Sources/LogInOut.php script where it checks for the $_SESSION['login_url'] variable, have it check for your cookie too, then set the login url if the cookie is found and delete the cookie
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Rune-Cpsv.info

Visit us at http://rune-cpsv.info


Andre N

Quote from: RCStewie on January 06, 2012, 12:07:06 PM
how can i do that?

In line ~988 of your SSI.php file you'll see:

function ssi_login($redirect_to = '', $output_method = 'echo')
{
global $scripturl, $txt, $user_info, $context, $modSettings;

if ($redirect_to != '')
$_SESSION['login_url'] = $redirect_to;


which is the point where the url you want to redirect to is set in the $_SESSION array for SMF to use. Since that's not working for you, for whatever reason, change that code to be this:


function ssi_login($redirect_to = '', $output_method = 'echo')
{
global $scripturl, $txt, $user_info, $context, $modSettings;

if ($redirect_to != '') {
$_SESSION['login_url'] = $redirect_to;
setcookie('login_url', $redirect_to, 0, '/');
    }


So now, when you call ssi_login($login_url) the url you want to be redirected to after login will be set in a cookie called 'login_url'.

In your /Sources/LogInOut.php file you need to modify the Login2() function to check for your cookie and set the redirect url for you (and delete the cookie). In that file, at line ~93 you'll see this code:

function Login2()
{
global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;

// Load cookie authentication stuff.


replace with this:


function Login2()
{
global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;

if (isset($_COOKIE['login_url']) && !empty($_COOKIE['login_url'])) {
        $_SESSION['login_url'] = $_COOKIE['login_url'];
        $_SESSION['old_url']   = $_COOKIE['login_url']; //just in case ;)
        setcookie ('login_url', '', time() - 3600); //delete cookie
}


So now as soon as SMF hits the Login2 function it will check for the existence of your cookie, and put your login url into the SMF $_SESSION variables, then delete the cookie.

So, try making those changes and let me know if it works for you :)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Rune-Cpsv.info

Quote from: andre nickatina on January 06, 2012, 01:25:00 PM
Quote from: RCStewie on January 06, 2012, 12:07:06 PM
how can i do that?

In line ~988 of your SSI.php file you'll see:

function ssi_login($redirect_to = '', $output_method = 'echo')
{
global $scripturl, $txt, $user_info, $context, $modSettings;

if ($redirect_to != '')
$_SESSION['login_url'] = $redirect_to;


which is the point where the url you want to redirect to is set in the $_SESSION array for SMF to use. Since that's not working for you, for whatever reason, change that code to be this:


function ssi_login($redirect_to = '', $output_method = 'echo')
{
global $scripturl, $txt, $user_info, $context, $modSettings;

if ($redirect_to != '') {
$_SESSION['login_url'] = $redirect_to;
setcookie('login_url', $redirect_to, 0, '/');
    }


So now, when you call ssi_login($login_url) the url you want to be redirected to after login will be set in a cookie called 'login_url'.

In your /Sources/LogInOut.php file you need to modify the Login2() function to check for your cookie and set the redirect url for you (and delete the cookie). In that file, at line ~93 you'll see this code:

function Login2()
{
global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;

// Load cookie authentication stuff.


replace with this:


function Login2()
{
global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;

if (isset($_COOKIE['login_url']) && !empty($_COOKIE['login_url'])) {
        $_SESSION['login_url'] = $_COOKIE['login_url'];
        $_SESSION['old_url']   = $_COOKIE['login_url']; //just in case ;)
        setcookie ('login_url', '', time() - 3600); //delete cookie
}


So now as soon as SMF hits the Login2 function it will check for the existence of your cookie, and put your login url into the SMF $_SESSION variables, then delete the cookie.

So, try making those changes and let me know if it works for you :)
hi i added $_SESSION['old_url'] together with calling my forum ssi.php.
But still, it is not working at all, still redirecting me to my index.php...

but if i add in
<?php
if ($context['user']['is_guest'])
   $_SESSION['old_url']
{
   ssi_login();
}
else
{
   ssi_welcome();
   ssi_logout();
}
?>

it will give me error.
Visit us at http://rune-cpsv.info


Andre N

Quote from: RCStewie on January 08, 2012, 12:23:19 AM
Quote from: andre nickatina on January 06, 2012, 01:25:00 PM
Quote from: RCStewie on January 06, 2012, 12:07:06 PM
how can i do that?

In line ~988 of your SSI.php file you'll see:

function ssi_login($redirect_to = '', $output_method = 'echo')
{
global $scripturl, $txt, $user_info, $context, $modSettings;

if ($redirect_to != '')
$_SESSION['login_url'] = $redirect_to;


which is the point where the url you want to redirect to is set in the $_SESSION array for SMF to use. Since that's not working for you, for whatever reason, change that code to be this:


function ssi_login($redirect_to = '', $output_method = 'echo')
{
global $scripturl, $txt, $user_info, $context, $modSettings;

if ($redirect_to != '') {
$_SESSION['login_url'] = $redirect_to;
setcookie('login_url', $redirect_to, 0, '/');
    }


So now, when you call ssi_login($login_url) the url you want to be redirected to after login will be set in a cookie called 'login_url'.

In your /Sources/LogInOut.php file you need to modify the Login2() function to check for your cookie and set the redirect url for you (and delete the cookie). In that file, at line ~93 you'll see this code:

function Login2()
{
global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;

// Load cookie authentication stuff.


replace with this:


function Login2()
{
global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;

if (isset($_COOKIE['login_url']) && !empty($_COOKIE['login_url'])) {
        $_SESSION['login_url'] = $_COOKIE['login_url'];
        $_SESSION['old_url']   = $_COOKIE['login_url']; //just in case ;)
        setcookie ('login_url', '', time() - 3600); //delete cookie
}


So now as soon as SMF hits the Login2 function it will check for the existence of your cookie, and put your login url into the SMF $_SESSION variables, then delete the cookie.

So, try making those changes and let me know if it works for you :)
hi i added $_SESSION['old_url'] together with calling my forum ssi.php.
But still, it is not working at all, still redirecting me to my index.php...

but if i add in
<?php
if ($context['user']['is_guest'])
   $_SESSION['old_url']
{
   ssi_login();
}
else
{
   ssi_welcome();
   ssi_logout();
}
?>

it will give me error.


The changes I posted above will only help you redirect people on login. The usage will be like this:

require_once($_SERVER['DOCUMENT_ROOT'] . '/path/to/SSI.php');
ssi_login($redirectUrlGoesHere);

Don't bother messing with the $_SESSION variables anymore; it doesn't look like SMF will have access to them, you're probably in another session with your other site.

This code:

if ($context['user']['is_guest'])
   $_SESSION['old_url']
{
   ssi_login();
}

is malformed. You don't have a semi-colon after $_SESSION['old_url'], you aren't assigning anything to it, and you have the if condition brackets placed after it rather than the if statement.
Try this instead:

if ($context['user']['is_guest'])
{
   ssi_login($myRedirectUrl);
}


You might want to make sure the $context variable is even set first before you use it. If it's not set you'll ALWAYS see the login box even if they are logged in
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Rune-Cpsv.info

Quote from: andre nickatina on January 09, 2012, 11:06:26 AM
Quote from: RCStewie on January 08, 2012, 12:23:19 AM
Quote from: andre nickatina on January 06, 2012, 01:25:00 PM
Quote from: RCStewie on January 06, 2012, 12:07:06 PM
how can i do that?

In line ~988 of your SSI.php file you'll see:

function ssi_login($redirect_to = '', $output_method = 'echo')
{
global $scripturl, $txt, $user_info, $context, $modSettings;

if ($redirect_to != '')
$_SESSION['login_url'] = $redirect_to;


which is the point where the url you want to redirect to is set in the $_SESSION array for SMF to use. Since that's not working for you, for whatever reason, change that code to be this:


function ssi_login($redirect_to = '', $output_method = 'echo')
{
global $scripturl, $txt, $user_info, $context, $modSettings;

if ($redirect_to != '') {
$_SESSION['login_url'] = $redirect_to;
setcookie('login_url', $redirect_to, 0, '/');
    }


So now, when you call ssi_login($login_url) the url you want to be redirected to after login will be set in a cookie called 'login_url'.

In your /Sources/LogInOut.php file you need to modify the Login2() function to check for your cookie and set the redirect url for you (and delete the cookie). In that file, at line ~93 you'll see this code:

function Login2()
{
global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;

// Load cookie authentication stuff.


replace with this:


function Login2()
{
global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;

if (isset($_COOKIE['login_url']) && !empty($_COOKIE['login_url'])) {
        $_SESSION['login_url'] = $_COOKIE['login_url'];
        $_SESSION['old_url']   = $_COOKIE['login_url']; //just in case ;)
        setcookie ('login_url', '', time() - 3600); //delete cookie
}


So now as soon as SMF hits the Login2 function it will check for the existence of your cookie, and put your login url into the SMF $_SESSION variables, then delete the cookie.

So, try making those changes and let me know if it works for you :)
hi i added $_SESSION['old_url'] together with calling my forum ssi.php.
But still, it is not working at all, still redirecting me to my index.php...

but if i add in
<?php
if ($context['user']['is_guest'])
   $_SESSION['old_url']
{
   ssi_login();
}
else
{
   ssi_welcome();
   ssi_logout();
}
?>

it will give me error.


The changes I posted above will only help you redirect people on login. The usage will be like this:

require_once($_SERVER['DOCUMENT_ROOT'] . '/path/to/SSI.php');
ssi_login($redirectUrlGoesHere);

Don't bother messing with the $_SESSION variables anymore; it doesn't look like SMF will have access to them, you're probably in another session with your other site.

This code:

if ($context['user']['is_guest'])
   $_SESSION['old_url']
{
   ssi_login();
}

is malformed. You don't have a semi-colon after $_SESSION['old_url'], you aren't assigning anything to it, and you have the if condition brackets placed after it rather than the if statement.
Try this instead:

if ($context['user']['is_guest'])
{
   ssi_login($myRedirectUrl);
}


You might want to make sure the $context variable is even set first before you use it. If it's not set you'll ALWAYS see the login box even if they are logged in
i don't really get what you mean. but i tried the method you gave me, it still not working.
Visit us at http://rune-cpsv.info


Andre N

Quotei don't really get what you mean. but i tried the method you gave me, it still not working.

By 'not working' you mean it still redirects to SMF's index.php after login? Or you are still getting an error message? Or no login box being drawn?

When you try:

//set redirect url
$redirect_url = 'www.someplace.com';

ssi_login($redirect_url);


and login after making the changes previously given, what is the result?

Does $context have data set in it?

Would it be easier for you to pm me a temporary ftp account and forum account so I can check it out?
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Rune-Cpsv.info

it will still redirect to my main page.
Visit us at http://rune-cpsv.info


Andre N

Ok, I looked at your site.
When I log in from the home page I am redirected to the home page afterwards.
When I log in from the forum I am redirected to the board index after.
You're saying that in both cases you want to be redirected to your forum board index?
What url are you setting in the $redirect_url variable that you pass into the ssi_login() function?
Some things you could try would be setting the variable to '', setting it to http://forum.rune-cpsv.info/index.php, setting it to http://rune-cpsv.info/forum/index.php or http://forum.rune-cpsv.info
if none of those work, undo all the changes I gave you and we'll set up an integration hook to look for this particular redirect and hijack it.
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Rune-Cpsv.info

what i mean is that my other page : donate.php, i log in with an account but it will redirect me to my home page. I want it to redirect to my donate.php page after i log in on donate.php page.
Visit us at http://rune-cpsv.info


Advertisement: