Server Auth Model
The server auth model is an essential model for connecting to the auth database of the server. On this page, you can find documentation of the available functions of this model.
connect
$this->server_auth_model->connect() — Connect to auth DB
$this->server_auth_model->connect(): object
Parameters
This function has no parameters.
Return Values
Returns an object that establishes the connection to the auth database.
Examples
$auth = $this->server_auth_model->connect();
// Returns quantity of active bans
$count = $auth->from('account_banned')
    ->where('active', 1)
    ->count_all_results();
account
$this->server_auth_model->account() — Get account
$this->server_auth_model->account($id): mixed
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $id | int | Account id | 
Return Values
Returns an object with all the data of the account or null if not exist.
Examples
// Returns account data if the id '1' exists
$account = $this->server_auth_model->account(1);
account_id
$this->server_auth_model->account_id() — Get the account id by searching a value in a column
$this->server_auth_model->account_id($value, $column = 'username'): int
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $value | string | Value searched in the column | 
| $column | string | Column name in the account table | 
Allowed column names:
usernameemail
Return Values
Returns account id, or 0 if the searched value is not found.
Examples
// Returns the account id if the username 'nick' exists
$id = $this->server_auth_model->account_id('nick');
// Returns the account id if the email 'example@domain.tld' exists
$id = $this->server_auth_model->account_id('example@domain.tld', 'email');
account_exists
$this->server_auth_model->account_exists() — Check if an account with a column value exists
$this->server_auth_model->account_exists($value, $column = 'username'): bool
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $value | string | Value searched in the column | 
| $column | string | Column name in the account table | 
Allowed column names:
usernameemail
Return Values
Returns true if the column value exist or false on failure.
Examples
if ($this->server_auth_model->account_exists('emina')) {
    echo 'The account with the username emina exists';
}
account_gmlevel
$this->server_auth_model->account_gmlevel() — Get the gmlevel of an account
$this->server_auth_model->account_gmlevel($id = null): int
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $id | int|null | Account id | 
Return Values
Return the gmlevel of an account or 0 if it doesn't have assigned.
Examples
// Returns the gmlevel of your account if you are logged in
$gmlevel = $this->server_auth_model->account_gmlevel();
// Returns the gmlevel of account '1'
$gmlevel = $this->server_auth_model->account_gmlevel(1);
is_banned
$this->server_auth_model->is_banned() — Check if an account is banned
$this->server_auth_model->is_banned($id = null): bool
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $id | int|null | Account id | 
Return Values
Returns true if the account is banned or false on failure.
Examples
if ($this->server_auth_model->is_banned()) {
    echo 'Your account is banned';
}
if ($this->server_auth_model->is_banned(1)) {
    echo 'Account 1 is banned';
}