FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Login in and out via the API
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Login in and out via the API [message #31112] Sun, 02 April 2006 20:36 Go to next message
matt(at)bikernight(dot)co(dot)uk is currently offline  matt(at)bikernight(dot)co(dot)uk   United Kingdom
Messages: 20
Registered: March 2006
Karma: 0
Junior Member
HI

I've managed to get my own registration script to insert a corresponding record in the fud registration table using fud_add_user. I've also disabled users from being able to register directly to the fud forum as I want them to use my own registration and login. When a user logins into my site I also call external_fud_login to set the correct information for the forum. Then they log out of my site I also call external_fud_logout.

Is this correct? I think it is.

However, I don't want them to see the logout link within the forum templates. Nor do I want them to be able to view or change their SETTING ( they can if they click on the User_CP link)!

Also if they are NOT logged in and looking at the forums and suddenly decide to post a comment, they are show
"Login Form
ERROR: Insufficient Privileges
Anonymous users are not allowed to create topics."
followed by the fud forum login.

I need them to be redirected to my login.

I'm almost there, just a few things to iron out and I'll have completed my mission. Not bad as I've never coded before.

If anyone can please help, I'd be very greatful.
Matt


Re: Login in and out via the API [message #31119 is a reply to message #31112] Mon, 03 April 2006 13:51 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
matt(at)bikernight(dot)co(dot)uk wrote on Sun, 02 April 2006 16:36

HI

I've managed to get my own registration script to insert a corresponding record in the fud registration table using fud_add_user. I've also disabled users from being able to register directly to the fud forum as I want them to use my own registration and login. When a user logins into my site I also call external_fud_login to set the correct information for the forum. Then they log out of my site I also call external_fud_logout.



That's is correct.

Quote:


However, I don't want them to see the logout link within the forum templates. Nor do I want them to be able to view or change their SETTING ( they can if they click on the User_CP link)!



The simple solution is to edit the usercp.tmpl template and remove the User CP and the Logout links.

Quote:


Also if they are NOT logged in and looking at the forums and suddenly decide to post a comment, they are show
"Login Form
ERROR: Insufficient Privileges
Anonymous users are not allowed to create topics."
followed by the fud forum login.

I need them to be redirected to my login.



The permissions error is handled via invl_inp_err() function inside err.inc.t, change it to redirect the to the desired page.


FUDforum Core Developer
Re: Login in and out via the API [message #31146 is a reply to message #31119] Tue, 04 April 2006 21:11 Go to previous messageGo to next message
matt(at)bikernight(dot)co(dot)uk is currently offline  matt(at)bikernight(dot)co(dot)uk   United Kingdom
Messages: 20
Registered: March 2006
Karma: 0
Junior Member
Hi
Thanks for your original reply.
I'm a little stuck with the redirect that I though would be easy. I found the file and function you told me to, edited the file as below, rebuilt the theme and when I return to the forums I just get a black white screen. So I removed my new code replaced the file and all works. So what have I got wrong?
Please advise.
Ta Matt


function invl_inp_err()
{
#error_dialog('{TEMPLATE: core_err_invinp_title}', '{TEMPLATE: core_err_invinp_err}');
header('Location: http://www.mydomain.co.uk/user/);
exit;
}
Re: Login in and out via the API [message #31166 is a reply to message #31146] Thu, 06 April 2006 02:38 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Don't use # to comment out lines with template code, use /* ... */ or remove the line all together.

FUDforum Core Developer
Re: Login in and out via the API [message #31178 is a reply to message #31166] Thu, 06 April 2006 09:45 Go to previous messageGo to next message
matt(at)bikernight(dot)co(dot)uk is currently offline  matt(at)bikernight(dot)co(dot)uk   United Kingdom
Messages: 20
Registered: March 2006
Karma: 0
Junior Member
OK
I've done that.
I edited the file locally and uploaded via dreamweaver.
I've rebuilt my theme in the admin control panel.

Result is as follows :
Now I get the fud forum login page again!
Better then a white screen but still not my login page! ahhh
Any ideas ?


function invl_inp_err()
{
/* error_dialog('{TEMPLATE: core_err_invinp_title}', '{TEMPLATE: core_err_invinp_err}'); */
header("Location: http://www.mydomain.co.uk/user/");
}


Login Form
ERROR: Insufficient PrivilegesAnonymous users are not allowed to create topics.

You are not logged in. This could be due to one of several reasons: etc

[Updated on: Thu, 06 April 2006 11:31]

Report message to a moderator

Re: Login in and out via the API [message #31191 is a reply to message #31178] Fri, 07 April 2006 00:41 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Inside the std_error() function also add a handler for situations where $type == 'perms'

FUDforum Core Developer
Re: Login in and out via the API [message #31201 is a reply to message #31191] Sat, 08 April 2006 13:09 Go to previous messageGo to next message
matt(at)bikernight(dot)co(dot)uk is currently offline  matt(at)bikernight(dot)co(dot)uk   United Kingdom
Messages: 20
Registered: March 2006
Karma: 0
Junior Member
HI
I've put this inplace (see below) think it's right, I've rebuild my Theme, but I still get the fud login not the one that I need.
I just don't know what I'm doing wrong!
Matt

<?php
/**
* copyright : (C) 2001-2006 Advanced Internet Designs Inc.
* email : forum(at)prohost(dot)org
* $Id: err.inc.t,v 1.51 2005/12/07 18:07:45 hackie Exp $
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
**/

function error_dialog($title, $msg, $level='WARN', $ses=null)
{
if (!$ses) {
$ses = (int) $GLOBALS['usr']->sid;
}

$error_msg = '[Error] '.$title.'<br />';
$error_msg .= '[Message Sent to User] '.trim($msg).'<br />';
$error_msg .= '[User IP] '.get_ip().'<br />';
$error_msg .= '[Requested URL] http://';
$error_msg .= isset($_SERVER['HTTP_HOST']) ? htmlspecialchars($_SERVER['HTTP_HOST']) : '';
$error_msg .= isset($_SERVER['REQUEST_URI']) ? htmlspecialchars($_SERVER['REQUEST_URI']) : '';
$error_msg .= !empty($_POST) ? '<br />[Post-Data] '.base64_encode(serialize($_POST)) : '';
$error_msg .= '<br />';

if (isset($_SERVER['HTTP_REFERER'])) {
$error_msg .= '[Referring Page] '.htmlspecialchars($_SERVER['HTTP_REFERER']).'<br />';
}
$pfx = sprintf("?%-10d?%-10d?", strlen($error_msg) + 1, __request_timestamp__);
ini_set('log_errors_max_len', 0);
error_log($pfx.$error_msg."\n", 3, $GLOBALS['ERROR_PATH'].'fud_errors');

/* no need to redirect, we just want to log the error */
if ($level == 'ATCH') {
return;
}

ses_putvar($ses, array('er_msg' => $msg, 'err_t' => $title));

if (is_int($ses)) {
if ($GLOBALS['FUD_OPT_2'] & 32768) {
header('Location: {FULL_ROOT}{ROOT}/e/'._rsidl);
} else {
header('Location: {FULL_ROOT}{ROOT}?t=error&'._rsidl);
}
} else {
if ($GLOBALS['FUD_OPT_2'] & 32768) {
header('Location: {FULL_ROOT}{ROOT}/e/0/'.$ses);
} else {
header('Location: {FULL_ROOT}{ROOT}?t=error&S='.$ses);
}
}
exit;
}

function std_error($type)
{


if (!isset($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = 'unknown';
}

$ses_id = s;
$usr_d->email = $GLOBALS['usr']->email;

if ($type == 'login') {
if (__fud_real_user__) {
$type = 'perms';
} else {
ses_anonuser_auth($GLOBALS['usr']->sid, '{TEMPLATE: ERR_login_msg}');
}
}

if ($type == 'perms'){
header("Location: http://www.bikernight.co.uk/user/");
exit;
}

$err_array = array(
'ERR_disabled'=>array('{TEMPLATE: ERR_disabled_ttl}', '{TEMPLATE: ERR_disabled_msg}'),
'ERR_access'=>array('{TEMPLATE: ERR_access_ttl}', '{TEMPLATE: ERR_access_msg}'),
'ERR_registration_disabled'=>array('{TEMPLATE: ERR_registration_disabled_ttl}', '{TEMPLATE: ERR_registration_disabled_msg}'),
'ERR_user'=>array('{TEMPLATE: ERR_user_ttl}', '{TEMPLATE: ERR_user_msg}'),
'ERR_perms'=>array('{TEMPLATE: permission_denied_title}', '{TEMPLATE: permission_denied_msg}'),
'ERR_systemerr'=>array('{TEMPLATE: ERR_systemerr_ttl}', '{TEMPLATE: ERR_systemerr_msg}'),
'ERR_emailconf'=>array('{TEMPLATE: ERR_emailconf_ttl}', '{TEMPLATE: ERR_emailconf_msg}')
);

if (isset($err_array['ERR_'.$type])) {
$err = $err_array['ERR_'.$type];
error_dialog($err[0], $err[1]);
}
error_dialog('{TEMPLATE: err_inc_criticaltitle}', '{TEMPLATE: err_inc_criticalmsg}');
}

function invl_inp_err()
{
/* error_dialog('{TEMPLATE: core_err_invinp_title}', '{TEMPLATE: core_err_invinp_err}'); */
header("Location: http://www.bikernight.co.uk/user/");
exit;
}
?>
Re: Login in and out via the API [message #31214 is a reply to message #31201] Sun, 09 April 2006 17:28 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You need to add handling in the ses_anonuser_auth() case as well.

FUDforum Core Developer
Re: Login in and out via the API [message #31217 is a reply to message #31214] Sun, 09 April 2006 18:02 Go to previous messageGo to next message
matt(at)bikernight(dot)co(dot)uk is currently offline  matt(at)bikernight(dot)co(dot)uk   United Kingdom
Messages: 20
Registered: March 2006
Karma: 0
Junior Member
Hello
Thanks for the helps so far.
I've done what you said, but I still fail to get this work, so can I check a few things.

firstly I'm editing the file \forum-data\src\err.inc.t
This is the correct file right?

secondly this file contains the changes that I belive I'm supposed to be making shown in bold below?

Then I upload the file and rebuild my Theme.
I do this but I get no joy!
Cheers Matt


function std_error($type)
{


if (!isset($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = 'unknown';
}

$ses_id = s;
$usr_d->email = $GLOBALS['usr']->email;

if ($type == 'login') {
if (__fud_real_user__) {
$type = 'perms';
} else {
/* ses_anonuser_auth($GLOBALS['usr']->sid, '{TEMPLATE: ERR_login_msg}'); */
header("Location: http://www.bikernight.co.uk/user/");
exit;

}
}

if ($type == 'perms'){
header("Location: http://www.bikernight.co.uk/user/");
exit;
}


$err_array = array(
'ERR_disabled'=>array('{TEMPLATE: ERR_disabled_ttl}', '{TEMPLATE: ERR_disabled_msg}'),
'ERR_access'=>array('{TEMPLATE: ERR_access_ttl}', '{TEMPLATE: ERR_access_msg}'),
'ERR_registration_disabled'=>array('{TEMPLATE: ERR_registration_disabled_ttl}', '{TEMPLATE: ERR_registration_disabled_msg}'),
'ERR_user'=>array('{TEMPLATE: ERR_user_ttl}', '{TEMPLATE: ERR_user_msg}'),
'ERR_perms'=>array('{TEMPLATE: permission_denied_title}', '{TEMPLATE: permission_denied_msg}'),
'ERR_systemerr'=>array('{TEMPLATE: ERR_systemerr_ttl}', '{TEMPLATE: ERR_systemerr_msg}'),
'ERR_emailconf'=>array('{TEMPLATE: ERR_emailconf_ttl}', '{TEMPLATE: ERR_emailconf_msg}')
);

if (isset($err_array['ERR_'.$type])) {
$err = $err_array['ERR_'.$type];
error_dialog($err[0], $err[1]);
}
error_dialog('{TEMPLATE: err_inc_criticaltitle}', '{TEMPLATE: err_inc_criticalmsg}');
}


function invl_inp_err()
{
/* error_dialog('{TEMPLATE: core_err_invinp_title}', '{TEMPLATE: core_err_invinp_err}'); */
header("Location: http://www.bikernight.co.uk/user/");
exit;
}



Re: Login in and out via the API [message #31237 is a reply to message #31217] Mon, 10 April 2006 21:09 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
The change appear to be correct, on what page do you see login error being generated and not redirect to the desired page?

FUDforum Core Developer
Re: Login in and out via the API [message #31242 is a reply to message #31237] Mon, 10 April 2006 21:28 Go to previous messageGo to next message
matt(at)bikernight(dot)co(dot)uk is currently offline  matt(at)bikernight(dot)co(dot)uk   United Kingdom
Messages: 20
Registered: March 2006
Karma: 0
Junior Member
I simply look at the live forum postings, go to reply or create a new topic and then I get the fud login page!
Matt
Re: Login in and out via the API [message #31245 is a reply to message #31242] Tue, 11 April 2006 14:52 Go to previous messageGo to next message
matt(at)bikernight(dot)co(dot)uk is currently offline  matt(at)bikernight(dot)co(dot)uk   United Kingdom
Messages: 20
Registered: March 2006
Karma: 0
Junior Member
Lets check that I am seein the correct template from my chosen theme. I'll make a small textual change to the fud login screen just to check, can you advise which template this is?
ta Matt
Re: Login in and out via the API [message #31263 is a reply to message #31245] Thu, 13 April 2006 10:48 Go to previous messageGo to next message
matt(at)bikernight(dot)co(dot)uk is currently offline  matt(at)bikernight(dot)co(dot)uk   United Kingdom
Messages: 20
Registered: March 2006
Karma: 0
Junior Member
ok .. well I started from scratch, installed a new competely new version fud forum in totally different directorys.

Went through the steps above and hit the same old problem. That's seven days of tinkering and still no joy, call me sad .. but I gave up.

I've now modify the headers to redirect any non-registered users to my login page! Simple and dirty!

Kinda sucks. I don't like it.

If anyone has managed to get their non registered users to their very own registration page (not the FUD page), please please please reply to this post and let me know how you did it.
Cheers Matt
Re: Login in and out via the API [message #31285 is a reply to message #31245] Fri, 14 April 2006 20:50 Go to previous message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
The login template is login.tmpl

FUDforum Core Developer
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Importing archive mailing lists (existing mailing lists) into FUDforum
Next Topic: File permissions
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 19:59:42 GMT 2024

Total time taken to generate the page: 0.02128 seconds