<?php
class ServerClass {
var $server_conn;
function load_server_db($db) {
$this->server_conn = mysql_connect($db['host'], $db['user'], $db['pass'], "SET NAMES 'utf8'") or die ("Unable to connect!");
mysql_select_db('pugbot', $this->server_conn) or die ("Unable to select database! LANG");
$utf8 = mysql_query("SET NAMES UTF8");
return $this->server_conn;
}
public function load_servers() {
$query = mysql_query("SELECT * FROM `servers` WHERE `status`!='RCONFAIL'", $this->server_conn);
$server_a = array();
while ($server = mysql_fetch_array($query)) {
$server_a[] = $server;
}
return $server_a;
}
public function load_banner_server($server_addy, $server_port) {
$query = mysql_query("SELECT * FROM `servers` WHERE `host`='$server_addy' AND `port`='$server_port'", $this->server_conn);
$server = mysql_fetch_array($query);
$server_a = array();
$server_a['sv_id'] = $server['server_id'];
$server_a['name'] = $server['name'];
$server_a['slots'] = $server['slots'];
$server_a['players'] = $server['players'];
$server_a['map'] = $server['current_map'];
$sv_id = $server_a['sv_id'];
$query = mysql_query("SELECT * FROM `tracker_aliases` WHERE `server_id`='$sv_id'", $this->server_conn);
$server_a['num_a'] = mysql_num_rows($query);
return $server_a;
}
public function close_db() {
mysql_close($this->server_conn);
}
public function set_irc_colors($urt_string) {
$urt_string = str_replace("^0",'<font color="black">',$urt_string);
$urt_string = str_replace("^1",'<font color="red">',$urt_string);
$urt_string = str_replace("^2",'<font color="green">',$urt_string);
$urt_string = str_replace("^3",'<font color="yellow">',$urt_string);
$urt_string = str_replace("^4",'<font color="blue">',$urt_string);
$urt_string = str_replace("^5",'<font color="cyan">',$urt_string);
$urt_string = str_replace("^6",'<font color="magenta">',$urt_string);
$urt_string = str_replace("^7",'<font color="white">',$urt_string);
return $urt_string;
}
}
?>