Exemple #1
0
 /**
  * Gets the current instance of the class, there can only be one instance (this make the class a singleton class)
  * 
  * @return object $instance - the current instance of the class
  */
 public static function getInstance($host, $user, $pass, $name, $error_on = false)
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self($host, $user, $pass, $name, $error_on);
     }
     return self::$instance;
 }
Exemple #2
0
// class to deal with the management of sesssions
require 'classes/members-class.php';
// class to preform all B3 DB related actions
## fire up the Sessions ##
$ses = new Session();
// create Session instance
$ses->sesStart('echelon', 0, PATH);
// start session (name 'echelon', 0 => session cookie, path is echelon path so no access allowed oustide echelon path is allowed)
## create istance of the members class ##
$mem = new member($_SESSION['user_id'], $_SESSION['name'], $_SESSION['email']);
## Is B3 needed on this page ##
if ($b3_conn) {
    // This is to stop connecting to the B3 Db for non B3 Db connection pages eg. Home, Site Admin, My Account
    require 'classes/mysql-class.php';
    // class to preform all B3 DB related actions
    $db = DB_B3::getInstance($game_db_host, $game_db_user, $game_db_pw, $game_db_name, DB_B3_ERROR_ON);
    // create connection to the B3 DB
    // unset all the db info vars
    unset($game_db_host);
    unset($game_db_user);
    unset($game_db_pw);
    unset($game_db_name);
}
## Plugins Setup ##
if (!$no_plugins_active) {
    // if there are any registered plugins with this game
    require 'classes/plugins-class.php';
    // require the plugins base class
    $plugins = new plugins(NULL);
    foreach ($config['game']['plugins'] as $plugin) {
        // foreach plugin there is
Exemple #3
0
 public function editSettings($tables, $names)
 {
     global $game;
     // current game id
     $dbl = DBL::getInstance();
     // get Echelon db pointer
     $db = DB_B3::getPointer();
     // get B3 Db pointer
     $tables_array = explode(',', $tables);
     foreach ($tables_array as $table) {
         // check each table exists
         $query = "SELECT id FROM {$table} LIMIT 1";
         if (!($stmt = $db->mysql->prepare($query))) {
             // if table does not exist then prepare will fail
             return false;
         }
         // if not return false
     }
     // Update the tables row
     $result = $dbl->updateSettings($tables, 'chats_table_' . $game, 's');
     if (!$result) {
         $result = $dbl->setSettings($tables, 'chats_table_' . $game, 's');
         if (!$result) {
             return false;
         }
     }
     // update the names row
     $result = $dbl->updateSettings($names, 'chats_names_' . $game, 's');
     if (!$result) {
         $result = $dbl->setSettings($names, 'chats_names_' . $game, 's');
         if (!$result) {
             return false;
         }
     }
     return true;
 }
Exemple #4
0
 /**
  * Internal function to connect to the DB and retrieve clients XLR bio Infomation
  */
 private function getClientBio()
 {
     $db = DB_B3::getPointer();
     // get the pointer to the current B3 connection
     global $cid;
     ## Get information for xlrstats ##
     $query_xlr = "SELECT id, kills, deaths, ratio, skill, rounds, hide, fixed_name FROM xlr_playerstats WHERE client_id = ? LIMIT 1";
     $stmt = $db->mysql->prepare($query_xlr) or die('Database Error');
     $stmt->bind_param('i', $cid);
     $stmt->execute();
     $stmt->store_result();
     if ($stmt->num_rows > 0) {
         $this->xlr_user = true;
         $stmt->bind_result($id, $kills, $deaths, $ratio, $skill, $rounds, $hide, $fixed_name);
         $stmt->fetch();
         $results = array('id' => $id, 'kills' => $kills, 'deaths' => $deaths, 'ratio' => $ratio, 'skill' => $skill, 'rounds' => $rounds, 'hide' => $hide, 'fixed_name' => $fixed_name);
         $this->xlr_fixed_name = $fixed_name;
         $this->xlr_hide = $hide;
     } else {
         $this->xlr_user = false;
     }
     $stmt->free_result();
     $stmt->close();
     return $results;
 }
$i = 0;
// start counter at 0
$total_overall_rows = 0;
// set default value to 0
## Loop thro the tables and retrieve the relevant data
while ($i < $num_tables) {
    // write and preform query for each server
    // create query array
    $query = array();
    $table_name = $tables[$i];
    if (empty($table_name)) {
        $table_name = 'chatlog';
    }
    // write query
    $query[$i] = "SELECT id, msg_time, msg_type, msg FROM {$table_name} WHERE client_id = {$cid} ORDER BY msg_time DESC LIMIT {$limit_rows}";
    $db = DB_B3::getPointer();
    // run query
    $results = $db->mysql->query($query[$i]) or die('DB Error');
    while ($row = $results->fetch_object()) {
        $records[$i][] = array('id' => $row->id, 'msg_time' => $row->msg_time, 'msg_type' => $row->msg_type, 'msg' => $row->msg);
    }
    // find num of rows found
    $num_rows_[$i] = $results->num_rows;
    // start count on num of total overall rows
    $total_overall_rows = $total_overall_rows + $num_rows_[$i];
    // keeps last loop number plus addition of this loops num_rows
    // add 1 to counter
    $i++;
    $results = NULL;
}
// end while looping thro all tables to find any records