// Copyright (C) 2010 Winch Gate Property Limited
//
// 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 .
$publicAccess = false;
$allowNevrax = true;
include('authenticate.php');
include('request_interface.php');
if ($preselServ != "")
{
list($presel_shard, $presel_server, $presel_service) = explode(".", $preselServ);
if ($presel_service)
{
$aliases = split('[/-]', $presel_service);
if (count($aliases) == 3)
$presel_service = $aliases[0];
}
}
if ($reset_filters)
{
$filter_shard = "";
$filter_server = "";
$filter_service = "";
$filter_entity = "";
}
htmlProlog($_SERVER['PHP_SELF'], "Commands");
// input variables :
// - $preselServ : preselected service address
// - $execCommand : executed command on preselected service, like a normal service
//
echo "Services commands
\n";
echo "
\n";
echo "\n";
echo "\n";
echo "\n";
echo "Shard | Server | Service | \n";
$query = "SELECT shard, server, name FROM service";
if ($filter_shard != "") $where[] = "shard like '%$filter_shard%'";
if ($filter_server != "") $where[] = "server like '%$filter_server%'";
if ($filter_service != "") $where[] = "name like '%$filter_service%'";
if (count($where)>=1)
$query .= " WHERE ".join(" AND ", $where);
$query .= " ORDER BY shard, server, name";
$result = sqlquery($query);
unset($pshard);
unset($pserver);
$scolor = 1;
while ($result && ($arr=sqlfetch($result)))
{
$shard = $arr["shard"];
$server = $arr["server"];
$service = $arr["name"];
$addr = "$shard.$server.$service";
$dshard = ($pshard == $shard ? "" : $shard);
if ($pshard != $shard)
$scolor = 1-$scolor;
$dserver = ($pserver == $server && $pshard == $shard ? "" : $server);
$dcolor = "bgcolor=".($scolor==0 ? "#EEEEEE" : "DDDDDD");
if ($presel_shard == $shard)
$dcolor = "bgcolor=#FFCCDD";
if ($presel_shard == $shard && $presel_service != "" && strstr($service, $presel_service) != FALSE)
{
$dispServ = "$service";
$dcolor = "bgcolor=#FF88AA";
}
else
$dispServ = "$service";
echo "$dshard | $dserver | $dispServ | \n";
$pshard = $shard;
$pserver = $server;
}
echo " \n";
echo " | \n";
echo " | \n";
echo "\n";
echo "\n";
if (isset($preselServ) && $preselServ != "" && isset($execCommand) && $execCommand != "")
{
$fullCmd = $preselServ.".".stripslashes($execCommand);
logUser($uid, "SYS_COMMAND=".$fullCmd);
$qstate = nel_query($preselServ.".".stripslashes($execCommand), $commandResult);
}
if ($commandResult)
{
echo "\n";
}
echo " | \n";
echo "
\n";
echo "\n";
htmlEpilog();
?>