mirror of
https://github.com/slawkens/myaac.git
synced 2025-06-13 08:14:31 +02:00
Use config() instead of global $config, use exec instead of query
This commit is contained in:
parent
219f128cb7
commit
6a89b12258
@ -16,14 +16,14 @@ class Items
|
|||||||
|
|
||||||
public static function loadFromXML($show = false)
|
public static function loadFromXML($show = false)
|
||||||
{
|
{
|
||||||
global $config, $db;
|
global $db;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$db->query("DELETE FROM `myaac_items`;");
|
$db->exec("DELETE FROM `myaac_items`;");
|
||||||
} catch (PDOException $error) {
|
} catch (PDOException $error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_path = $config['data_path'] . 'items/items.xml';
|
$file_path = config('data_path') . 'items/items.xml';
|
||||||
if (!file_exists($file_path)) {
|
if (!file_exists($file_path)) {
|
||||||
self::$error = 'Cannot load file ' . $file_path;
|
self::$error = 'Cannot load file ' . $file_path;
|
||||||
return false;
|
return false;
|
||||||
@ -82,7 +82,7 @@ class Items
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getDescription($id, $count = 1) {
|
public static function getDescription($id, $count = 1) {
|
||||||
global $config, $db;
|
global $db;
|
||||||
|
|
||||||
$item = self::getItem($id);
|
$item = self::getItem($id);
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ class Items
|
|||||||
else
|
else
|
||||||
$s .= 'an item of type ' . $item['id'];
|
$s .= 'an item of type ' . $item['id'];
|
||||||
|
|
||||||
if(strtolower($attr['type']) == 'rune') {
|
if(isset($attr['type']) && strtolower($attr['type']) == 'rune') {
|
||||||
$query = $db->query('SELECT `level`, `maglevel`, `vocations` FROM `' . TABLE_PREFIX . 'spells` WHERE `item_id` = ' . $id);
|
$query = $db->query('SELECT `level`, `maglevel`, `vocations` FROM `' . TABLE_PREFIX . 'spells` WHERE `item_id` = ' . $id);
|
||||||
if($query->rowCount() == 1) {
|
if($query->rowCount() == 1) {
|
||||||
$query = $query->fetch();
|
$query = $query->fetch();
|
||||||
@ -124,11 +124,12 @@ class Items
|
|||||||
$s .= '. ' . ($count > 1 ? "They" : "It") . ' can only be used by ';
|
$s .= '. ' . ($count > 1 ? "They" : "It") . ' can only be used by ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$configVocations = config('vocations');
|
||||||
if(!empty(trim($query['vocations']))) {
|
if(!empty(trim($query['vocations']))) {
|
||||||
$vocations = json_decode($query['vocations']);
|
$vocations = json_decode($query['vocations']);
|
||||||
if(count($vocations) > 0) {
|
if(count($vocations) > 0) {
|
||||||
foreach($vocations as $voc => $show) {
|
foreach($vocations as $voc => $show) {
|
||||||
$vocations[$config['vocations'][$voc]] = $show;
|
$vocations[$configVocations[$voc]] = $show;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user