diff --git a/engine/function/itemparser/itemlistparser.php b/engine/function/itemparser/itemlistparser.php index 408c6ad..214166b 100644 --- a/engine/function/itemparser/itemlistparser.php +++ b/engine/function/itemparser/itemlistparser.php @@ -1,5 +1,4 @@ '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; } +?> \ No newline at end of file diff --git a/market.php b/market.php index a8efca6..5c53856 100644 --- a/market.php +++ b/market.php @@ -5,6 +5,21 @@ $imageType = $config['shop']['imageType']; $items = getItemList(); $compare = &$_GET['compare']; +// If we failed to load items.xml, a string is returned (not an array) +// with the attempted loaded file path. +// So if $items is not an array, send an error message, include the footer and ignore rest of this page. +if (is_array($items) === false): + ?> +
Failed to load item list.
+Attempted to load this file:
+Configure correct 'server_path' in config.php.
+If the path is correct, make sure your web user has access to read it.
+