<div align="center"></div>
<?PHP
if(isset($_GET['start'])) {
$command = _DNAS_EXEC." "._DNAS_CONFIG." > /dev/null 2>&1 & echo \$!";
$start_server = exec("$command");
$check = exec("ps p $start_server --no-heading");
if($check == "") {
echo "<center><strong>".server_info('name',$_GET['id'])."</strong> couldn't be started!<BR>This usually means that <strong>".server_info('name',$_GET['id'])."</strong> is already started.</center>";
}
else
{
echo "<center><strong>".server_info('name',$_GET['id'])."</strong> was successfully started.</center>";
$sql = "UPDATE servers SET pid ='".$start_server."', status='1' WHERE id = '".server_info('id',$_GET['id'])."' LIMIT 1";
$result = mysql_query($sql,$conn) or die (mysql_error());
}
}
if(isset($_GET['stop'])) {
$sql = "SELECT * FROM servers WHERE id = '".server_info('id',$_GET['id'])."' LIMIT 1";
$result = mysql_query($sql,$conn) or die (mysql_error());
$data = mysql_fetch_array($result);
if($data['status'] == 1)
{
$check = exec("ps p ".$data['pid']." --no-heading");
if($check != "")
{
exec("kill -9 ".$data['pid']);
$check2 = exec("ps p ".$data['pid']." --no-heading");
if($check2 == "")
{
$sql = "UPDATE servers SET pid ='', status='0' WHERE id = '".server_info('id',$_GET['id'])."' LIMIT 1";
mysql_query($sql,$conn);
$message = "<strong>".$data['name']."</strong> has been successfully stopped.";
}
else
{
$message = "<strong>".$data['name']."</strong> couldn't be killed!";
}
}
else
{
$sql = "UPDATE servers SET pid ='', status='0' WHERE id = '".server_info('id',$_GET['id'])."' LIMIT 1";
mysql_query($sql,$conn);
$message = "Oops! <strong>".$data['name']."</strong> wasn't actually running!";
}
}
elseif ($data['status'] == 0)
{
if($data['pid'] == "")
{
$message = "<strong>".$data['name']."</strong> isn't running!";
}
else
{
$sql = "UPDATE servers SET pid ='', status='0' WHERE id = '".server_info('id',$_GET['id'])."' LIMIT 1";
mysql_query($sql,$conn);
$message = "The database shows that <strong>".$data['name']."</strong> is running, but we can't find it's proccess!<BR>This usually means that it isn't actually running.<BR>We've gone ahead and fixed the database to show <strong>".$data['name']."</strong> as not running.";
}
}
echo "<center>".$message."</center>";
}
?>