/**
 *	@author João Reis
 *	@Year 2016
 *	@param $Id
 *	@return Boolean
 */
function _apagarServidor($Id)
{
    try {
        _pararServidor($Id);
        $comando = "rm -r /home/cyberpanel/" . $Id . "; exit";
        shell_exec("sudo tmux new-session -s apaga{$Id} -d");
        shell_exec("sudo tmux send -t apaga{$Id} '{$comando}' ENTER");
        eliminarServidorById($Id);
        return true;
    } catch (Exception $ex) {
        return false;
    }
}
function _atualizarServidor($Id)
{
    echo "Updating";
    _pararServidor($Id);
    shell_exec("sudo tmux new-session -s {$Id} -d");
    shell_exec("sudo tmux send -t {$Id} 'chown {$Id}:cyberpanel /home/cyberpanel/{$Id}/* -R; chmod 770 /home/cyberpanel/{$Id}/* -R; sudo su - cyberpanel -c \"bash /home/cyberpanel/steamcmd.sh +login anonymous +force_install_dir /home/cyberpanel/{$Id}/ +app_update 740 +quit\"; exit' ENTER");
}
 /**
  *	@author João Reis
  *	Para Servidor
  */
 function pararServidor()
 {
     // Comando para parar servidor
     # shell_exec("sudo tmux kill-session -t '".$this->Id."'");
     @(include "modulos/modulos.conf.php");
     @(include "../modulos/modulos.conf.php");
     #@include_once(__DIR__."/modulos/modulos.conf.php");
     $existe = false;
     $index = 1;
     $i = 0;
     if (isset($Vmodulos)) {
         $modulos = array();
         $modulos = $Vmodulos;
         foreach ($modulos as $modulo) {
             $i++;
             if ($modulo['tipoServidor'] == $this->getTipoServidor()) {
                 $existe = true;
                 $index = $i;
                 break;
             }
         }
         if ($existe) {
             if (function_exists('_pararServidor')) {
                 runkit_function_remove('_pararServidor');
             }
             @(include $modulos[$index]['dir']);
             @(include "../" . $modulos[$index]['dir']);
             if (isset($modulos)) {
                 return _pararServidor($this->Id);
             }
             return false;
         } else {
             return false;
         }
     }
 }