-
Notifications
You must be signed in to change notification settings - Fork 3
/
everquest_who.parser.class.php
84 lines (72 loc) · 3.36 KB
/
everquest_who.parser.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/* Project: EQdkp-Plus
* Package: RaidLogImport Plugin
* Link: http://eqdkp-plus.eu
*
* Copyright (C) 2006-2016 EQdkp-Plus Developer Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if(!defined('EQDKP_INC'))
{
header('HTTP/1.0 Not Found');
exit;
}
if(!class_exists('everquest_who')) {
class everquest_who extends rli_parser {
public static $name = 'Everquest \who';
public static $xml = false;
public static function check($text) {
$back[1] = true;
// plain text format - nothing to check
return $back;
}
public static function parse($text) {
//[Fri Nov 02 23:00:00 2018] [52 Heretic] Zibaxia
$regex = '~\[(ANONYMOUS|(?<lvl>[0-9]{1,3})\h(?<class>\w*))\]\h(?<name>\w*)~';
preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
foreach($matches as $match) {
$lvl = (isset($match['lvl']) && $match['lvl'] != "") ? trim($match['lvl']) : 0;
$class = (isset($match['class']) && $match['class'] != "") ? trim($match['class']) : '';
$data['members'][] = array(trim($match['name']), $class, '', $lvl);
$data['times'][] = array(trim($match['name']), time() - (2*3600), 'join');
$data['times'][] = array(trim($match['name']), time(), 'leave');
}
//[Fri Nov 02 23:00:00 2018] [52 Heretic (Someclass)] Zibaxia (Iksar) <The Fallen Ones>
$regex = '~((\[ANONYMOUS\])|((\[(?<lvl>[0-9]{1,3})\h(?<title>\w*\s?\w*)\h\((?<class>.*)\)\])))\h(?<name>\w*)\h*((\((?<race>.*)\))*\h*(<(?<guild>.*)>)*)*~';
preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
foreach($matches as $match) {
$lvl = (isset($match['lvl']) && $match['lvl'] != "") ? trim($match['lvl']) : 0;
$class = (isset($match['class']) && $match['class'] != "") ? trim($match['class']) : '';
$data['members'][] = array(trim($match['name']), $class, '', $lvl);
$data['times'][] = array(trim($match['name']), time() - (2*3600), 'join');
$data['times'][] = array(trim($match['name']), time(), 'leave');
}
//[Fri Nov 02 23:00:00 2018] [52 Heretic] Zibaxia (Iksar) <The Fallen Ones>
$regex = '~((\[ANONYMOUS\])|((\[(?<lvl>[0-9]{1,3})\h(?<title>\w*\s?\w*)\])))\h(?<name>\w*)\h*((\((?<race>.*)\))*\h*(<(?<guild>.*)>)*)*~';
preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
foreach($matches as $match) {
$lvl = (isset($match['lvl']) && $match['lvl'] != "") ? trim($match['lvl']) : 0;
$class = (isset($match['class']) && $match['class'] != "") ? trim($match['class']) : '';
$data['members'][] = array(trim($match['name']), $class, '', $lvl);
$data['times'][] = array(trim($match['name']), time() - (2*3600), 'join');
$data['times'][] = array(trim($match['name']), time(), 'leave');
}
$data['zones'][] = array('unknown zone', time() - (2*4000), time());
$data['bosses'][] = array('unknown boss', time() - (1*3600), 0);
return $data;
}
}
}
?>