<?PHP
$path = $config['site']['server_path'];
$exename = "theforgottenserver.exe";
if($group_id_of_acc_logged >= $config['site']['access_admin_panel'])
{
if($action == "")
{
$main_content .= '<table style=\'clear:both\' border=0 cellpadding=0 cellspacing=0 width=\'100%\'>
<tr bgcolor='.$config['site']['darkborder'].'><td width="150"><font color="red"><b>Option</b></font></td><td><font color="red"><b>Description</b></font></td></tr>
<tr bgcolor='.$config['site']['lightborder'].'><td width="150"><b><a href="?subtopic=restarter&action=restart">Restart</a></b></td><td><b>Kills server process and starts new one.</b></td></tr>
<tr bgcolor='.$config['site']['darkborder'].'><td width="150"><b><a href="?subtopic=restarter&action=kill">Kill process</a></b></td><td><b>Kills server process.</b></td></tr>
<tr bgcolor='.$config['site']['lightborder'].'><td width="150"><b><a href="?subtopic=restarter&action=start">Start server</a></b></td><td><b>Starts server.</b></td></tr>
<tr bgcolor='.$config['site']['darkborder'].'><td width="150"><b><a href="?subtopic=restarter&action=shutdown">Shutdown server instantly</a></b></td><td><b>Allows you to safe shutdown server(using servers own shutdown function).</b></td></tr>
<tr bgcolor='.$config['site']['lightborder'].'><td width="150"><b><a href="?subtopic=restarter&action=shutdownlong">Player-friendly shutdown</a></b></td><td><b>Performs safe shutdown after broadcast warning and 5 minutes delay.</b></td></tr>
<tr bgcolor='.$config['site']['darkborder'].'><td width="150"><b><a href="?subtopic=adminpanel">Back to admin panel</a></b></td><td><b>Go back to admin panel.</b></td></tr>
</table>';
}
getcwd();
chdir($path);
if($action == "restart")
{
exec('TASKKILL /F /IM ".$exename."');
$command = 'START/HIGH '.$exename;
$tmpnam = "temp.bat";
$fp = fopen ($tmpnam, "w");
fwrite($fp, $command);
fclose ($fp);
$foo = @popen($tmpnam, 'r');
$main_content .='<center>Server restarted.<br><b><a href="?subtopic=restarter">Back</a></center>';
}
if($action == "kill"){exec('TASKKILL /F /IM "'.$exename.'"'); $main_content .='<center>Server closed.<br><b><a href="?subtopic=restarter">Back</a></center>';}
if($action == "start")
{
$command = 'START/HIGH '.$exename;
$tmpnam = "temp.bat";
$fp = fopen ($tmpnam, "w");
fwrite($fp, $command);
fclose ($fp);
$foo = @popen($tmpnam, 'r');
$main_content .='<center>Server started. <br><b><a href="?subtopic=restarter">Back</a></center>';
}
if($action == "shutdown")
{
$SQL->query('UPDATE '.$SQL->tableName('z_shut').' SET `shutdown`="1", `long`="0" WHERE id = "1";');
$main_content .='<center>Server will shut down soon. <br><b><a href="?subtopic=restarter">Back</a></center>';
}
if($action == "shutdownlong")
{
$SQL->query('UPDATE '.$SQL->tableName('z_shut').' SET `shutdown`="1", `long`="1" WHERE `id` = "1";');
$main_content .='<center>Server will shut down soon. <br><b><a href="?subtopic=restarter">Back</a></center>';
}
}
else
{
$title = $GLOBALS['config']['server']["serverName"]." - OTS";
$main_content .= 'Invalid subtopic. Can\'t load page.';
}
?>