// 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 .
global $HTTP_POST_VARS, $HTTP_GET_VARS;
$publicAccess = false;
include('authenticate.php');
// -----------------------------
// page commands
unset($error);
// remove user, ask for confirmation
if (isset($rmUid) && isset($uuid) && $uuid!=$uid)
{
$result = sqlquery("SELECT login FROM user WHERE uid='$uuid'");
if ($result && mysql_num_rows($result) == 1)
{
htmlProlog($_SERVER['PHP_SELF'], "Administration");
$arr = mysql_fetch_array($result);
echo "You are about to delete user ".$arr["login"]." ($uid)
\n";
echo "Are you sure ?
\n";
echo "YES | NO\n";
htmlEpilog();
die;
}
}
// remove effectively user
else if (isset($confirmRmUid) && $confirmRmUid!=$uid)
{
sqlquery("DELETE FROM user WHERE uid='$confirmRmUid'");
$numUserDeleted = mysql_affected_rows();
sqlquery("DELETE FROM user_variable WHERE uid='$confirmRmUid'");
$result = sqlquery("SELECT tid FROM view_table WHERE uid='$confirmRmUid'");
sqlquery("DELETE FROM view_table WHERE uid='$confirmRmUid'");
while ($result && ($arr=mysql_fetch_array($result)))
{
sqlquery("DELETE FROM view_rows WHERE tid='".$arr["tid"]."'");
}
$editUsers = true;
}
// force user password
else if (isset($forcePass))
{
sqlquery("UPDATE user SET password='".crypt($forcedPass, "NL")."' WHERE uid='$forcePass'");
}
// update user variables
else if (isset($updVars) && isset($editUser))
{
foreach ($HTTP_POST_VARS as $var => $value)
{
if (strncmp($var, "avv_", 4) != 0)
continue;
$vid = (int)substr($var, 4);
$ovar = "aovv_$vid";
if (!isset($HTTP_POST_VARS[$ovar]))
continue;
$ovalue = $HTTP_POST_VARS[$ovar];
if ($value == $ovalue)
continue;
sqlquery("DELETE FROM user_variable WHERE uid='$editUser' AND vid='$vid'");
if ($value != "inv")
sqlquery("INSERT INTO user_variable SET privilege='$value', uid='$editUser', vid='$vid'");
/*
// get all
$result = sqlquery("SELECT uid FROM user WHERE gid='$editUser' OR uid='$editUser'");
while ($result && ($arr=sqlfetch($result)))
{
sqlquery("DELETE FROM user_variable WHERE uid='".$arr["uid"]."' AND vid='$vid'");
if ($value != "inv")
sqlquery("INSERT INTO user_variable SET privilege='$value', uid='".$arr["uid"]."', vid='$vid'");
}
*/
}
}
// create user
else if (isset($createUid) && isset($nulogin) && isset($nupassword) && isset($nuconfirmpassword) && isset($nugroup) && isset($nuallowedIp))
{
if ($nupassword != $nuconfirmpassword)
{
$error = $error."Password is invalid (password confirmation failed)
\n";
}
else if (strspn($nulogin, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") == 0)
{
$error = $error."Login '$admlogin' contains other characters than alphabetic and digits
\n";
}
else
{
$result = sqlquery("INSERT INTO user SET login='$nulogin', password='".crypt($nupassword, "NL")."', gid='$nugroup', allowed_ip='$nuallowedIp'");
if (mysql_affected_rows() != 1)
{
$error .= "Can't create user '$nulogin', database request failed (already used login?)
\n";
unset($nupassword);
unset($nuconfirmpassword);
}
else
{
unset($nulogin);
unset($nupassword);
unset($nuconfirmpassword);
}
}
$editUsers = true;
}
// reset user variables
else if ($resetVars)
{
$result = sqlquery("DELETE FROM user_variable WHERE uid='$editUser'");
}
// import user var setup
/* else if ($impVarSetup && isset($editUser) && isset($impUid))
{
$result = sqlquery("SELECT vid, privilege FROM user_variable WHERE uid='$impUid'");
if ($result && mysql_num_rows($result)>0)
{
$delete_query = "DELETE FROM user_variable WHERE uid='$editUser' AND (";
$copy_query = "INSERT INTO user_variable VALUES";
$first = true;
while ($result && ($arr=mysql_fetch_array($result)))
{
$delete_query .= ($first ? "" : " OR ") . "vid='".$arr["vid"]."'";
$copy_query .= ($first ? "" : ",") . " ('$editUser', '".$arr["vid"]."', '".$arr["privilege"]."')";
$first = false;
}
$delete_query .= ")";
// remove previous variables
sqlquery($delete_query);
// add new variables
sqlquery($copy_query);
//echo $delete_query."
".$copy_query;
if (mysql_affected_rows == -1)
$error .= "Import failed, database query failed
\n";
}
}*/
// update user group
else if (isset($updUid) && isset($chugroup))
{
sqlquery("UPDATE user SET gid='$chugroup' WHERE uid='$updUid'");
$editUsers=true;
}
// update user cookie
else if (isset($updUid) && isset($chucookie))
{
sqlquery("UPDATE user SET useCookie='$chucookie' WHERE uid='$updUid'");
$editUsers=true;
}
// update user allowed ip
else if (isset($allowIp) && isset($allowedIp))
{
sqlquery("UPDATE user SET allowed_ip='$allowedIp' WHERE uid='$allowIp'");
$editUsers=true;
}
// remove variable
else if (isset($rmVar) && isset($vid))
{
$editVariables = true;
sqlquery("DELETE FROM variable WHERE vid='$vid'");
if (mysql_affected_rows() != 1)
{
$error .= "Couldn't remove variable $vid/$chVarName, database request failed.
\n";
}
else
{
sqlquery("DELETE FROM user_variable WHERE vid='$vid'");
sqlquery("DELETE FROM view_row WHERE vid='$vid'");
$error .= "Removed effectively variable $vid/$chVarName/$chVarPath/$chVarState
\n";
}
}
// create variable
else if (isset($createVid) && isset($nvname) && isset($nvpath) && isset($nvstate) && isset($chVarGroup) && isset($nvgraphupdate))
{
$editVariables = true;
$result = sqlquery("INSERT INTO variable SET name='$nvname', vgid='$chVarGroup', path='$nvpath', state='$nvstate', warning_bound='$nvwarning', error_bound='$nverror', alarm_order='$nvorder', graph_update='$nvgraphupdate', command=".(isset($nvvartype) ? "'variable'" : "'command'"));
if (mysql_affected_rows() != 1)
{
$error .= "Can't create variable '$nvname', database request failed (already used variable name?)
\n";
unset($nvpath);
unset($nvstate);
}
else
{
$error .= "Effectively created variable '$nvname'
\n";
$result = sqlquery("SELECT vid FROM variable WHERE name='$nvname' AND vgid='$chVarGroup' AND path='$nvpath' AND state='$nvstate'");
if ($result && ($arr=sqlfetch($result)))
{
$vid = $arr["vid"];
foreach ($HTTP_POST_VARS as $var => $value)
{
if (strncmp($var, "setgroup_", 9) != 0)
continue;
$id = (int)substr($var, 9);
$priv = $value;
if ($nvstate == 'rd' && $priv == 'rw')
$priv = 'rd';
if ($priv == '')
continue;
$error .= "Set right '$priv' to users of group '$id':";
//$result = sqlquery("SELECT uid, login FROM user WHERE gid='$id'");
$query = "INSERT INTO user_variable VALUES ('$id', '$vid', '$priv')";
/*$first = true;
while ($result && ($arr=sqlfetch($result)))
{
$query .= (!$first ? "," : "")." ('".$arr["uid"]."', '$vid', '$priv')";
$error .= (!$first ? "," : "")." ".$arr["login"];
$first = false;
}*/
sqlquery($query);
$error .= "
\n";
}
}
unset($nvname);
unset($nvpath);
unset($nvstate);
}
}
// update variable
else if (isset($chVar) && isset($vid) && isset($chVarName) && isset($chVarPath) && isset($chVarState) && isset($chVarGraphUpdate))
{
$editVariables = true;
$result = sqlquery("UPDATE variable SET name='$chVarName', vgid='$chVarGroup', path='$chVarPath', state='$chVarState', warning_bound='$chVarWarning', error_bound='$chVarError', alarm_order='$chVarOrder', graph_update='$chVarGraphUpdate', command=".(isset($chVarType) ? "'variable'" : "'command'")." WHERE vid='$vid'");
if (mysql_affected_rows() == -1)
{
$error .= "Can't update variable $vid properties, database query failed (name changed to already used?)
\n";
}
else if ($chVarState == "rd")
{
sqlquery("UPDATE user_variable SET privilege='rd' WHERE privilege='rw' AND vid='$vid'");
}
}
// create var group
else if (isset($createVarGroup))
{
sqlquery("INSERT INTO variable_group SET name='$createVarGroup'");
}
// remove var group
else if (isset($rmVarGroup) && $rmVarGRoup!='1')
{
sqlquery("DELETE FROM variable_group WHERE vgid='$rmVarGroup'");
sqlquery("UPDATE variable SET vgid='1' WHERE vgid='$rmVarGroup'");
}
// add shard access
else if (isset($nshardaccess) && isset($editUser))
{
sqlquery("INSERT INTO shard_access SET uid='$editUser', shard='$nshardaccess'");
}
// remove shard access
else if (isset($rmShardAccess) && isset($editUser))
{
sqlquery("DELETE FROM shard_access WHERE uid='$editUser' AND shard='$rmShardAccess'");
}
// update shard access
else if (isset($chShardAccess) && isset($editUser))
{
sqlquery("DELETE FROM shard_access WHERE uid='$editUser'");
$query = "INSERT INTO shard_access VALUES";
$first = true;
if (isset($shardAccesses))
{
foreach($shardAccesses as $shard)
{
if (!$first)
$query .= ", ";
$first = false;
$query .= "('$editUser', '$shard')";
}
sqlquery($query);
}
}
else if (isset($crViewCommand) && isset($nViewCommand) && isset($nViewCommandName) && isset($editTid))
{
sqlquery("INSERT INTO view_command SET name='$nViewCommandName', command='$nViewCommand', tid='$editTid'");
}
else if (isset($rmViewCommand) && isset($viewCommand) && isset($editTid))
{
sqlquery("DELETE FROM view_command WHERE name='$viewCommand' AND tid='$editTid'");
}
// create server
else if (isset($createServer) && isset($serverName) && isset($serverIP))
{
sqlquery("INSERT INTO server SET name='$serverName', address='$serverIP'");
}
// delete server
else if (isset($rmServer) && isset($serverName))
{
sqlquery("DELETE FROM server WHERE name='$serverName'");
}
// update server name
else if (isset($updServerName) && isset($newServerName))
{
sqlquery("UPDATE server SET name='$newServerName' WHERE name='$updServerName'");
sqlquery("UPDATE service SET server='$newServerName' WHERE server='$updServerName'");
}
// update server ip
else if (isset($updServerIP) && isset($newServerIP))
{
sqlquery("UPDATE server SET address='$newServerIP' WHERE name='$updServerIP'");
}
// create service
else if (isset($createService) && isset($shardName) && isset($serverName) && isset($serviceName))
{
sqlquery("INSERT INTO service SET shard='$shardName', server='$serverName', name='$serviceName'");
}
// delete service
else if (isset($rmService) && isset($serviceId))
{
sqlquery("DELETE FROM service WHERE service_id='$serviceId'");
}
// update shard name
else if (isset($newShardName) && isset($serviceId))
{
sqlquery("UPDATE service SET shard='$newShardName' WHERE service_id='$serviceId'");
}
// update server name
else if (isset($newServerName) && isset($serviceId))
{
sqlquery("UPDATE service SET server='$newServerName' WHERE service_id='$serviceId'");
}
// update service name
else if (isset($newServiceName) && isset($serviceId))
{
sqlquery("UPDATE service SET name='$newServiceName' WHERE service_id='$serviceId'");
}
else if ($editServices == 'update' && isset($updateList))
{
unset($services);
$services = explode("\r", $updateList);
$editServiceError = '';
$editServiceLog = '';
$insertList = array();
$success = true;
$lineCount;
foreach ($services as $line)
{
++$lineCount;
$l = trim($line);
if ($l == '' || $l[0] == '*')
continue;
if (!ereg("^[[:space:]]*([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]*$", $l, $regs))
{
$editServiceError = "Malformed string '$l' at line $lineCount";
$success = false;
break;
}
list($reg, $shard, $server, $service) = $regs;
$insertList[] = array( 'shard' => $shard, 'server' => $server, 'service' => $service);
}
if ($success)
{
$updateLog = '';
$updateCount = 0;
if (count($insertList) > 0)
{
foreach ($insertList as $l)
{
$query = "SELECT * FROM service WHERE shard='".$l['shard']."' AND server='".$l['server']."' AND name='".$l['service']."'";
$result = sqlquery($query);
if ($result && sqlnumrows($result) == 0)
{
$updateLog .= 'updated/inserted service '.$l['shard'].'.'.$l['server'].'.'.$l['service']."\n";
++$updateCount;
}
}
}
$query = 'DELETE FROM service';
//echo $query."
\n";
$result = sqlquery($query);
if ($result)
{
$insertSuccess = 0;
if (count($insertList) > 0)
{
foreach ($insertList as $l)
{
$query = "INSERT INTO service SET shard='".$l['shard']."', server='".$l['server']."', name='".$l['service']."'";
//echo $query."
\n";
sqlquery($query);
++$insertSuccess;
}
}
$editServiceLog .= "Successfully updated $insertSuccess services in database:\n";
$editServiceError = '';
}
else
{
$editServiceError = 'Failed to delete all services from database';
}
}
}
else if ($editServers == 'update' && isset($updateList))
{
unset($servers);
$servers = explode("\r", $updateList);
$editServerError = '';
$editServerLog = '';
$insertList = array();
$success = true;
$lineCount;
foreach ($servers as $line)
{
++$lineCount;
$l = trim($line);
if ($l == '' || $l[0] == '*')
continue;
if (!ereg("^[[:space:]]*([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]*$", $l, $regs))
{
$editServiceError = "Malformed string '$l' at line $lineCount";
$success = false;
break;
}
list($reg, $server, $ip) = $regs;
$insertList[] = array( 'server' => $server, 'ip' => $ip);
}
if ($success)
{
$updateLog = '';
$updateCount = 0;
if (count($insertList) > 0)
{
foreach ($insertList as $l)
{
$query = "SELECT * FROM server WHERE name='".$l['server']."' AND address='".$l['ip']."'";
$result = sqlquery($query);
if ($result && sqlnumrows($result) == 0)
{
$updateLog .= 'updated/inserted server '.$l['server'].' at '.$l['ip']."\n";
++$updateCount;
}
}
}
$query = 'DELETE FROM server';
//echo $query."
\n"; $result=true;
$result = sqlquery($query);
if ($result)
{
$insertSuccess = 0;
if (count($insertList) > 0)
{
foreach ($insertList as $l)
{
$query = "INSERT INTO server SET name='".$l['server']."', address='".$l['ip']."'";
//echo $query."
\n";
sqlquery($query);
++$insertSuccess;
}
}
$editServerLog .= "Successfully updated $insertSuccess servers in database:\n";
$editServerError = '';
}
else
{
$editServerError = 'Failed to delete all servers from database';
}
}
}
// -----------------------------
// page display
htmlProlog($_SERVER['PHP_SELF'], "Administration");
subBar( array( "Users" => $_SERVER['PHP_SELF']."?editUsers=true",
"Variables" => $_SERVER['PHP_SELF']."?editVariables=true",
"Services" => $_SERVER['PHP_SELF']."?editServices=true",
"Servers" => $_SERVER['PHP_SELF']."?editServers=true",
"Shards" => $_SERVER['PHP_SELF']."?editShards=true" ));
echo "Administration tools
\n";
if ($error)
echo "Reported errors:
\n$error
";
if (!$editUser && !$editUsers && !$editVariables && !$editShards && !$editServices && !$editServers)
$editUsers = true;
// ---------------------------------------------------------------------------------
// edit a single user
// ---------------------------------------------------------------------------------
if ($editUser)
{
$resURL = $_SERVER['PHP_SELF']."?editUser=$editUser&selGroup=$selGroup";
$result = sqlquery("SELECT * FROM user WHERE uid='$editUser'");
if ($result && ($arr=mysql_fetch_array($result)))
{
$editLogin = $arr["login"];
$defaultView = $arr["default_view"];
$userGroup = $arr["gid"];
echo "$editLogin variables/views setup edit
\n";
echo "User variables setup
";
echo "
\n";
echo "
\n | \n";
if ($editUser != $uid)
{
echo " \n";
}
echo " | \n | \n";
echo "\n";
// Variable setup import form
echo " \n";
echo "
| \n";
echo" \n";
echo " | \n";
// user views setup
echo "User views setup\n";
echo "\n";
echo "Views | \n";
$result = sqlquery("SELECT name, tid FROM view_table WHERE uid='$editUser' ORDER BY ordering");
while ($result && ($arr=sqlfetch($result)))
{
$disp = "".$arr["name"]."";
$bgcolor = ($editTid == $arr["tid"] ? " bgcolor=#eeeeee" : "");
if ($arr["tid"] == $defaultView)
echo " $disp | \n";
else
echo " $disp | \n";
}
echo " \n";
echo " | \n";
echo " | \n";
if (isset($editTid) && $editTid != "")
{
echo "Variables \n";
echo "User name | System name | Path | User filter | \n";
$result = sqlquery("SELECT view_row.name AS name, variable.name AS sname, path, filter FROM view_row, variable WHERE tid='$editTid' AND view_row.vid=variable.vid ORDER BY ordering");
while ($result && ($arr=sqlfetch($result)))
{
echo "".$arr["name"]." | ".$arr["sname"]." | ".$arr["path"]." | ".$arr["filter"]." | \n";
}
echo "
\n";
echo "Commands \n";
echo "Name | Service command | \n";
$result = sqlquery("SELECT name, command FROM view_command WHERE tid='$editTid' ORDER BY name");
while ($result && ($arr=sqlfetch($result)))
{
echo " \n";
}
echo " | \n";
echo " \n";
echo "
\n";
}
echo " |
\n";
// user activity display
echo "User activity
\n";
echo "
\n";
}
else
{
echo "User $editUser not found in database.
";
}
}
// ---------------------------------------------------------------------------------
// edit users
// ---------------------------------------------------------------------------------
if ($editUsers)
{
echo "Users setup
\n";
unset($groupNames);
unset($actualGroups);
$result = sqlquery("SELECT login AS gname, uid, gid FROM user");
while ($result && ($arr=mysql_fetch_array($result)))
{
$groupNames[$arr["gname"]] = $arr["uid"];
if ($arr["gid"] == $arr["uid"])
$actualGroups[$arr["gname"]] = $arr["uid"];
}
echo "\n";
echo "Login | Uid | ";
echo "";
echo "Cookie | Force password | Allowed IP mask | Commands |
\n";
if (!isset($uViewGroups) || $uViewGroups == '')
$query = "SELECT uuser.login AS login, uuser.uid AS uid, uuser.useCookie AS useCookie, uuser.gid AS gid, ugroup.login AS gname, uuser.allowed_ip AS allowed_ip FROM user AS uuser, user AS ugroup WHERE uuser.gid=ugroup.uid ORDER BY uid";
else
$query = "SELECT uuser.login AS login, uuser.uid AS uid, uuser.useCookie AS useCookie, uuser.gid AS gid, ugroup.login AS gname, uuser.allowed_ip AS allowed_ip FROM user AS uuser, user AS ugroup WHERE uuser.gid=ugroup.uid AND uuser.gid='$uViewGroups' ORDER BY uid";
$result = sqlquery($query);
while ($result && ($arr=mysql_fetch_array($result)))
{
$ulogin = $arr["login"];
$uuid = $arr["uid"];
$ugid = $arr["gid"];
$ugname = $arr["gname"];
$uallowedip = $arr["allowed_ip"];
$uuseCookie = ($arr["useCookie"] == "yes");
echo "".
"$ulogin | \n".
"$uuid | \n".
"\n";
echo "";
echo "";
echo "";
echo "Delete |
\n";
}
echo "
\n";
$result = sqlquery("SELECT login, uid FROM user");
echo "\n";
}
// ---------------------------------------------------------------------------------
// edit variables
// ---------------------------------------------------------------------------------
if ($editVariables)
{
echo "Variables setup".help("Variables")."
\n";
echo "\n";
if ($importVarSetup && $importedVarSetup)
{
$result = sqlquery("SELECT name, vgid FROM variable_group");
unset($groups);
while ($result && ($arr=mysql_fetch_array($result)))
{
if ((!isset($varGroup) || $varGroup=="") && $arr["name"] == "NoGroup")
$varGroup = $arr["vgid"];
$groups[$arr["vgid"]] = $arr["name"];
}
$array = explode("\n", $importedVarSetup);
if (count($array) > 0)
{
unset($groupnames);
foreach ($groups as $vgid => $vgname)
$groupnames[$vgname] = $vgid;
foreach ($array as $varSetup)
{
if ($varSetup == '')
continue;
list($vname, $vpath, $vstate, $vgname, $vwarn, $verr, $valarm, $vgraph, $vcmd) = explode("|", $varSetup);
$result = sqlquery("SELECT count(*) as count FROM variable WHERE name='$vname'");
if ($result && ($arr=sqlfetch($result)) && $arr["count"] == 0)
{
if (!isset($groupnames[$vgname]))
{
sqlquery("INSERT INTO variable_group SET name='$vgname'");
$result = sqlquery("SELECT vgid FROM variable_group WHERE name='$vgname'");
if ($result && ($arr=sqlfetch($result)))
{
$vgid = $arr["vgid"];
$groupnames[$vgname] = $vgid;
}
else
{
$vgid = -1;
}
}
else
$vgid = $groupnames[$vgname];
if ($vgid != -1)
{
sqlquery("INSERT INTO variable SET name='$vname', path='$vpath', state='$vstate', vgid='$vgid', warning_bound='$vwarn', error_bound='$verr', alarm_order='$valarm', graph_update='$vgraph', command='$vcmd'");
}
}
}
}
}
$result = sqlquery("SELECT name, vgid FROM variable_group");
unset($groups);
while ($result && ($arr=mysql_fetch_array($result)))
{
if ((!isset($varGroup) || $varGroup=="") && $arr["name"] == "NoGroup") {
print "ERG! VARGROUP GUNNA BE: ".$arr["vgid"];
$varGroup = $arr["vgid"];
}
$groups[$arr["vgid"]] = $arr["name"];
}
if ($varGroup=="-1")
$result = sqlquery("SELECT * FROM variable ORDER BY vgid, name");
else
$result = sqlquery("SELECT * FROM variable WHERE vgid='$varGroup' ORDER BY name");
echo "\n";
echo "Name | Vid | Group | Path | State | Warning | Error | Order | Graph | Variable | Commands | \n";
$lastGroup = -1;
while ($result && ($arr=mysql_fetch_array($result)))
{
$name = $arr["name"];
$vid = $arr["vid"];
$vgid = $arr["vgid"];
$path = $arr["path"];
$state = $arr["state"];
$warn_bound = $arr["warning_bound"];
$err_bound = $arr["error_bound"];
$alarm_order = $arr["alarm_order"];
$graph_update = $arr["graph_update"];
$var_type = $arr["command"];
if ($lastGroup != -1 && $lastGroup != $vgid)
echo " | \n";
$lastGroup = $vgid;
echo " \n";
}
echo " | \n";
if (!isset($nvpath)) $nvpath = "*.*.*.*[.*]";
if (!isset($nvstate)) $nvstate = "rd";
echo " \n";
echo " | \n";
echo "\n";
echo " | | \n";
echo " \n";
echo " | | \n";
echo "\n";
echo "View by variable group | ";
echo "
| \n";
echo "\n";
echo "Create a variable group | \n";
echo " \n";
echo "
| \n";
echo "Delete a variable group | ";
echo "
| \n";
echo "\n";
echo "Export variables setup | \n";
echo " \n";
echo " \n";
echo " |
\n";
echo "\n";
}
// ---------------------------------------------------------------------------------
// edit shard organization
// ---------------------------------------------------------------------------------
if ($editShards)
{
echo "Shards setup".help("Shards")."
\n";
echo "\n";
if (!isset($serverOrder))
$serverOrder = "name";
if (!isset($serviceOrder))
$serviceOrder = "shard, server, name";
unset($servers);
$result = sqlquery("SELECT * FROM server ORDER BY $serverOrder");
echo "\n";
echo " | \n";
echo " | \n";
if ($fshard == "")
unset($result);
else if ($fshard == "*")
$result = sqlquery("SELECT * FROM service ORDER BY $serviceOrder");
else
$result = sqlquery("SELECT * FROM service WHERE shard LIKE '%$fshard%' ORDER BY $serviceOrder");
echo "\n";
echo " |
\n";
}
if ($editServices)
{
echo "Services setup".help("Services")."
\n";
if ($editServiceError != '')
{
echo "WARNING: failed to rebuild services list: error '$editServiceError'. List is kept unmodified.
\n";
}
if ($editServiceLog != '')
{
echo "RESULT: $editServiceLog
\n";
}
echo "\n";
}
if ($editServers)
{
echo "Servers setup".help("Servers")."
\n";
if ($editServerError != '')
{
echo "WARNING: failed to rebuild servers list: error '$editServerError'. List is kept unmodified.
\n";
}
if ($editServerLog != '')
{
echo "RESULT: $editServerLog
\n";
}
echo "\n";
}
htmlEpilog();
?>