Ejemplo n.º 1
0
 /**
  * phpArmory5Cache class constructor.
  * @access      public
  * @param       string      $areaName
  * @param       string      $dataStore
  * @param       string      $mysqlString
  * @param       string      $mysqlTable
  * @param       int         $downloadRetries
  * @return      mixed       $result                 Returns TRUE if the class could be instantiated properly. Returns FALSE and an error string, if the class could not be instantiated.
  */
 public function __construct($areaName = NULL, $dataStore = NULL, $dataPath = NULL, $mysqlString = NULL, $downloadRetries = NULL)
 {
     parent::__construct($areaName, $downloadRetries);
     if ($dataStore == NULL && $this->dataStore) {
         $dataStore = $this->dataStore;
     } else {
         $this->dataStore = $dataStore;
     }
     if ($mysqlString == NULL && $this->mysqlString) {
         $mysqlString = $this->mysqlString;
     } else {
         $this->mysqlString = $mysqlString;
     }
     if ($mysqlTable == NULL && $this->mysqlTable) {
         $mysqlTable = $this->mysqlTable;
     } else {
         $this->mysqlTable = $mysqlTable;
     }
     switch ($this->dataStore) {
         case 'file':
             if ($dataPath == NULL && $this->dataPath) {
                 $dataPath = $this->dataPath;
             } else {
                 $this->dataPath = $dataPath;
             }
             break;
         case 'mysql':
             if (!extension_loaded('mysql') || !extension_loaded('mysqli')) {
                 self::triggerError("Either PHP extension \"mysql\" or \"mysqli\" extension is required to use this class.");
             } else {
                 if ($dataPath == NULL && $this->mysqlTable) {
                     $dataPath = $this->mysqlTable;
                 } else {
                     $this->mysqlTable = $dataPath;
                 }
                 $conn = @parse_url($this->mysqlString);
                 $this->mysqlString = mysql_connect($conn['host'], $conn['user'], $conn['pass']) or die("Failed to connect to database");
                 mysql_select_db(str_replace('/', '', $conn['path']), $this->mysqlString) or die("Unable to select database table");
                 $query = "CREATE TABLE IF NOT EXISTS `" . $this->mysqlTable . "` (\n                    `cache_id` VARCHAR(100) NOT NULL DEFAULT '',\n                    `cache_time` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,\n                    `cache_xml` TEXT,\n                    PRIMARY KEY `cache_id` (`cache_id`))";
                 mysql_query($query, $this->mysqlString) or self::triggerError("Unable to create the cache table");
             }
             break;
         default:
             die("Invalid dataStore defined.");
             break;
     }
     parent::setArea($areaName);
 }
Ejemplo n.º 2
0
$characterName      = "Arkanella";
$characterRealmName = "Madmortem";

$guildName          = "Divinitas";
$guildRealmName     = "Madmortem";

// Instantiate the class library
if ( $armory = new phpArmory5($areaName = $usArea) ) {
    echo "We have created an instance of phpArmory5 with the area \"" . $usArea ."\" selected.\n";

    echo "The current armory patch level is: " . $armory->getPatchLevel() . "\n";

    echo "World of Warcraft provides us with " . count ($armory->getTalentData()) . " talent definitions.\n";

    if ( $armory->setArea($euArea) ) {

        $armoryAreaData = $armory->getArea();

        echo "Area used now is \"" . $armoryAreaData[0] ."\".\n";

        echo "Armory site used now is \"" . $armoryAreaData[1] ."\".\n";

        echo "Web site used now is \"" . $armoryAreaData[2] ."\".\n";

        $itemIDData = $armory->getItemData($itemID);

        $itemNameData = $armory->getItemDataByName($itemName);

        $characterData = $armory->getCharacterData($characterName, $characterRealmName);