3 include_once('nel_message.php');
5 /////////////////////////////////////////////////////////////////
6 // WARNING : this is a generated file, don't change it !
7 /////////////////////////////////////////////////////////////////
9 class CAdminServiceWeb
extends CCallbackClient
12 function globalCmd($command)
15 $msg->setName("GCMD");
18 $msg->serialString($command);
20 return parent
::sendMessage($msg);
25 function controlCmd($serviceAlias, $command)
28 $msg->setName("CCMD");
31 $msg->serialString($serviceAlias);
32 $msg->serialString($command);
34 return parent
::sendMessage($msg);
39 function serviceCmd($serviceAlias, $command)
42 $msg->setName("SCMD");
45 $msg->serialString($serviceAlias);
46 $msg->serialString($command);
48 return parent
::sendMessage($msg);
53 function getShardOrders()
61 $ret = parent
::sendMessage($msg);
65 $this->invokeError("getShardOrders", "Error in 'sendMessage'");
69 $retMsg = parent
::waitMessage();
73 $this->invokeError("getShardOrders", "Error in 'waitMessage'");
76 if (!($retMsg->MsgName
=== "R_GSO"))
79 $this->invokeError("getShardOrders", "Invalid response, awaited 'R_GSO', received '".$retMsg->MsgName
."'");
83 // serial the return value
85 $retMsg->serialUInt32($nbElem);
87 for ($i=0; $i<$nbElem;$i++
)
89 $retMsg->serialString($item);
94 // return the return value
108 $ret = parent
::sendMessage($msg);
112 $this->invokeError("getStates", "Error in 'sendMessage'");
116 $retMsg = parent
::waitMessage();
120 $this->invokeError("getStates", "Error in 'waitMessage'");
124 if (!($retMsg->MsgName
=== "R_GS"))
127 $this->invokeError("getStates", "Invalid response, awaited 'R_GS', received '".$retMsg->MsgName
."'");
131 // serial the return value
133 $retMsg->serialUInt32($nbElem);
136 for ($i=0; $i<$nbElem;$i++
)
138 $retMsg->serialString($item);
143 // return the return value
149 function getHighRezGraph($varAddr, $startDate, $endDate, $milliStep)
152 $msg->setName("GHRG");
155 $msg->serialString($varAddr);
156 $msg->serialUint32($startDate);
157 $msg->serialUint32($endDate);
158 $msg->serialUint32($milliStep);
161 $ret = parent
::sendMessage($msg);
165 $this->invokeError("getHighRezGraph", "Error in 'sendMessage'");
169 $retMsg = parent
::waitMessage();
173 $this->invokeError("getHighRezGraph", "Error in 'waitMessage'");
176 if (!($retMsg->MsgName
=== "R_GHRG"))
179 $this->invokeError("getHighRezGraph", "Invalid response, awaited 'R_GHRG', received '".$retMsg->MsgName
."'");
183 // serial the return value
185 $retMsg->serialUInt32($nbElem);
187 for ($i=0; $i<$nbElem;$i++
)
189 $retMsg->serialString($item);
194 // return the return value
201 function waitCallback()
203 $message = parent
::waitMessage();
205 if ($message == false)
208 switch($message->MsgName
)
211 $this->commandResult_skel($message);
221 function commandResult_skel(&$message)
223 $message->serialString($serviceAlias);
224 $message->serialString($result);
226 $this->commandResult($serviceAlias, $result);
230 /////////////////////////////////////////////////////////////////
231 // Copy paste this part of code in your derived class
232 // and implement code to ract to incoming message
233 /////////////////////////////////////////////////////////////////
235 function commandResult($serviceAlias, $result)
241 class MyAdminService
extends CAdminServiceWeb
243 function commandResult($serviceModuleName, $result)
245 global $command_return_data;
247 $command_return_data = trim("===[ Service ". strtoupper($serviceModuleName) ." returned ]===\n". trim($result) ."\n\n");
252 function parseDumpGuildList($data)
258 foreach($data as $server_data)
260 $data_ary = explode("\n",$server_data);
262 foreach($data_ary as $rline)
264 $rline = trim($rline);
266 if (preg_match('/^===\[ Service ([^\ ]+) returned \]===/', $rline, $params))
268 $server = $params[1];
269 $result[$server] = array();
270 $result[$server]['name'] = array();
271 $result[$server]['dump'] = array();
273 elseif (preg_match("/^id = ([[:digit:]]+)\:([[:digit:]]+) \(([^\ ]+)\) (\(0x[[:alnum:]]+\:[[:alnum:]]+\:[[:alnum:]]+\:[[:alnum:]]+\)), name = '([^\']+)', ([[:digit:]]+) members/",$rline,$params))
275 // id = 101:1 (Local) (0x0006500001:0c:00:88), name = 'Les Gardiens de l Atrium', 21 members
278 $result[$server]['dump'][] = $params;
279 $result[$server]['name'][] = $params[5];
290 function parseDumpOutpostList($data)
296 foreach($data as $server_data)
298 $data_ary = explode("\n",$server_data);
300 foreach($data_ary as $rline)
302 $rline = trim($rline);
304 if (preg_match("/^([[:digit:]]+)\: Alias\: \((A\:[[:digit:]]+\:[[:digit:]]+)\), Name\: '([^\']+)', Sheet\: '([^\']+)', State\: '([^\']+)', Level\: ([[:digit:]]+), Owner\: '([^\']+)'/",$rline,$params))
306 $result[$params[3]] = $params;
317 function parseDisplayPlayers($data)
323 $data = str_replace('\\\'', '', $data);
325 foreach($data as $server_data)
327 $data_ary = explode("\n",$server_data);
329 foreach($data_ary as $rline)
331 $rline = trim($rline);
333 if (preg_match('/^Player: ([[:digit:]]+) Name: ([^ ]+) ID: (\(0x[[:alnum:]]+\:[[:alnum:]]+\:[[:alnum:]]+\:[[:alnum:]]+\)) FE: [[:digit:]]+ Sheet: [a-z]+\.race_stats - [[:digit:]]+ Priv: ([^ ]+) Pos: ([0-9]+),(-[0-9]+),([0-9\-]+) Session: [0-9]01/',$rline,$params))
335 // Player: 723931 Name: Deodand(Atys) ID: (0x0000b0bdb0:00:00:8b) FE: 139 Sheet: tryker.race_stats - 533 Priv: \'\' Pos: 15264,-34428,-3 Session: 101
336 $result[$params[1]] = $params;
346 function parseDumpGuild($data)
352 foreach($data as $server_data)
354 $data_ary = explode("\n",$server_data);
357 foreach($data_ary as $rline)
359 if (preg_match('/^===\[ Service ([^\ ]+) returned \]===/',$rline,$params))
361 $server = $params[1];
362 $result[$server] = array();
364 // <GUILD_DUMP> Guild id: 1, name: 'Les Gardiens de l Atrium', eid: (0x0000000001:0c:00:81)
365 //if (ereg("^[[:space:]]*\<GUILD_DUMP\> Guild id: ([[:digit:]]+), name: \'([[:alnum:]]+)\', eid: (\(0x[[:alnum:]]+\:[[:alnum:]]+\:[[:alnum:]]+\:[[:alnum:]]+\))$",$rline,$params))
366 elseif (preg_match('/^\<GUILD_DUMP\> Guild id: ([[:digit:]]+)\:([[:digit:]]+) \(([^\ ]+)\), name: \'([A-Za-z0-9\ _-]+)\', eid: (\(0x[[:alnum:]]+\:[[:alnum:]]+\:[[:alnum:]]+\:[[:alnum:]]+\))/',$rline,$params))
368 $guild_name = $params[4];
369 $result[$server] = array();
370 $result[$server]['dump'] = $params;
372 // Description: 'French CSR'
373 elseif (preg_match('/^[[:space:]]*Description: \'(.*)\'/',$rline,$params))
377 $result[$server]['desc'] = $params[1];
380 // Icon: 0x0000000000000681
381 elseif (preg_match('/^[[:space:]]*Icon: (0x[[:alnum:]]+)/',$rline,$params))
385 $result[$server]['icon'] = hexdec($params[1]);
389 elseif (preg_match('/^[[:space:]]*Money: ([[:alnum:]]+)/',$rline,$params))
393 $result[$server]['money'] = $params[1];
397 elseif (preg_match('/^[[:space:]]*Race: (.*)/',$rline,$params))
401 $result[$server]['race'] = $params[1];
404 // Building: building_instance_FY_guild_327
405 elseif (preg_match('/^[[:space:]]*Building: (.*)/',$rline,$params))
409 $result[$server]['building'] = $params[1];
412 // Civ Allegiance: Fyros
413 elseif (preg_match('/^[[:space:]]*Civ Allegiance: (.*)/',$rline,$params))
417 $result[$server]['civ'] = $params[1];
420 // Cult Allegiance: Kami
421 elseif (preg_match('/^[[:space:]]*Cult Allegiance: (.*)/',$rline,$params))
425 $result[$server]['cult'] = $params[1];
429 elseif (preg_match('/^[[:space:]]*Nb of members: ([[:digit:]]+)/',$rline,$params))
433 $result[$server]['count'] = $params[1];
436 // Member 'Yotto' (0x00000096f0:00:00:86), index: 2, grade: HighOfficer, enter time: 60960905
437 elseif (preg_match('/^[[:space:]]*Member \'([^\ ]+)\' (\(0x[[:alnum:]]+\:[[:alnum:]]+\:[[:alnum:]]+\:[[:alnum:]]+\)), index: ([[:digit:]]+), grade: ([[:alnum:]]+), enter time: ([[:digit:]]+)/',$rline,$params))
441 $result[$server][$params[4]][] = $params[1];
449 function querySelectedShard($name, $service_name, $fullcmd, $cmd='', $waitCallback=true, $is_control=false) {
450 global $command_return_data;
452 $nel_result = array();
453 $nel_status = !$waitCallback;
457 $adminService = new MyAdminService
;
459 if ($adminService->connect($name, '46700', $res) !== false) {
460 $command_return_data = '';
462 //echo "NEL[$service_name] : $service_command\n";
463 if (is_array($fullcmd)) {
464 foreach ($fullcmd as $service_command) {
466 $adminService->controlCmd($service_name, $service_command);
468 $adminService->serviceCmd($service_name, $service_command);
472 $adminService->controlCmd($service_name, $fullcmd);
474 $adminService->serviceCmd($service_name, $fullcmd);
475 $service_command = $fullcmd;
476 //echo "NEL[$service_name] : OK\n";
477 if ($waitCallback && $adminService->waitCallback()) {
478 //echo "NEL[$service_name] : Successful!\n";
481 $nel_result[] = $command_return_data;
482 //print_r($command_return_data);
484 //echo "NEL[$service_name] : Failed!\n";
488 @$adminService->close();
492 if (strlen($cmd) > 0) {
493 $func_name = 'parse'.ucfirst($cmd);
494 if (function_exists($func_name))
495 $p_result = call_user_func($func_name,$nel_result);
499 return array('status' => $nel_status, 'query' => $service_name.':'.$service_command, 'raw' => $nel_result, 'parsed' => $p_result);
502 function queryShard($service_name, $fullcmd, $cmd='', $waitCallback=true, $is_control=false)
504 return querySelectedShard('localhost', $service_name, $fullcmd, $cmd, $waitCallback, $is_control);