Mac
New Member
- Feb 9, 2011
- 111
- 2
PHP:
<?php
class User {
public $isBanned = false;
public $isLoggedIn = false;
public $hasEmptyCredits = false;
public $isUsingWhat = false;
public $sql = mysql_query("SELECT * FROM users WHERE name='{$_SESSION['name']}'");
public $row = mysql_fetch_array($this->sql);
public function userCheck() {
if($this->row["banned"] == "1"): # If row banned is 1 (Yes)
$this->isBanned = true; # Variable isBanned will be true
endif;
if(isset($_SESSION['name'], $_SESSION['password'])): # If is set session for user
$this->isLoggedIn = true; # Variable isLoggedIn will be true
endif;
if($this->row["credits"] < 1): # If row credits is low than 1
$this->hasEmptyCredits = true; # Variable hasEmptyCredits will be true.
endif;
if($this->isUsingWhat == false) {
$this->isUsingWhat = str_replace("C:", " ", $_SERVER["SystemRoot"]);
}
}
}
$user = new User;
$user->userCheck();
if($user->isLoggedIn):
if($user->isBanned):
echo "<p>You are banned</p>";
else:
if($user->hasEmptyCredits):
echo "<p>You have empty credits!</p>";
else:
echo
<<< END
Object for store
END;
endif;
echo "<p>You are using{$user->isUsingWhat}</p>";
endif;
endif;
?>