本文整理汇总了PHP中Armory类的典型用法代码示例。如果您正苦于以下问题:PHP Armory类的具体用法?PHP Armory怎么用?PHP Armory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Armory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LoadTemplate
public static function LoadTemplate($template_name, $overall = false)
{
if ($overall) {
$template = __ARMORYDIRECTORY__ . '/admin/template/overall/overall_' . $template_name . '.php';
} else {
$template = __ARMORYDIRECTORY__ . '/admin/template/' . $template_name . '.php';
}
if (file_exists($template)) {
include $template;
} else {
Armory::Log()->writeError('%s : unable to find template "%s" (template theme: %s, overall: %d, path: %s)!', __METHOD__, $template_name, self::GetTemplateTheme(), (int) $overall, $template);
}
}
示例2: BuildOpposingTeamList
/**
* Build opponents list for current arena team
* @category Arenateams class
* @access public
* @return array
**/
public function BuildOpposingTeamList()
{
if (!$this->arenateamid) {
Armory::Log()->writeError('%s : arenateamid not provided', __METHOD__);
return false;
}
$game_ids = Armory::$cDB->select("SELECT DISTINCT `gameid` FROM `armory_game_chart` WHERE `teamid`=%d", $this->arenateamid);
if (!$game_ids) {
Armory::Log()->writeLog('%s : unable to find any game for teamId %d', __METHOD__, $this->arenateamid);
return false;
}
$all_games = array();
$counter = count($game_ids);
foreach ($game_ids as $game) {
$all_games[] = $game['gameid'];
}
$game_chart = Armory::$cDB->select("\n SELECT\n `armory_game_chart`.`gameid`,\n `armory_game_chart`.`teamid`,\n `armory_game_chart`.`guid`,\n COUNT(`armory_game_chart`.`teamid`) AS `countTeam`,\n `arena_team`.`name`,\n `arena_team`.`type`\n FROM `armory_game_chart` AS `armory_game_chart`\n LEFT JOIN `arena_team` AS `arena_team` ON `arena_team`.`arenateamid`=`armory_game_chart`.`teamid`\n WHERE `armory_game_chart`.`gameid` IN (%s) AND `armory_game_chart`.`teamid` <> %d\n GROUP BY `armory_game_chart`.`gameid`", $all_games, $this->arenateamid);
if (!$game_chart) {
Armory::Log()->writeError('%s : game_ids were fetched from DB, but script was unable to get data for these matches from characters DB (arenateamid:%d)', __METHOD__, $this->arenateamid);
return false;
}
$chart_data = array();
foreach ($game_chart as $team) {
if (!isset($chart_data[$team['teamid']])) {
// Do not add same teams more than 1 time
$rating_change = Armory::$cDB->select("SELECT `gameid`, `changeType`, `ratingChange` FROM `armory_game_chart` WHERE `teamid`=%d AND `gameid` IN (%s)", $team['teamid'], $all_games);
$rd = 0;
if ($rating_change) {
$exists = array();
foreach ($rating_change as $rCh) {
if (!isset($exists[$rCh['gameid']])) {
if ($rCh['changeType'] == 1) {
$rd += $rCh['ratingChange'];
} else {
$rd -= $rCh['ratingChange'];
}
$exists[$rCh['gameid']] = true;
}
}
}
$losses = Armory::$cDB->selectCell("SELECT COUNT(distinct(`gameid`)) FROM `armory_game_chart` WHERE `changeType`=1 AND `teamid`='%d' AND `gameid` IN (%s)", $team['teamid'], $all_games);
$wins = Armory::$cDB->selectCell("SELECT COUNT(distinct(`gameid`)) FROM `armory_game_chart` WHERE `changeType`=2 AND `teamid`='%d' AND `gameid` IN (%s)", $team['teamid'], $all_games);
$chart_data[$team['teamid']] = array('deleted' => $this->TeamExists($team['teamid']) ? 'false' : 'true', 'games' => $losses + $wins, 'losses' => $losses, 'rd' => $rd, 'realm' => Armory::$currentRealmInfo['name'], 'teamName' => $team['name'], 'teamUrl' => sprintf("r=%s&ts=%d&t=%s", urlencode(Armory::$currentRealmInfo['name']), $team['type'], urlencode($team['name'])), 'wins' => $wins);
$chart_data[$team['teamid']]['winPer'] = Utils::GetPercent($chart_data[$team['teamid']]['games'], $chart_data[$team['teamid']]['wins']);
}
}
return $chart_data;
}
示例3: GetRandomSuffixData
/**
* @return array
**/
public function GetRandomSuffixData()
{
if ($this->m_server != SERVER_MANGOS) {
Armory::Log()->writeError('%s : this method is usable with MaNGOS servers only.', __METHOD__);
return false;
}
return array($this->GetUInt32Value(ITEM_FIELD_ENCHANTMENT_8_1), $this->GetUInt32Value(ITEM_FIELD_ENCHANTMENT_9_1), $this->GetUInt32Value(ITEM_FIELD_ENCHANTMENT_10_1));
}
示例4: die
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**/
if (!defined('__ARMORY__')) {
die('Direct access to this file not allowed!');
}
session_start();
if (!@(include 'classes/class.armory.php')) {
die('<b>Error:</b> unable to load Armory class!');
}
if (!@(include 'revision_nr.php')) {
die('<b>Error:</b> unable to load revision_nr.php!');
}
$_SESSION['last_url'] = str_replace('.php', '.xml', $_SERVER['PHP_SELF']) . '?' . str_replace('locale=', 'l=', $_SERVER['QUERY_STRING']);
$armory = new Armory();
/* Check DbVersion */
$dbVersion = $armory->aDB->selectCell("SELECT `version` FROM `ARMORYDBPREFIX_db_version`");
if ($dbVersion != DB_VERSION) {
if (!$dbVersion) {
if (isset($armory->armoryconfig['checkVersionType']) && $armory->armoryconfig['checkVersionType'] == 'log') {
$armory->Log()->writeError('ArmoryChecker: wrong Armory DB name!');
} else {
echo '<b>Fatal error</b>: wrong Armory DB name<br/>';
}
}
$errorDBVersion = sprintf('Current version is %s but expected %s.<br />
Apply all neccessary updates from \'sql/updates\' folder and refresh this page.', $dbVersion ? "'" . $dbVersion . "'" : 'not defined', "'" . DB_VERSION . "'");
if (isset($armory->armoryconfig['checkVersionType']) && $armory->armoryconfig['checkVersionType'] == 'log') {
$armory->Log()->writeError('ArmoryChecker : DB_VERSION error: %s', defined('DB_VERSION') ? $errorDBVersion : 'DB_VERSION constant not defined!');
} else {
示例5: define
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**/
define('__ARMORY__', true);
if (!@(include 'includes/armory_loader.php')) {
die('<b>Fatal error:</b> unable to load system files.');
}
header('Content-type: text/xml');
$page_element = array('globalSearch' => 1, 'lang' => Armory::GetLocale(), 'requestUrl' => 'login-status.xml');
$xml->XMLWriter()->startElement('page');
foreach ($page_element as $page_key => $page_value) {
$xml->XMLWriter()->writeAttribute($page_key, $page_value);
}
$xml->XMLWriter()->startElement('loginStatus');
if (isset($_SESSION['username'])) {
$xml->XMLWriter()->writeAttribute('username', $_SESSION['username']);
} else {
$xml->XMLWriter()->writeAttribute('username', null);
}
$xml->XMLWriter()->endElement();
//loginStatus
$xml->XMLWriter()->endElement();
//page
echo $xml->StopXML();
示例6: GetServerTypeByString
/**
* Returns server type ID
* @category Utils class
* @access public
* @param string $server
* @return int
**/
public function GetServerTypeByString($server)
{
$server = strtolower($server);
if ($server == 'mangos') {
return SERVER_MANGOS;
} elseif ($server == 'trinity') {
return SERVER_TRINITY;
}
Armory::Log()->writeError('%s : unsupported server type ("%s")!', __METHOD__, $server);
return UNK_SERVER;
}
示例7: define
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**/
define('__ARMORY__', true);
define('__ARMORYDIRECTORY__', dirname(dirname(__FILE__)));
if (!@(include __ARMORYDIRECTORY__ . '/includes/classes/class.armory.php')) {
die('<b>Error:</b> unable to load Armory class!');
}
$update_type = 'echo';
// Change to 'echo' to show query in you browser. Or choose 'update' to execute all queries directly to DB.
Armory::InitializeArmory();
echo '<title>World of Warcraft Armory</title>';
$check_builded = Armory::$aDB->selectCell("SELECT `loot_builded` FROM `ARMORYDBPREFIX_db_version`");
if ($check_builded === 1) {
die("You've already builded loot tables for bosses. If you want to re-build list, change field `loot_builded` to 0 in `armory_db_version` table: <br /><code>UPDATE `armory_db_version` SET `loot_builded`=0;</code>");
}
// Select all ids
$instance_data = Armory::$aDB->select("SELECT `id`, `name_id`, `type` FROM `ARMORYDBPREFIX_instance_data`");
if (!$instance_data) {
die('Error: can not find any boss data!');
}
foreach ($instance_data as $data) {
switch ($data['type']) {
case 'npc':
if (isset($data['name_id']) && $data['name_id'] > 0) {
$data['id'] = $data['name_id'];
示例8: die
if (!(include __ARMORYDIRECTORY__ . '/includes/classes/class.arenateams.php')) {
die('<b>Error:</b> unable to load arenateams class!');
}
$arenateams = new Arenateams();
}
if (defined('load_search_class')) {
if (!(include __ARMORYDIRECTORY__ . '/includes/classes/class.search.php')) {
die('<b>Error:</b> unable to load search engine class!');
}
$search = new SearchMgr();
}
if (defined('load_itemprototype_class')) {
if (!(include __ARMORYDIRECTORY__ . '/includes/classes/class.itemprototype.php')) {
die('<b>Error:</b> unable to load ItemPrototype class!');
}
// Do not create class instance here. It should be created in Characters or Items classes.
}
if (defined('load_item_class')) {
if (!(include __ARMORYDIRECTORY__ . '/includes/classes/class.item.php')) {
die('<b>Error:</b> unable to load Item class!');
}
// Do not create class instance here. It should be created in Characters or Items classes.
}
// Start XML parser
if (!(include __ARMORYDIRECTORY__ . '/includes/classes/class.xmlhandler.php')) {
die('<b>Error:</b> unable to load XML Handler class!');
}
$xml = new XMLHandler(Armory::GetLocale());
if (!defined('RSS_FEED')) {
$xml->StartXML();
}
示例9: foreach
$xml->XMLWriter()->writeAttribute('name', Armory::$aDB->selectCell("SELECT `name_" . Armory::GetLocale() . "` FROM `ARMORYDBPREFIX_petcalc` WHERE `id` < 0 AND `key`='tenacity'"));
$xml->XMLWriter()->writeAttribute('order', 1);
$pet_tenacity = $utils->GetPetTalentCalculatorData('tenacity');
foreach ($pet_tenacity as $tenacity) {
$xml->XMLWriter()->startElement('family');
foreach ($tenacity as $tenacity_key => $tenacity_value) {
$xml->XMLWriter()->writeAttribute($tenacity_key, $tenacity_value);
}
$xml->XMLWriter()->endElement();
//family
}
$xml->XMLWriter()->endElement();
//petTalentTab
$xml->XMLWriter()->startElement('petTalentTab');
$xml->XMLWriter()->writeAttribute('key', 'Ferocity');
$xml->XMLWriter()->writeAttribute('name', Armory::$aDB->selectCell("SELECT `name_" . Armory::GetLocale() . "` FROM `ARMORYDBPREFIX_petcalc` WHERE `id` < 0 AND `key`='ferocity'"));
$xml->XMLWriter()->writeAttribute('order', 0);
$pet_ferocity = $utils->GetPetTalentCalculatorData('ferocity');
foreach ($pet_ferocity as $ferocity) {
$xml->XMLWriter()->startElement('family');
foreach ($ferocity as $ferocity_key => $ferocity_value) {
$xml->XMLWriter()->writeAttribute($ferocity_key, $ferocity_value);
}
$xml->XMLWriter()->endElement();
//family
}
$xml->XMLWriter()->endElement();
//petTalentTab
}
$xml->XMLWriter()->endElement();
//talentTabs or petTalentTabs
示例10: SetLocale
/**
* Sets locale
* @category Armory class
* @access public
* @return bool
**/
public static function SetLocale($locale, $locale_id)
{
self::$_locale = $locale;
self::$_loc = $locale_id;
return true;
}
示例11: _query
protected function _query($safe_sql, $queryType)
{
// Execute query and calculate execution time
$make_array = array();
$query_start = microtime(true);
$this->queryCount++;
$performed_query = mysql_query($safe_sql, $this->connectionLink);
if (!$performed_query) {
if (!$this->disableNextError) {
Armory::Log()->writeLog('%s : unable to execute SQL query (%s). MySQL error: %s', __METHOD__, $safe_sql, mysql_error($this->connectionLink) ? sprintf('"%s" (Error #%d)', mysql_error($this->connectionLink), mysql_errno($this->connectionLink)) : 'none');
}
if ($this->disableNextError) {
$this->disableNextError = false;
}
return false;
}
$result = false;
switch ($queryType) {
case QueryType::SINGLE_CELL:
$row = mysql_fetch_row($performed_query);
$result = $row[0];
break;
case QueryType::SINGLE_ROW:
$result = mysql_fetch_assoc($performed_query);
if (is_array($result)) {
foreach ($result as $rKey => $rValue) {
if (is_string($rKey)) {
$make_array[$rKey] = $rValue;
}
}
$result = $make_array;
}
break;
case QueryType::MULTIPLY_ROW:
$result = array();
while ($_result = mysql_fetch_assoc($performed_query)) {
if (is_array($_result)) {
foreach ($_result as $rKey => $rValue) {
if (is_string($rKey)) {
$make_array[$rKey] = $rValue;
}
}
$result[] = $make_array;
} else {
$result[] = $_result;
}
}
break;
case QueryType::OBJECT_QUERY:
$result = array();
while ($_result = mysql_fetch_object($performed_query)) {
$result[] = $_result;
}
break;
case QueryType::SQL_QUERY:
$result = true;
break;
default:
$result = false;
break;
}
$query_end = microtime(true);
$queryTime = round($query_end - $query_start, 4);
Armory::Log()->writeSql('[%s ms]: %s', $queryTime, $safe_sql);
$this->queryTimeGeneration += $queryTime;
return $result;
}
示例12: array
$xml->LoadXSLT('items/info.xsl');
$xml->XMLWriter()->startElement('page');
$xml->XMLWriter()->writeAttribute('globalSearch', 1);
$xml->XMLWriter()->writeAttribute('lang', Armory::GetLocale());
$xml->XMLWriter()->writeAttribute('requestUrl', 'item-info.xml');
$xml->XMLWriter()->writeAttribute('requestQuery', 'i=' . $itemID);
if (!$items->IsItemExists($itemID)) {
$xml->XMLWriter()->startElement('itemInfo');
$xml->XMLWriter()->endElement();
//itemInfo
echo $xml->StopXML();
exit;
}
// Do not query all rows - item data generated by item-tooltip.php
$data = $items->GetItemData($itemID);
$item_data = array('icon' => $items->GetItemIcon($itemID, $data['displayid']), 'id' => $itemID, 'level' => $data['ItemLevel'], 'name' => Armory::GetLocale() == 'en_gb' || Armory::GetLocale() == 'en_us' ? $data['name'] : $items->GetItemName($itemID), 'quality' => $data['Quality'], 'type' => null);
$xml->XMLWriter()->startElement('itemInfo');
$xml->XMLWriter()->startElement('item');
foreach ($item_data as $item_data_key => $item_data_value) {
$xml->XMLWriter()->writeAttribute($item_data_key, $item_data_value);
}
$extended_cost = $mangos->GetVendorExtendedCost($itemID);
if ($data['SellPrice'] > 0 || $data['BuyPrice'] || $extended_cost > 0) {
$xml->XMLWriter()->startElement('cost');
if ($data['SellPrice'] > 0) {
$xml->XMLWriter()->writeAttribute('sellPrice', $data['SellPrice']);
}
if ($data['BuyPrice'] > 0 && $items->IsVendorItem($itemID)) {
$xml->XMLWriter()->writeAttribute('buyPrice', $data['BuyPrice']);
}
$cost_info = $mangos->GetExtendedCost($extended_cost);
示例13: ConvertArray
protected function ConvertArray($source)
{
if (!is_array($source)) {
Armory::Log()->writeError('%s : source must have array type!', __METHOD__);
return null;
}
$returnString = null;
$count = count($source);
for ($i = 0; $i < $count; $i++) {
if (!isset($source[$i])) {
continue;
}
if ($i) {
$returnString .= ", '" . $this->SanitizeString($source[$i]) . "'";
} else {
$returnString .= "'" . $this->SanitizeString($source[$i]) . "'";
}
}
return $returnString;
}
示例14: strtolower
$xml->XMLWriter()->endElement();
//title
$xml->XMLWriter()->startElement('updated');
$xml->XMLWriter()->text($fdate);
$xml->XMLWriter()->endElement();
//updated
$xml->XMLWriter()->startElement('published');
$xml->XMLWriter()->text($fdate);
$xml->XMLWriter()->endElement();
//published
$xml->XMLWriter()->startElement('id');
$xml->XMLWriter()->text(sprintf('%s@%s_%s_%s', strtolower(urlencode($characters->GetName())), strtolower(urlencode($characters->GetRealmName())), $feed['hard_data'], date('dmYHis', $feed['hard_date'])));
$xml->XMLWriter()->endElement();
//id
$xml->XMLWriter()->startElement('link');
$xml->XMLWriter()->writeAttribute('href', sprintf('character-feed.xml?r=%s&cn=%s&locale=%s', urldecode($characters->GetRealmName()), urldecode($characters->GetName()), Armory::GetLocale()));
$xml->XMLWriter()->endElement();
//link
$xml->XMLWriter()->startElement('content');
$xml->XMLWriter()->writeAttribute('type', 'html');
$xml->XMLWriter()->writeCData($feed['desc']);
$xml->XMLWriter()->endElement();
//content
$xml->XMLWriter()->endElement();
//entry
}
$xml->XMLWriter()->endElement();
//feed
$xml_cache_data = $xml->StopXML();
echo $xml_cache_data;
if (Armory::$armoryconfig['useCache'] == true && !isset($_GET['skipCache'])) {
示例15: GenerateAchievements
private function GenerateAchievements()
{
if (!is_array($this->achievements_storage)) {
Armory::Log()->writeError('%s : unable to generate achievements ID: achievements storage is empty!', __METHOD__);
return false;
}
$this->achievements_id = array();
$ach_storage = array();
$criterias_storage = array();
$latest_count = 0;
foreach ($this->achievements_storage as $achievement) {
if ($latest_count < 6) {
$this->latest_achievements[] = $achievement;
$latest_count++;
}
$ach_storage[$achievement['achievement']] = $achievement;
$this->achievements_id[] = $achievement['achievement'];
}
foreach ($this->achievements_progress_storage as $criteria) {
$criterias_storage[$criteria['criteria']] = $criteria;
}
$this->achievements_storage = $ach_storage;
$this->achievements_progress_storage = $criterias_storage;
unset($ach_storage, $criterias_storage);
return true;
}