Solved

how to call a class properly

Posted on 2012-03-26
3
182 Views
Last Modified: 2012-04-13
How would i call the following class??

<?php
class vBulletinUser{
	public static function login($username, $remember_me = false){
		chdir(VB_ROOT_PATH);
		require_once('./global.php');
		require_once(DIR . '/includes/functions_login.php');
		global $vbulletin,$vbphrase;
		$remember_me = $remember_me ? true : false;	//force to true or false value
		$vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, 
			username, password, salt FROM ".TABLE_PREFIX."user WHERE username = '".
			$vbulletin->db->escape_string(htmlspecialchars_uni($username))."'");
			
		if ($vbulletin->userinfo){
			process_new_login($vbulletin->GPC['logintype'], $remember_me, $vbulletin->GPC['cssprefs']);
			exec_shut_down();
			return true;
		}
		return false;
	}
}

new vBulletinUser();
?>

Open in new window

0
Comment
Question by:runnerjp2005
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
I don't think I would call it.  It looks like a PHP4 implementation, maybe.  No class constructor, etc.  But that aside...

$x = new VBulletinUser();
if ($x->login('UserName', TRUE)) echo "WE GOT LOGGED IN";
0
 
LVL 7

Expert Comment

by:designatedinitializer
Comment Utility
It's not PHP4 because it's 'static', and there weren't static methods back then.
You call it like this:
VBulletinUser::login('UserName', TRUE);

Open in new window

0
 
LVL 7

Expert Comment

by:designatedinitializer
Comment Utility
seems like there are different meanings to the word "properly"...
0

Featured Post

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now