WoW Realm Status PHP Class
I am working on a PHP Class called RealmStatus that will pull WoW Realm information from the WoW Realm Status Page without XML feeds available.
The RealmStatus Class currently supports the following operations:
--getAllServers() - Returns an associative array of all Server Names, Statuses, Populations, Types, and Locale.
--getServerType($) - Returns the type of a given server.
--getServerStatus($) - Returns the status of a given server.
--getServerPopulation($) - Returns the population of a given server.
--getServerLocale($) - Returns the locale of a given server.
For a detailed explanation of the operations, please read the function headers in the RealmStatus.php and example.php files.
The files can be pulled from GitHub here.
WoW Roster PHP Class
I am working on a PHP Class called RosterAPI that will parse the WoW Armory without XML Files. Unlike my previous two posts (Part 1 and Part 2), the information for each character can be pulled through get methods. Also included in RosterAPI are guild specific functions not included in my previous posts.
The following methods are currently included:
Character Specific:
* getLevel()
* getGender()
* getClass()
* getRace()
* getAchievementPoints()
* getProfessions(): Returns an associative array containing the name and value of each profession.
* getTalents(): Returns an associative array containing the name and value of each talent tree.
* getStat($stat): Please view the comment header of the getStat() function for a list of valid $stats.
Guild Specific:
* getGuildMembers($rank): If $rank is true, an associative array containing guild names and ranks will be returned. If $rank is false, an array will be returned containing all names in the guild.
* getTopWeeklyContributers(): Returns an array of the Top 5 Weekly Contributers in the guild.
* getGuildPerks(): Returns an array of the perks a guild currently has.
UPDATE:
I have received several emails with suggestions over the past week. In addition to everything listed above, my RosterAPI will also:
*getItems: Returns an Associative Array that will return every item equipped on a character along with the Item Level, Enchants, and Gems.
*getStatistics: Given a specific Statistic (ex: Number of deaths), the value of the statistic will be returned.
The code can be obtained via GitHub. While it is still a work in progress, it should be stable enough for personal use. This class is being used to power the backend of the We Know Roster. Please read the README file along with the example.php file for a brief introduction on how to use the class. I recommend reading the comments above each function in RosterAPI to understand what exactly will be returned (especially with those functions that return associative arrays).
Update #2
The Roster API now returns Glyphs for each character.
EDIT #2:
By request in the comments, here is a Paypal Donate button:
Parsing the WoW Armory without XML – Part 2
This post is a continuation of my original post about parsing the WoW Armory with no XML feeds available. In my original post, I showed how to pull basic character information, such as professions and talents, from each member in a specified guild. This post will expand on more specific character information such as HP, MP, and Stats.
The getCharacterInformation($charName) function in my previous post can be expanded to include additional information available on the WoW Armory. (Please view my original post for the sample code). For the most part, the code below can be directly copied into the existing method. As in my previous post, I assume you have the knowledge to make minor changes to the method (such as modifying the return array).
Exact Health and Mana:
$health = $xpath->query('//li[@class="health"]/span[@class="value"]'); $mana = $xpath->query('//li[@id="summary-power"]/span[@class="value"]'); echo $health->item(0)->nodeValue."<br />"; echo $mana->item(0)->nodeValue."<br />";
Exact Talents:
This will return the exact talent in the form of xx/xx/xx for both talents.
$exactBuilds = $xpath->query('//span[@class="name-build"]/span[@class="build"]'); echo $exactBuilds->item(0)->nodeValue."<br />"; echo $exactBuilds->item(1)->nodeValue;
Stats and Resistances:
A stat listed in the comment above the code needs to be added to the $stat variable.
/** * Valid $stat values: * strength, agility, stamina, intellect, * spirit, mastery, meleedamage, meleedps, * meleeattackpower, meleespeed, meleehaste, * meleehit, meleecrit, meleecrip, expertise, * rangeddamage, rangeddps, rangedattackpower, * rangedspeed, rangedhaste, rangedhit, rangedcrit, * spellpower, spellhaste, spellhit, spellcrit, * spellpenetration, manaregen, combatregen, armor, * dodge, parry, block, resilience, arcaneres, fireres, * frostres, natureres, shadowres, */ $stat = "ADD_STAT_FROM_ABOVE_HERE"; $statName = $xpath->query('//li[@data-id="'.$stat.'"]/span[@class="name"]'); $statValue = $xpath->query('//li[@data-id="'.$stat.'"]/span[@class="value"]'); echo $statName->item(0)->nodeValue."<br />"; echo $statValue->item(0)->nodeValue."<br />";
Battleground Rating and Kills
$rating = $xpath->query('//li[@class="rating"]/span[@class="value"]'); $kills = $xpath->query('//li[@class="kills"]/span[@class="value"]'); echo $rating->item(0)->nodeValue."<br />"; echo $kills->item(0)->nodeValue."<br />";
My next post will cover looking into more interesting character information such as Achievements, Reputation, or Statistics.
Parsing the WoW Armory without XML
A month or so ago Blizzard moved the WoW Armory to Battle.net servers. Currently, the new WoW Armory does not offer XML feeds for the data. I spent a few hours working with PHP and DOM to create a 'parser' for the new Armory. The below script is a trimmed down version of what is currently being used for the We Know Roster. I am only providing the back end script that will do the parsing and store the information in a MySQL database. Front end displaying can easily be achieved by querying the database with the stored results.
The script will pull the following information for each member in a specified guild: Name, Level, Class, Rank, Achievement Points, Profession 1 Name+Level, Profession 2 Name+Level, Talent1, and Talent2.
The scripts below require modifications to work properly. I recommend having knowledge of PHP/CLI before working with this script. I will develop a more user friendly version of this script only if Blizzard does not supply useful XML or JSON feeds in a reasonable amount of time.
The Bash Script:
The bash script pulls the newest HTML Roster file from the new Armory. This could probably be pulled via the PHP script, but since the file is several thousand lines long, I found it more efficient to save the file first and read it locally.
Please pay special attention to the paths, they will need to be altered in order to work correctly.
#!/bin/bash #Replace YOUR_GUILD_NAME_HERE with your guild name. If your Guild Name is two or more words, it should be in the format #of Your%20Guild%20Name wget --directory-prefix=/path/to/your/desired/directory/ http://us.battle.net/wow/en/guild/YOUR_SERVER_HERE/YOUR_GUILD_NAME_HERE/roster mv /path/to/your/desired/directory/roster /path/to/your/desired/directory/roster.html php /path/to/php/file/ParseRoster.php
The SQL Dump:
Import this into a MySQL database.
-- -- Table structure for table `roster` -- CREATE TABLE IF NOT EXISTS `roster` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `race` VARCHAR(255) NOT NULL, `class` VARCHAR(255) NOT NULL, `level` VARCHAR(255) NOT NULL, `rank` VARCHAR(255) NOT NULL, `ap` VARCHAR(255) NOT NULL, `prof1name` VARCHAR(255) DEFAULT NULL, `prof1value` VARCHAR(255) DEFAULT NULL, `prof2name` VARCHAR(255) DEFAULT NULL, `prof2value` VARCHAR(255) DEFAULT NULL, `talent1` VARCHAR(255) DEFAULT NULL, `talent2` VARCHAR(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
The PHP Backend:
The PHP file should be fairly straight forward.
A few notes:
- I have a config file that holds information for my database, if you have a similar file you should include it, otherwise add in the proper mysql_connect() information.
- Make sure the path to the Roster.html file is correct.
< ?php /** * This script will parse the new WoW Armory without an XML file. * This script will currently pull the Name, Level, Class, Race, * Achievement Points, Professions, and Talents of every member * In a specified guild. The script works for me but may not work * as expected on every system. Use at your own risk. * * @author Josh Grochowski (josh[dot]kastang[at]gmail[dot]com) * */ set_time_limit(8000); include("/path/to/config/file.php"); getRosterInformation(); function getRosterInformation() { $roster = file_get_contents("/path/to/roster/file/roster.html"); $dom = new domDocument; $dom->loadHTML($roster); $dom->preserveWhiteSpace = false; //The first tbody tag marks the start of the actual //'roster' part of the html. $roster = $dom->getElementsByTagName('tbody'); //Each Character has its own tr block. $char = $roster->item(0)->getElementsByTagName('tr'); foreach ($char as $c) { //Character information is split into individual //td blocks. $charInfo = $c->getElementsByTagName('td'); $charImages = $c->getElementsByTagName('img'); //I only care about active characters. Inactive characters //will display 0 Achievement points. if((int)$charInfo->item(5)->nodeValue > 0) { $name = $charInfo->item(0)->nodeValue; $race = $charImages->item(0)->getAttribute('src'); $class = $charImages->item(1)->getAttribute('src'); $level = $charInfo->item(3)->nodeValue; $rank = trim($charInfo->item(4)->nodeValue); $ap = trim($charInfo->item(5)->nodeValue); //Returns an array containing the professions name/level and //talents of each individual character. $charArray = getCharacterInformation($name); $query = "INSERT INTO roster(name,race,class,level,rank,ap,prof1name,prof1value,prof2name,prof2value,talent1,talent2) VALUES('$name','$race','$class','$level','$rank','$ap','$charArray[profName1]','$charArray[profValue1]', '$charArray[profName2]','$charArray[profValue2]','$charArray[talent1]','$charArray[talent2]')"; mysql_query($query) or die(mysql_error()); //Wait 5 seconds inbetween queries to keep from getting banned from WoW Armory servers. //This can probably be adjusted to three or four seconds, but if you do get banned, it can //last las long as 48 hours. sleep(5); } } } function getCharacterInformation($charName) { //link to characters page on WoW Armory $charInfo = file_get_contents("http://us.battle.net/wow/en/character/eitrigg/".$charName."/simple"); $dom = new domDocument; $dom->loadHTML($charInfo); $dom->preserveWhiteSpace = false; //Profession Names $xpath = new DOMXPath($dom); $profName = $xpath->query('//span[@class="profession-details"]/span[@class="name"]'); //Profession Values $profValue = $xpath->query('//span[@class="profession-details"]/span[@class="value"]'); //Talents $talents = $xpath->query('//span[@class="name-build"]/span[@class="name"]'); $charArray = array("profName1" => $profName->item(0)->nodeValue, "profValue1" => $profValue->item(0)->nodeValue, "profName2" => $profName->item(1)->nodeValue, "profValue2" => $profValue->item(1)->nodeValue, "talent1" => $talents->item(0)->nodeValue, "talent2" => $talents->item(1)->nodeValue); return $charArray; } ?>
Installing and Configuring WoW on Linux
A few months ago I wrote a blog post answering some frequently asked questions about playing World of Warcraft on Linux (more specifically, on Ubuntu). I am making a return to WoW after an extensive break. During my break I did a fresh install of Ubuntu 10.04. I am in the process of reinstalling WoW on my Ubuntu partition. While reinstalling and reconfiguring WoW for my system, I took a few screenshots and notes. Hopefully they will be helpful for anyone who wants to play WoW on Linux.
This guide is tailored to Ubuntu 10.04 users, but should be similar for any Debian based OS users. I like to think everything is fairly straight forward. I assume you have some sort of basic Linux knowledge before attempting this guide. For example, if you do not know how to navigate around in Terminal, you probably shouldn't try this.
Prerequisites
Before installing Wine or WoW a few things need to be done with your system.
- Update your graphics drivers: Updating your graphic drivers is probably the most important thing to do to ensure stable performance in WoW. Both NVidia and ATI have made great improvement over the past few years in improving the quality of their Linux drivers. Each release seems to increase the stability and performance of their cards.
- Turn off special effects: If you are using Compiz (or an equivalent) turn it off before trying to play WoW. 9/10 times it will severely diminish performance and cause system lockups. If you use Gnome or KDE, I suggest switching to more lightweight option such as XFCE. This is not mandatory, XFCE my desktop environment of choice. If you want to give XFCE a try, in terminal type:
sudo apt-get install xubuntu-desktop
Install and Configuring Wine
Make sure you have the newest version of Wine installed. If you are using Ubuntu, open terminal and type the following:
sudo apt-add-repository ppa:ubuntu-wine/ppa sudo apt-get update sudo apt-get install wine
The above commands will install the newest version of Wine on your system. At the time of this writing, the newest version is Wine 1.2. After issuing the above commands, type wine --version in Terminal to make sure you have the newest version available. To check the newest version, head over to WineHQ and check the latest Stable Release version.
Generally speaking the newest version of Wine is always the best. Occasionally a bug will occur in a build in which case you will have to manually install a previous version. World of Warcraft is a very well supported game in the Wine community so the chances of such a bug happening are slim.
For now, only one optional change needs to be made in the Wine Configuration. If you are only using a single monitor system, you can probably skip this. If you are using dual (or more) monitors, you should set an emulate desktop. Type winecfg in terminal. Click the Graphics tab, and check the "Emulate a virtual desktop" checkbox. Enter the screen resolution of the monitor you are going to play WoW on under Desktop Size. What this does is create a virtual desktop for Wine programs to run in. This is sometimes needed because certain games may appear distorted or overlap to a second monitor in full screen mode. If you are using Dual Monitors for example, you will need this activated so you can play correctly in full windowed mode and still be able to access your second monitor while playing WoW.
Installing WoW from Scratch
*If you have WoW installed on a seperate Windows partition you can use it rather then installing from scratch. If you do, ignore the installation instructions below and scroll down to Special Cases at the bottom of this post.
After Wine is installed and configured we can start the installation process. This process is pretty straight forward. I am using the WoW Online installer since I do not own the physical WoW discs. You can download the WoW Installer directly from Battle.net here. If this link does not work, login to your Battle.net account and download the Windows version of the WoW Installer.
After the file downloads, open terminal and navigate to the directory where InstallWoW.exe is located and run:
wine InstallWoW.exeIf this is your first time using Wine, the process may take a few extra seconds while configuration files are created. Your screen may also flicker a few times, don't worry, its normal. If all goes well, a screen should pop up asking which version of WoW you want to install. Select WoLK. You should see the following screen shortly after:
After the required files are done downloading, you may receive an error about some system components failing the minimum requirements. This is most likely due to Ubuntu not reporting the proper system information. Ignore any such warnings and click Install.
Next you will be prompted to select an install location for WoW. I personally chose C:\Program Files inside of Wine. You can safely choose whichever directory you want. For future reference, the "C" drive Wine creates is mapped to ~/.wine/drive_c/. In my example, my WoW folder will be: ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/
The longest part of the install when 7.5 GB of WoLK files are being downloaded and installed. I am receiving pretty constant speeds from Blizzards servers of around 800-900KB/s with spikes sometimes around 1.5MB/s. The install part will take a few hours to complete. I would recommend getting to this step before bed.
After the base install of WOLK is done, the game will automatically launch the Blizzard updater and patch WoW to the newest version. If all goes well, this should be done automatically, without issue. In my case, Wine froze while updating to Patch 3.3.3. If the game freezes on you during updating, open terminal and type:
sudo killall wineserver wine ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/Launcher.exe
The launcher should re-launch and the game should continue to upload without any issues.
Configuring WoW
By now WoW should be installed and fully patched. Before running the game, I recommend editing the Config.wtf file before launching WoW for the first time.
#Copy your original Config file to a new location. cp ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/WTF/Config.wtf ~ #Remove the original rm ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/WTF/Config.wtf #Create a new Config.wtf file and copy the below inside it vi ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/WTF/Config.wtf
This config file sets all of the performance settings to the lowest possible setting(don't worry, you'll adjust these later. Just for the initial launch it makes life easier), sets OpenGL by default, accepts the TOS and EULA, and sets a low screen resolution.
SET readTOS "1"
SET readEULA "1"
SET readScanning "-1"
SET readContest "-1"
SET readTerminationWithoutNotice "-1"
SET installType "Retail"
SET locale "enUS"
SET movie "0"
SET showToolsUI "1"
SET portal "us"
SET realmList "us.logon.worldofwarcraft.com"
SET patchlist "us.version.worldofwarcraft.com"
SET hwDetect "0"
SET gxWindow "1"
SET gxRefresh "60"
SET gxMultisampleQuality "0.000000"
SET gxFixLag "0"
SET videoOptionsVersion "3"
SET textureFilteringMode "0"
SET Gamma "1.000000"
SET Sound_OutputDriverName "System Default"
SET Sound_MusicVolume "0.40000000596046"
SET Sound_AmbienceVolume "0.60000002384186"
SET farclip "177"
SET particleDensity "0.10000000149012"
SET baseMip "1"
SET environmentDetail "0.5"
SET weatherDensity "0"
SET ffxGlow "0"
SET ffxDeath "0"
SET gxResolution "1024x760"
SET gxApi "opengl"
Now you should be good to boot the game for the first time. You should have a WoW Icon on your Desktop. If you do, double click on it and it will launch the WoW screen. If you do not have a WoW Icon on your desktop, enter the following command in terminal:
wine ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/Wow.exe
If you did not have a WoW Icon on your Desktop, look at the bottom of this post to see how to create an Alias to launch WoW through terminal.
From here it is up to you to configure the settings to your liking. I recommend taking it slow, gradually update the settings until you are happy with the performance. Personally speaking, most of my settings are very similar to the settings I would play with in Windows. Both ATI and NVidia Linux drivers have come a long way in recent years. You should not see much a performance loss between playing on Windows or Linux. In some instances, you may even see a performance boost.
AddOns
Generally speaking, all AddOns will work fine under Linux. Rather then manually installing my AddOns, I prefer having a program do the manual work for me. One of my favorite programs for such a task is WoWMatrix. As far as I know, WoWMatrix is the only AddOn updater I know that offers a native Linux client.
Download WoWMatrix Linux version from WoWMatrix and execute the following commands:
#Navigate to where wowmatrix.tar.gz file was downloaded tar zxvf wowmatrix.tar.gz ./wowmatrix
If all goes well, WoWMatrix should launch and ask where your WoW folder is located. In the window, right click in the white space and click Show Hidden Files. Navigate to ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/ - After the folder is selected, accept the license agreement. The rest should be self explanatory.
As with configuring your video performance, I recommend gradually adding AddOns. Make sure none cause issues.
Create a Terminal Alias for WoW
If for some reason a Desktop icon was not created, or you do not use a windows manager, you can create an alias to launch WoW via Terminal. If you use bash, add this to your ~/.bash_aliases file:
alias wow='wine ~/.wine/drive_c/Program\ Files/World\ of\ Warcraft/Wow.exe'
After changes are made to your aliases file, you will need to apply the changes by typing source ~/.bash_aliases in Terminal. From now on you will be able to type wow in Terminal and the game will execute.
Special Cases
Unless you were previously directed to read this section, skip it.
Using an existing WoW Install:
If you already have WoW installed on a Windows partition, you have two options to choose from:
- Running WoW directly from your Windows partition.
- Copying your WoW directory from your Windows partition to your Ubuntu parition.
I am assuming you do not have your Windows partition mounted. If this is the case you will first need to know the which partition your Windows is located:
$ sudo fdisk -l Device Boot Start End Blocks Id System /dev/sda1 * 1 13 102400 7 HPFS/NTFS Partition 1 does not end on cylinder boundary. /dev/sda2 13 31871 255897600 7 HPFS/NTFS /dev/sda3 31871 44648 102631425 5 Extended /dev/sda5 31871 44029 97654784 83 Linux /dev/sda6 44029 44527 3998720 82 Linux swap / Solaris /dev/sda7 44527 44648 975872 83 Linux
Issue the above command. it will display a list off all partitions on your hard drives. Look for the largest NTFS filesystem, this will most likely be your Windows partition. In my case, my Windows partition is located on /dev/sda2.
Now that you know which partition Windows is installed on, execute the following commands:
sudo mkdir -p /media/Windows #REPLACE /dev/sda2 with your Windows partition. sudo mount /dev/sda2 /media/Windows
This will create a directory for your Windows partition to reside in then mount the partition to the newly created folder. I recommend you copy your existing WoW install your Ubuntu partition. For consistency, we will move your WoW folder to Wine virtual directories. This is not necessary though, the WoW folder can be placed anywhere on your Ubuntu HD.
sudo cp -r /media/Windows/path/to/World\ of\ Warcraft/ ~/.wine/drive_c/Program\ Files/
This will take awhile to complete. I suggest starting the copy and walking away for an hour.
If you choose to use your Windows partition to run WoW instead of copying it to Ubuntu, you should automount your NTFS drive on boot. Look up how to by editing your fstab file. I will not cover this in my guide.
Conclusion
If you are at this point, chances are you have a working WoW install. Congratulations!



