<?php define("GM_REQUIRED", True); require_once '../config.php'; isset($_REQUEST['action']) ? $action = $_REQUEST['action'] : printNoResults(); switch ($action) { case "getCharacterList": isset($_REQUEST['query']) ? $query = $_REQUEST['query'] : printNoResults(); echo json_encode(getCharacterList($query)); break; case "getCharacterInfo": isset($_REQUEST['query']) ? $query = $_REQUEST['query'] : printNoResults(); echo json_encode(getCharacterInfo($query)); break; case "udpateCharacterAttribute": isset($_REQUEST['query']) ? $query = $_REQUEST['query'] : printNoResults(); echo json_encode(udpateCharacterAttribute($query)); break; } die; function getCharacterList($query) { global $pdo; //Could probably build the sql more effectively here, but I'm lazy atm if (is_numeric($query)) { $sth = $pdo->prepare("SELECT `characters`.`Id`, `characters`.`Name`\n\t\t\t\t\t\t\tFROM `characters`, `login` \n\t\t\t\t\t\t\tWHERE `characters`.`Username` = `login`.`Username`\n\t\t\t\t\t\t\tAND `login`.`Id` = :userId"); $arguments = array(':userId' => $query); } else { $sth = $pdo->prepare("SELECT `characters`.`Id`, `characters`.`Name`\n\t\t\t\t\t\t\t\t\tFROM `characters` \n\t\t\t\t\t\t\t\t\tWHERE `characters`.`Username` = :username"); $arguments = array(':username' => $query); }
function getGuildMembers($base_url, $realm, $guild, $minLevel, $clsFilter = false) { $url = $base_url . "/guild-info.xml?r=" . urlencode(stripslashes($realm)) . "&n=" . urlencode(stripslashes($guild)) . "&p=1"; $xml = $this->pharsexml($url); $node = $xml->xpath("/page/guildInfo/guild/members"); $attr = attribs($node[0]); $maxPages = $attr["maxPage"]; $cList = $this->getCharacterList($xml, $minLevel, $clsFilter); for ($i = 2; $i <= $maxPages; $i++) { $url = $base_url . "/guild-info.xml?r=" . urlencode(stripslashes($realm)) . "&n=" . urlencode(stripslashes($guild)) . "&p={$i}"; $xml = $this->getArmoryDataXML($url); $cList = array_merge($cList, getCharacterList($xml, $minLevel, $clsFilter)); } return $cList; }