Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
User Authentication Class #312798
01/19/2007 3:59 PM
01/19/2007 3:59 PM
Joined: Jan 2003
Posts: 3,765
Saint Johns, PA
I
Ian Spence Offline OP
Master Hacker
Ian Spence  Offline OP
Master Hacker
I

Joined: Jan 2003
Posts: 3,765
Saint Johns, PA
Attached is the file. Rename it user_auth.inc.php and throw it in the includes directory of your forums.

Then just require the file and use it as follows
PHP Code
// Usage:

$userob = new user_auth();

// Am I logged in?
if( $userob->is_logged_in ) {
	// I am logged in
}

// Am I in group 3?
if( $userob->in_group( 3 ) ) {
	// Why, yes we are
}

// Who cares what group I'm in! I wanna know
// if I can read a topic from forum 7
if( $userob->check_access( 7, "read" ) ) {
	// Apparently I can
}

// What if I want to know if I'm an administrator
if( $userob->fields['USER_MEMBERSHIP_LEVEL'] == "Administrator" ) {
	// That means I'm teh uber user	
}

// Want to create a welcome message?
if( $userob->is_logged_in ) {
	if( $userob->is_banned ) {
		echo "Go away, " . $userob->fields['USER_DISPLAY_NAME'];
	} else {
		echo "Welcome, " . $userob->fields['USER_DISPLAY_NAME'];
	}
} else {
	echo "Please register";
} 


Note that $userob->fields is the same as the $user you've been using before, just wanted to not have two different variables hanging around

If you have any problems, it could be due to some paths being off, but the php error will explain that

Attached Files
2389-user_auth.txt (183 downloads)
Sponsored Links
Re: User Authentication Class [Re: Ian Spence] #312801
01/19/2007 6:00 PM
01/19/2007 6:00 PM
Joined: Mar 2000
Posts: 25,587
Texas
AllenAyres Offline
I type Like navaho
AllenAyres  Offline
I type Like navaho

Joined: Mar 2000
Posts: 25,587
Texas
Grazie Ian thumbsup


- Allen wavey
- What Drives You?
Re: User Authentication Class [Re: AllenAyres] #312806
01/19/2007 6:59 PM
01/19/2007 6:59 PM
Joined: Jan 2000
Posts: 5,941
Portland, OR, USA
Gizmo Offline

UBB.Dev / UBB.Wiki Owner
Time Lord
Gizmo  Offline

UBB.Dev / UBB.Wiki Owner
Time Lord

Joined: Jan 2000
Posts: 5,941
Portland, OR, USA
Looks awesome :), can't wait to get some time to fiddle hehe


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, UBB.SitemapsJames Corthell
Re: User Authentication Class [Re: Ian Spence] #312808
01/19/2007 8:03 PM
01/19/2007 8:03 PM
Joined: Dec 2002
Posts: 71
Calpy Offline
Power User
Calpy  Offline
Power User

Joined: Dec 2002
Posts: 71
Hi, thanks for the code! As usual, I'm trying to do something weird with things and have a little prob:

I get this error message:
Fatal error: Cannot instantiate non-existent class: userauth in /home/XXXX/public_html/wiki/extensions/ubbt_auth_mod.php on line 24

I have tow domains set up like this:
www.hairfacts.com
www.hairtell.com (which is actually located at www.hairfacts.com/hairtell)

I'm trying to make people have to be logged into the forum at www.hairtell.com/forum before they can access an editing page at www.hairfacts.com/wiki

I know usually this wouldn't work cross-domain, but since hairtell.com is actually a folder inside hairfacts.com, I thought it might work. It actually includes the files, and recognizes the sql class, but dies on the "userauth" class. I also don't know why it's showing "userauth" in lowercase letters in the error message, since it's declared and called like "UserAuth"

Any thoughts? =)

Re: User Authentication Class [Re: Calpy] #312810
01/19/2007 8:29 PM
01/19/2007 8:29 PM
Joined: Mar 2000
Posts: 25,587
Texas
AllenAyres Offline
I type Like navaho
AllenAyres  Offline
I type Like navaho

Joined: Mar 2000
Posts: 25,587
Texas
I'll bet it's the cross-domain issue.


- Allen wavey
- What Drives You?
Sponsored Links
Re: User Authentication Class [Re: AllenAyres] #312812
01/19/2007 8:44 PM
01/19/2007 8:44 PM
Joined: Jan 2000
Posts: 5,941
Portland, OR, USA
Gizmo Offline

UBB.Dev / UBB.Wiki Owner
Time Lord
Gizmo  Offline

UBB.Dev / UBB.Wiki Owner
Time Lord

Joined: Jan 2000
Posts: 5,941
Portland, OR, USA
Yes, the cookies belong to one domain, security won't allow it to run on a seperate domain properly, imo

Last edited by Gizmo; 01/19/2007 8:45 PM.

UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, UBB.SitemapsJames Corthell
Re: User Authentication Class [Re: Gizmo] #312813
01/19/2007 8:57 PM
01/19/2007 8:57 PM
Joined: Dec 2002
Posts: 71
Calpy Offline
Power User
Calpy  Offline
Power User

Joined: Dec 2002
Posts: 71
The cookies are an issue, definitely. I wonder why it's seeing the UserAuth class as non-existant, though. Its existance wouldn't be tied to a cookie issue...

Re: User Authentication Class [Re: Calpy] #312814
01/19/2007 9:05 PM
01/19/2007 9:05 PM
Joined: Jan 2000
Posts: 5,941
Portland, OR, USA
Gizmo Offline

UBB.Dev / UBB.Wiki Owner
Time Lord
Gizmo  Offline

UBB.Dev / UBB.Wiki Owner
Time Lord

Joined: Jan 2000
Posts: 5,941
Portland, OR, USA
As long as the URLs are properly set in the userauth.php file, and the path to said file is proper, it should work :scratches head:


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, UBB.SitemapsJames Corthell
Re: User Authentication Class [Re: Gizmo] #312816
01/20/2007 12:36 AM
01/20/2007 12:36 AM
Joined: Nov 2001
Posts: 11,330
Charlotte, NC
JoshPet Offline
I type Like navaho
JoshPet  Offline
I type Like navaho

Joined: Nov 2001
Posts: 11,330
Charlotte, NC
$userob = new UserAuth();
appears before line 24 in public_html/wiki/extensions/ubbt_auth_mod.php ?

The error message returning the class name in lowercase is a PHP bug which has been fixed I think in the latest PHP. So I don't think that's your problem.

Re: User Authentication Class [Re: Ian Spence] #313532
03/14/2007 9:08 AM
03/14/2007 9:08 AM
Joined: Feb 2007
Posts: 330
The Netherlands
B
blaaskaak Offline
Yarp™
blaaskaak  Offline
Yarp™
B

Joined: Feb 2007
Posts: 330
The Netherlands
Originally Posted by Ian Spence
if( $userob->check_access( 7, "read" ) ) {
// Apparently I can


The authentication works like a charm, but I do have troubles with this one.

It worked yesterday evening, and suddenly stopped working. After puzzling around for a while, finally it was fixed by updating the permissions from the control panel.

No changes or anything, just hit the update button.

Edit: It happened again. I commented out the caching check and it seems to work stable now.
Code
		//if( ! $data ) {
			$this->build_permissions();
			return true;
//		}

Last edited by blaaskaak; 03/14/2007 11:34 AM.

[Linked Image]
Sponsored Links
Re: User Authentication Class [Re: blaaskaak] #313890
04/17/2007 11:15 AM
04/17/2007 11:15 AM
Joined: Feb 2007
Posts: 330
The Netherlands
B
blaaskaak Offline
Yarp™
blaaskaak  Offline
Yarp™
B

Joined: Feb 2007
Posts: 330
The Netherlands
When a user has a valid cookie file, but that account was deleted, this class also gives an error at line 78.

Code
foreach( $temp as $k => $v ) {


[Linked Image]
Re: User Authentication Class [Re: blaaskaak] #313905
04/19/2007 4:16 PM
04/19/2007 4:16 PM
Joined: Jan 2003
Posts: 3,765
Saint Johns, PA
I
Ian Spence Offline OP
Master Hacker
Ian Spence  Offline OP
Master Hacker
I

Joined: Jan 2003
Posts: 3,765
Saint Johns, PA
Updated first post to address all bugs mentioned. Note that the class was renamed to work with a bug in php (it's now user_auth, not UserAuth)

Re: User Authentication Class [Re: Ian Spence] #314160
05/21/2007 4:26 PM
05/21/2007 4:26 PM
Joined: Feb 2007
Posts: 330
The Netherlands
B
blaaskaak Offline
Yarp™
blaaskaak  Offline
Yarp™
B

Joined: Feb 2007
Posts: 330
The Netherlands
Originally Posted by Ian Spence
Updated first post to address all bugs mentioned. Note that the class was renamed to work with a bug in php (it's now user_auth, not UserAuth)


Thanks for the fixes! I use this one extensively in just about every supporting script I have running here!


[Linked Image]
Re: User Authentication Class [Re: Ian Spence] #315115
08/08/2007 7:13 PM
08/08/2007 7:13 PM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline

Beta Tester
Mark_S  Offline

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
Now here is a surprise !
Its not working for me? It seems that its not picking up on $userob.

File saved and uploaded into forums/includes folder as user_auth.inc.php
Paths updated
New file with simple test code

PHP Code


file test-auth.php 
<?php
include ('forums/includes/user_auth.inc.php');
echo "test auth <br />";

$userob = new user_auth();

// Am I logged in?
if( $userob->is_logged_in ) {
echo "you are logged in";
}

?>


 

Out put only my first test echo of test auth

If i'm logged in or not the result is the same?
ive tried full paths and relative paths frown
If they are wrong i do get the php error so they are correct.
Humm what could be wrong?

Help << i'm stuck.

Aso if i run the file with all of the examples in the first post,
i get this error which made me use the test text.

Quote
$userob = new user_auth();

// Am I logged in?
if( $userob->is_logged_in ) {
// I am logged in
}

// Am I in group 3?
if( $userob->in_group( 3 ) ) {
// Why, yes we are
}

// Who cares what group I'm in! I wanna know
// if I can read a topic from forum 7
if( $userob->check_access( 7, "read" ) ) {
// Apparently I can
}

// What if I want to know if I'm an administrator
if( $userob->fields['USER_MEMBERSHIP_LEVEL'] == "Administrator" ) {
// That means I'm teh uber user
}

// Want to create a welcome message?
if( $userob->is_logged_in ) {
if( $userob->is_banned ) {
echo "Go away, " . $userob->fields['USER_DISPLAY_NAME'];
} else {
echo "Welcome, " . $userob->fields['USER_DISPLAY_NAME'];
}
} else {
echo "Please register";
}


Warning: in_array() [function.in-array]: Wrong datatype for second argument in forums/includes/user_auth.inc.php on line 202

Whats wrong ?

Thanks for any help as always wink


BOOM 7.6.+ rocks....
Re: User Authentication Class [Re: Mark_S] #315144
08/10/2007 6:34 AM
08/10/2007 6:34 AM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline

Beta Tester
Mark_S  Offline

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
In my best Penelope Pit stop voice

Any one ?
Helllp


BOOM 7.6.+ rocks....
Re: User Authentication Class [Re: Mark_S] #315148
08/10/2007 1:36 PM
08/10/2007 1:36 PM
Joined: Mar 2000
Posts: 25,587
Texas
AllenAyres Offline
I type Like navaho
AllenAyres  Offline
I type Like navaho

Joined: Mar 2000
Posts: 25,587
Texas
hmmm, it could use some 'or die' statements to show where it's failing, tho I guess if it doesn't print any of them none of them are working.

I would first double-check the path/url posted to the top - some servers want full paths/urls to the include file, not a relative one - this could be why it's not printing any results.


- Allen wavey
- What Drives You?
Re: User Authentication Class [Re: AllenAyres] #315151
08/10/2007 2:01 PM
08/10/2007 2:01 PM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline

Beta Tester
Mark_S  Offline

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
PHP Version 5.2.2

im using full paths in all instances wink


ive chopped out the full path in my example

/home/cwcom/domains/xxxxx.co.uk/public_html/forums

include ('/home/xxxxx/domains/xxxxxxxx.co.uk/public_html/forums/includes/user_auth.inc.php');


the 2 paths in the /includes folder are also correct.

require_once( "/home/xxxxx/domains/xxxxxxx.co.uk/public_html/forums/includes/config.inc.php" );
require_once( "/home/xxxxx/domains/xxxxxx.co.uk/public_html/forums/libs/mysql.inc.php" );

Last edited by Mark_S; 08/10/2007 2:02 PM.

BOOM 7.6.+ rocks....
Re: User Authentication Class [Re: Mark_S] #315158
08/11/2007 7:09 AM
08/11/2007 7:09 AM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline

Beta Tester
Mark_S  Offline

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
any little scripts i can try to start to debug this ?


BOOM 7.6.+ rocks....
Re: User Authentication Class [Re: Mark_S] #315161
08/11/2007 8:32 AM
08/11/2007 8:32 AM
Joined: Mar 2000
Posts: 25,587
Texas
AllenAyres Offline
I type Like navaho
AllenAyres  Offline
I type Like navaho

Joined: Mar 2000
Posts: 25,587
Texas
Good question - Ian may be your only hope, I haven't tried this one but if it works for others it should work for you.


- Allen wavey
- What Drives You?
Re: User Authentication Class [Re: AllenAyres] #315165
08/11/2007 8:49 PM
08/11/2007 8:49 PM
Joined: Jan 2003
Posts: 3,765
Saint Johns, PA
I
Ian Spence Offline OP
Master Hacker
Ian Spence  Offline OP
Master Hacker
I

Joined: Jan 2003
Posts: 3,765
Saint Johns, PA
Find:
Code
function UserAuth() {


Replace with:
Code
function user_auth() {


The constructor didn't get renamed when I renamed the class. I can't wait until Threads stops supporting PHP 4.X

Re: User Authentication Class [Re: Ian Spence] #315167
08/11/2007 10:46 PM
08/11/2007 10:46 PM
Joined: Jan 2000
Posts: 5,941
Portland, OR, USA
Gizmo Offline

UBB.Dev / UBB.Wiki Owner
Time Lord
Gizmo  Offline

UBB.Dev / UBB.Wiki Owner
Time Lord

Joined: Jan 2000
Posts: 5,941
Portland, OR, USA
Originally Posted by Ian Spence
The constructor didn't get renamed when I renamed the class. I can't wait until Threads stops supporting PHP 4.X
Talked to Rick about that, he said that anything like that would be far off smirk


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, UBB.SitemapsJames Corthell
Re: User Authentication Class [Re: Gizmo] #315182
08/13/2007 12:20 AM
08/13/2007 12:20 AM
Joined: Mar 2000
Posts: 25,587
Texas
AllenAyres Offline
I type Like navaho
AllenAyres  Offline
I type Like navaho

Joined: Mar 2000
Posts: 25,587
Texas
Not much after Dec 31, eh? wink


- Allen wavey
- What Drives You?
Re: User Authentication Class [Re: AllenAyres] #315230
08/16/2007 3:15 PM
08/16/2007 3:15 PM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline

Beta Tester
Mark_S  Offline

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
Originally Posted by Ian Spence
Find:
Code
function UserAuth() {


Replace with:
Code
function user_auth() {


The constructor didn't get renamed when I renamed the class. I can't wait until Threads stops supporting PHP 4.X


Done but still not working. ??

Snip it from the includes file.
PHP Code


class user_auth {
	var $fields;
	var $is_logged_in;
	var $permissions;
	var $is_banned;
	var $groups;

	function user_auth() {
		global $config, $dbh;

		// First, the stupid stuff we do in every constructor


 


My page is test.php
PHP Code

<?php
include ('/home/xxxxx/domains/xxxxxxxxx/public_html/forums/includes/user_auth.inc.php');

// Want to create a welcome message? 
if( $userob->is_logged_in ) { if( $userob->is_banned ) { echo "Go away, " . $userob->fields['USER_DISPLAY_NAME']; } else { echo "Welcome, " . $userob->fields['USER_DISPLAY_NAME']; } } else { echo "Please register<br />"; } 
echo "Script has ran. <br />";
?>



1. I am logged into my forums
2. Output = "Please register"
3. No errors out put ??

I cant understand what's wrong?

Its there a die script i can do for the sql?
To see where its failing??

Thanks for the help and assistance as always. wink


BOOM 7.6.+ rocks....
Re: User Authentication Class [Re: Mark_S] #315231
08/16/2007 3:23 PM
08/16/2007 3:23 PM
Joined: Nov 2003
Posts: 491
SoCal
S
sirdude Offline
Enthusiast
sirdude  Offline
Enthusiast
S

Joined: Nov 2003
Posts: 491
SoCal
$userob = new user_auth();

needs to be there, before you can start using the class.. :2c:

PHP Code



<?php
include ('../libs/forums/includes/user_auth.inc.php');

// Instantiate the user auth class as muhaha, for example
$muhaha = new user_auth();	 // w00t, yah baby :rawk:

// Want to create a welcome message? 
if( $muhaha->is_logged_in ) { 
  if( $muhaha->is_banned ) { 
	echo "*cough* be gone, " . $muhaha->fields['USER_DISPLAY_NAME']; 
  } 
else { 
  echo "Waaazzaaaap, " . $muhaha->fields['USER_DISPLAY_NAME']; 
  } 
} else { echo "Please register<br />"; 
  } 
echo "Veni, vidi, vici!! <br />";
?>



of course, use 'userob' for your case. i just kinda like 'muhaha' laugh

Re: User Authentication Class [Re: sirdude] #315285
08/19/2007 4:13 AM
08/19/2007 4:13 AM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline

Beta Tester
Mark_S  Offline

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
Sweet that works wink

Thanks for getting back smile

looks like i was missing the

$muhaha = new user_auth(); // w00t, yah baby :rawk:
in my protected page wink

Thanks again.
i laughed at the outputs lol


BOOM 7.6.+ rocks....
Re: User Authentication Class [Re: Mark_S] #316733
02/19/2008 3:39 PM
02/19/2008 3:39 PM
Joined: Nov 2003
Posts: 331
UK
M
Mark_S Offline

Beta Tester
Mark_S  Offline

Beta Tester
M

Joined: Nov 2003
Posts: 331
UK
Will this work in 7.3 ??


BOOM 7.6.+ rocks....
Chat Profile:Need convert user_name to user_number [Re: Mark_S] #316842
04/07/2008 3:31 AM
04/07/2008 3:31 AM
Joined: Feb 2008
Posts: 11
C
curiousguy Offline
Newbie
curiousguy  Offline
Newbie
C

Joined: Feb 2008
Posts: 11
For chat integration, the chat should be able to call up the ubb profile of a user.

This is complicated by the fact that these are not organized by user name but by number.

Can you please post a conversion routine from user name to user number?
Or a routine that outputs the profile but uses user name as input?
Or even better, both of the above?


I post this here in the midst of this thread, as this is intrinsically related to user authentication, and actually a by-product of the user authentication code. Whoever needs user authentication for an external product like a chat could use a user profile link.

And like Mark_S, I am curious if all this will work for 7.3

Thank you


Re: Chat Profile:Need convert user_name to user_number [Re: curiousguy] #316843
04/07/2008 11:38 AM
04/07/2008 11:38 AM
Joined: Feb 2007
Posts: 330
The Netherlands
B
blaaskaak Offline
Yarp™
blaaskaak  Offline
Yarp™
B

Joined: Feb 2007
Posts: 330
The Netherlands
This works in 7.3, except for the permission reading stuff. That has changed. If you need that, like I do, this script would have to be updated.

A query that gets a username if you only have a number is easy.

Code
select ubbt_USER_DISPLAY_NAME from ubbt_USERS where USER_ID = 50


[Linked Image]
Re: Chat Profile:Need convert user_name to user_number [Re: blaaskaak] #316846
04/08/2008 9:09 AM
04/08/2008 9:09 AM
Joined: Mar 2000
Posts: 25,587
Texas
AllenAyres Offline
I type Like navaho
AllenAyres  Offline
I type Like navaho

Joined: Mar 2000
Posts: 25,587
Texas
Thanks Yarp! smile


- Allen wavey
- What Drives You?
Re: Chat Profile:Need convert user_name to user_number [Re: blaaskaak] #316955
05/12/2008 7:46 AM
05/12/2008 7:46 AM
Joined: Feb 2007
Posts: 330
The Netherlands
B
blaaskaak Offline
Yarp™
blaaskaak  Offline
Yarp™
B

Joined: Feb 2007
Posts: 330
The Netherlands
Originally Posted by blaaskaak
This works in 7.3,


FYI: It does *NOT* work. It might have when I tested it a while ago, but it doesn't work anymore now.


[Linked Image]
Re: User Authentication Class [Re: blaaskaak] #316956
05/12/2008 12:43 PM
05/12/2008 12:43 PM
Joined: Feb 2007
Posts: 330
The Netherlands
B
blaaskaak Offline
Yarp™
blaaskaak  Offline
Yarp™
B

Joined: Feb 2007
Posts: 330
The Netherlands
Originally Posted by blaaskaak
FYI: It does *NOT* work. It might have when I tested it a while ago, but it doesn't work anymore now.


okay, got it working again. If you are in desperate need for it, pm me, since my fixes are far from neat. I just plunged through it and tried stuff till I got it working.

Also, the forum permissions stuff is all disabled in my fix.


[Linked Image]
Re: User Authentication Class [Re: Ian Spence] #317385
07/08/2008 5:53 AM
07/08/2008 5:53 AM
Joined: Sep 1999
Posts: 97
Sydney, Australia
M
Myke Offline
Power User
Myke  Offline
Power User
M

Joined: Sep 1999
Posts: 97
Sydney, Australia
PHP Code
// Am I in group 3?
if( $userob->in_group( 3 ) ) {
	// Why, yes we are
} 


Is anyone out there using the in_group check successfully? I'm running 7.2.2 and it doesn't seem to work for me.

I've got a simple conditional check:

PHP Code
if ($userob->is_logged_in ) {
  if (in_array($userob->fields['USER_ID'], $authors)) {
	// Allow specific IDs
	$allow = 1;
  } elseif ($userob->in_group(5)) {
	// Allow members in Group 5
	$allow = 1;
  } else {
	// Not allowed
	$allow = 0;
  }
} 


which fails, even though a user is part of group id 5. The individual ID check works fine though.

Re: User Authentication Class [Re: Myke] #317386
07/08/2008 9:04 AM
07/08/2008 9:04 AM
Joined: Jan 2000
Posts: 5,941
Portland, OR, USA
Gizmo Offline

UBB.Dev / UBB.Wiki Owner
Time Lord
Gizmo  Offline

UBB.Dev / UBB.Wiki Owner
Time Lord

Joined: Jan 2000
Posts: 5,941
Portland, OR, USA
Has anyone gotten this working (at least checking groups) in 7.3? I need something for a project I'm working on...


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, UBB.SitemapsJames Corthell
Re: User Authentication Class [Re: Gizmo] #317387
07/08/2008 5:40 PM
07/08/2008 5:40 PM
Joined: Feb 2007
Posts: 330
The Netherlands
B
blaaskaak Offline
Yarp™
blaaskaak  Offline
Yarp™
B

Joined: Feb 2007
Posts: 330
The Netherlands
I've got it working in 7.3, but I did not implement group checking yet. I only need it in one homemade script, and just made a query in that specific script.

PHP Code
$query = "
	select count(USER_ID) from ubbt_USER_GROUPS
	where USER_ID = ?
	and GROUP_ID in (
	SELECT GROUP_ID
	FROM ubbt_FORUM_PERMISSIONS
	WHERE FORUM_ID = ?
	AND READ_TOPICS > 0 )
";
$sth = $dbh -> do_placeholder_query($query,array($myuserid,$board),__LINE__,__FILE__);
list($access) = $dbh->fetch_array($sth);

if (!$access) { 
echo "SeeYa";exit; }
 


I am converting most of my scripts to the ubb environment where authentication and group checking is done for me smile


[Linked Image]
Re: User Authentication Class [Re: blaaskaak] #317388
07/08/2008 6:11 PM
07/08/2008 6:11 PM
Joined: Nov 2003
Posts: 491
SoCal
S
sirdude Offline
Enthusiast
sirdude  Offline
Enthusiast
S

Joined: Nov 2003
Posts: 491
SoCal
as long as you include user.inc.php in your user auth dude, the code would be

PHP Code
$yarp = new user();  // only needs to be done 1 time
if (!$yarp->check_access('forum','READ_TOPICS',$board)) {
   echo 'Ciao bella!';
   exit;
}
if ($yarp->check_access('site','CAN_USE_ARCADE')) {
  echo 'w00t! and arcade :)';
}  


reason for $userobaxx is that $userob is prolly in use for the user_auth dealio smile

so to modify my original post a bit:

PHP Code
include ('../libs/forums/includes/user.inc.php');
include ('../libs/forums/includes/user_auth.inc.php');

// Instantiate the user auth class as muhaha, for example
$muhaha = new user_auth();	 // w00t, yah baby :rawk:
$yarp = new user();

// Want to create a welcome message? 
if( $muhaha->is_logged_in ) { 
  if( $muhaha->is_banned ) { 
	echo "*cough* be gone, " . $muhaha->fields['USER_DISPLAY_NAME']; 
  } 
else { 
  echo "Waaazzaaaap, " . $muhaha->fields['USER_DISPLAY_NAME']; 
  } 
} else { echo "Please register<br />"; 
  } 
echo "Veni, vidi, vici!! <br />";

// New perm crapola goes here :)
if (!$yarp->check_access('forum','READ_TOPICS',$board)) {
   echo 'Ciao bella!';
   exit;
}
if ($yarp->check_access('site','CAN_USE_ARCADE')) {
  echo 'w00t! and arcade :)';
} 
?> 



Re: User Authentication Class [Re: Ian Spence] #317416
07/17/2008 5:57 PM
07/17/2008 5:57 PM
Joined: Oct 2004
Posts: 30
S
swebs Offline
User
swebs  Offline
User
S

Joined: Oct 2004
Posts: 30
This shows me all the fields|values under the "fields" array but I cant seem to dump the "groups" array.

foreach ($userob->fields as $key => $value) { print "$key $value
"; }


Last edited by swebs; 07/17/2008 6:24 PM.
Re: User Authentication Class [Re: swebs] #317418
07/18/2008 11:50 AM
07/18/2008 11:50 AM
Joined: Nov 2003
Posts: 491
SoCal
S
sirdude Offline
Enthusiast
sirdude  Offline
Enthusiast
S

Joined: Nov 2003
Posts: 491
SoCal
that's because it's an array, so you'd need a nested for loop for that array wink

Re: User Authentication Class [Re: Ian Spence] #317421
07/18/2008 6:19 PM
07/18/2008 6:19 PM
Joined: Oct 2004
Posts: 30
S
swebs Offline
User
swebs  Offline
User
S

Joined: Oct 2004
Posts: 30
What do we add to this so that we get the site wrapper.

I mean I have what I want working but I would like it all to be placed in the middle section of the site?

Re: User Authentication Class [Re: swebs] #317427
07/21/2008 8:54 AM
07/21/2008 8:54 AM
Joined: Sep 1999
Posts: 97
Sydney, Australia
M
Myke Offline
Power User
Myke  Offline
Power User
M

Joined: Sep 1999
Posts: 97
Sydney, Australia
Originally Posted by swebs
What do we add to this so that we get the site wrapper.

I mean I have what I want working but I would like it all to be placed in the middle section of the site?

Check the sticky thread titled [7.x] Generic Page Outside of forum directory in this forum.

Re: User Authentication Class [Re: Ian Spence] #317428
07/21/2008 1:44 PM
07/21/2008 1:44 PM
Joined: Oct 2004
Posts: 30
S
swebs Offline
User
swebs  Offline
User
S

Joined: Oct 2004
Posts: 30
The problem is that I have a bunch of dynamic pages that call eachother. I would have to create a bunch of wrapper pages.

Is there any way to create 1 file the I can include in my code to add the header and footer of the site?

Page 1 of 2 1 2

Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with, and recommend, the following Web Hosts:
· Stable Host
· Blue Host
· Interserver.net
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,180
Joined: July 2001
Show All Member Profiles 
Forum Statistics
Forums64
Topics37,454
Posts293,496
Members13,800
Most Online1,498
Mar 17th, 2017
Top Posters(All Time)
AllenAyres 25,587
JoshPet 11,330
Rick 8,373
LK 7,396
Lord Dexter 6,503
Gizmo 5,941
Greg Hard 5,533
Top Posters(30 Days)
isaac 8
Gizmo 3
driv 1
Today's Statistics
Currently Online 866
Topics Created 1
Posts Made 1
Users Online 1
Birthdays 22
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2018 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 7.6.3
(Snapshot build 20180915.dev)
Page Time: 0.159s Queries: 17 (0.057s) Memory: 3.6371 MB (Peak: 4.1186 MB) Zlib enabled. Server Time: 2018-09-22 16:36:51 UTC