Skip to content

Commit

Permalink
[463] Added configuration option to disable characters loading from b…
Browse files Browse the repository at this point in the history
…anned accounts. Do not forget to update your config file from configuration.php.default. Also, move character requirements checks to separate method.
  • Loading branch information
Shadez committed Jan 20, 2011
1 parent ecf577f commit f6ccadf
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 37 deletions.
79 changes: 46 additions & 33 deletions includes/classes/class.characters.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 462
* @revision 463
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -299,6 +299,49 @@ public function SetOptions($options) {
return true;
}

private function IsCharacterFitsRequirements(&$player_data) {
$gmLevel = 0;
// Disable next SQL error
Armory::$rDB->SkipNextError();
if($this->m_server == SERVER_TRINITY) {
$gmLevel = Armory::$rDB->selectCell("SELECT `gmlevel` FROM `account_access` WHERE `id`=%d AND `RealmID` IN (-1, %d)", $player_data['account'], Armory::$connectionData['id']);
}
elseif($this->m_server == SERVER_MANGOS) {
$gmLevel = Armory::$rDB->selectCell("SELECT `gmlevel` FROM `account` WHERE `id`=%d LIMIT 1", $player_data['account']);
}
$allowed = ($gmLevel <= Armory::$armoryconfig['minGmLevelToShow']) ? true : false;
if(!$allowed) {
Armory::Log()->writeLog('%s : unable to display character %s (GUID: %d): GM level restriction!', __METHOD__, $player_data['name'], $player_data['guid']);
return false;
}
if($player_data['level'] < Armory::$armoryconfig['minlevel']) {
Armory::Log()->writeLog('%s : unable to load character %s (GUID: %d): level restriction.', __METHOD__, $player_data['name'], $player_data['guid']);
return false;
}
if(Armory::$armoryconfig['skipBanned'] && Armory::$rDB->selectCell("SELECT 1 FROM `account_banned` WHERE `id` = %d AND `active` = 1", $player_data['account'])) {
Armory::Log()->writeLog('%s : unable to load character %s (GUID: %d) from banned account %d.', __METHOD__, $player_data['name'], $player_data['guid'], $player_data['account']);
return false;
}
// Class/race/faction checks
if($player_data['class'] >= MAX_CLASSES) {
// Unknown class
Armory::Log()->writeError('%s : character %s (GUID: %d) has wrong data in DB: classID %d was not found. Unable to continue.', __METHOD__, $player_data['name'], $player_data['guid'], $player_data['class']);
return false;
}
elseif($player_data['race'] >= MAX_RACES) {
// Unknown race
Armory::Log()->writeError('%s : character %s (GUID: %d) has wrong data in DB: raceID %d was not found. Unable to continue.', __METHOD__, $player_data['name'], $player_data['guid'], $player_data['race']);
return false;
}
$this->faction = Utils::GetFactionId($player_data['race']);
if($this->faction === false) {
// Unknown faction
Armory::Log()->writeError('%s : character %s (GUID: %d) has wrong data in DB: factionID %d was not found (raceID: %d).', __METHOD__, $player_data['name'], $player_data['guid'], $this->faction, $player_data['race']);
return false;
}
return true;
}

/**
* Init character, load data from DB, checks for requirements, etc.
* @category Characters class
Expand Down Expand Up @@ -397,39 +440,9 @@ public function BuildCharacter($name, $realmId = 1, $full = true, $initialBuild
$this->HandleCharacterData();
}
// Can we display this character?
$gmLevel = false;
Armory::$rDB->SkipNextError();
if($this->m_server == SERVER_TRINITY) {
$gmLevel = Armory::$rDB->selectCell("SELECT `gmlevel` FROM `account_access` WHERE `id`=%d AND `RealmID` IN (-1, %d)", $player_data['account'], Armory::$connectionData['id']);
}
elseif($this->m_server == SERVER_MANGOS) {
$gmLevel = Armory::$rDB->selectCell("SELECT `gmlevel` FROM `account` WHERE `id`=%d LIMIT 1", $player_data['account']);
}
$allowed = ($gmLevel <= Armory::$armoryconfig['minGmLevelToShow']) ? true : false;
if(!$allowed || $player_data['level'] < Armory::$armoryconfig['minlevel']) {
Armory::Log()->writeLog('%s : Player %d (%s) can not be displayed (GM level restriction or has low level (%d level))!', __METHOD__, $player_data['guid'], $player_data['name'], $player_data['level']);
unset($player_data);
return false;
}
// Class/race/faction checks
if($player_data['class'] >= MAX_CLASSES) {
// Unknown class
Armory::Log()->writeError('%s : Player %d (%s) has wrong data in DB: classID %d was not found.', __METHOD__, $player_data['guid'], $player_data['name'], $player_data['class']);
unset($player_data);
return false;
}
elseif($player_data['race'] >= MAX_RACES) {
// Unknown race
Armory::Log()->writeError('%s : Player %d (%s) has wrong data in DB: raceID %d was not found.', __METHOD__, $player_data['guid'], $player_data['name'], $player_data['race']);
unset($player_data);
return false;
}
$this->faction = Utils::GetFactionId($player_data['race']);
if($this->faction === false) {
// Unknown faction
Armory::Log()->writeError('%s : Player %d (%s) has wrong data in DB: factionID %d was not found (raceID: %d).', __METHOD__, $player_data['guid'], $player_data['name'], $this->faction, $player_data['class']);
unset($player_data);
if(!$this->IsCharacterFitsRequirements($player_data)) {
return false;
// Debug message will be added from Characters::IsCharacterFitsRequirements()
}
foreach($player_data as $pData_key => $pData_value) {
if(is_string($pData_key)) {
Expand Down
10 changes: 8 additions & 2 deletions includes/classes/configuration.php.default
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 456
* @revision 463
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -100,6 +100,11 @@ $ArmoryConfig['mysql']['charset_realmd'] = 'UTF8';
# 1 (Everyone except Administrators and GMs will be displayed in Armory)
# 0 (Only players will be displayed in Armory)
#
# skipBanned
# Disable characters loading from banned accounts?
# Default: false (Recommended)
# true
#
# defaultLocale
# Site default locale
# Default: en_gb (UK English)
Expand Down Expand Up @@ -141,11 +146,12 @@ $ArmoryConfig['settings']['cache_lifetime'] = 86400;
$ArmoryConfig['settings']['db_prefix'] = 'armory';
$ArmoryConfig['settings']['minlevel'] = 10;
$ArmoryConfig['settings']['minGmLevelToShow'] = 3;
$ArmoryConfig['settings']['skipBanned'] = false;
$ArmoryConfig['settings']['defaultLocale'] = 'en_gb';
$ArmoryConfig['settings']['maintenance'] = false;
$ArmoryConfig['settings']['useDebug'] = true;
$ArmoryConfig['settings']['logLevel'] = 2;
$ArmoryConfig['settings']['configVersion'] = '1801201101';
$ArmoryConfig['settings']['configVersion'] = '2001201101';
$ArmoryConfig['settings']['checkVersionType'] = 'show';

##############################################################################################
Expand Down
4 changes: 2 additions & 2 deletions includes/revision_nr.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define('ARMORY_REVISION', 462);
define('ARMORY_REVISION', 463);
define('DB_VERSION', 'armory_r456');
define('CONFIG_VERSION', '1801201101');
define('CONFIG_VERSION', '2001201101');
?>

0 comments on commit f6ccadf

Please sign in to comment.