Topic: My own logout link?

Pun 1.2.17 seems to do it differently, what I did before was use

<a href="login.php?action=out&id='.$pun_user['id'].'">Logout</a>

but that doesnt seem to work anymore.

Re: My own logout link?

Right. We added a CSRF token to the logout URL, with the token being a pun_hash of user ID prepended to the current IP.

Re: My own logout link?

What about deleting PunBB's cookie?

Re: My own logout link?

That hasn't changed.
The question wasn't about implementing a logout of PunBB function, it was about making a working logout link for PunBB.

Re: My own logout link?

smarty your on a roll...

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: My own logout link?

I don't understand: Is there a possibility to insert an logout-link at another part of page? What is the code for it?

Thx!

Re: My own logout link?

Yes, it is possible. The code for it is in include/functions.php, in the generate_navlinks function.

Re: My own logout link?

Smartys wrote:

Yes, it is possible. The code for it is in include/functions.php, in the generate_navlinks function.

Thanks, I wrote the part of the array who is for the logout-button in a variable - directly under the define of common.php:

$logout = '<a href="board/login.php?action=out&id='.$pun_user['id'].'&csrf_token='.sha1($pun_user['id'].sha1(get_remote_address())).'">'.$lang_common['Logout'].'</a>';

And I inserted it via echo at the right position. Is this secure?

The only problem I have: If I click logout, I will be refered to the board's page. Is it possible to reload the page where the button is?

Thanks!

Re: My own logout link?

It is secure.

To change the redirect you need to edit login.php.

Re: My own logout link?

Smartys wrote:

To change the redirect you need to edit login.php.

I looked at the login.php, but I don't found the line.
And what is the command to relay to the last page?

Thanks!

Re: My own logout link?

Can someone give me a hint and and show me additionally how to you save the last page (the page where the login/logout-link has been clicked) in order to refer to it?

Thanks!

Re: My own logout link?

functions.php look for generate_navlinks

Re: My own logout link?

kierownik wrote:

functions.php look for generate_navlinks

Thanks, I found it. But I don't have a clou where I have to change the referer.

Re: My own logout link?

you want to change the redirect after they logged out?

Re: My own logout link?

kierownik wrote:

you want to change the redirect after they logged out?

Yes, at login and logout it want to change the redirect to the page visited before loggin in/out.

Re: My own logout link?

That is a whole modification. You have to have something in the database that holds the url, just like punbb 1.3 beta.
I think!

Re: My own logout link?

My idea: You read out the filename of the current file and give over it as a variable (e.g. login.php?link=history.php). The file login.php is checking the variable and uses it (otherwise it will work von the standard way). After loggin in (or out) you make a redirect to the file in the variable. Ain't that possible?

Re: My own logout link?

It is possible, yes.

Re: My own logout link?

kierownik wrote:

It is possible, yes.

And how? wink

Re: My own logout link?

do not know wink roll

21 (edited by Goldex 2008-08-07 10:29)

Re: My own logout link?

I couldn't get it work with the new way either, can someone help me out?

<a href=\"/login.php?action=out&id='.$pun_user['id'].'&csrf_token='.sha1($pun_user['id'].sha1(get_remote_address())).'\">'.$lang_common['Logout'].'</a>

What is wrong with this line?

edit: n/m, I think I got it working:

<a href=\"/web/forum/login.php?action=out&id=".pun_htmlspecialchars($pun_user['id'])."&csrf_token=".sha1($pun_user['id'].sha1(get_remote_address()))."\">'.$lang_common['Logout'].'</a>

22 (edited by volomike 2008-09-27 06:56)

Re: My own logout link?

In my case, I have another page on my site, with forums as a subdirectory. I figured out much of the profile integration for register, edit profile, username, user id, private message link, private message count, forgot password, and a form for logging in. For the logout link, I did it like so:

<?php
define('FORUM_ROOT','forums/');
require_once('forums/config.php');
require_once('forums/include/common.php');
ini_set('error_reporting',6135);

$USERID = $forum_user['id'];
$USERNAME = $forum_user['username'];
$LOGOUT_TOKEN = generate_form_token('logout' . $USERID);

// you may have another way to get your base URL; this is mine
$sScriptName = $_SERVER['SCRIPT_NAME'];
$sBaseName = basename($sScriptName);
$BASE = str_replace($sBaseName,'',$sScriptName);

// your other code goes here
?>
<a href="<?= $BASE ?>forums/login.php?action=out&id=<?= $USERID ?>&csrf_token=<?= $LOGOUT_TOKEN ?>">Logout <?= $USERNAME ?></a>

Tested on PunBB 1.3 RC.