mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-10-14 02:14:53 +02:00
Item parser + functions
This commit is contained in:
35
engine/function/itemparser/itemlistparser.php
Normal file
35
engine/function/itemparser/itemlistparser.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
function getItemNameById($id) {
|
||||
|
||||
$item_list = explode(PHP_EOL, file_get_contents('item_list.txt'));
|
||||
|
||||
foreach ($item_list as $items) {
|
||||
|
||||
$item_array = explode('@', $items);
|
||||
|
||||
if ($item_array[0] == $id) {
|
||||
|
||||
echo ucfirst($item_array[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getItemIdByName($name) {
|
||||
|
||||
$item_list = explode(PHP_EOL, file_get_contents('item_list.txt'));
|
||||
|
||||
foreach ($item_list as $items) {
|
||||
|
||||
$item_array = explode('@', $items);
|
||||
|
||||
if ($item_array[1] == $name) {
|
||||
|
||||
echo ucfirst($item_array[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
18
engine/function/itemparser/itemparser.php
Normal file
18
engine/function/itemparser/itemparser.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
$items = simplexml_load_file($config['server_path'].'/data/items/items.xml');
|
||||
|
||||
// Create our parsed item list
|
||||
$item_list = fopen('item_list.txt', 'w');
|
||||
|
||||
foreach ($items->children() as $item) {
|
||||
|
||||
if ($item['id'] && $item['name'] != NULL) {
|
||||
|
||||
fwrite($item_list, $item['id'].'@'.$item['name'].PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
fclose($item_list);
|
||||
|
||||
|
Reference in New Issue
Block a user