PDA

View Full Version : After an Action Redirecting


alexwriting
04-15-2002, 08:05 PM
Hi Everyone,

After subscribing to a thread or a Forum, it redirects you back. Within the program, what contols that? How would I write it to redirect and log out?

I think it has something to do with this code in the member2.php file:

eval("standardredirect(\"".gettemplate("redirect_subsadd")."\",\"\$url\");");


Thanks,

Alex

tubedogg
04-16-2002, 12:46 AM
You want to be automatically logged out after subscribing to a thread?

alexwriting
04-16-2002, 01:09 AM
Hi Tubedogg,


Thanks for replying!! :) :) Yes, that's right. How to rewrite it so that it subscribes you, but then you come back logged out.

All the best,

Alex

Mike Sullivan
04-16-2002, 03:15 PM
The $url variable is dynamic -- it varies based on where you last came from.

If you replace the:

\$url

in that line (yes, include the \), with:

member.php?action=logout&s=\$session[sessionhash]

it should work.

eval("standardredirect(\"".gettemplate("redirect_subsadd")."\",\"member.php?acti on=logout&s=\$session[sessionhash]\");");

alexwriting
04-16-2002, 07:03 PM
Hi Ed,

That's what I wanted :) But, I think we both overlooked one detail. Because the subscription process includes the .gettemplate("redirect_subsadd") as the second to last step, the logout works great, and the return too, but that .gettemplate("redirect_subsadd") is the returned to location, which then goes to the logout, which then goes to the... and it gets in a loop. How would I write it so it redirects back ?2? places, instead of just to the immediately previous location

Many, many thanks, :) :) :)

Alex

Mike Sullivan
04-16-2002, 09:37 PM
Logging out shouldn't be a redirect, and the template that is used to say you're now logged out -- error_cookieclear -- doesn't have any references to $url, so that shouldn't be happening. Have you hacked logging out so it redirects as well?

alexwriting
04-16-2002, 09:56 PM
Dr. E,

Of course you were right. :classic: I had. Took that out. Now, it subscribes them, and they finish at the "All cookies cleared. Click here to return to the forums index." What would I need to add to have it redirect them back as the last step?

Thanks, :):) :)

Alex

Mike Sullivan
04-16-2002, 10:03 PM
Presumably, if you change the subscription redirection to include $url:

eval("standardredirect(\"".gettemplate("redirect_subsadd")."\",\"member.php?action=logout&url=\$url&s=\$session[sessionhash]\");");

Then put your $url-dependent logout code back in, it should work. No guarantees though. :)

alexwriting
04-17-2002, 05:00 PM
Hey Dr. E,

I had used this one for the logout

https://vborg.vbsupport.ru/showthread.php?s=&threadid=24889.

That's the only hack I have right now. Everything else is native.

Added that back with your new code, but still got subscribe, logout then stop there, no redirect. Tried to rewrite it a few other ways, but came up empty :P Any other way to write it? I can remove that hack if it will help.

Thanks, :) :) :)

Alex

Admin
04-17-2002, 05:55 PM
You can also stick the code from member.php's logout action in member2.php, and change the redirect to a standarderror. If you need more info let me know. :)

(and stop with all the smilies, makes the page load slower ;) j/k)

alexwriting
04-18-2002, 12:53 AM
Hi FireFly,

Wow, thanks for replying! smile, smile, smile, ;)

The closest I got was, subscribe, log out and then the redirect code broke into the top of the screen. Darn... close! Any suggestions?

Thanks,

Alex

Admin
04-18-2002, 10:36 AM
Try this, not tested but should work.

In member2.php replace this:
if (!$checkid=$DB_site->query_first("SELECT $tableid FROM $table WHERE userid=$bbuserinfo[userid] AND $typeid=".intval($id))) {
$id=verifyid($type,$id);
$DB_site->query("INSERT INTO $table ($tableid,userid,$typeid) VALUES (NULL,$bbuserinfo[userid],".intval($id).")");
}

$url = str_replace("\"", "", $url);
eval("standardredirect(\"".gettemplate("redirect_subsadd")."\",\"\$url\");");
With this:
if (!$checkid=$DB_site->query_first("SELECT $tableid FROM $table WHERE userid=$bbuserinfo[userid] AND $typeid=".intval($id))) {
$id=verifyid($type,$id);
$DB_site->query("INSERT INTO $table ($tableid,userid,$typeid) VALUES (NULL,$bbuserinfo[userid],".intval($id).")");
}

vbsetcookie("bbuserid","",1);
vbsetcookie("bbpassword","",1);
vbsetcookie("bbstyleid","",1);

if ($bbuserinfo[userid]!=0 and $bbuserinfo[userid]!=-1) {
$DB_site->query("UPDATE user SET lastactivity='".(time()-$cookietimeout)."',lastvisit='".time()."' WHERE userid='$bbuserinfo[userid]'");
}

//$DB_site->query("UPDATE session SET userid=0 WHERE sessionhash='".addslashes($session[sessionhash])."'");
$DB_site->query("DELETE FROM session WHERE sessionhash='".addslashes($session[dbsessionhash])."'");
// make sure any other of this user's sessions are deleted (incase they ended up with more than one)
$DB_site->query("DELETE FROM session WHERE userid='$bbuserinfo[userid]'");

$session['sessionhash']=md5(uniqid(microtime()));
$session['dbsessionhash']=$session['sessionhash'];
$DB_site->query("INSERT INTO session (sessionhash,userid,host,useragent,lastactivity,st yleid) VALUES ('".addslashes($session['sessionhash'])."','0','".addslashes($session['host'])."','".addslashes($session['useragent'])."','".time()."','0')");
vbsetcookie("sessionhash",$session['sessionhash'],0);

eval("standarderror(\"".gettemplate("redirect_subsadd")."\");");