示例#1
0
 /**
  * Initialize database handlers, debug handler, sets up sql/site configs
  * @category Armory class
  * @access   public
  * @return   bool
  **/
 public static function InitializeArmory()
 {
     if (!(require __ARMORYDIRECTORY__ . '/includes/classes/configuration.php')) {
         die('<b>Error</b>: unable to load configuration file!');
     }
     if (!(require __ARMORYDIRECTORY__ . '/includes/classes/class.debug.php')) {
         die('<b>Error</b>: unable to load debug class!');
     }
     if (!(require __ARMORYDIRECTORY__ . '/includes/classes/mysql/class.databaseHandler.php')) {
         die('<b>Error</b>: unable to load database abstract class!');
     }
     if (!(require __ARMORYDIRECTORY__ . '/includes/classes/mysql/class.' . $ArmoryConfig['mysql']['DbExtension'] . 'Client.php')) {
         die('<b>Error</b>: unable to load mysql client class! (Unable to load: class.' . $ArmoryConfig['mysql']['DbExtension'] . 'Client.php');
     }
     self::$mysqlconfig = $ArmoryConfig['mysql'];
     self::$armoryconfig = $ArmoryConfig['settings'];
     self::$debugHandler = new ArmoryDebug(array('useDebug' => self::$armoryconfig['useDebug'], 'logLevel' => self::$armoryconfig['logLevel']));
     self::$realmData = $ArmoryConfig['multiRealm'];
     if (!defined('SKIP_DB')) {
         self::$dbClass = self::$mysqlconfig['DbExtension'] . 'Client';
         self::$aDB = new self::$dbClass(self::$mysqlconfig['host_armory'], self::$mysqlconfig['user_armory'], self::$mysqlconfig['pass_armory'], self::$mysqlconfig['port_armory'], self::$mysqlconfig['name_armory'], self::$mysqlconfig['charset_armory'], self::$armoryconfig['db_prefix']);
         self::$rDB = new self::$dbClass(self::$mysqlconfig['host_realmd'], self::$mysqlconfig['user_realmd'], self::$mysqlconfig['pass_realmd'], self::$mysqlconfig['port_realmd'], self::$mysqlconfig['name_realmd'], self::$mysqlconfig['charset_realmd']);
         if (isset($_GET['r'])) {
             if (preg_match('/,/', $_GET['r'])) {
                 // Achievements/statistics comparison cases
                 $rData = explode(',', $_GET['r']);
                 $realmName = urldecode($rData[0]);
             } else {
                 $realmName = urldecode($_GET['r']);
             }
             $realm_id = self::FindRealm($realmName);
             if (isset(self::$realmData[$realm_id])) {
                 self::$connectionData = self::$realmData[$realm_id];
                 self::$cDB = new self::$dbClass(self::$connectionData['host_characters'], self::$connectionData['user_characters'], self::$connectionData['pass_characters'], self::$connectionData['port_characters'], self::$connectionData['name_characters'], self::$connectionData['charset_characters']);
                 self::$currentRealmInfo = array('name' => self::$connectionData['name'], 'id' => $realm_id, 'type' => self::$connectionData['type'], 'connected' => true);
                 self::$wDB = new self::$dbClass(self::$connectionData['host_world'], self::$connectionData['user_world'], self::$connectionData['pass_world'], self::$connectionData['port_world'], self::$connectionData['name_world'], self::$connectionData['charset_world']);
             }
         }
         $realm_info = self::$realmData[1];
         if (self::$cDB == null) {
             self::$cDB = new self::$dbClass($realm_info['host_characters'], $realm_info['user_characters'], $realm_info['pass_characters'], $realm_info['port_characters'], $realm_info['name_characters'], $realm_info['charset_characters']);
         }
         if (self::$wDB == null) {
             self::$wDB = new self::$dbClass($realm_info['host_world'], $realm_info['user_world'], $realm_info['pass_world'], $realm_info['port_world'], $realm_info['name_world'], $realm_info['charset_world']);
         }
         if (!self::$currentRealmInfo) {
             self::$currentRealmInfo = array('name' => $realm_info['name'], 'id' => 1, 'type' => $realm_info['type'], 'connected' => true);
         }
         if (!self::$connectionData) {
             self::$connectionData = $realm_info;
         }
     }
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $user_locale = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
         if ($user_locale && ($http_locale = self::IsAllowedLocale($user_locale))) {
             self::$_locale = isset($_SESSION['armoryLocale']) ? $_SESSION['armoryLocale'] : $http_locale;
         }
     }
     if (!self::$_locale) {
         self::$_locale = isset($_SESSION['armoryLocale']) ? $_SESSION['armoryLocale'] : self::$armoryconfig['defaultLocale'];
     }
     switch (self::$_locale) {
         case 'en_gb':
         case 'en_us':
             self::$_loc = 0;
             break;
         case 'fr_fr':
             self::$_loc = 2;
             break;
         case 'de_de':
             self::$_loc = 3;
             break;
         case 'zh_cn':
             self::$_loc = 4;
             break;
         case 'es_es':
             self::$_loc = 6;
             break;
         case 'es_mx':
             self::$_loc = 7;
             break;
         case 'ru_ru':
             self::$_loc = 8;
             break;
     }
 }