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.
You are not logged in. Please login or register.
PunBB Forums → PunBB 1.2 modifications, plugins and integrations → 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.
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.
What about deleting PunBB's cookie?
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.
smarty your on a roll...
Q
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!
Yes, it is possible. The code for it is in include/functions.php, in the generate_navlinks function.
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!
It is secure.
To change the redirect you need to edit login.php.
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!
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!
functions.php look for generate_navlinks
Thanks, I found it. But I don't have a clou where I have to change the referer.
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.
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!
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?
It is possible, yes.
And how?
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>
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.
PunBB Forums → PunBB 1.2 modifications, plugins and integrations → My own logout link?
Powered by PunBB, supported by Informer Technologies, Inc.