Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php session_start();
- //error_reporting(0);
- include 'config.php';
- include 'templates/header.tpl';
- mysql_connect($mysql_host,$mysql_user,$mysql_pw);
- mysql_select_db($mysql_db);
- if(!isset($_SESSION['username']) && !isset($_POST['username'])){
- include 'templates/login.tpl';
- include 'templates/footer.tpl';
- exit;
- }
- if(isset($_POST['username']) && isset($_GET['action']) && $_GET['action'] == 'login')
- {
- $result = mysql_query("select * from Users where Username = '".$_POST['username']."'");
- if(mysql_result($result,0,'Password') == md5($_POST['password']))
- {
- $_SESSION['username'] = $_POST['username'];
- echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=overview">';
- }
- else
- {
- include 'templates/login.tpl';
- echo '<font color="red"><u><b>Fehlerhafter Login</b></u></font>';
- }
- }
- else if(isset($_GET['action']))
- {
- include 'includes/cmd.php';
- if($_GET['action'] == 'logout')
- {
- session_unset();
- session_destroy();
- unset($_SESSION['username']);
- echo '<meta http-equiv="refresh" content="0; URL=/index.php">';
- }
- else if($_GET['action'] == 'upload')
- {
- $connection = ssh2_connect($ssh_host,$ssh_port);
- $target_path = $server_directory.$_POST['folder'];
- $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
- if(!ssh2_auth_password($connection, $ssh_user, $ssh_password)) echo '<font color="red">Fehler beim Verbinden auf die Shell</font>';
- else if(ssh2_scp_send($connection,$_FILES['uploadedfile']['tmp_name'], $target_path)) {
- echo "<font color='green'>Die Datei ". basename( $_FILES['uploadedfile']['name']).
- ' wurde erfolgreich hochgeladen</font>';
- ssh2_exec($connection,"chmod ".$upload_chmod." ".$target_path);
- ssh2_exec($connection,"exit");
- } else echo "<font color='red'>Beim hochladen entstand ein Fehler!</font>";
- }
- else if($_GET['action'] == 'startserver')
- {
- $connection = ssh2_connect($ssh_host,$ssh_port);
- if(!ssh2_auth_password($connection, $ssh_user, $ssh_password)) echo '<font color="red">Fehler beim Verbinden auf die Shell</font>';
- else if(!ssh2_exec($connection,'cd '.$server_directory.' && screen -dmS SAMP-Server ./'.$server_file)) echo '<font color="red">Startdatei konnte nicht gefunden werden</font>';
- else echo '<font color="green">Server wurde erfolgreich gestartet</font>';
- }
- else if($_GET['action'] == 'stopserver')
- {
- $connection = ssh2_connect($ssh_host,$ssh_port);
- if(!ssh2_auth_password($connection, $ssh_user, $ssh_password)) echo '<font color="red">Fehler beim Verbinden auf die Shell</font>';
- else if(!ssh2_exec($connection,'killall '.$server_file)) echo '<font color="red">Prozess konnte nicht gefunden werden</font>';
- else
- {
- echo '<font color="green">Server wurde erfolgreich gestoppt</font>';
- ssh2_exec($connection,"exit");
- }
- }
- else if($_GET['action'] == 'editwe')
- {
- $_GET['result'] = str_replace("_20"," ",$_GET['result']);
- rcon("weather ".$_GET['result']);
- echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=overview">';
- }
- else if($_GET['action'] == 'restartserver')
- {
- rcon("gmx");
- echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=manage">';
- }
- else if($_GET['action'] == 'kickuser')
- {
- rcon("kick " . $_GET['targetuser']);
- echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=overview">';
- }
- else if($_GET['action'] == 'banuser')
- {
- rcon("ban " . $_GET['targetuser']);
- echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=overview">';
- }
- else if($_GET['action'] == 'banip')
- {
- rcon("banip " . $_GET['ip']);
- echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=manage">';
- }
- else if($_GET['action'] == 'unbanip')
- {
- rcon("unbanip " . $_GET['ip']);
- echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=manage">';
- }
- else if($_GET['action'] == 'announce')
- {
- rcon("say " . $_GET['announce']);
- echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=manage">';
- }
- else if($_GET['action'] == 'sendcmd')
- {
- rcon($_GET['cmd']);
- echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=manage">';
- }
- else if($_GET['action'] == 'edithostname')
- {
- $_GET['result'] = str_replace("_20"," ",$_GET['result']);
- rcon("hostname " . $_GET['result'] );
- echo '<meta http-equiv="refresh" content="0; URL=/index.php?page=overview">';
- }
- else if($_GET['action'] == 'savefile')
- {
- $connection = ssh2_connect($ssh_host,$ssh_port);
- if(!ssh2_auth_password($connection, $ssh_user, $ssh_password)) echo '<font color="red">Fehler beim Verbinden auf die Shell</font>';
- else $sftp = ssh2_sftp($connection);
- if(!isset($_POST['content'])) echo '<font color="red">Fehler bei der Übertragung</font>';
- else if(!isset($_GET['file']) || $_GET['file'] == 'server_log.txt') echo '<font color="red">Es wurde keine Datei angegeben</font>';
- else if(!$sftp) echo '<font color="red">Fehler beim Verbinden per SFTP.</font>';
- else
- {
- $filename = "ssh2.sftp://".$sftp.$server_directory.$_GET['file'];
- $handle = fopen($filename,"w");
- if(!fwrite($handle,$_POST['content'])) echo '<font color="red">Fehler beim Schreiben der Datei</font>';
- else echo '<font color="green">Die Datei wurde erfolgreich bearbeitet</font>';
- fclose($handle);
- }
- }
- }
- else
- {
- if(!isset($_GET['page'])) header("Location: index.php?page=overview");
- else if($_GET['page'] == 'manage') include 'templates/manage.tpl';
- else if($_GET['page'] == 'webftp') include 'templates/webftp.tpl';
- else if($_GET['page'] == 'overview') include 'templates/overview.tpl';
- else if($_GET['page'] == 'console') include 'templates/console.tpl';
- }
- include 'templates/footer.tpl'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement