Linux multi-monitor fullscreen support
[ryzomcore.git] / nelns / admin / public_html / commands.php
blobeb71f01c920aea5b29d6ea32177d7849980f24ca
1 <?php
2 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
3 // Copyright (C) 2010 Winch Gate Property Limited
4 //
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.
9 //
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/>.
18 $publicAccess = false;
19 $allowNevrax = true;
20 include('authenticate.php');
22 include('request_interface.php');
25 if ($preselServ != "")
27 list($presel_shard, $presel_server, $presel_service) = explode(".", $preselServ);
29 if ($presel_service)
31 $aliases = split('[/-]', $presel_service);
32 if (count($aliases) == 3)
33 $presel_service = $aliases[0];
37 if ($reset_filters)
39 $filter_shard = "";
40 $filter_server = "";
41 $filter_service = "";
42 $filter_entity = "";
45 htmlProlog($_SERVER['PHP_SELF'], "Commands");
47 // input variables :
48 // - $preselServ : preselected service address
49 // - $execCommand : executed command on preselected service, like a normal service
52 echo "Services commands<br>\n";
54 echo "<table border=1><form method=post action='".$_SERVER['PHP_SELF']."'>\n";
55 echo "<tr><th rowspan=2>&nbsp;Filters&nbsp;</th><th>shard</th><th>server</th><th>service</th><th>entity</th><td rowspan=2>&nbsp;<input type=submit name='display_view' value='Update\nfilters'>&nbsp;</td><td rowspan=2>&nbsp;<input type=submit name='reset_filters' value='Reset\nfilters'>&nbsp;</td></tr>\n";
56 echo "<tr>\n";
57 echo "<td><input type=text name=filter_shard value='$filter_shard' size=12 maxlength=256></td>\n";
58 echo "<td><input type=text name=filter_server value='$filter_server' size=12 maxlength=256></td>\n";
59 echo "<td><input type=text name=filter_service value='$filter_service' size=12 maxlength=256></td>\n";
60 echo "<td><input type=text name=filter_entity value='$filter_entity' size=28 maxlength=1024></td>\n";
61 echo "</tr>\n";
62 echo "</form></table><br>\n";
64 echo "<table border=0><tr valign=top>\n";
66 echo "<td>\n";
68 echo "<table border=0 cellpadding=2 cellspacing=0>\n";
69 echo "<tr><th>Shard</th><th>Server</th><th>Service</th></tr>\n";
71 $query = "SELECT shard, server, name FROM service";
73 if ($filter_shard != "") $where[] = "shard like '%$filter_shard%'";
74 if ($filter_server != "") $where[] = "server like '%$filter_server%'";
75 if ($filter_service != "") $where[] = "name like '%$filter_service%'";
77 if (count($where)>=1)
78 $query .= " WHERE ".join(" AND ", $where);
80 $query .= " ORDER BY shard, server, name";
82 $result = sqlquery($query);
84 unset($pshard);
85 unset($pserver);
86 $scolor = 1;
88 while ($result && ($arr=sqlfetch($result)))
90 $shard = $arr["shard"];
91 $server = $arr["server"];
92 $service = $arr["name"];
93 $addr = "$shard.$server.$service";
94 $dshard = ($pshard == $shard ? "" : $shard);
95 if ($pshard != $shard)
96 $scolor = 1-$scolor;
97 $dserver = ($pserver == $server && $pshard == $shard ? "" : $server);
98 $dcolor = "bgcolor=".($scolor==0 ? "#EEEEEE" : "DDDDDD");
100 if ($presel_shard == $shard)
101 $dcolor = "bgcolor=#FFCCDD";
103 if ($presel_shard == $shard && $presel_service != "" && strstr($service, $presel_service) != FALSE)
105 $dispServ = "<b><a href='".$_SERVER['PHP_SELF']."?preselServ=$addr'>$service</a></b>";
106 $dcolor = "bgcolor=#FF88AA";
108 else
109 $dispServ = "<a href='".$_SERVER['PHP_SELF']."?preselServ=$addr'>$service</a>";
111 echo "<tr><td $dcolor>$dshard</td><td $dcolor>$dserver</td><td $dcolor>$dispServ</td></tr></a>\n";
112 $pshard = $shard;
113 $pserver = $server;
116 echo "</table>\n";
117 echo "</td>\n";
119 echo "<td width=30>&nbsp;</td>\n";
121 echo "<td>\n";
122 echo "<table border=0><form method=post action='".$_SERVER['PHP_SELF']."' name='cmdform'>\n";
123 echo "<tr><th align=left>Service Path</th><th align=left>Command (exact service syntax)</th></tr>\n";
124 echo "<tr><td><input name=preselServ value='$preselServ' size=32 maxlength=256></td>\n";
125 echo "<td><input name=execCommand value='".stripslashes($execCommand)."' size=50 maxlength=20480></td>\n";
126 echo "<td><input type=submit value=Execute></td></tr>\n";
127 echo "</form></table>\n";
129 if (isset($preselServ) && $preselServ != "" && isset($execCommand) && $execCommand != "")
131 $fullCmd = $preselServ.".".stripslashes($execCommand);
132 logUser($uid, "SYS_COMMAND=".$fullCmd);
133 $qstate = nel_query($preselServ.".".stripslashes($execCommand), $commandResult);
136 if ($commandResult)
138 echo "<textarea rows=60 cols=300 readOnly style='font-family: Terminal, Courier; font-size: 10pt;'>".stripslashes($commandResult)."</textarea>\n";
141 echo "</td>\n";
143 echo "</tr></table>\n";
145 echo "<script type='text/javascript'><!--\n";
146 echo "if (document.cmdform) { document.cmdform.execCommand.focus(); }\n";
147 echo "// --></script>\n";
149 htmlEpilog();