Example #1
0
// Character Database Server Connection
$connC = array('driver' => 'mysql', 'host' => 'localhost', 'port' => '3306', 'username' => 'admin', 'password' => 'admin', 'database' => 'characters');
// === End Configs... Dont edit anything below this line === //
// For benchmarking purposes
$start = microtime(1);
/* 
| -------------------------------------------------------------- 
| This example shows you how to load a realm, and fetch an account
| --------------------------------------------------------------
*/
// Include the wowlib class
include 'Wowlib.php';
// Init the wowlib
Wowlib::Init($emulator);
// Fetch realm, and Dump the account id of 5
$Realm = Wowlib::getRealm('myrealmid', $connA);
$Account = $Realm->fetchAccount($accountId);
echo "This account username for account id {$accountId} is " . $Account->getUsername();
/* 
| -------------------------------------------------------------- 
| In this next example, Lets fetch a character
| --------------------------------------------------------------
*/
// Load a driver first, which ever is most compatible with your core revision
// We will skip the world data connection by placing null as the 3rd param
$Driver = Wowlib::load('_default', $connC, null);
// The driver... Each method under the driver object, is a class that is loacated
// inside the loaded driver folder "drivers/$emulator/_default" in this case
$Character = $Driver->characters->fetch(2);
if (is_object($Character)) {
    echo "<br /><br />This character's name is " . $Character->getName() . " and he is level " . $Character->getLevel() . "!";
Example #2
0
 public function realm($instance = TRUE)
 {
     // Get our emulator from the Config File
     $emulator = ucfirst(config('emulator'));
     $class_name = "Emulator_" . $emulator;
     // Make sure we havent loaded the lib already
     $realm = \Registry::load($class_name);
     if ($realm !== NULL) {
         goto Instance;
     }
     // Init the class if it doesnt exist
     if (!class_exists('Wowlib', false)) {
         $this->_initWowlib();
     }
     // Add debug tracer
     \Debug::trace('Loading Realm from Wowlib', __FILE__, __LINE__);
     // Fetch the emulator class
     try {
         $realm = \Wowlib::getRealm(0, 'RDB');
     } catch (\Exception $e) {
         \Debug::silent_mode(false);
         $message = 'Wowlib Error: ' . $e->getMessage();
         // Add debug tracer
         \Debug::trace($message, __FILE__, __LINE__);
         show_error($message, false, E_ERROR);
     }
     // Store the class statically and return the class
     \Registry::store($class_name, $realm);
     // Instance
     Instance:
     if ($instance == TRUE) {
         $FB = get_instance();
         if (is_object($FB)) {
             $FB->realm = $realm;
         }
     }
     // We need to make sure the realm loaded ok, or thrown an error
     if (!is_object($realm)) {
         // Add debug tracer
         $message = 'Wowlib failed to fetch realm. Assuming the realm database is offline.';
         \Debug::trace($message, __FILE__, __LINE__);
         show_error($message, false, E_ERROR);
     } else {
         \Debug::trace('Successfully fetched the realm connection from the Wowlib', __FILE__, __LINE__);
     }
     return $realm;
 }