Solved

how to call a class properly

Posted on 2012-03-26
3
185 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 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 37768684
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
ID: 37789850
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
ID: 37844571
seems like there are different meanings to the word "properly"...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
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 count occurrences of each item in an array.

809 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