Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- Class Panel()
- {
- private static var $ssh2; //Connect!!
- private static var $ssh_ip; // Ssh ip
- private static var $ssh_port; // Ssh port
- private static var $ssh_pass; // Ssh user password
- private static var $ssh_user; // Ssh username
- private static var $type; // Server type
- private static var $gamefolder; // Virtual Private Server Game Dir.
- private static var $isfolder; // CD /home/game/$gamefolder
- static function set($ip, $port, $user, $pass, $type, $gamefolder)
- {
- self::$ssh_ip = $ip;
- self::$ssh_pass = $pass;
- self::$ssh_port = $port;
- self::$ssh_user = $user;
- self::$type = $type;
- }
- static function writelog($nr)
- {
- switch($nr)
- {
- case 1: $enter = ' '.self::$type.':Server on käivitatud.\n'; Break;
- case 2: $enter = ' '.self::$type.':Sever on peatatud!\n'; Break;
- case 3: $enter = ' '.self::$type.':Server teeb restarti!\n'; Break;
- case 4: $enter = ' '.self::$type.':Server tegi restardi.\n' Break;
- }
- $filename = 'log_file.txt';
- $handle = fopen($filename, 'a')
- fwrite($handle, $enter)
- fclose($handle);
- }
- static function connect()
- {
- self::$ssh2 = ssh2_connect(self::$ssh_ip, self::$ssh_port) or die("Error connect to ssh2");
- self::$ssh2 = ssh2_auth_password(self::$ssh2, self::$ssh_user, self::$ssh_pass) or die("Error connect to ssh2");
- self::$isfolder = ssh2_exec(self::$ssh2, 'cd /home/game/' . self::$gamefolder);
- }
- static function server_start()
- {
- self::$isfolder;
- switch(self::$type)
- {
- case 'cs': ssh2_exec(self::$ssh2, ' ./samp03svr'); Break;
- case 'samp': ssh2_exec(self::$ssh2, ' ./samp03svr'); Break;
- case 'minecraft': ssh2_exec(self::$ssh2, ' ./samp03svr'); Break;
- }
- self::$writelog(1);
- }
- static function server_restart()
- {
- self::$isfolder;
- switch(self::$type)
- {
- case 'cs':
- ssh2_exec(self::$ssh2, 'killall ./hlds_run');
- ssh2_exec(self::$ssh2, ' ./hlds_run');
- Break;
- case 'samp':
- ssh2_exec(self::$ssh2, 'kilalll ./samp03svr');
- ssh2_exec(self::$ssh2, ' ./samp03svr');
- Break;
- case 'minecraft':
- ssh2_exec(self::$ssh2, 'killall ./samp03svr');
- ssh2_exec(self::$ssh2, ' exec java -Xmx1G -Xms1G -jar minecraft_server.jar');
- Break;
- self::$writelog(3);
- self::$writelog(4);
- }
- }
- static function server_stop()
- {
- self::$isfolder;
- switch(self::$type)
- {
- case 'cs': ssh2_exec(self::$ssh2, 'killall ./samp03svr'); Break;
- case 'samp': ssh2_exec(self::$ssh2, ' killall ./samp03svr'); Break;
- case 'minecraft': ssh2_exec(self::$ssh2, 'killall ./samp03svr'); Break;
- }
- self::$writelog(2);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement