'#333333','control' => '#333333','config' => '#333333','logs' => '#333333','support' => '#333333'); // Change #666666 to another colour to change the default 'selected' tab colour var $high_bg = '#666666'; // Leave these alone var $server_id; var $tab_output = ''; var $output = ''; var $error = array(); var $control_message = ''; var $password_message = ''; var $advconfig_message = ''; var $s_gametype; var $s_username; var $s_password; var $s_ip; var $s_port; var $current_status; var $disk_used; var $server_cfg; var $server_log; var $status; var $password; var $referer; function fragzzPanel () { global $cfgs; global $HTTP_POST_VARS; global $HTTP_COOKIE_VARS; if($GLOBALS['logout'] == true) { $this->logout(); header('Location: /fragzzPanel'); } if ($HTTP_POST_VARS['S_LOGIN_status'] == "trying") { $this->status = $HTTP_POST_VARS['S_LOGIN_status']; $this->server_id = $HTTP_POST_VARS['S_LOGIN_server_id']; $this->password = $HTTP_POST_VARS['S_LOGIN_password']; $this->referer = $HTTP_POST_VARS['S_LOGIN_referer']; $this->login(); $this->back(); } elseif ($HTTP_COOKIE_VARS['S_LOGIN_status'] == "loggedin") { $this->status = $HTTP_COOKIE_VARS['S_LOGIN_status']; $this->server_id = $HTTP_COOKIE_VARS['S_LOGIN_server_id']; $this->password = $HTTP_COOKIE_VARS['S_LOGIN_password']; $this->check_login(); } else { $GLOBALS['action'] = 'login'; } if($this->status == 'loggedin') { if($GLOBALS['control_action'] == 'Update Password') { $this->update_password(); } $serverSQL = $DB->query("SELECT S.gametype, I.username, I.password, S.ip, S.port, I.current_config, I.player_slots, I.branding, I.public FROM s_db AS S LEFT JOIN s_internal_db AS I ON S.server_id = I.server_id WHERE S.server_id = '$this->server_id'") or die($DB->error()); list($this->s_gametype,$this->s_username,$this->s_password,$this->s_ip,$this->s_port,$this->s_current_config,$this->s_player_slots,$this->s_branding, $this->s_public) = $DB->fetch_row($serverSQL); $this->current_status = `/usr/bin/fragzzPanel_status /servers/$this->s_username`; $this->disk_used = `du -hs /servers/$this->s_username`; if($GLOBALS['control_action'] == 'Restart') { if($this->s_username == 'demo') { $this->error[microtime()] = 'Disabled for demo!!'; $this->end(); } $this->restart(); } if($GLOBALS['control_action'] == 'Start') { if($this->s_username == 'demo') { $this->error[microtime()] = 'Disabled for demo!!'; $this->end(); } $this->start(); } if($GLOBALS['control_action'] == 'Stop') { if($this->s_username == 'demo') { $this->error[microtime()] = 'Disabled for demo!!'; $this->end(); } $this->stop(); } if($GLOBALS['config_action'] == 'edit main config file') { if($this->s_username == 'demo') { $this->error[microtime()] = 'Disabled for demo!!'; $this->end(); } else { if(!empty($GLOBALS['u_server_cfg'])) { $server_cfg_f = fopen("/servers/".$this->s_gametype."/".$this->s_username."/".$cfgs[$this->s_gametype]['path']."/".$cfgs[$this->s_gametype]['filename'],'w'); fwrite($server_cfg_f,stripslashes($GLOBALS['u_server_cfg'])); fclose($server_cfg_f); $this->advconfig_message = '[i] Main Configuration File Updated!'; } else { $this->error[microtime()] = 'Config Data Empty!'; $this->end(); } } } if($GLOBALS['config_action'] == 'apply new config') { if($this->s_username == 'demo') { $this->error[microtime()] = 'Disabled for demo!!'; $this->end(); } else { if(!empty($GLOBALS['server_config_id'])) { $new_config = $DB->fetch_array($DB->query("SELECT * FROM s_config_db WHERE server_config_id = '".$GLOBALS['server_config_id']."'")); $new_gametype = $DB->fetch_array($DB->query("SELECT * FROM s_gametype_db WHERE server_gametype_id = '".$new_config['gametype']."'")); $CFG = $server_config_id.'.cfg'; eval("\$new_gametype['binary_arguments'] = \"".$new_gametype['binary_arguments']."\";"); $server_cfg_f = fopen("/servers/".$this->s_username."/run",'w'); $new_run_file = '#!/bin/sh USERNAME="'.$this->s_username.'" BINARY="'.$new_gametype["binary_path"].'" EXTRA="'.$new_gametype["binary_arguments"].'" exec nice --adjustment=-20 envdir /servers/$USERNAME/env setuidgid $USERNAME $BINARY $EXTRA 2>&1'; fwrite($server_cfg_f,$new_run_file); fclose($server_cfg_f); $DB->query("UPDATE s_db SET gametype = '".$new_config['gametype']."' WHERE server_id = '".$this->server_id."';") or trigger_error($DB->error(),E_USER_ERROR); $this->restart(); $this->advconfig_message = '[i] New config file applied and server restarted!'; } else { $this->error[microtime()] = 'Config Data Empty!'; $this->end(); } } } if($GLOBALS['support_action'] == 'send support request') { if($this->s_username == 'demo') { $this->error[microtime()] = 'Disabled for demo!!'; $this->end(); } if(!empty($GLOBALS['support_text'])) { global $support_topics; $support_email = 'Hello A support request has been sent. Here are the details: Server ID: '.$this->server_id.' Game type: '.$this->s_gametype.' IP: '.$this->s_ip.' Port: '.$this->s_port.' User name: '.$this->s_username.' Password: '.$this->s_password.' Subject: '.$GLOBALS['support_subject'].' Email: '.$GLOBALS['support_email'].' Message: '.$GLOBALS['support_text'].' Thanks fragzzPanel Support'; mail($support_topics[$GLOBALS['support_subject']],'fragzzPanel Support: '.$GLOBALS['support_subject'],$support_email,'From: fragzzPanel '); $this->support_message = '[i] Your support request has been sent. You should receive a reply within 48 hours, but probobly within 24 hours.'; } else { $this->error[microtime()] = 'Your message was empty!'; $this->end(); } } $server_log_f = fopen("/servers/".$this->s_username."/logs/current",'r'); $this->server_log = fread($server_log_f,filesize("/servers/".$this->s_username."/current")); fclose($server_log_f); } } function end () { print "fragzzPanel Error
"; foreach($this->error AS $value) { print "[!] ".$value."
"; } exit; } function restart () { if($this->s_username == 'demo') { $this->error[microtime()] = 'Disabled for demo!!'; $this->end(); } $out = `/usr/bin/fragzzPanel_restart /servers/$this->s_username`; $this->control_message = '[i] Server Restarted'; } function start () { if($this->s_username == 'demo') { $this->error[microtime()] = 'Disabled for demo!!'; $this->end(); } $out = `/usr/bin/fragzzPanel_start /servers/$this->s_username`; $this->control_message = '[i] Server Started'; } function stop () { if($this->s_username == 'demo') { $this->error[microtime()] = 'Disabled for demo!!'; $this->end(); } $out = `/usr/bin/fragzzPanel_stop /servers/$this->s_username`; $this->control_message = '[i] Server Stopped'; } function update_password() { global $u_password; if($this->s_username == 'demo') { $this->error[microtime()] = 'Disabled for demo!!'; $this->end(); } if($DB->query("UPDATE s_internal_db SET password = '$u_password' WHERE server_id = '$this->server_id'")) { $this->password_message .= '[i] Password Updated'; return true; } else { $this->error[microtime()] = 'Password could not be updated: '.$DB->error(); $this->end(); } } function tab ($tab = 'home') { global $game_types; $this->bg[$tab] = $this->high_bg; switch ($tab) { case "home": $this->tab_output .= '
[-] login details
User name: '.$this->s_username.'
Password: '.$this->s_password.'


[-] ftp details
Host name: ftp.fragzz.com
User name: '.$this->s_username.'
Password: '.$this->s_password.'

Disk space used:
'.$this->disk_used.'
[-] server details
Game Type: '.$DB->get_data('s_gametype_db','shortname','server_gametype_id',$this->s_gametype).'
IP: '.$this->s_ip.'
Port: '.$this->s_port.'

Player Slots: '.$this->s_player_slots.'
Branding: '.$this->s_branding.'
Public: '.$this->s_public.'


[-] server status
Current Status:
'.$this->current_status.'
'; break; case "control": $this->tab_output .= '
[-] server status
Current Status:
'.$this->current_status.'


[-] server control
'.$this->control_message.'









[-] login details
'.$this->password_message.'
User Name : '.$this->s_username.'
Password :



'; break; case "config": $sql1 = $DB->query("SELECT G.name, C.caption, C.server_config_id FROM s_config_db AS C LEFT JOIN s_gametype_db AS G ON C.gametype = G.server_gametype_id WHERE C.server_id = '0' OR C.server_id = '$this->server_id' ORDER BY gametype ASC") or trigger_error($DB->error(),E_USER_ERROR); while($configs = $DB->fetch_array($sql1)) { $config_list .= ''; } $this->tab_output .= '
[-] apply new config

'.$this->config_applynew_message.'



[-] apply new config

'.$this->advconfig_message.'



'; break; case "logs": $this->tab_output .= '
[-] main config file


'; break; case "support": global $support_topics; $subject_text = ''; foreach($support_topics AS $key => $value) { $subject_text .= "\n"; } $this->tab_output .= '
[-] support

'.$this->support_message.'

Subject :
Contact
(a way we can contact you i.e. email address)
:
Message :


'; break; case "login": $this->tab_output .= '
user name :

password :


[?] To find your server login details, please select \'Your Servers\' in the myFragID Panel.'; break; } print ' '; $this->output .= '
home
control
config
logs
support

fragzzPanel

'; if($this->status == 'loggedin') { $this->output .= 'log out'; } $this->output .= '
'.$this->tab_output.'
'; } function back () { if(empty($this->referer)) { header("Location: /fragzzPanel"); } else { header("Location: $this->referer"); } } function get ($field,$extra = 'internal_') { $query = $DB->query("SELECT $field FROM s_".$internal."db WHERE server_id = '$this->server_id'"); if ($query && $DB->num_rows($query) != 0) { $result = $DB->result($query,0); } else { $result = "Failed"; } return($result); } function login () { $lrows = $DB->num_rows($DB->query("SELECT public FROM s_internal_db WHERE server_id = '$this->server_id' OR username = '$this->server_id' LIMIT 1")); if ($lrows != 1) { die("Sorry, but your user ID could not be found. Please try again"); } else { $passsql = $DB->query("SELECT password FROM s_internal_db WHERE server_id = '$this->server_id' OR username = '$this->server_id' LIMIT 1"); $pass = $DB->result($passsql,0); if ($pass != $this->password) { die("Sorry, but your password did not match our database. Please try again"); } else { $this->server_id = $DB->result($DB->query("SELECT server_id FROM s_internal_db WHERE server_id = '$this->server_id' OR username = '$this->server_id' LIMIT 1"),0); setcookie ("S_LOGIN_server_id", $this->server_id,time()+31536000); setcookie ("S_LOGIN_password", md5($this->password),time()+31536000); setcookie ("S_LOGIN_status", "loggedin",time()+31536000); $this->status = "loggedin"; } } } function check_login () { $lrows = $DB->num_rows($DB->query("SELECT server_id FROM s_internal_db WHERE server_id = '$this->server_id'")); if ($lrows != 1) { $this->wipe_login("Sorry, but your user ID could not be found. Please try again"); } else { $passsql = $DB->query("SELECT password FROM s_internal_db WHERE server_id = '$this->server_id'"); $pass = $DB->result($passsql,0); $pass2 = $pass; if (md5($pass2) != $this->password) { $this->wipe_login("Sorry, but your password did not match our database. Please try again"); } else { $this->password = $pass; $this->status = "loggedin"; } } } function wipe_login ($message) { print $message; setcookie ("S_LOGIN_server_id", "",time()-31536000); setcookie ("S_LOGIN_password", "",time()-31536000); setcookie ("S_LOGIN_status", "loggedout",time()+31536000); $this->status = "loggedout"; $this->server_id = ""; $this->password = ""; } function logout () { setcookie ("S_LOGIN_server_id", "",time()-31536000); setcookie ("S_LOGIN_password", "",time()-31536000); setcookie ("S_LOGIN_status", "loggedout",time()+31536000); $this->status = "loggedout"; } } $panel = new fragzzPanel; if(!isset($action)) { $panel->tab(); } else { $panel->tab($action); } echo $panel->output; ?>