2 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
3 // Copyright (C) 2010 Winch Gate Property Limited
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Affero General Public License as
7 // published by the Free Software Foundation, either version 3 of the
8 // License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Affero General Public License for more details.
15 // You should have received a copy of the GNU Affero General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 include('authenticate.php');
20 include('request_interface.php');
22 if ($preselServ != "")
24 list($presel_shard, $presel_server, $presel_service) = explode(".", $preselServ);
28 $aliases = split('[/-]', $presel_service);
29 if (count($aliases) == 3)
30 $presel_service = $aliases[0];
34 htmlProlog($_SERVER['PHP_SELF'], "Player Locator");
36 echo "<script><!--\n";
37 echo "//----------------------------------\n";
38 echo "function clickOnEntity(entity)\n";
40 echo " player_select[entity] = !player_select[entity];\n";
41 echo " if (player_select[entity])\n";
43 echo " document.getElementById('player_'+entity).style.background = player_sel_bgcolor[entity];\n";
47 echo " document.getElementById('player_'+entity).style.background = player_bgcolor[entity];\n";
49 echo " var total_select = 0;\n";
50 echo " var list_select = ''\n";
51 echo " var list_active = ''\n";
52 echo " for (i=0; i<num_player; ++i)\n";
54 echo " if (player_select[i])\n";
56 echo " if (list_select != '') list_select += ',';\n";
57 echo " ++total_select;\n";
58 echo " list_select += player_eid[i];\n";
59 echo " if (player_state[i] == 'Offline')\n";
61 echo " if (list_active != '') list_active += ',';\n";
62 echo " list_active += player_uidslot[i];\n";
66 echo " if (total_select > 1) list_select = '['+list_select+']';\n";
67 echo " document.getElementById('filter_entity_hidden').value = list_select;\n";
68 echo " document.getElementById('active_player_hidden').value = list_active;\n";
69 echo " window.status = list_active;\n";
72 echo "//----------------------------------\n";
73 echo "function submitForm(entity)\n";
75 echo " return true;\n";
78 echo "//--></script>\n";
81 // - $preselServ : preselected service address
82 // - $execCommand : executed command on preselected service, like a normal service
87 echo "<table border=0><tr valign=top>\n";
88 echo "<form method=post action='".$_SERVER['PHP_SELF']."' name='cmdform'>\n";
91 $result = sqlquery("SELECT DISTINCT shard FROM service ORDER BY shard");
93 echo "<select multiple size=".(sqlnumrows($result))." name='selshards[]'>";
94 while ($result && ($arr=sqlfetch($result)))
96 $selected = (isset($selshards) && in_array($arr["shard"], $selshards)) ||
97 (isset($admfilter_shard) && $admfilter_shard!="" && strstr($arr["shard"], $admfilter_shard) ||
98 ($admfilter_shard == "" && !isset($selshards)));
101 $selected_shards[] = $arr["shard"];
103 echo "<option value='".$arr["shard"]."'".($selected ?
" selected" : "").">".$arr["shard"];
109 echo "<td width=30> </td>\n";
112 echo "<table border=0>\n";
113 echo "<tr><th align=left>Player/Character name</th></tr>\n";
114 echo "<tr><td><input name=char_name value='".stripslashes($char_name)."' size=50 maxlength=20480></td>\n";
115 echo "<td><input type=submit value='Locate'></td></tr>\n";
116 echo "</form></table>\n";
118 if (isset($char_name))
120 $addr = (count($selected_shards) > 0 ?
"[".join(",", $selected_shards)."]" : "*").".*.EGS.playerInfo $char_name";
121 $qstate = nel_query($addr, $commandResult);
126 $res_array = explode("\n", $commandResult);
138 echo "<script><!--\n";
139 echo "var player_eid = new Array(30000);\n";
140 echo "var player_select = new Array(30000);\n";
141 echo "var player_bgcolor = new Array(30000);\n";
142 echo "var player_sel_bgcolor = new Array(30000);\n";
143 echo "var player_state = new Array(30000);\n";
144 echo "var player_uidslot = new Array(30000);\n";
145 echo "//--></script>\n";
149 if ($res_array[$parse_start] == "")
153 list($res_shard) = sscanf($res_array[$parse_start], "----- Result from Shard %s");
154 list($num_res) = sscanf($res_array[$parse_start+
$offset-1], "%d");
155 $start = $parse_start+
$offset;
156 $stop = $start+
$num_res;
157 $parse_start +
= $num_res+
$offset;
162 echo "<b>Result of search for '$char_name' on Shard '$res_shard' ($num_res entr".($num_res>1 ?
"ies" : "y")." found)</b><br>\n";
163 echo "<font size=-2>Click on EntityId to get directly to DefaultPlayer view, <br>or click anywhere else to select a player and then click Select Players button.</font><br><br>\n";
165 echo "<table border=1><tr><th>UId</th><th>UserName</th><th>EId</th><th>EntityName</th><th>EntitySlot</th><th>State</th><th>Ext commands</th></tr>\n";
167 for ($line=$start; $line<$stop; ++
$line)
169 $l = explode(" ", $res_array[$line]);
171 for ($i=1; $i<count($l); $i+
=2)
172 $parse[$l[$i-1]] = str_replace("'", "", $l[$i]);
173 $parse["State"] = $l[count($l)-1];
175 $chUser = ($last_uid == "");
176 if ($last_uid != "" && $parse["UId"] != $last_uid)
182 $last_uid = $parse["UId"];
184 $bgcolor_online = ($icolor ?
"#CCEECC" : "#BBDDBB");
185 $bgcolor_offline = ($icolor ?
"#EEEEEE" : "#DDDDDD");
186 $bgcolor = ($parse['State'] == 'Online') ?
$bgcolor_online : $bgcolor_offline;
187 $sel_bgcolor = ($icolor ?
"#FFDDAA" : "#FFCC88");
189 echo "<script><!--\n";
190 echo "player_eid[$num_player]='".$parse["EId"]."';\n";
191 echo "player_select[$num_player]=false;\n";
192 echo "player_bgcolor[$num_player]='$bgcolor';\n";
193 echo "player_sel_bgcolor[$num_player]='$sel_bgcolor';\n";
194 echo "player_uidslot[$num_player]='".$parse["UId"]." ".$parse["EntitySlot"]."';\n";
195 echo "player_state[$num_player]='".$parse["State"]."';\n";
196 echo "//--></script>\n";
198 echo "<tr id='player_$num_player' onClick='clickOnEntity($num_player); return true;' bgcolor=$bgcolor>";
199 echo "<td>".($chUser ?
$parse["UId"] : "")."</td>";
200 echo "<td>".$parse["UserName"]."</td>";
201 echo "<td><a href='index.php?select_view=DefaultPlayer&filter_shard=$res_shard&filter_entity=".$parse["EId"]."'>".$parse["EId"]."</a></td>";
202 echo "<td>".$parse["EntityName"]."</td>";
203 echo "<td>".$parse["EntitySlot"]."</td>";
204 echo "<td>".$parse["State"]."</td>";
206 if (isset($parse["SaveFile"]))
208 echo "<a href='backup_interface.php?charid=".$parse["EId"]."&file=".$parse["SaveFile"]."'>Load/Save sheet</a>";
219 echo "<script><!--\n";
220 echo "var num_player = $num_player;\n";
221 echo "//--></script>\n";
223 echo "<form name='select_player_form' method=post action='index.php?select_view=DefaultPlayer'>\n";
224 echo "<input type=submit name='from_player_locator' value='Select Players'>\n";
225 echo "<input id='filter_entity_hidden' type=hidden name=filter_entity value=''>\n";
226 echo "<input id='active_player_hidden' type=hidden name=active_player value=''>\n";
232 echo "</tr></table>\n";
234 echo "<script type='text/javascript'><!--\n";
235 echo "if (document.cmdform) { document.cmdform.execCommand.focus(); }\n";
236 echo "// --></script>\n";