1: <?php
2:
3: namespace Budabot\Core;
4:
5: /*
6: ** Author: Sebuda, Derroylo (RK2)
7: ** Description: AO xml abstaction layer for guild info, whois, player history and server status.
8: ** Version: 1.1
9: **
10: ** Developed for: Budabot(http://sourceforge.net/projects/budabot)
11: **
12: ** Date(created): 01.10.2005
13: ** Date(last modified): 16.01.2007
14: **
15: ** Copyright (C) 2005, 2006, 2007 Carsten Lohmann and J. Gracik
16: **
17: ** Licence Infos:
18: ** This file is part of Budabot.
19: **
20: ** Budabot is free software; you can redistribute it and/or modify
21: ** it under the terms of the GNU General Public License as published by
22: ** the Free Software Foundation; either version 2 of the License, or
23: ** (at your option) any later version.
24: **
25: ** Budabot is distributed in the hope that it will be useful,
26: ** but WITHOUT ANY WARRANTY; without even the implied warranty of
27: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28: ** GNU General Public License for more details.
29: **
30: ** You should have received a copy of the GNU General Public License
31: ** along with Budabot; if not, write to the Free Software
32: ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33: */
34:
35: //class provide some basic function to splice XML Files or getting an XML file from a URL
36: class xml {
37: //Extracts one entry of the XML file
38: public static function spliceData($sourcefile, $start, $end) {
39: $data = explode($start, $sourcefile, 2);
40: if (!$data || (is_array($data) && count($data) < 2)) {
41: return "";
42: }
43: $data = $data[1];
44: $data = explode($end, $data, 2);
45: if (!$data || (is_array($data) && count($data) < 2)) {
46: return "";
47: }
48: return $data[0];
49: }
50:
51: //Extracts more then one entry of the XML file
52: public static function spliceMultiData($sourcefile, $start, $end) {
53: $targetdata = array();
54: $sourcedata = explode($start, $sourcefile);
55: array_shift($sourcedata);
56: forEach ($sourcedata as $indsplit) {
57: $target = explode($end, $indsplit, 2);
58: $targetdata[] = $target[0];
59: }
60: return $targetdata;
61: }
62: }
63: