3 require_once('common.php');
4 require_once('functions_tool_main.php');
5 require_once('functions_tool_player_locator.php');
7 if (!tool_admin_applications_check('tool_player_locator')) nt_common_redirect('index.php');
9 nt_common_add_debug('-- Starting on \'tool_player_locator.php\'');
11 $tpl->assign('tool_title', "Player Locator");
13 $view_domain_id = nt_auth_get_session_var('view_domain_id');
14 $view_shard_id = nt_auth_get_session_var('view_shard_id');
18 $view_domain_id = $nel_user['group_default_domain_id'];
19 $view_shard_id = $nel_user['group_default_shard_id'];
20 nt_auth_set_session_var('view_domain_id', $view_domain_id);
21 nt_auth_set_session_var('view_shard_id', $view_shard_id);
24 if (isset($NELTOOL['GET_VARS']['domain']))
26 if ($view_domain_id != $NELTOOL['GET_VARS']['domain'])
28 $view_domain_id = $NELTOOL['GET_VARS']['domain'];
29 nt_auth_set_session_var('view_domain_id', $view_domain_id);
31 $view_shard_id = null;
32 nt_auth_unset_session_var('view_shard_id');
36 if (isset($NELTOOL['GET_VARS']['shard']))
38 $view_shard_id = $NELTOOL['GET_VARS']['shard'];
39 nt_auth_set_session_var('view_shard_id', $view_shard_id);
42 if (isset($NELTOOL['GET_VARS']['refdata']))
44 $tmp_data = unserialize(base64_decode($NELTOOL['GET_VARS']['refdata']));
45 if (is_array($tmp_data))
47 $NELTOOL['POST_VARS'] = $tmp_data;
51 $current_refresh_rate = nt_auth_get_session_var('current_refresh_rate');
53 if (isset($_POST['services_refresh']))
55 if ($current_refresh_rate != $_POST['services_refresh'])
57 $current_refresh_rate = $_POST['services_refresh'];
58 nt_auth_set_session_var('current_refresh_rate',$current_refresh_rate);
62 if ($current_refresh_rate == null)
64 $current_refresh_rate = 0;
66 elseif ($current_refresh_rate > 0)
68 $tpl->assign('nel_tool_refresh', '<meta http-equiv=refresh content="'. $current_refresh_rate .'">');
71 $tpl->assign('tool_refresh_list', $refresh_rates);
72 $tpl->assign('tool_refresh_rate', $current_refresh_rate);
74 $tpl->assign('tool_domain_list', $nel_user['access']['domains']);
75 $tpl->assign('tool_domain_selected', $view_domain_id);
77 $tpl->assign('tool_shard_list', $nel_user['access']['shards']);
78 $tpl->assign('tool_shard_selected', $view_shard_id);
80 $tool_shard_filters = tool_main_get_shard_ids($view_shard_id);
81 $tpl->assign('tool_shard_filters', $tool_shard_filters);
83 if (tool_admin_applications_check('tool_player_locator_display_players')) $tpl->assign('restriction_tool_player_locator_display_players', true);
84 if (tool_admin_applications_check('tool_player_locator_locate')) $tpl->assign('restriction_tool_player_locator_locate', true);
85 if (tool_admin_applications_check('tool_player_locator_userid_check')) $tpl->assign('restriction_tool_player_locator_userid_check', true);
86 if (tool_admin_applications_check('tool_player_locator_csr_relocate')) $tpl->assign('restriction_tool_player_locator_csr_relocate', true);
90 $tool_as_error = null;
92 $AS_Name = tool_main_get_domain_name($view_domain_id);
93 $AS_Host = tool_main_get_domain_host($view_domain_id);
94 $AS_Port = tool_main_get_domain_port($view_domain_id);
95 $AS_ShardName = tool_main_get_shard_name($view_shard_id);
96 $AS_Application = tool_main_get_domain_data($view_domain_id, 'domain_application');
97 $AS_RingSQL = tool_main_get_domain_data($view_domain_id, 'domain_sql_string');
99 $tpl->assign('tool_page_title', 'Player Locator - '. $AS_Name . ($AS_ShardName != '' ?
' / '. $AS_ShardName : ''));
101 $tool_as_error = null;
103 if ($AS_Host && $AS_Port)
105 $adminService = new MyAdminService
;
106 if (@$adminService->connect($AS_Host, $AS_Port, $res) === false)
108 nt_common_add_debug($res);
109 $tpl->assign('tool_domain_error', $res );
113 if (isset($NELTOOL['POST_VARS']['services_pl']))
115 $tool_services_pl = $NELTOOL['POST_VARS']['services_pl'];
116 $tpl->assign('tool_post_data', base64_encode(serialize($NELTOOL['POST_VARS'])));
118 switch ($tool_services_pl)
120 case 'display players':
122 if (tool_admin_applications_check('tool_player_locator_display_players'))
124 $service_list = tool_main_get_checked_services();
125 if (sizeof($service_list))
127 $service_command = 'displayPlayers';
129 nt_log("Domain '$AS_Name' : '$service_command' on ". implode(', ',array_values($service_list)));
131 $tpl->assign('tool_service_select_list', array_combine($service_list, $service_list));
132 $tpl->assign('tool_execute_result', '');
133 $command_return_data = array();
135 reset($service_list);
136 foreach($service_list as $service)
138 //nt_common_add_debug("about to run 'displayPlayers' on '$service' ...");
140 $adminService->serviceCmd($service, $service_command);
141 if (!$adminService->waitCallback())
143 nt_common_add_debug('Error while waiting for callback on service \''. $service .'\' for command : '. $service_command);
147 // the locator displays a nice output, no need for the raw one
148 //$tpl->assign('tool_execute_command', $service_command);
152 if (sizeof($command_return_data))
154 $player_data = tool_pl_parse_display_players($command_return_data);
155 $tpl->assign('tool_player_data', $player_data);
162 // case 'csr relocate':
167 if (tool_admin_applications_check('tool_player_locator_csr_relocate'))
169 $relocate_su = $NELTOOL['POST_VARS']['pl_su'];
170 $relocate_shardid = $NELTOOL['POST_VARS']['relocate_shardid'];
171 $relocate_eid = $NELTOOL['POST_VARS']['relocate_eid'];
173 if ($relocate_eid != 'na' && $relocate_shardid != 'na')
175 $service = $relocate_su;
176 $service_command = 'cs.relocChar ' . $relocate_eid . ' ' . $relocate_shardid;
178 nt_common_add_debug("about to run command '$service_command' on '$service' ...");
180 $tpl->assign('tool_execute_result', '');
181 $command_return_data = array();
183 $adminService->serviceCmd($service, $service_command);
184 if (!$adminService->waitCallback())
186 nt_common_add_debug('Error while waiting for callback on service \''. $service .'\' for command : '. $service_command);
190 //$tpl->assign('tool_execute_command', $service_command);
193 if (sizeof($command_return_data))
195 $relocate_data = tool_pl_parse_relocate($command_return_data);
196 $tpl->assign('tool_relocate_data', $relocate_data);
206 if (tool_admin_applications_check('tool_player_locator_locate'))
208 $tool_locate_name = trim($NELTOOL['POST_VARS']['services_pl_locate']);
209 $tpl->assign('tool_locate_value', $tool_locate_name);
211 $service_list = tool_main_get_checked_services();
212 if (sizeof($service_list) && ($tool_locate_name != ''))
214 $service_command = 'playerInfo '. $tool_locate_name;
215 nt_log("Domain '$AS_Name' : '$service_command' on ". implode(', ',array_values($service_list)));
217 $tpl->assign('tool_service_select_list', array_combine($service_list, $service_list));
218 //$tpl->assign('tool_execute_result', '');
219 $command_return_data = array();
221 reset($service_list);
222 foreach($service_list as $service)
224 nt_common_add_debug("about to run 'playerInfo' on '$service' ...");
226 $adminService->serviceCmd($service, $service_command);
227 if (!$adminService->waitCallback())
229 nt_common_add_debug('Error while waiting for callback on service \''. $service .'\' for command : '. $service_command);
233 // the locator displays a nice output, no need for the raw one
234 //$tpl->assign('tool_execute_command', $service_command);
238 if (sizeof($command_return_data))
240 $locate_data = tool_pl_parse_locate($command_return_data);
241 $tpl->assign('tool_locate_data', $locate_data);
248 case 'Compute User IDs and Clear SQL Cache':
250 if (tool_admin_applications_check('tool_player_locator_userid_check'))
252 $check_su = $NELTOOL['POST_VARS']['pl_su'];
254 tool_pl_fix_character_check_list($AS_Application);
256 $service = $check_su;
257 $service_command = 'sqlObjectCache.clearCache';
258 nt_common_add_debug("about to run command '$service_command' on '$service' ...");
260 $adminService->serviceCmd($service, $service_command);
261 if (!$adminService->waitCallback())
263 nt_common_add_debug('Error while waiting for callback on service \''. $service .'\' for command : '. $service_command);
272 if (isset($NELTOOL['GET_VARS']['eid']))
274 $locate_eid = $NELTOOL['GET_VARS']['eid'];
276 // someday i'll do something here :)
279 $status = $adminService->getStates();
280 nt_common_add_debug($status);
282 $domainServices = tool_main_parse_status($status);
284 $filteredServices = array();
285 reset($domainServices);
286 foreach($domainServices as $aKey => $aService)
288 // we are only interested in EGS
289 if ($aService['ShortName'] == 'EGS')
291 $filteredServices[] = $aService;
295 $tpl->assign('tool_services_list', $filteredServices);
297 $tpl->assign('shard_su_name', tool_main_get_su_from_status($domainServices));
299 // user_id == 0 check system
300 if (tool_admin_applications_check('tool_player_locator_userid_check'))
302 $user_check_list = tool_pl_get_character_check_list($AS_Application, $AS_RingSQL);
303 $tpl->assign('user_check_list', $user_check_list);
311 $tpl->display('tool_player_locator.tpl');