mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-10-13 18:04:54 +02:00
Market: Display error message instead of crashing if fail to load items.xml file.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/* Returns a PHP array $id => 'name'
|
||||
$items = getItemList();
|
||||
echo $items[2160]; // Returns 'Crystal Coin'
|
||||
@@ -18,17 +17,18 @@ function getItemById($id) {
|
||||
}
|
||||
|
||||
function parseItems() {
|
||||
global $config;
|
||||
|
||||
$items = simplexml_load_file($config['server_path'].'/data/items/items.xml');
|
||||
$out = array();
|
||||
|
||||
// Create our parsed item list
|
||||
foreach ($items->children() as $item) {
|
||||
if ($item['id'] && $item['name'] != NULL) {
|
||||
$out[(int)$item['id']] = (string)$item['name'];
|
||||
$file = Config('server_path') . '/data/items/items.xml';
|
||||
if (file_exists($file)) {
|
||||
$itemList = array();
|
||||
$items = simplexml_load_file($file);
|
||||
// Create our parsed item list
|
||||
foreach ($items->children() as $item) {
|
||||
if ($item['id'] && $item['name'] != NULL) {
|
||||
$itemList[(int)$item['id']] = (string)$item['name'];
|
||||
}
|
||||
}
|
||||
return $itemList;
|
||||
}
|
||||
|
||||
return $out;
|
||||
return $file;
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user