* @author Daan Janssens, mentored by Matthew Lagoe
*
* @author Daan Janssens, mentored by Matthew Lagoe
*/
class Helpers {
/**
* workhorse of the website, it loads the template and shows it or returns th html.
* it uses smarty to load the $template, but before displaying the template it will pass the $vars to smarty. Also based on your language settings a matching
* array of words & sentences for that page will be loaded. In case the $returnHTML parameter is set to true, it will return the html instead of displaying the template.
*
*
* @param $template the name of the template(page) that we want to load.
* @param $vars an array of variables that should be loaded by smarty before displaying or returning the html.
* @param $returnHTML (default=false) if set to true, the html that should have been displayed, will be returned.
* @todo for the drupal module it might be possible that drupal_mkdir needs to be used instead of mkdir, also this should be in the install.php instead.
*/
static public function create_folders() {
@ -112,19 +112,19 @@ class Helpers {
$SITEBASE . '/configs'
);
foreach ( $arr as &$value ) {
if ( !file_exists( $value ) ) {
print( $value );
mkdir( $value );
}
}
}
}
}
}
/**
* check if the http request is sent ingame or not.
*
*
* @return returns true in case it's sent ingame, else false is returned.
*/
static public function check_if_game_client()
@ -135,37 +135,37 @@ class Helpers {
return true;
} else {
return false;
}
}
}
}
/**
* Handles the language specific aspect.
* The language can be changed by setting the $_GET['Language'] & $_GET['setLang'] together. This will also change the language entry of the user in the db.
* Cookies are also being used in case the user isn't logged in.
*
*
* @return returns the parsed content of the language .ini file related to the users language setting.
* Time output function for handling the time display.
*
* @return returns the time in the format specified in the $TIME_FORMAT global variable.
*/
static public function outputTime( $time, $str = 1 ) {
global $TIME_FORMAT;
if ( $str ) {
return date( $TIME_FORMAT, strtotime( $time ) );
} else {
return date( $TIME_FORMAT, $time );
}
}
/**
* Time output function for handling the time display.
*
* @return returns the time in the format specified in the $TIME_FORMAT global variable.
*/
static public function outputTime($time, $str = 1) {
global $TIME_FORMAT;
if ($str) {
return date($TIME_FORMAT, strtotime($time));
} else {
return date($TIME_FORMAT, $time);
}
}
/**
* Auto login function for ingame use.
* This function will allow users who access the website ingame, to log in without entering the username and password. It uses the COOKIE entry in the open_ring db.
* it checks if the cookie sent by the http request matches the one in the db. This cookie in the db is changed everytime the user relogs.
*
* @return returns "FALSE" if the cookies didn't match, else it returns an array with the user's id and name.
*/
static public function check_login_ingame() {
return NULL;
// FIXME
/*
if ( helpers :: check_if_game_client () or $forcelibrender = false ) {
* This function will allow users who access the website ingame, to log in without entering the username and password. It uses the COOKIE entry in the open_ring db.
* it checks if the cookie sent by the http request matches the one in the db. This cookie in the db is changed everytime the user relogs.
*
* @return returns "FALSE" if the cookies didn't match, else it returns an array with the user's id and name.
*/
static public function check_login_ingame() {
if ( helpers :: check_if_game_client () or $forcelibrender = false ) {
* This is the base function, it should be overwritten by the WebUsers class.
@ -353,7 +355,7 @@ class Users{
protected static function checkLoginMatch($user,$pass){
print('This is the base class!');
}
/**
* check if the changing of a password is valid.
* a mod/admin doesn't has to fill in the previous password when he wants to change the password, however for changing his own password he has to fill it in.
@ -412,7 +414,7 @@ class Users{
return $pageElements;
}
}
/**
* sets the shards password.
* in case the shard is offline, the entry will be stored in the ams_querycache.
@ -421,9 +423,9 @@ class Users{
* @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline.
*/
protected static function setAmsPassword($user, $pass){
$values = Array('Password' => $pass);
try {
//make connection with and put into shard db
$dbs = new DBLayer("shard");
@ -440,9 +442,9 @@ class Users{
}catch (PDOException $e) {
return "liboffline";
}
}
}
}
/**
* sets the shards email.
* in case the shard is offline, the entry will be stored in the ams_querycache.
@ -451,9 +453,9 @@ class Users{
* @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline.
*/
protected static function setAmsEmail($user, $mail){