Advertisement
Guest User

Grex | www.sa-rl.de

a guest
Jul 13th, 2010
1,118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. <?php session_start();
  2. //error_reporting(0);
  3. include 'config.php';
  4. include 'templates/header.tpl';
  5. mysql_connect($mysql_host,$mysql_user,$mysql_pw);
  6. mysql_select_db($mysql_db);
  7. if(!isset($_SESSION['username']) && !isset($_POST['username'])){
  8. include 'templates/login.tpl';
  9. include 'templates/footer.tpl';
  10. exit;
  11. }
  12. if(isset($_POST['username']) && isset($_GET['action']) && $_GET['action'] == 'login')
  13. {
  14. $result = mysql_query("select * from Users where Username = '".$_POST['username']."'");
  15. if(mysql_result($result,0,'Password') == md5($_POST['password']))
  16. {
  17. $_SESSION['username'] = $_POST['username'];
  18. echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=overview">';
  19.  
  20. }
  21. else
  22. {
  23. include 'templates/login.tpl';
  24. echo '<font color="red"><u><b>Fehlerhafter Login</b></u></font>';
  25. }
  26. }
  27. else if(isset($_GET['action']))
  28. {
  29. include 'includes/cmd.php';
  30. if($_GET['action'] == 'logout')
  31. {
  32. session_unset();
  33. session_destroy();
  34. unset($_SESSION['username']);
  35. echo '<meta http-equiv="refresh" content="0; URL=/index.php">';
  36. }
  37. else if($_GET['action'] == 'upload')
  38. {
  39. $connection = ssh2_connect($ssh_host,$ssh_port);
  40. $target_path = $server_directory.$_POST['folder'];
  41. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  42. if(!ssh2_auth_password($connection, $ssh_user, $ssh_password)) echo '<font color="red">Fehler beim Verbinden auf die Shell</font>';
  43. else if(ssh2_scp_send($connection,$_FILES['uploadedfile']['tmp_name'], $target_path)) {
  44. echo "<font color='green'>Die Datei ". basename( $_FILES['uploadedfile']['name']).
  45. ' wurde erfolgreich hochgeladen</font>';
  46. ssh2_exec($connection,"chmod ".$upload_chmod." ".$target_path);
  47. ssh2_exec($connection,"exit");
  48. } else echo "<font color='red'>Beim hochladen entstand ein Fehler!</font>";
  49. }
  50. else if($_GET['action'] == 'startserver')
  51. {
  52. $connection = ssh2_connect($ssh_host,$ssh_port);
  53. if(!ssh2_auth_password($connection, $ssh_user, $ssh_password)) echo '<font color="red">Fehler beim Verbinden auf die Shell</font>';
  54. else if(!ssh2_exec($connection,'cd '.$server_directory.' && screen -dmS SAMP-Server ./'.$server_file)) echo '<font color="red">Startdatei konnte nicht gefunden werden</font>';
  55. else echo '<font color="green">Server wurde erfolgreich gestartet</font>';
  56. }
  57. else if($_GET['action'] == 'stopserver')
  58. {
  59. $connection = ssh2_connect($ssh_host,$ssh_port);
  60. if(!ssh2_auth_password($connection, $ssh_user, $ssh_password)) echo '<font color="red">Fehler beim Verbinden auf die Shell</font>';
  61. else if(!ssh2_exec($connection,'killall '.$server_file)) echo '<font color="red">Prozess konnte nicht gefunden werden</font>';
  62. else
  63. {
  64. echo '<font color="green">Server wurde erfolgreich gestoppt</font>';
  65. ssh2_exec($connection,"exit");
  66. }
  67. }
  68. else if($_GET['action'] == 'editwe')
  69. {
  70. $_GET['result'] = str_replace("_20"," ",$_GET['result']);
  71. rcon("weather ".$_GET['result']);
  72. echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=overview">';
  73. }
  74. else if($_GET['action'] == 'restartserver')
  75. {
  76. rcon("gmx");
  77. echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=manage">';
  78. }
  79. else if($_GET['action'] == 'kickuser')
  80. {
  81. rcon("kick " . $_GET['targetuser']);
  82. echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=overview">';
  83. }
  84. else if($_GET['action'] == 'banuser')
  85. {
  86. rcon("ban " . $_GET['targetuser']);
  87. echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=overview">';
  88.  
  89. }
  90. else if($_GET['action'] == 'banip')
  91. {
  92. rcon("banip " . $_GET['ip']);
  93. echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=manage">';
  94.  
  95. }
  96. else if($_GET['action'] == 'unbanip')
  97. {
  98. rcon("unbanip " . $_GET['ip']);
  99. echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=manage">';
  100.  
  101. }
  102. else if($_GET['action'] == 'announce')
  103. {
  104. rcon("say " . $_GET['announce']);
  105. echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=manage">';
  106.  
  107. }
  108. else if($_GET['action'] == 'sendcmd')
  109. {
  110. rcon($_GET['cmd']);
  111. echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=manage">';
  112.  
  113. }
  114. else if($_GET['action'] == 'edithostname')
  115. {
  116. $_GET['result'] = str_replace("_20"," ",$_GET['result']);
  117. rcon("hostname " . $_GET['result'] );
  118. echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=overview">';
  119. }
  120. else if($_GET['action'] == 'savefile')
  121. {
  122. $connection = ssh2_connect($ssh_host,$ssh_port);
  123. if(!ssh2_auth_password($connection, $ssh_user, $ssh_password)) echo '<font color="red">Fehler beim Verbinden auf die Shell</font>';
  124. else $sftp = ssh2_sftp($connection);
  125. if(!isset($_POST['content'])) echo '<font color="red">Fehler bei der &Uuml;bertragung</font>';
  126. else if(!isset($_GET['file']) || $_GET['file'] == 'server_log.txt') echo '<font color="red">Es wurde keine Datei angegeben</font>';
  127. else if(!$sftp) echo '<font color="red">Fehler beim Verbinden per SFTP.</font>';
  128. else
  129. {
  130. $filename = "ssh2.sftp://".$sftp.$server_directory.$_GET['file'];
  131. $handle = fopen($filename,"w");
  132. if(!fwrite($handle,$_POST['content'])) echo '<font color="red">Fehler beim Schreiben der Datei</font>';
  133. else echo '<font color="green">Die Datei wurde erfolgreich bearbeitet</font>';
  134. fclose($handle);
  135. }
  136. }
  137. }
  138. else
  139. {
  140. if(!isset($_GET['page'])) header("Location: index.php?page=overview");
  141. else if($_GET['page'] == 'manage') include 'templates/manage.tpl';
  142. else if($_GET['page'] == 'webftp') include 'templates/webftp.tpl';
  143. else if($_GET['page'] == 'overview') include 'templates/overview.tpl';
  144. else if($_GET['page'] == 'console') include 'templates/console.tpl';
  145. }
  146. include 'templates/footer.tpl'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement