Get process status and kill a process
Posted: Mon Jul 26, 2010 8:11 pm
Im having some issues creating my GameServer control panel 
This is the code so far:
It works all fine and start the server, but the thing i uses to check if a process is already running isnt working. And i want it to work so it check if a file (Lets say D:\server\hey.exe) is running, if not it start the file. I don't want it to check if the file named hay.exe is running, that would be useless if i want to be able to host more than 1 server using this control panel
Hope you guys can help me sort this issue out, and maybe give me a idea how to close a process using file patch(Same for process check).
Thx in advanced
This is the code so far:
Code: Select all
function Start($id)
{
$id = strtoupper($id);
$tegn = "#[^a-zA-Z0-9_\-]#";
if(preg_match($tegn,$id)) {
echo '<script type="text/javascript">window.location = "bruger.php";</script>';
}else{
MysqlConnect();
$sql = mysql_query("SELECT * FROM servers WHERE id = '" . $id . "'");
$get = mysql_fetch_array($sql);
if($get['bruger_id'] == $_SESSION['bruger_id']) {
exec("ps -C " . $get['serverfil'] . "", $pids);
if (count($pids) > 1) {
echo "<br /><i>" . $get['ip'] . " skal lukkes før den kan startes!</i>";
}else{
_exec("" . $get['serverfil'] . "" . $get['commandline'] . "");
echo "<br /><i>" . $get['ip'] . " blev started!</i>";
}
}else{
echo '<script type="text/javascript">window.location = "bruger.php";</script>';
}
}
}
Thx in advanced