Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(isset($_GET['action'])){
- if($_GET['action'] == 'stop'){
- $connection = ssh2_connect('localhost', 22);
- if ($connection === false) {
- $error = error_get_last();
- throw new Exception("Impossible de s'identifier en SSH au serveur distant : <br/><br/>
- Type d'erreur : ".$error["type"]."<br/>
- Message : ".$error["message"]."<br/>
- Fichier : ".$error["file"]."<br/>
- Ligne : ".$error["line"]."<br/>");
- }
- ssh2_auth_password($connection, 'user', 'pass');
- $stdio_stream = ssh2_shell($connection);
- ssh2_exec($connection, 'screen -S ftb -p 0 -X stuff "stop^M"');
- echo "<script type='text/javascript'>document.location.replace('index.php');</script>";
- }
- if($_GET['action'] == 'boot'){
- $connection = ssh2_connect('localhost', 22);
- if ($connection === false) {
- $error = error_get_last();
- throw new Exception("Impossible de s'identifier en SSH au serveur distant : <br/><br/>
- Type d'erreur : ".$error["type"]."<br/>
- Message : ".$error["message"]."<br/>
- Fichier : ".$error["file"]."<br/>
- Ligne : ".$error["line"]."<br/>");
- }
- ssh2_auth_password($connection, 'user', 'pass');
- $stdio_stream = ssh2_shell($connection);
- ssh2_exec($connection, 'cd ftb/ && ./ServerStart.sh');
- echo "<script type='text/javascript'>document.location.replace('index.php');</script>";
- }
- if($_GET['action'] == 'restart'){
- $connection = ssh2_connect('localhost', 22);
- if ($connection === false) {
- $error = error_get_last();
- throw new Exception("Impossible de s'identifier en SSH au serveur distant : <br/><br/>
- Type d'erreur : ".$error["type"]."<br/>
- Message : ".$error["message"]."<br/>
- Fichier : ".$error["file"]."<br/>
- Ligne : ".$error["line"]."<br/>");
- }
- ssh2_auth_password($connection, 'user', 'pass');
- $stdio_stream = ssh2_shell($connection);
- ssh2_exec($connection, 'screen -S ftb -p 0 -X stuff "broadcast Server Reboot in 1Min^M"');
- sleep(60);
- ssh2_exec($connection, 'screen -S ftb -p 0 -X stuff "stop^M"');
- sleep(4);
- ssh2_exec($connection, 'cd ftb/ && ./ServerStart.sh');
- echo "<script type='text/javascript'>document.location.replace('index.php');</script>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement