userdata["acclevel"] < 80) die ("Access denied!"); if ( count($_POST) > 0 ) { $db->query("SELECT * FROM `hlstats_Servers` WHERE `address` = '" . $db->escape(clean_data($_POST['server_address'])) . "' AND `port` = '" . $db->escape(clean_data($_POST['server_port'])) . "'"); if ( $row = $db->fetch_array() ) message("warning", "Server [" . $row['name'] . "] already exists"); else { $db->query("SELECT `realgame` FROM `hlstats_Games` WHERE `code` = '" . $db->escape($selGame) . "'"); if ( list($game) = $db->fetch_row() ) { $script_path = (isset($_SERVER['SSL']) || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on")) ? 'https://' : 'http://'; $script_path .= $_SERVER['HTTP_HOST']; $script_path .= str_replace("\\","/",dirname($_SERVER["PHP_SELF"])); $db->query(sprintf("INSERT INTO `hlstats_Servers` (`address`, `port`, `name`, `game`, `publicaddress`, `rcon_password`) VALUES ('%s', '%d', '%s', '%s', '%s', '%s')", $db->escape(clean_data($_POST['server_address'])), $db->escape(clean_data($_POST['server_port'])), $db->escape(clean_data($_POST['server_name'])), $db->escape($selGame), $db->escape(clean_data($_POST['public_address'])), $db->escape(mystripslashes($_POST['server_rcon'])) )); $insert_id = $db->insert_id(); $db->query("INSERT INTO `hlstats_Servers_Config` (`serverId`, `parameter`, `value`) SELECT '" . $insert_id . "', `parameter`, `value` FROM `hlstats_Mods_Defaults` WHERE `code` = '" . $db->escape(mystripslashes($_POST['game_mod'])) . "';"); $db->query("INSERT INTO `hlstats_Servers_Config` (`serverId`, `parameter`, `value`) VALUES ('" . $insert_id . "', 'Mod', '" . $db->escape(mystripslashes($_POST['game_mod'])) . "');"); $db->query("INSERT INTO `hlstats_Servers_Config` (`serverId`, `parameter`, `value`) SELECT '" . $insert_id . "', `parameter`, `value` FROM `hlstats_Games_Defaults` WHERE `code` = '" . $db->escape($game) . "' ON DUPLICATE KEY UPDATE `value` = VALUES(`value`);"); $db->query("UPDATE hlstats_Servers_Config SET `value` = '" . $db->escape($script_path) . "' WHERE serverId = '" . $insert_id . "' AND `parameter` = 'HLStatsURL'"); $_POST = array(); // psychonic - worst. redirect. ever. // but we can't just use header() since admin.php already started part of the page and hacking it in before would be even messier echo ""; exit; } } } function clean_data($data) { return trim(htmlspecialchars(mystripslashes($data))); } ?> Enter the address of a server that you want to accept data from.

The "Public Address" should be the address you want shown to users. If left blank, it will be generated from the IP Address and Port. If you are using any kind of log relaying utility (i.e. hlstats.pl will not be receiving data directly from the game servers), you will want to set the IP Address and Port to the address of the log relay program, and set the Public Address to the real address of the game server. You will need a separate log relay for each game server. You can specify a hostname (or anything at all) in the Public Address.

Server IP Address
Server Port
Server Name
Rcon Password
Public Address
Admin Mod