class fragzzPanel {
// Set $self to the URL which fragzzPanel should use when linking to itself
var $self = './?a=1';
// Change #333333 to another colour to change the default 'not-selected' tab colour
var $bg = array('home' => '#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
[-] login details
'.$this->password_message.'
';
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.'
';
break;
case "login":
$this->tab_output .= '
[?] To find your server login details, please select \'Your Servers\' in the myFragID Panel.';
break;
}
print '
[?] home
on this tab you can find all of the account details for your server, as well as other general information
[?] control
here you can start, stop and restart your server
you can also change your server\' password
[?] config
this tab provides a simple and easy interface to modify your server configuration file COMING SOON
[?] logs
here you can view your server\'s latest logs to debug errors
[?] support
you can contact fragzz with our priority support form from here