php forum
php mysql forum
php mysql smarty
 
Page 1 of 3 1 2 3 >
Topic Options
#312798 - 01/19/07 02:59 PM User Authentication Class
Ian Spence Offline
Master Hacker

Registered: 01/25/03
Posts: 3765
Loc: 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


Attachments
2389-user_auth.txt (163 downloads)

_________________________
Code monkey like Fritos

Top
#312801 - 01/19/07 05:00 PM Re: User Authentication Class [Re: Ian Spence]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25452
Loc: Texas
Grazie Ian thumbsup
_________________________
- Allen wavey
- What Drives You?

Top
#312806 - 01/19/07 05:59 PM Re: User Authentication Class [Re: AllenAyres]
Gizmo Administrator Offline
Wizard

Registered: 01/10/00
Posts: 5134
Loc: Portland, OR, USA
Looks awesome :), can't wait to get some time to fiddle hehe
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top
#312808 - 01/19/07 07:03 PM Re: User Authentication Class [Re: Ian Spence]
Calpy Offline
Power User

Registered: 12/17/02
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? =)

Top
#312810 - 01/19/07 07:29 PM Re: User Authentication Class [Re: Calpy]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25452
Loc: Texas
I'll bet it's the cross-domain issue.
_________________________
- Allen wavey
- What Drives You?

Top
#312812 - 01/19/07 07:44 PM Re: User Authentication Class [Re: AllenAyres]
Gizmo Administrator Offline
Wizard

Registered: 01/10/00
Posts: 5134
Loc: Portland, OR, USA
Yes, the cookies belong to one domain, security won't allow it to run on a seperate domain properly, imo


Edited by Gizmo (01/19/07 07:45 PM)
_________________________
UBB.Dev - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top
#312813 - 01/19/07 07:57 PM Re: User Authentication Class [Re: Gizmo]
Calpy Offline
Power User

Registered: 12/17/02
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...

Top
#312814 - 01/19/07 08:05 PM Re: User Authentication Class [Re: Calpy]
Gizmo Administrator Offline
Wizard

Registered: 01/10/00
Posts: 5134
Loc: 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 - Where you too can render your UBB install completely useless...
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top
#312816 - 01/19/07 11:36 PM Re: User Authentication Class [Re: Gizmo]
JoshPet Offline
I type Like navaho

Registered: 11/29/01
Posts: 11330
Loc: 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.
_________________________
Joshua Pettit
www.JoshuaPettit.com
My abilities are for hire.

Top
#313532 - 03/14/07 09:08 AM Re: User Authentication Class [Re: Ian Spence]
blaaskaak Offline
Enthusiast

Registered: 02/25/07
Posts: 304
Loc: 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;
//		}


Edited by blaaskaak (03/14/07 11:34 AM)
_________________________

Top
#313890 - 04/17/07 11:15 AM Re: User Authentication Class [Re: blaaskaak]
blaaskaak Offline
Enthusiast

Registered: 02/25/07
Posts: 304
Loc: 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 ) {
_________________________

Top
#313905 - 04/19/07 04:16 PM Re: User Authentication Class [Re: blaaskaak]
Ian Spence Offline
Master Hacker

Registered: 01/25/03
Posts: 3765
Loc: 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)
_________________________
Code monkey like Fritos

Top
#314160 - 05/21/07 04:26 PM Re: User Authentication Class [Re: Ian Spence]
blaaskaak Offline
Enthusiast

Registered: 02/25/07
Posts: 304
Loc: 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!
_________________________

Top
#315115 - 08/08/07 07:13 PM Re: User Authentication Class [Re: Ian Spence]
Mark_S Offline
Power User

Registered: 11/15/03
Posts: 85
Loc: 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 <yes>
Paths updated <yes>
New file with simple test code <yes>

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 <br />
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.

Click to reveal..
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

Top
#315144 - 08/10/07 06:34 AM Re: User Authentication Class [Re: Mark_S]
Mark_S Offline
Power User

Registered: 11/15/03
Posts: 85
Loc: UK
In my best Penelope Pit stop voice

Any one ?
Helllp

Top
#315148 - 08/10/07 01:36 PM Re: User Authentication Class [Re: Mark_S]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25452
Loc: 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?

Top
#315151 - 08/10/07 02:01 PM Re: User Authentication Class [Re: AllenAyres]
Mark_S Offline
Power User

Registered: 11/15/03
Posts: 85
Loc: 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" );


Edited by Mark_S (08/10/07 02:02 PM)

Top
#315158 - 08/11/07 07:09 AM Re: User Authentication Class [Re: Mark_S]
Mark_S Offline
Power User

Registered: 11/15/03
Posts: 85
Loc: UK
any little scripts i can try to start to debug this ?

Top
#315161 - 08/11/07 08:32 AM Re: User Authentication Class [Re: Mark_S]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25452
Loc: 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?

Top
#315165 - 08/11/07 08:49 PM Re: User Authentication Class [Re: AllenAyres]
Ian Spence Offline
Master Hacker

Registered: 01/25/03
Posts: 3765
Loc: 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
_________________________
Code monkey like Fritos

Top
Page 1 of 3 1 2 3 >


Moderator:  sirdude 
Who's Online
0 registered (), 18 Guests and 10 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
Wisdom needed
by Gizmo
Yesterday at 10:54 AM
How to hide sub forums from summary page
by blaaskaak
12/03/08 09:54 AM
Spell Check [beta]
by Bill B
12/01/08 09:16 PM
PhotoPost BB Code Popup
by AllenAyres
12/01/08 09:41 AM
Problems reading a lot of old posts here
by AllenAyres
12/01/08 09:35 AM
Forum 'Trader Ratings'.
by AllenAyres
12/01/08 09:33 AM
Customization needed
by Gizmo
11/12/08 12:28 PM
New Mods
User Authentication Class
by
01/19/07 02:59 PM
Multiple Identity Detector
by
12/30/06 06:39 PM
PhotoPost BB Code Popup
by
11/06/06 05:43 PM
Spell Check [beta]
by
10/17/06 09:24 PM
Newest Members
Truth, David DelMonte, nick1, Begbie, cenk
13364 Registered Users
Top Posters
AllenAyres 25452
JoshPet 11330
Rick 8372
LK 7396
Lord Dexter 6503
Greg Hard 5533
Charles Capps 5438

 

 

 
fusionbb message board php hacks