Explorar el Código

Added AMX mod X admin, changed to use module pages, javascript moved to separated file.

DieFeM hace 8 años
padre
commit
bf2c41c3f8

+ 363 - 0
js/modules/util.js

@@ -0,0 +1,363 @@
+$(function(){
+	$("#tabs").tabs();
+	$("#loading").removeClass('hide').addClass('show');
+	var select_agent = $('#translation').attr('data-select_agent'),
+		target_empty = $('#translation').attr('data-target_empty'),
+		command_empty = $('#translation').attr('data-command_empty'),
+		agent_invalid = $('#translation').attr('data-agent_invalid'),
+		post_failed = $('#translation').attr('data-post_failed'),
+		select_server = $('#translation').attr('data-select_server'),
+		select_server_option = $('#translation').attr('data-select_server_option');
+	
+	// Load the agents via an external script so the user isn't waiting an eternity if they have several agents and multiple are offline
+	$.getJSON("home.php?m=util&p=agents&type=cleared", function(data){
+		var agents = "";
+		var agentsOnline = 0;
+		
+		$("#loading_agents").removeClass('show').addClass('hide');
+		$("#loading").removeClass('show').addClass('hide');
+		$("#options").removeClass('hide').addClass('show');
+		
+		agents += "<label for=\"agent\">" + select_agent + "</label>\r\n"
+		agents += "<select id=\"agent\" name=\"agent\">\r\n"
+		
+		for(var i = 0; i<data.length; ++i){
+			agents += "\t<option value=\"" + data[i]['id'] + "\"" + (data[i]['status']===0?" disabled":"") + ">" + data[i]['name'] +"</option>\r\n";
+			
+			if(data[i]['status'] == 1){
+				++agentsOnline;
+			}
+		}
+		
+		agents += "</select>";
+		
+		if(agentsOnline == 0){
+			$("#options").removeClass('show').addClass('hide');
+			$("#agents_offline").removeClass('hide').addClass('show');
+			
+			// Hide the sourcemod add admin form if all agents are offline.
+			$("#addadmin_form").addClass('hide');
+			$("#all_servers_offline").removeClass('hide').addClass('show');
+		}else if($("#command option").length == 0){
+			$("#options").removeClass('show').addClass('hide');
+			$("#no_commands").removeClass('hide').addClass('show');
+		}else{
+			$("#select_agent").html(agents);
+		}
+	}).fail(function(){
+		$("#loading_agents").removeClass('show').addClass('hide');
+		$("#loading").removeClass('show').addClass('hide');
+		$("#loading_failed").removeClass('hide').addClass('show');
+	});
+	
+	// Handle the network_tools form.
+	$("#network_tools").on("submit", function(e){
+		var target = $("#remote_target").val();
+		var agent = $("#agent").val();
+		var command = $("#command").val();
+		
+		// Some validation browser-side. Still need to do the same server-side.
+		if(target.length === 0){
+			// target input is empty.
+			$("#output").removeClass('hide').addClass('show').html("<pre>" + target_empty + "</pre>");
+		}else if(agent.length === 0){
+			// We'll only get to this point if there's no agents, or all agents are offline but the form was still submitted.
+			$("#output").removeClass('hide').addClass('show').html("<pre>" + agent_invalid + "</pre>");
+		}else if(command.length === 0){
+			// We'll only get to this point if there's no command specified.
+			$("#output").removeClass('hide').addClass('show').html("<pre>" + command_empty + "</pre>");
+		}else{
+			$("#loading").removeClass('hide').addClass('show');
+			$("#output").removeClass('show').addClass('hide');
+			
+			$("#network_tools button").prop({disabled:true}); // Disable the submit button if we're about to post - preventing stuff being ran several times via spamming the button and/or enter.
+			$.post("home.php?m=util&p=network_tools&type=cleared", $("#network_tools").serialize(), function(postCommand){
+				$("#loading").removeClass('show').addClass('hide');
+				$("#output").removeClass('hide').addClass('show').html("<pre>" + postCommand + "</pre>");
+				
+				$("#network_tools button").prop({disabled:false});
+			}).fail(function(){
+				$("#loading").removeClass('show').addClass('hide');
+				$("#output").removeClass('hide').addClass('show').html("<pre>" + post_failed + "</pre>");
+				
+				$("#network_tools button").prop({disabled:false});
+			});
+		}
+		e.preventDefault();
+	});// ./end network_tools form handling.
+	
+	// ----- Sourcemod Admins -----
+	$.getJSON("home.php?m=util&p=addadmin_helper&type=cleared", function(gs){
+		if(gs.length === 0){
+			$("#no_servers").removeClass('hide').addClass('show');
+		}else{
+			var games = "";
+			$("#add_admin").removeClass('hide').addClass('show');
+			
+			games += "<label for=\"gameserver_id\">" + select_server + "</label>\r\n"
+			games += "<select id=\"gameserver_id\" name=\"gameserver_id\">\r\n"
+			games += "<option value=\"0\" selected>" + select_server_option + "</option>\r\n"
+			
+			for(var i = 0; i<gs.length; ++i){
+				games += "\t<option value=\"" + gs[i]['home_id'] + "\">" + gs[i]['home_name'] +"</option>\r\n";
+			}
+			
+			games += "</select>";
+			$("#games").html(games);
+			
+			$("#gameserver_id").change(function(){
+				var home = $("#gameserver_id").val();
+				var gameserver_id = $("#gameserver_id").val();
+				
+				// although the disabled attribute is put on the option, set all the values to 0 if it's somehow chosen again via the form being edited
+				if(gameserver_id == 0){
+					$("#remote_server_id").val(0);
+					$("#gameserver_name").val(0);
+					$("#gameserver_ip").val(0);
+					$("#gameserver_port").val(0);
+				}else{
+					for(var i = 0; i<gs.length; ++i){
+						if(home === gs[i]['home_id']){
+							$("option[value='0']").attr("disabled", "disabled");
+							$("#remote_server_id").val(gs[i]['remote_server_id']);
+							$("#gameserver_name").val(gs[i]['game_name']);
+							$("#gameserver_ip").val(gs[i]['ip']);
+							$("#gameserver_port").val(gs[i]['port']);
+							break;
+						}
+					}
+				}
+			});
+		}
+	}); // ./end Sourcemod Admins
+		
+	$("#sourcemod_perms").change(function(){
+		var sourcemod_perms = $("#sourcemod_perms").val();
+		
+		if(sourcemod_perms === 'root'){
+			$("#sourcemod_flagList").removeClass('show').addClass('hide');
+			$('.item input[type="checkbox"]').prop('checked', false);
+		}else{
+			$("#sourcemod_flagList").removeClass('hide').addClass('show');
+		}
+	});
+	
+	// Process the sourcemod admin form on submission.
+	$("#addadmin_form").on("submit", function(e){
+		$("#addadmin_form button").prop({disabled:true});
+		
+		var errors = 0;
+		var remoteId = $("#remote_server_id").val();
+		var gameName = $("#gameserver_name").val();
+		var gameIp = $("#gameserver_ip").val();
+		var gamePort = $("#gameserver_port").val();
+		var addSteamid = $("#addSteamid").val();
+		var immunity = $("#immunity").val();
+		
+		// Set the message divs back to defaults.
+		$("#invalid_server").removeClass('show').addClass('hide');
+		$("#invalid_steamid_admin").removeClass('show').addClass('hide');
+		$("#invalid_response_admin").removeClass('show').addClass('hide');
+		$("#invalid_immunity").removeClass('show').addClass('hide');
+		$("#addadmin_response").removeClass('show').addClass('hide');
+		
+		if(remoteId.length === 0 || gameName.length === 0 || gameIp.length === 0 || gamePort.length === 0){
+			$("#invalid_server").removeClass('hide').addClass('show');
+			++errors;
+		}
+		
+		if(!(addSteamid.match(/^STEAM_[01]:[01]:\d+$/))){
+			$("#invalid_steamid_admin").removeClass('hide').addClass('show');
+			++errors;
+		}
+		
+		if(immunity.length > 2 || isNaN(immunity)){
+			$("#invalid_immunity").removeClass('hide').addClass('show');
+			++errors;
+		}
+		
+		if(errors === 0){
+			$.post("home.php?m=util&p=addadmin_helper&type=cleared", $("#addadmin_form").serialize(), function(postCommand){
+				$("#addadmin_response").removeClass('hide').addClass('show').html(postCommand);
+				$("#addadmin_form button").prop({disabled:false});
+			}).fail(function(){
+				$("#invalid_response_admin").removeClass('hide').addClass('show');
+				$("#addadmin_form button").prop({disabled:false});
+			});
+		}else{
+			$("#addadmin_form button").prop({disabled:false});
+		}
+		
+		e.preventDefault();
+	}); // add_admin form handling
+	
+	// ----- AMX mod Admins -----
+	$.getJSON("home.php?m=util&p=amx_addadmin_helper&type=cleared", function(gs){
+		if(gs.length === 0){
+			$("#amx_no_servers").removeClass('hide').addClass('show');
+		}else{
+			var games = "";
+			$("#amx_add_admin").removeClass('hide').addClass('show');
+			
+			games += "<label for=\"amx_gameserver_id\">" + select_server + "</label>\r\n"
+			games += "<select id=\"amx_gameserver_id\" name=\"amx_gameserver_id\">\r\n"
+			games += "<option value=\"0\" selected>" + select_server_option + "</option>\r\n"
+			
+			for(var i = 0; i<gs.length; ++i){
+				games += "\t<option value=\"" + gs[i]['home_id'] + "\">" + gs[i]['home_name'] +"</option>\r\n";
+			}
+			
+			games += "</select>";
+			$("#amx_games").html(games);
+			
+			$("#amx_gameserver_id").change(function(){
+				var home = $("#amx_gameserver_id").val();
+				var gameserver_id = $("#amx_gameserver_id").val();
+				
+				// although the disabled attribute is put on the option, set all the values to 0 if it's somehow chosen again via the form being edited
+				if(gameserver_id == 0){
+					$("#amx_remote_server_id").val(0);
+					$("#amx_gameserver_name").val(0);
+					$("#amx_gameserver_ip").val(0);
+					$("#amx_gameserver_port").val(0);
+				}else{
+					for(var i = 0; i<gs.length; ++i){
+						if(home === gs[i]['home_id']){
+							$("option[value='0']").attr("disabled", "disabled");
+							$("#amx_remote_server_id").val(gs[i]['remote_server_id']);
+							$("#amx_gameserver_name").val(gs[i]['game_name']);
+							$("#amx_gameserver_ip").val(gs[i]['ip']);
+							$("#amx_gameserver_port").val(gs[i]['port']);
+							break;
+						}
+					}
+				}
+			});
+		}
+	}); // ./end AMX mod Admins
+	
+	$("#amx_mod_perms").change(function(){
+		var amx_mod_perms = $("#amx_mod_perms").val();
+		
+		if(amx_mod_perms === 'root'){
+			$("#amx_mod_flagList").removeClass('show').addClass('hide');
+			$('.amx_item input[type="checkbox"]').prop('checked', false);
+		}else{
+			$("#amx_mod_flagList").removeClass('hide').addClass('show');
+		}
+	});
+	
+	$("#amx_login_type").change(function(){
+		var amx_login_type = $("#amx_login_type").val();
+		
+		if(amx_login_type === 'amx_login_steamid'){
+			$("#amx_login_nick_pass").removeClass('show').addClass('hide');
+			$("#amx_Nickname").prop('required',false);
+			$("#amx_Password").prop('required',false);
+			$("#amx_Steamid").prop('required',true);
+			$("#amx_login_steamid").removeClass('hide').addClass('show');
+		}else{
+			$("#amx_login_steamid").removeClass('show').addClass('hide');
+			$("#amx_Nickname").prop('required',true);
+			$("#amx_Password").prop('required',true);
+			$("#amx_Steamid").prop('required',false);
+			$("#amx_login_nick_pass").removeClass('hide').addClass('show');
+		}
+	});
+	
+	// Process the amx mod admin form on submission.
+	$("#amx_addadmin_form").on("submit", function(e){
+		$("#amx_addadmin_form button").prop({disabled:true});
+		
+		var errors = 0;
+		var remoteId = $("#amx_remote_server_id").val();
+		var gameName = $("#amx_gameserver_name").val();
+		var gameIp = $("#amx_gameserver_ip").val();
+		var gamePort = $("#amx_gameserver_port").val();
+		var login_type = $("#amx_login_type").val();
+		
+		// Set the message divs back to defaults.
+		$("#amx_invalid_server").removeClass('show').addClass('hide');
+		$("#amx_invalid_nickname_admin").removeClass('show').addClass('hide');
+		$("#amx_invalid_password_admin").removeClass('show').addClass('hide');
+		$("#amx_invalid_steamid_admin").removeClass('show').addClass('hide');
+		$("#amx_invalid_response_admin").removeClass('show').addClass('hide');
+		$("#amx_addadmin_response").removeClass('show').addClass('hide');
+		
+		if(login_type == 'amx_login_steamid')
+		{
+			var Steamid = $("#amx_Steamid").val();
+			if(!(Steamid.match(/^STEAM_[01]:[01]:\d+$/))){
+				$("#amx_invalid_steamid_admin").removeClass('hide').addClass('show');
+				++errors;
+			}
+		}
+		else
+		{
+			var Nickname = $("#amx_Nickname").val();
+			var Password = $("#amx_Password").val();
+			if(!(Nickname.match(/^[^\s][A-zÀ-ÿ0-9 !@)(,}/|\.:?;{#$%&*+=-]{1,28}[^\s]$/))){
+				$("#amx_invalid_nickname_admin").removeClass('hide').addClass('show');
+				++errors;
+			}
+			if(!(Password.match(/^[^\s][A-zÀ-ÿ0-9 !@)(,}/|\.:?;{#$%&*+=-]{1,28}[^\s]$/))){
+				$("#amx_invalid_password_admin").removeClass('hide').addClass('show');
+				++errors;
+			}
+		}
+		
+		if(remoteId.length === 0 || gameName.length === 0 || gameIp.length === 0 || gamePort.length === 0){
+			$("#amx_invalid_server").removeClass('hide').addClass('show');
+			++errors;
+		}
+		
+		if(errors === 0){
+			$.post("home.php?m=util&p=amx_addadmin_helper&type=cleared", $("#amx_addadmin_form").serialize(), function(postCommand){
+				$("#amx_addadmin_response").removeClass('hide').addClass('show').html(postCommand);
+				$("#amx_addadmin_form button").prop({disabled:false});
+			}).fail(function(){
+				$("#amx_invalid_response_admin").removeClass('hide').addClass('show');
+				$("#amx_addadmin_form button").prop({disabled:false});
+			});
+		}else{
+			$("#amx_addadmin_form button").prop({disabled:false});
+		}
+		e.preventDefault();
+	}); // add_admin form handling
+	
+	// ----- Steam Converter -----
+	$("#steam_converter").on("submit", function(e){
+		$("#steam_converter button").prop({disabled:true});
+		$.post("home.php?m=util&p=steamid_converter&type=cleared", $("#steam_converter").serialize(), function(steam_data){
+			var json = $.parseJSON(steam_data);
+			
+			if(json.length === 0){
+				$("#steam_info").removeClass('show').addClass('hide');
+				$("#invalid_steamid").removeClass('hide').addClass('show');
+				$("#invalid_response").removeClass('show').addClass('hide');
+				
+				$("#steam_converter button").prop({disabled:false});
+			}else{
+				$("#steam_info").removeClass('hide').addClass('show');
+				$("#invalid_steamid").removeClass('show').addClass('hide');
+				$("#invalid_response").removeClass('show').addClass('hide');
+				
+				$("#steamLink").html('<b>Profile Link:</b> ' + json.steamProfile);
+				$("#steamId").html('<b>Legacy ID:</b> ' + json.steamId);
+				$("#steamId3").html('<b>SteamID3:</b> ' + json.steamId3);
+				$("#steamId64").html('<b>SteamID64:</b> ' + json.communityId);
+				
+				$("#steam_converter button").prop({disabled:false});
+			}
+		}).fail(function(){
+			$("#invalid_steamid").removeClass('show').addClass('hide');
+			$("#steam_info").removeClass('show').addClass('hide');
+			$("#invalid_response").removeClass('hide').addClass('show');
+		});
+		e.preventDefault();
+	}); // ./end steam_converter form handling.
+	
+	$("#your-address").click(function(){
+		$("#remote_target").val($("#your-address").text());
+	});
+});

+ 29 - 0
lang/English/modules/util.php

@@ -93,4 +93,33 @@ define('OGP_LANG_invalid_steamid', "You have entered an invalid Steam ID.");
 define('OGP_LANG_invalid_immunity', "You entered an invalid immunity value.");
 define('OGP_LANG_submit', "Submit");
 define('OGP_LANG_post_failed', "The POST action failed. Unable to retrieve a response.");
+define('OGP_LANG_amx_mod_admins', "AMX mod X Admins");
+define('OGP_LANG_amx_login_type', "Login Type");
+define('OGP_LANG_amx_login_steamid', "Steam ID");
+define('OGP_LANG_amx_login_nick_pass', "Nickname + Password");
+define('OGP_LANG_nickname', "Nickname");
+define('OGP_LANG_amx_mod_perms', "AMX mod X Permissions:");
+define('OGP_LANG_amx_mod_perm_root', "AMX mod X All Flags.");
+define('OGP_LANG_amx_mod_perm_custom', "AMX mod X Custom Flags.");
+define('OGP_LANG_amx_mod_flag_a', "immunity (can't be kicked/baned/slayed/slaped and affected by other commmands)");
+define('OGP_LANG_amx_mod_flag_b', "reservation (can join on reserved slots)");
+define('OGP_LANG_amx_mod_flag_c', "amx_kick command");
+define('OGP_LANG_amx_mod_flag_d', "amx_ban and amx_unban commands");
+define('OGP_LANG_amx_mod_flag_e', "amx_slay and amx_slap commands");
+define('OGP_LANG_amx_mod_flag_f', "amx_map command");
+define('OGP_LANG_amx_mod_flag_g', "amx_cvar command (not all cvars will be available)");
+define('OGP_LANG_amx_mod_flag_h', "amx_cfg command");
+define('OGP_LANG_amx_mod_flag_i', "amx_chat and other chat commands");
+define('OGP_LANG_amx_mod_flag_j', "amx_vote and other vote commands");
+define('OGP_LANG_amx_mod_flag_k', "access to sv_password cvar (by amx_cvar command)");
+define('OGP_LANG_amx_mod_flag_l', "access to amx_rcon command and rcon_password cvar (by amx_cvar command)");
+define('OGP_LANG_amx_mod_flag_m', "custom level A (for additional plugins)");
+define('OGP_LANG_amx_mod_flag_n', "custom level B");
+define('OGP_LANG_amx_mod_flag_o', "custom level C");
+define('OGP_LANG_amx_mod_flag_p', "custom level D");
+define('OGP_LANG_amx_mod_flag_q', "custom level E");
+define('OGP_LANG_amx_mod_flag_r', "custom level F");
+define('OGP_LANG_amx_mod_flag_s', "custom level G");
+define('OGP_LANG_amx_mod_flag_t', "custom level H");
+define('OGP_LANG_amx_mod_flag_u', "menu access");
 ?>

+ 94 - 147
modules/util/addadmin_helper.php

@@ -2,7 +2,7 @@
 /*
  *
  * OGP - Open Game Panel
- * Copyright (C) 2008 - 2017 The OGP Development Team
+ * Copyright (C) 2008 - 2018 The OGP Development Team
  *
  * http://www.opengamepanel.org/
  *
@@ -21,179 +21,126 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
  */
-
-	include 'util_config.php';
+require 'includes/lib_remote.php';
+function exec_ogp_module() 
+{
+	global $db;
+	include 'modules/util/functions.php';
+	include 'modules/util/util_config.php';
+	$servers = getUserServers($db->getIpPortsForUser($_SESSION['user_id']), $subuserAdminManagement, $supportedGames);
 	
-	session_name($sessionName);
-	session_start();
-	
-	if(!empty($_SESSION['user_id']) === true){
-		// This entire section is nothing but a big, messy, workaround.
-		// Make ogpLang happy.
-		$_REQUEST['m'] = 'util';
-		// We need to change directory to be able to include lib_remote and make a database connection without any errors
-		// This is becasue the following files include other files via their relative path rather than absolute path... could be fixed by editing them... but until then, this is just a hacky workaround.
-		$cwd = getcwd();
-		if(chdir('../../') === true){
-			require_once('includes/config.inc.php');
-			require_once('includes/helpers.php');
-			require_once('includes/lib_remote.php');
-			include_once("includes/lang.php");
-			ogpLang();
-			
-			$db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
-		}else{
-			die(get_lang('chdir_failed'));
-		}
+	// If it's a post request and the user is signed in - process it.
+	// Otherwise, remove some sensitive info (such as encryption_key) from $servers - only keeping what the user needs to see and json_encode it for JS to process.
+	if($_SERVER['REQUEST_METHOD'] === 'POST'){
+		$serverInfo = array();
+		$flags = '';
+		$sourcemodFlags = range('a', 't');
+		$immunityRange = range(1, 99);
 		
-		if(chdir($cwd) === false){
-			die(get_lang('chdir_failed'));
-		}
-		
-		// Get gameservers belonging to each user with matching permissions if they're not an admin.
-		function getUserServers($servers, $flags){
-			global $db, $supportedGames;
-			
-			$info = array();
-			$userInfo = $db->getUserById($_SESSION['user_id']);
-			$userRole = $userInfo['users_role'];
-			
-			if(!empty($servers)){
-				foreach($servers as $server){
-					$gamehome = $db->getUserGameHome($_SESSION['user_id'], $server['home_id']);
-					
-					if(in_array($gamehome['game_name'], $supportedGames) === true){
-						if($userRole !== 'admin'){
-							if(strpbrk($gamehome['access_rights'], $flags) !== false){
-								$info[] = $server;
-							}
-						}else{
-							$info[] = $server;
-						}
-					}
+		// Don't use isset here because they're always going to be set if the form is submitted - we only want to process the data if the following isn't empty.
+		if(!empty($_POST['gameserver_id']) && !empty($_POST['remote_server_id']) && !empty($_POST['gameserver_name'])
+		&& !empty($_POST['gameserver_ip']) && !empty($_POST['gameserver_port']) && !empty($_POST['addSteamid']) && !empty($_POST['sourcemod_perms'])){
+				
+			foreach($servers as $server){
+				// Try to check if hidden form values have been manually edited. If not, process.
+				if($server['remote_server_id'] == $_POST['remote_server_id'] && $server['home_id'] == $_POST['gameserver_id']
+				&& $server['game_name'] == $_POST['gameserver_name'] && $server['ip'] == $_POST['gameserver_ip'] && $server['port'] == $_POST['gameserver_port']){	
+					$serverInfo = $server;
 				}
 			}
 			
-			return $info;
-		}
-		
-		$servers = getUserServers($db->getIpPortsForUser($_SESSION['user_id']), $subuserAdminManagement);
-		
-		// If it's a post request and the user is signed in - process it.
-		// Otherwise, remove some sensitive info (such as encryption_key) from $servers - only keeping what the user needs to see and json_encode it for JS to process.
-		if($_SERVER['REQUEST_METHOD'] === 'POST'){
-			$serverInfo = array();
-			$flags = '';
-			$sourcemodFlags = range('a', 't');
-			$immunityRange = range(1, 99);
-			
-			// Don't use isset here because they're always going to be set if the form is submitted - we only want to process the data if the following isn't empty.
-			if(!empty($_POST['gameserver_id']) && !empty($_POST['remote_server_id']) && !empty($_POST['gameserver_name'])
-			&& !empty($_POST['gameserver_ip']) && !empty($_POST['gameserver_port']) && !empty($_POST['addSteamid']) && !empty($_POST['sourcemod_perms'])){
-					
-				foreach($servers as $server){
-					// Try to check if hidden form values have been manually edited. If not, process.
-					if($server['remote_server_id'] == $_POST['remote_server_id'] && $server['home_id'] == $_POST['gameserver_id']
-					&& $server['game_name'] == $_POST['gameserver_name'] && $server['ip'] == $_POST['gameserver_ip'] && $server['port'] == $_POST['gameserver_port']){	
-						$serverInfo = $server;
-					}
-				}
+			if(!empty($serverInfo)){
+				$remote = new OGPRemoteLibrary($serverInfo['agent_ip'], $serverInfo['agent_port'], $serverInfo['encryption_key'], $serverInfo['timeout']);
 				
-				if(!empty($serverInfo)){
-					$remote = new OGPRemoteLibrary($serverInfo['agent_ip'], $serverInfo['agent_port'], $serverInfo['encryption_key'], $serverInfo['timeout']);
-					
-					if($remote->status_chk() === 1){
-						if(preg_match('/^STEAM_[01]:[01]:\d+$/', $_POST['addSteamid'])){
-							$immunity = (!empty($_POST['immunity']) && in_array($_POST['immunity'], $immunityRange)) ? $_POST['immunity'] : '';
-							
-							if($_POST['sourcemod_perms'] == 'root'){
-								$flags = 'z';
-							}elseif($_POST['sourcemod_perms'] == 'custom'){
-								if(!empty($_POST['flags']) && is_array($_POST['flags'])){
-									$x = array_intersect(array_values($_POST['flags']), $sourcemodFlags);
-									$flags = implode('', ($x));
-								}
+				if($remote->status_chk() === 1){
+					if(preg_match('/^STEAM_[01]:[01]:\d+$/', $_POST['addSteamid'])){
+						$immunity = (!empty($_POST['immunity']) && in_array($_POST['immunity'], $immunityRange)) ? $_POST['immunity'] : '';
+						
+						if($_POST['sourcemod_perms'] == 'root'){
+							$flags = 'z';
+						}elseif($_POST['sourcemod_perms'] == 'custom'){
+							if(!empty($_POST['flags']) && is_array($_POST['flags'])){
+								$x = array_intersect(array_values($_POST['flags']), $sourcemodFlags);
+								$flags = implode('', ($x));
 							}
+						}
+						
+						if(!empty($flags)){
+							$adminFile = $serverInfo['home_path'].'/'.$serverInfo['mod_key'].'/'.$adminFiles['sourcemod'];
+							// Build up what the new line will be.
+							$newLine = "\"{$_POST['addSteamid']}\"\t\"".(!empty($immunity) ? $immunity.':' : '').$flags."\"";
 							
-							if(!empty($flags)){
-								$adminFile = $serverInfo['home_path'].'/'.$serverInfo['mod_key'].'/'.$adminFiles['sourcemod'];
-								// Build up what the new line will be.
-								$newLine = "\"{$_POST['addSteamid']}\"\t\"".(!empty($immunity) ? $immunity.':' : '').$flags."\"";
+							// Only process if the $adminFile exists;
+							if($remote->rfile_exists($adminFile) === 1){
+								$remote->remote_readfile($adminFile, $file_content);
 								
-								// Only process if the $adminFile exists;
-								if($remote->rfile_exists($adminFile) === 1){
-									$remote->remote_readfile($adminFile, $file_content);
-									
-									// Decide if it's replacing an existing line or is a new line.
-									if(preg_match('/'.$_POST['addSteamid'].'/i', $file_content)){
-										$file_content = preg_replace('/.*'.$_POST['addSteamid'].'.*/i', $newLine, $file_content);
-									}else{
-										$file_content .= $newLine."\r\n";
-									}
-									
-									if($remote->remote_writefile($adminFile, $file_content) === 1){
-										if(!empty($serverInfo['control_password'])){
-											$reloadAdmins = $remote->remote_send_rcon_command($serverInfo['home_id'], $serverInfo['ip'], $serverInfo['port'], 'rcon2', $serverInfo['control_password'], '', 'sm_reloadadmins', $return);
-											
-											if($reloadAdmins === -1){
-												echo get_lang('rcon_reload_admins_failed');
-											}elseif($reloadAdmins === 1){
-												if(preg_match('/Admin cache has been refreshed/i', $return)){
-													echo get_lang_f('reload_admins_success', $_POST['addSteamid']);
-												}else{
-													echo get_lang('reload_admins_failed');
-												}
+								// Decide if it's replacing an existing line or is a new line.
+								if(preg_match('/'.$_POST['addSteamid'].'/i', $file_content)){
+									$file_content = preg_replace('/.*'.$_POST['addSteamid'].'.*/i', $newLine, $file_content);
+								}else{
+									$file_content .= $newLine."\r\n";
+								}
+								
+								if($remote->remote_writefile($adminFile, $file_content) === 1){
+									if(!empty($serverInfo['control_password'])){
+										$reloadAdmins = $remote->remote_send_rcon_command($serverInfo['home_id'], $serverInfo['ip'], $serverInfo['port'], 'rcon2', $serverInfo['control_password'], '', 'sm_reloadadmins', $return);
+										
+										if($reloadAdmins === -1){
+											echo get_lang('rcon_reload_admins_failed');
+										}elseif($reloadAdmins === 1){
+											if(preg_match('/Admin cache has been refreshed/i', $return)){
+												echo get_lang_f('reload_admins_success', $_POST['addSteamid']);
+											}else{
+												echo get_lang('reload_admins_failed');
 											}
-										}else{
-											// No rcon password stored - can't reload admins
-											echo get_lang_f('add_success_no_rcon', $_POST['addSteamid']);
 										}
 									}else{
-										// There was a problem writing to the admin file.
-										echo get_lang_f('writefile_error', $adminFile);
+										// No rcon password stored - can't reload admins
+										echo get_lang_f('add_success_no_rcon', $_POST['addSteamid']);
 									}
 								}else{
-									// The remote admin file doesn't exist.
-									echo get_lang_f('remotefile_nonexistent', $adminFiles['sourcemod']);
+									// There was a problem writing to the admin file.
+									echo get_lang_f('writefile_error', $adminFile);
 								}
 							}else{
-								// There wasn't any flags specified.
-								echo get_lang('empty_flag_list');
+								// The remote admin file doesn't exist.
+								echo get_lang_f('remotefile_nonexistent', $adminFiles['sourcemod']);
 							}
 						}else{
-							// invalid steam_id format given.
-							echo get_lang('invalid_steam_format');
+							// There wasn't any flags specified.
+							echo get_lang('empty_flag_list');
 						}
 					}else{
-						// Agent is offline. We can't add any admins here.
-						echo get_lang('selected_server_offline');
+						// invalid steam_id format given.
+						echo get_lang('invalid_steam_format');
 					}
 				}else{
-					// the hidden input values don't exist in our servers array. however, they should exist.
-					// if we're here: 1) the hidden variables have either been manually changed, or 2) the user was removed from accessing the selected server while still on the page.
-					echo get_lang('malformed_form');
+					// Agent is offline. We can't add any admins here.
+					echo get_lang('selected_server_offline');
 				}
 			}else{
-				// An empty form was submitted.
-				echo get_lang('empty_form_data');
+				// the hidden input values don't exist in our servers array. however, they should exist.
+				// if we're here: 1) the hidden variables have either been manually changed, or 2) the user was removed from accessing the selected server while still on the page.
+				echo get_lang('malformed_form');
 			}
 		}else{
-			$return = array();
-			for($x = 0; $x < count($servers); ++$x){
-				$return[] = array(
-					'remote_server_id'		=>	$servers[$x]['remote_server_id'],
-					'ip'					=>	$servers[$x]['ip'],
-					'port'					=>	$servers[$x]['port'],
-					'home_id'				=>	$servers[$x]['home_id'],
-					'home_name'				=>	$servers[$x]['home_name'],
-					'game_name'				=>	$servers[$x]['game_name'],
-				);
-			}
-			
-			echo json_encode($return);
+			// An empty form was submitted.
+			echo get_lang('empty_form_data');
 		}
 	}else{
-		header('HTTP/1.0 403 Forbidden');
-		exit;
+		$return = array();
+		for($x = 0; $x < count($servers); ++$x){
+			$return[] = array(
+				'remote_server_id'		=>	$servers[$x]['remote_server_id'],
+				'ip'					=>	$servers[$x]['ip'],
+				'port'					=>	$servers[$x]['port'],
+				'home_id'				=>	$servers[$x]['home_id'],
+				'home_name'				=>	$servers[$x]['home_name'],
+				'game_name'				=>	$servers[$x]['game_name'],
+			);
+		}
+		
+		echo json_encode($return);
 	}
+}
 ?>

+ 18 - 48
modules/util/agents.php

@@ -2,7 +2,7 @@
 /*
  *
  * OGP - Open Game Panel
- * Copyright (C) 2008 - 2017 The OGP Development Team
+ * Copyright (C) 2008 - 2018 The OGP Development Team
  *
  * http://www.opengamepanel.org/
  *
@@ -21,55 +21,25 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
  */
-
-	include 'util_config.php';
+include 'includes/lib_remote.php';
+function exec_ogp_module() 
+{
+	global $db;
+	$remoteServers = $db->getRemoteServers();
+	$servers = array();
 	
-	session_name($sessionName);
-	session_start();
-	
-	if(!empty($_SESSION['user_id'])){
-		// This entire section is nothing but a big, messy, workaround.
-		// Make ogpLang happy.
-		$_REQUEST['m'] = 'util';
-		// We need to change directory to be able to include lib_remote and make a database connection without any errors
-		// This is becasue the following files include other files via their relative path rather than absolute path... could be fixed by editing them... but until then, this is just a hacky workaround.
-		$cwd = getcwd();
-		if(chdir('../../') === true){
-			require_once('includes/config.inc.php');
-			require_once('includes/helpers.php');
-			include_once("includes/lang.php");
-			ogpLang();
-			
-			require_once('includes/lib_remote.php');
+	if(is_array($remoteServers)){
+		foreach($remoteServers as $server){
+			$remote = new OGPRemoteLibrary($server['agent_ip'], $server['agent_port'], $server['encryption_key'], 1);
+			$status = (int)$remote->status_chk();
 			
-			$db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
-		}else{
-			die(get_lang('chdir_failed'));
-		}
-		
-		if(chdir($cwd) === false){
-			die(get_lang('chdir_failed'));
-		}
-		
-		// Actual script functions now.
-		$remoteServers = $db->getRemoteServers();
-		$servers = array();
-		
-		if(is_array($remoteServers)){
-			foreach($remoteServers as $server){
-				$remote = new OGPRemoteLibrary($server['agent_ip'], $server['agent_port'], $server['encryption_key'], 1);
-				$status = (int)$remote->status_chk();
-				
-				$servers[] = array(
-					'id'		=>	$server['remote_server_id'],
-					'name'		=>	$server['remote_server_name'] .' '. (($status) === 0 ? '('.get_lang('offline').')' : '('.get_lang('online').')'),
-					'status'	=>	$status,
-				);
-			}
+			$servers[] = array(
+				'id'		=>	$server['remote_server_id'],
+				'name'		=>	$server['remote_server_name'] .' '. (($status) === 0 ? '('.get_lang('offline').')' : '('.get_lang('online').')'),
+				'status'	=>	$status,
+			);
 		}
-		echo json_encode($servers);
-	}else{
-		header('HTTP/1.0 403 Forbidden');
-		exit;
 	}
+	echo json_encode($servers);
+}
 ?>

+ 163 - 0
modules/util/amx_addadmin_helper.php

@@ -0,0 +1,163 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) 2008 - 2018 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+require 'includes/lib_remote.php';
+function exec_ogp_module() 
+{
+	global $db;
+	include 'modules/util/functions.php';
+	include 'modules/util/util_config.php';
+	$servers = getUserServers($db->getIpPortsForUser($_SESSION['user_id']), $subuserAdminManagement, $amx_supportedGames);
+	
+	// If it's a post request and the user is signed in - process it.
+	// Otherwise, remove some sensitive info (such as encryption_key) from $servers - only keeping what the user needs to see and json_encode it for JS to process.
+	if($_SERVER['REQUEST_METHOD'] === 'POST'){
+		$serverInfo = array();
+		$flags = '';
+		$amx_modFlags = range('a', 'u');
+		
+		// Don't use isset here because they're always going to be set if the form is submitted - we only want to process the data if the following isn't empty.
+		if(!empty($_POST['amx_gameserver_id']) && !empty($_POST['remote_server_id']) && !empty($_POST['gameserver_name'])
+		&& !empty($_POST['gameserver_ip']) && !empty($_POST['gameserver_port']) && !empty($_POST['amx_mod_perms'])
+		&& !empty($_POST['amx_login_type']) && (!empty($_POST['amx_Steamid']) || !empty($_POST['amx_Nickname']) && !empty($_POST['amx_Password']))){
+				
+			foreach($servers as $server){
+				// Try to check if hidden form values have been manually edited. If not, process.
+				if($server['remote_server_id'] == $_POST['remote_server_id'] && $server['home_id'] == $_POST['amx_gameserver_id']
+				&& $server['game_name'] == $_POST['gameserver_name'] && $server['ip'] == $_POST['gameserver_ip'] && $server['port'] == $_POST['gameserver_port']){	
+					$serverInfo = $server;
+					break;
+				}
+			}
+			
+			if(!empty($serverInfo)){
+				$remote = new OGPRemoteLibrary($serverInfo['agent_ip'], $serverInfo['agent_port'], $serverInfo['encryption_key'], $serverInfo['timeout']);
+				
+				if($remote->status_chk() === 1){
+					if(($_POST['amx_login_type'] == 'amx_login_steamid' && preg_match('/^STEAM_[01]:[01]:\d+$/', $_POST['amx_Steamid']))
+					|| ($_POST['amx_login_type'] == 'amx_login_nick_pass'
+					&& preg_match('/^[^\s][A-zÀ-ÿ0-9 !@)(,}\/|\.:?;{#$%&*+=-]{1,28}[^\s]$/', $_POST['amx_Nickname'])
+					&& preg_match('/^[^\s][A-zÀ-ÿ0-9 !@)(,}\/|\.:?;{#$%&*+=-]{1,28}[^\s]$/', $_POST['amx_Password']))){
+						
+						if($_POST['amx_mod_perms'] == 'root'){
+							$flags = 'abcdefghijklmnopqrstu';
+						}elseif($_POST['amx_mod_perms'] == 'custom'){
+							if(!empty($_POST['amx_flags']) && is_array($_POST['amx_flags'])){
+								$x = array_intersect(array_values($_POST['amx_flags']), $amx_modFlags);
+								$flags = implode('', ($x));
+							}
+						}
+						
+						if(!empty($flags)){
+							$adminFile = $serverInfo['home_path'].'/'.$serverInfo['mod_key'].'/'.$adminFiles['amx_mod'];
+							// Build up what the new line will be.
+							if($_POST['amx_login_type'] == 'amx_login_steamid')
+							{
+								$newLine = "\"{$_POST['amx_Steamid']}\" \"\" \"${flags}\" \"ce\"";
+							}
+							elseif($_POST['amx_login_type'] == 'amx_login_nick_pass')
+							{
+								$newLine = "\"{$_POST['amx_Nickname']}\" \"{$_POST['amx_Password']}\" \"${flags}\" \"a\"";
+							}
+														
+							// Only process if the $adminFile exists;
+							if($remote->rfile_exists($adminFile) === 1){
+								$remote->remote_readfile($adminFile, $file_content);
+								
+								// Decide if it's replacing an existing line or is a new line.
+								if($_POST['amx_login_type'] == 'amx_login_steamid')
+								{
+									if(preg_match('/'.preg_quote($_POST['amx_Steamid']).'/i', $file_content)){
+										$file_content = preg_replace('/.*'.preg_quote($_POST['amx_Steamid']).'.*/i', $newLine, $file_content);
+									}else{
+										$file_content .= $newLine."\r\n";
+									}
+								}
+								elseif($_POST['amx_login_type'] == 'amx_login_nick_pass')
+								{
+									if(preg_match('/'.preg_quote($_POST['amx_Nickname']).'/i', $file_content)){
+										$file_content = preg_replace('/.*'.preg_quote($_POST['amx_Nickname']).'.*/i', $newLine, $file_content);
+									}else{
+										$file_content .= $newLine."\r\n";
+									}
+								}
+								
+								if($remote->remote_writefile($adminFile, $file_content) === 1){
+									if(!empty($serverInfo['control_password'])){
+										$reloadAdmins = $remote->remote_send_rcon_command($serverInfo['home_id'], $serverInfo['ip'], $serverInfo['port'], 'rcon', $serverInfo['control_password'], '', 'amx_reloadadmins', $return);
+										
+										if($reloadAdmins === -1){
+											echo get_lang('rcon_reload_admins_failed');
+										}elseif($reloadAdmins === 1){
+											echo $return;
+										}
+									}else{
+										// No rcon password stored - can't reload admins
+										echo get_lang_f('add_success_no_rcon', $_POST['amx_Steamid']);
+									}
+								}else{
+									// There was a problem writing to the admin file.
+									echo get_lang_f('writefile_error', $adminFile);
+								}
+							}else{
+								// The remote admin file doesn't exist.
+								echo get_lang_f('remotefile_nonexistent', $adminFiles['amx_mod']);
+							}
+						}else{
+							// There wasn't any flags specified.
+							echo get_lang('empty_flag_list');
+						}
+					}else{
+						// invalid steam_id format given.
+						echo get_lang('invalid_steam_format');
+					}
+				}else{
+					// Agent is offline. We can't add any admins here.
+					echo get_lang('selected_server_offline');
+				}
+			}else{
+				// the hidden input values don't exist in our servers array. however, they should exist.
+				// if we're here: 1) the hidden variables have either been manually changed, or 2) the user was removed from accessing the selected server while still on the page.
+				echo get_lang('malformed_form');
+			}
+		}else{
+			// An empty form was submitted.
+			echo get_lang('empty_form_data');
+		}
+	}else{
+		$return = array();
+		for($x = 0; $x < count($servers); ++$x){
+			$return[] = array(
+				'remote_server_id'		=>	$servers[$x]['remote_server_id'],
+				'ip'					=>	$servers[$x]['ip'],
+				'port'					=>	$servers[$x]['port'],
+				'home_id'				=>	$servers[$x]['home_id'],
+				'home_name'				=>	$servers[$x]['home_name'],
+				'game_name'				=>	$servers[$x]['game_name'],
+			);
+		}
+		
+		echo json_encode($return);
+	}
+}
+?>

+ 119 - 0
modules/util/functions.php

@@ -0,0 +1,119 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) 2008 - 2018 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+function toCommunityID($id){
+	if(preg_match('/^STEAM_/', $id)){
+		$parts = explode(':', $id);
+		return bcadd(bcadd(bcmul($parts[2], '2'), '76561197960265728'), $parts[1]);
+	}elseif(is_numeric($id) && strlen($id) < 16){
+		return bcadd($id, '76561197960265728');
+	}else{
+		return $id;
+	}
+}
+
+function toSteamID($id){
+	if(is_numeric($id) && strlen($id) >= 16){
+		$z = bcdiv(bcsub($id, '76561197960265728'), '2');
+	}elseif(is_numeric($id)){
+		$z = bcdiv($id, '2');
+	}else{
+		return $id;
+	}
+	
+	$y = bcmod($id, '2');
+	return 'STEAM_0:'.$y.':'.floor($z);
+}
+
+function toUserID($id){
+	if(preg_match('/^STEAM_/', $id)){
+		$split = explode(':', $id);
+		return $split[2] * 2 + $split[1];
+	}elseif(preg_match('/^765/', $id) && strlen($id) > 15){
+		return bcsub($id, '76561197960265728');
+	}else{
+		return $id;
+	}
+}
+
+function getSteamId($input){
+	$xml = simplexml_load_file('http://steamcommunity.com/id/'.$input.'?xml=1');
+	$steamId64 = $xml->steamID64;
+	
+	if(preg_match('/^765/', $steamId64) === 0){
+		return false;
+	}else{
+		return (string)$steamId64;	// Cast it to a string, otherwise an SimpleXMLElement Object will be returned.
+	}
+}
+
+function convert($id){
+	if(preg_match('/^\[U:1:[0-9]+\]/', $id)){
+		$id = substr($id, 5, -1);
+	}
+	
+	// Check if the input is in legacyId, communityId, or SteamId3 format.
+	// If it's not, assume it's a custom Id and attempt to get the communityId from what the user entered.
+	if(preg_match('/^STEAM_[01]:[01]:\d+$/', $id) === 0 && preg_match('/^[0-9]/', $id) === 0 && preg_match('/^765/', $id) === 0){
+		if(($steamId = getSteamId($id)) === false){
+			return json_encode(array());
+		}
+		
+		$id = $steamId;
+	}
+	
+	echo json_encode(array(
+		'communityId'	=>	toCommunityID($id),
+		'steamId'		=>	toSteamID($id),
+		'steamId3'		=>	'[U:1:'.toUserID($id).']',
+		'steamProfile'	=>	'<a href="http://steamcommunity.com/profiles/'.toCommunityID($id).'">Steam Profile</a>',
+	));
+}
+
+// Get gameservers belonging to each user with matching permissions if they're not an admin.
+function getUserServers($servers, $flags, $supportedGames){
+	global $db;
+	$info = array();
+	$userInfo = $db->getUserById($_SESSION['user_id']);
+	$userRole = $userInfo['users_role'];
+	
+	if(!empty($servers)){
+		foreach($servers as $server){
+			$gamehome = $db->getUserGameHome($_SESSION['user_id'], $server['home_id']);
+			
+			if(in_array($gamehome['game_name'], $supportedGames) === true){
+				if($userRole !== 'admin'){
+					if(strpbrk($gamehome['access_rights'], $flags) !== false){
+						$info[] = $server;
+					}
+				}else{
+					$info[] = $server;
+				}
+			}
+		}
+	}
+	
+	return $info;
+}
+?>

+ 1 - 1
modules/util/module.php

@@ -2,7 +2,7 @@
 /*
  *
  * OGP - Open Game Panel
- * Copyright (C) 2008 - 2017 The OGP Development Team
+ * Copyright (C) 2008 - 2018 The OGP Development Team
  *
  * http://www.opengamepanel.org/
  *

+ 8 - 0
modules/util/navigation.xml

@@ -0,0 +1,8 @@
+<navigation>
+  <page key="default" file="util.php" access="user,admin,subuser" />
+  <page key="agents" file="agents.php" access="user,admin,subuser" />
+  <page key="addadmin_helper" file="addadmin_helper.php" access="user,admin,subuser" />
+  <page key="amx_addadmin_helper" file="amx_addadmin_helper.php" access="user,admin,subuser" />
+  <page key="steamid_converter" file="steamid_converter.php" access="user,admin,subuser" />
+  <page key="network_tools" file="network_tools.php" access="user,admin,subuser" />
+</navigation>

+ 62 - 91
modules/util/network_tools.php

@@ -2,7 +2,7 @@
 /*
  *
  * OGP - Open Game Panel
- * Copyright (C) 2008 - 2017 The OGP Development Team
+ * Copyright (C) 2008 - 2018 The OGP Development Team
  *
  * http://www.opengamepanel.org/
  *
@@ -21,105 +21,76 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
  */
-
-	include 'util_config.php';
+require 'includes/lib_remote.php';
+function exec_ogp_module() 
+{
+	global $db;
+	include 'modules/util/util_config.php';
+	$userInfo = $db->getUserById($_SESSION['user_id']);
+	$userRole = $userInfo['users_role'];
 	
-	session_name($sessionName);
-	session_start();
+	$command = trim($_POST['command']);
+	$target = trim($_POST['remote_target']);
 	
-	if(!empty($_SESSION['user_id'])){
-		// This entire section is nothing but a big, messy, workaround.
-		// Make ogpLang happy.
-		$_REQUEST['m'] = 'util';
-		// We need to change directory to be able to include lib_remote and make a database connection without any errors
-		// This is becasue the following files include other files via their relative path rather than absolute path... could be fixed by editing them... but until then, this is just a hacky workaround.
-		$cwd = getcwd();
-		if(chdir('../../') === true){
-			require_once('includes/config.inc.php');
-			require_once('includes/functions.php');
-			require_once('includes/helpers.php');
-			include_once("includes/lang.php");
-			ogpLang();
-			
-			require_once('includes/lib_remote.php');
-			$db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
-		}else{
-			die(get_lang('chdir_failed'));
-		}
-		
-		if(chdir($cwd) === false){
-			die(get_lang('chdir_failed'));
-		}
-		
-		// Actual script functions now.
-		$userInfo = $db->getUserById($_SESSION['user_id']);
-		$userRole = $userInfo['users_role'];
-		
-		$command = trim($_POST['command']);
-		$target = trim($_POST['remote_target']);
+	// Check if the specified agent exists. If it does, assign it to $servers. Otherwise, return that it's an invalid agent.
+	if(($server = $db->getRemoteServerById($_POST['agent'])) === false){
+		die(get_lang('agent_invalid'));
+	}
+	
+	$remote = new OGPRemoteLibrary($server['agent_ip'], $server['agent_port'], $server['encryption_key'], 60);
+	
+	if($remote->status_chk() === 0){
+		echo get_lang('networktools_agent_offline');
+	}elseif(empty($target)){
+		echo get_lang('target_empty');
+	}elseif(empty($command)){
+		echo get_lang('command_empty');
+	}else{
+		$os = preg_match("/CYGWIN/", $remote->what_os()) ? 'windows' : 'linux';
 		
-		// Check if the specified agent exists. If it does, assign it to $servers. Otherwise, return that it's an invalid agent.
-		if(($server = $db->getRemoteServerById($_POST['agent'])) === false){
-			die(get_lang('agent_invalid'));
+		// Loop over $availableCommands from util_config.php
+		// Assign a variable, $allowAccess based on the current user's role and if the config file states the user's role is allowed access to this command.
+		for($x = 0; $x < count($availableCommands); ++$x){
+			if($availableCommands[$x]['title'] == $command){
+				$command = $availableCommands[$x][$os];
+				$allowAccess  = $availableCommands[$x][$userRole];
+			}
 		}
 		
-		$remote = new OGPRemoteLibrary($server['agent_ip'], $server['agent_port'], $server['encryption_key'], 60);
-		
-		if($remote->status_chk() === 0){
-			echo get_lang('networktools_agent_offline');
-		}elseif(empty($target)){
-			echo get_lang('target_empty');
-		}elseif(empty($command)){
-			echo get_lang('command_empty');
-		}else{
-			$os = preg_match("/CYGWIN/", $remote->what_os()) ? 'windows' : 'linux';
-			
-			// Loop over $availableCommands from util_config.php
-			// Assign a variable, $allowAccess based on the current user's role and if the config file states the user's role is allowed access to this command.
-			for($x = 0; $x < count($availableCommands); ++$x){
-				if($availableCommands[$x]['title'] == $command){
-					$command = $availableCommands[$x][$os];
-					$allowAccess  = $availableCommands[$x][$userRole];
-				}
-			}
-			
-			if(isset($allowAccess) && $allowAccess === true){
-				// Check the command is available to us. If it's not, echo command_unavilable
-				$which = $remote->exec('which '.$command);
-				if(empty($which)){
-					echo get_lang('command_unavilable');
+		if(isset($allowAccess) && $allowAccess === true){
+			// Check the command is available to us. If it's not, echo command_unavilable
+			$which = $remote->exec('which '.$command);
+			if(empty($which)){
+				echo get_lang('command_unavilable');
+			}else{
+				// Not completely necessary - gethostbyaddr(gethostbyname()) will return false if it's anything that's not valid.
+				// This is mostly for logging attempted arbitrary commands.
+				if(strpbrk($target, $blockedCharacters)){
+					if($logMaliciousUsage){
+						$db->logger(get_lang_f('command_bad_characters', $command, htmlentities($target)));
+					}
+					echo get_lang('command_hacking_attempt');
 				}else{
-					// Not completely necessary - gethostbyaddr(gethostbyname()) will return false if it's anything that's not valid.
-					// This is mostly for logging attempted arbitrary commands.
-					if(strpbrk($target, $blockedCharacters)){
-						if($logMaliciousUsage){
-							$db->logger(get_lang_f('command_bad_characters', $command, htmlentities($target)));
-						}
-						echo get_lang('command_hacking_attempt');
+					$target = gethostbyaddr(gethostbyname($target));
+					if(!$target){
+						echo get_lang('target_invalid');
 					}else{
-						$target = gethostbyaddr(gethostbyname($target));
-						if(!$target){
-							echo get_lang('target_invalid');
-						}else{
-							$exec = $remote->exec($command.' '.$target);
-							echo ($exec === null) ? get_lang('exec_failed') : htmlentities(trim($exec));
-							if($logAllUsage){
-								$db->logger(get_lang_f('command_executed', $command, htmlentities($target)));
-							}
+						$exec = $remote->exec($command.' '.$target);
+						echo ($exec === null) ? get_lang('exec_failed') : htmlentities(trim($exec));
+						if($logAllUsage){
+							$db->logger(get_lang_f('command_executed', $command, htmlentities($target)));
 						}
 					}
 				}
-			}else{
-				// If the user isn't allowed access but they've somehow got this far then they've changed the value="" attr.
-				// return with command_no_permissions and log the event.
-				echo get_lang('command_no_access');
-				if($logMaliciousUsage){
-					$db->logger(get_lang_f('command_no_permissions', $command, htmlentities($target)));
-				}
-			}	//else allowAccess
-		}	// else status_chk / empty target / empty command
-	}else{//_SESSION check.
-		header('HTTP/1.0 403 Forbidden');
-		exit;
+			}
+		}else{
+			// If the user isn't allowed access but they've somehow got this far then they've changed the value="" attr.
+			// return with command_no_permissions and log the event.
+			echo get_lang('command_no_access');
+			if($logMaliciousUsage){
+				$db->logger(get_lang_f('command_no_permissions', $command, htmlentities($target)));
+			}
+		}	//else allowAccess
 	}
+}
 ?>

+ 7 - 82
modules/util/steamid_converter.php

@@ -2,7 +2,7 @@
 /*
  *
  * OGP - Open Game Panel
- * Copyright (C) 2008 - 2017 The OGP Development Team
+ * Copyright (C) 2008 - 2018 The OGP Development Team
  *
  * http://www.opengamepanel.org/
  *
@@ -21,85 +21,10 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
  */
-
-	include 'util_config.php';
-	
-	session_name($sessionName);
-	session_start();
-	
-	if(!empty($_SESSION['user_id']) && $_SERVER['REQUEST_METHOD'] === 'POST'){
-		function toCommunityID($id){
-			if(preg_match('/^STEAM_/', $id)){
-				$parts = explode(':', $id);
-				return bcadd(bcadd(bcmul($parts[2], '2'), '76561197960265728'), $parts[1]);
-			}elseif(is_numeric($id) && strlen($id) < 16){
-				return bcadd($id, '76561197960265728');
-			}else{
-				return $id;
-			}
-		}
-		
-		function toSteamID($id){
-			if(is_numeric($id) && strlen($id) >= 16){
-				$z = bcdiv(bcsub($id, '76561197960265728'), '2');
-			}elseif(is_numeric($id)){
-				$z = bcdiv($id, '2');
-			}else{
-				return $id;
-			}
-			
-			$y = bcmod($id, '2');
-			return 'STEAM_0:'.$y.':'.floor($z);
-		}
-		
-		function toUserID($id){
-			if(preg_match('/^STEAM_/', $id)){
-				$split = explode(':', $id);
-				return $split[2] * 2 + $split[1];
-			}elseif(preg_match('/^765/', $id) && strlen($id) > 15){
-				return bcsub($id, '76561197960265728');
-			}else{
-				return $id;
-			}
-		}
-		
-		function getSteamId($input){
-			$xml = simplexml_load_file('http://steamcommunity.com/id/'.$input.'?xml=1');
-			$steamId64 = $xml->steamID64;
-			
-			if(preg_match('/^765/', $steamId64) === 0){
-				return false;
-			}else{
-				return (string)$steamId64;	// Cast it to a string, otherwise an SimpleXMLElement Object will be returned.
-			}
-		}
-		
-		function convert($id){
-			if(preg_match('/^\[U:1:[0-9]+\]/', $id)){
-				$id = substr($id, 5, -1);
-			}
-			
-			// Check if the input is in legacyId, communityId, or SteamId3 format.
-			// If it's not, assume it's a custom Id and attempt to get the communityId from what the user entered.
-			if(preg_match('/^STEAM_[01]:[01]:\d+$/', $id) === 0 && preg_match('/^[0-9]/', $id) === 0 && preg_match('/^765/', $id) === 0){
-				if(($steamId = getSteamId($id)) === false){
-					return json_encode(array());
-				}
-				
-				$id = $steamId;
-			}
-			
-			return json_encode(array(
-				'communityId'	=>	toCommunityID($id),
-				'steamId'		=>	toSteamID($id),
-				'steamId3'		=>	'[U:1:'.toUserID($id).']',
-				'steamProfile'	=>	'<a href="http://steamcommunity.com/profiles/'.toCommunityID($id).'">Steam Profile</a>',
-			));
-		}
-		
-		echo convert($_POST['steam_input']);
-	}else{//_SESSION check.
-		header('HTTP/1.0 403 Forbidden');
-		exit;
-	}
+require 'modules/util/functions.php';
+function exec_ogp_module() 
+{
+	require 'modules/util/util_config.php';
+	convert($_POST['steam_input']);
+}
 ?>

+ 85 - 229
modules/util/util.php

@@ -2,7 +2,7 @@
 /*
  *
  * OGP - Open Game Panel
- * Copyright (C) 2008 - 2017 The OGP Development Team
+ * Copyright (C) 2008 - 2018 The OGP Development Team
  *
  * http://www.opengamepanel.org/
  *
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  *
  */
-
+echo '<script src="js/modules/util.js"></script>';
 function exec_ogp_module() 
 {
 	global $db;
@@ -50,7 +50,8 @@ function exec_ogp_module()
 	<ul>
 		<li><a href="#tabs-1"><?php echo get_lang('network_tools'); ?></a></li>
 		<li><a href="#tabs-2"><?php echo get_lang('sourcemod_admins'); ?></a></li>
-		<li><a href="#tabs-3"><?php echo get_lang('steam_converter'); ?></a></li>
+		<li><a href="#tabs-3"><?php echo get_lang('amx_mod_admins'); ?></a></li>
+		<li><a href="#tabs-4"><?php echo get_lang('steam_converter'); ?></a></li>
 	</ul>
 	
 	<div id="tabs-1">
@@ -140,6 +141,78 @@ function exec_ogp_module()
 	</div><!--/#tabs-2-->
 	
 	<div id="tabs-3">
+		<div>
+			<div>
+				<span id="amx_no_servers" class="hide"><?php echo get_lang('no_servers'); ?></span>
+			</div>
+			
+			<div id="amx_add_admin" class="hide">
+				<form action="" method="POST" id="amx_addadmin_form">
+					<div id="amx_games"></div>
+					
+					<label for="amx_login_type"><?php echo get_lang('amx_login_type'); ?></label>
+					<select id="amx_login_type" name="amx_login_type">
+						<option value="amx_login_steamid"><?php echo get_lang('amx_login_steamid'); ?></option>
+						<option value="amx_login_nick_pass"><?php echo get_lang('amx_login_nick_pass'); ?></option>
+					</select>
+					
+					<div id="amx_login_steamid">
+						<label for="amx_Steamid"><?php echo get_lang('steamid'); ?></label>
+						<input type="text" id="amx_Steamid" name="amx_Steamid" pattern="^STEAM_[01]:[01]:\d+$" required>
+					</div>
+					
+					<div id="amx_login_nick_pass"  class="hide">
+						<label for="amx_Nickname"><?php echo get_lang('nickname'); ?></label>
+						<input type="text" id="amx_Nickname" name="amx_Nickname" pattern="^[^\s][A-zÀ-ÿ0-9 !@)(,}/|\.:?;{#$%&*+=-]{1,28}[^\s]$">
+						<label for="amx_Password"><?php echo get_lang('password'); ?></label>
+						<input type="text" id="amx_Password" name="amx_Password" pattern="^[^\s][A-zÀ-ÿ0-9 !@)(,}/|\.:?;{#$%&*+=-]{1,28}[^\s]$">
+					</div>
+					
+					<label for="amx_mod_perms"><?php echo get_lang('amx_mod_perms'); ?></label>
+					<select id="amx_mod_perms" name="amx_mod_perms">
+						<option value="root"><?php echo get_lang('amx_mod_perm_root'); ?></option>
+						<option value="custom"><?php echo get_lang('amx_mod_perm_custom'); ?></option>
+					</select>
+					
+					<div id="amx_mod_flagList" class="hide">
+						<fieldset>
+							<?php
+								foreach(range('a', 'u') as $flag){
+							?>
+							
+							<div class="amx_item">
+								<input type="checkbox" id="amx_flag_<?php echo $flag; ?>" name="amx_flags[]" value="<?php echo $flag; ?>">
+								<label for="amx_flag_<?php echo $flag; ?>"><?php echo get_lang('amx_mod_flag_'.$flag); ?></label>
+							</div>
+							
+							<?php
+								}
+							?>
+						</fieldset>
+					</div>
+					
+					<input type="hidden" name="remote_server_id" id="amx_remote_server_id" value="">
+					<input type="hidden" name="gameserver_name" id="amx_gameserver_name" value="">
+					<input type="hidden" name="gameserver_ip" id="amx_gameserver_ip" value="">
+					<input type="hidden" name="gameserver_port" id="amx_gameserver_port" value="">
+					
+					<button type="submit"><?php echo get_lang('submit'); ?></button>
+				</form>
+			</div>
+			
+			<div id="amx_invalid_server" class="hide"><?php echo get_lang('server_not_selected'); ?></div>
+			<div id="amx_invalid_steamid_admin" class="hide"><?php echo get_lang('invalid_steamid'); ?></div>
+			<div id="amx_invalid_nickname_admin" class="hide"><?php echo get_lang('invalid_nickname'); ?></div>
+			<div id="amx_invalid_password_admin" class="hide"><?php echo get_lang('invalid_password'); ?></div>
+			<div id="amx_invalid_response_admin" class="hide"><?php echo get_lang('post_failed'); ?></div>
+			
+			<div id="amx_all_servers_offline" class="hide"><?php echo get_lang('agents_offline'); ?></div>
+			
+			<div id="amx_addadmin_response" class="hide"></div>
+		</div>
+	</div><!--/#tabs-3-->
+	
+		<div id="tabs-4">
 		<div>
 			<form action="" method="POST" id="steam_converter">
 				<label for="steam_input">SteamID / SteamID3 / SteamID64 / CustomID:</label>
@@ -158,233 +231,16 @@ function exec_ogp_module()
 			<div id="steamId3"></div>
 			<div id="steamId64"></div>
 		</div>
-	</div><!--/#tabs-3-->
+	</div><!--/#tabs-4-->
 </div> <!--/#tabs-->
-
-<script>
-	$(function(){
-		$("#tabs").tabs();
-		$("#loading").removeClass('hide').addClass('show');
-		
-		// Load the agents via an external script so the user isn't waiting an eternity if they have several agents and multiple are offline
-		$.getJSON("modules/util/agents.php", function(data){
-			var agents = "";
-			var agentsOnline = 0;
-			
-			$("#loading_agents").removeClass('show').addClass('hide');
-			$("#loading").removeClass('show').addClass('hide');
-			$("#options").removeClass('hide').addClass('show');
-			
-			agents += "<label for=\"agent\"><?php echo get_lang('select_agent'); ?></label>\r\n"
-			agents += "<select id=\"agent\" name=\"agent\">\r\n"
-			
-			for(var i = 0; i<data.length; ++i){
-				agents += "\t<option value=\"" + data[i]['id'] + "\"" + (data[i]['status']===0?" disabled":"") + ">" + data[i]['name'] +"</option>\r\n";
-				
-				if(data[i]['status'] == 1){
-					++agentsOnline;
-				}
-			}
-			
-			agents += "</select>";
-			
-			if(agentsOnline == 0){
-				$("#options").removeClass('show').addClass('hide');
-				$("#agents_offline").removeClass('hide').addClass('show');
-				
-				// Hide the sourcemod add admin form if all agents are offline.
-				$("#addadmin_form").addClass('hide');
-				$("#all_servers_offline").removeClass('hide').addClass('show');
-			}else if($("#command option").length == 0){
-				$("#options").removeClass('show').addClass('hide');
-				$("#no_commands").removeClass('hide').addClass('show');
-			}else{
-				$("#select_agent").html(agents);
-			}
-		}).fail(function(){
-			$("#loading_agents").removeClass('show').addClass('hide');
-			$("#loading").removeClass('show').addClass('hide');
-			$("#loading_failed").removeClass('hide').addClass('show');
-		});
-		
-		// Handle the network_tools form.
-		$("#network_tools").on("submit", function(e){
-			var target = $("#remote_target").val();
-			var agent = $("#agent").val();
-			var command = $("#command").val();
-			
-			// Some validation browser-side. Still need to do the same server-side.
-			if(target.length === 0){
-				// target input is empty.
-				$("#output").removeClass('hide').addClass('show').html("<pre><?php echo get_lang('target_empty'); ?></pre>");
-			}else if(agent.length === 0){
-				// We'll only get to this point if there's no agents, or all agents are offline but the form was still submitted.
-				$("#output").removeClass('hide').addClass('show').html("<pre><?php echo get_lang('agent_invalid'); ?></pre>");
-			}else if(command.length === 0){
-				// We'll only get to this point if there's no command specified.
-				$("#output").removeClass('hide').addClass('show').html("<pre><?php echo get_lang('command_empty'); ?></pre>");
-			}else{
-				$("#loading").removeClass('hide').addClass('show');
-				$("#output").removeClass('show').addClass('hide')
-				
-				$("#network_tools button").prop({disabled:true}); // Disable the submit button if we're about to post - preventing stuff being ran several times via spamming the button and/or enter.
-				$.post("modules/util/network_tools.php", $("#network_tools").serialize(), function(postCommand){
-					$("#loading").removeClass('show').addClass('hide');
-					$("#output").removeClass('hide').addClass('show').html("<pre>" + postCommand + "</pre>");
-					
-					$("#network_tools button").prop({disabled:false});
-				}).fail(function(){
-					$("#loading").removeClass('show').addClass('hide');
-					$("#output").removeClass('hide').addClass('show').html("<pre><?php echo get_lang('post_failed'); ?></pre>");
-					
-					$("#network_tools button").prop({disabled:false});
-				});
-			}
-			e.preventDefault();
-		});// ./end network_tools form handling.
-		
-		// ----- Sourcemod Admins -----
-		$.getJSON("modules/util/addadmin_helper.php", function(gs){
-			if(gs.length === 0){
-				$("#no_servers").removeClass('hide').addClass('show');
-			}else{
-				var games = "";
-				$("#add_admin").removeClass('hide').addClass('show');
-				
-				games += "<label for=\"gameserver_id\"><?php echo get_lang('select_server'); ?></label>\r\n"
-				games += "<select id=\"gameserver_id\" name=\"gameserver_id\">\r\n"
-				games += "<option value=\"0\" selected><?php echo get_lang('select_server_option'); ?></option>\r\n"
-				
-				for(var i = 0; i<gs.length; ++i){
-					games += "\t<option value=\"" + gs[i]['home_id'] + "\">" + gs[i]['home_name'] +"</option>\r\n";
-				}
-				
-				games += "</select>";
-				$("#games").html(games);
-				
-				$("#gameserver_id").change(function(){
-					var home = $("#gameserver_id").val();
-					var gameserver_id = $("#gameserver_id").val();
-					
-					// although the disabled attribute is put on the option, set all the values to 0 if it's somehow chosen again via the form being edited
-					if(gameserver_id == 0){
-						$("#remote_server_id").val(0);
-						$("#gameserver_name").val(0);
-						$("#gameserver_ip").val(0);
-						$("#gameserver_port").val(0);
-					}else{
-						for(var i = 0; i<gs.length; ++i){
-							if(home === gs[i]['home_id']){
-								$("option[value='0']").attr("disabled", "disabled");
-								$("#remote_server_id").val(gs[i]['remote_server_id']);
-								$("#gameserver_name").val(gs[i]['game_name']);
-								$("#gameserver_ip").val(gs[i]['ip']);
-								$("#gameserver_port").val(gs[i]['port']);
-								break;
-							}
-						}
-					}
-				});
-			}
-		}); // ./end Sourcemod Admins
-		
-		$("#sourcemod_perms").change(function(){
-			var sourcemod_perms = $("#sourcemod_perms").val();
-			
-			if(sourcemod_perms === 'root'){
-				$("#sourcemod_flagList").removeClass('show').addClass('hide');
-				$('.item input[type="checkbox"]').prop('checked', false);
-			}else{
-				$("#sourcemod_flagList").removeClass('hide').addClass('show');
-			}
-		});
-		
-		// Process the sourcemod admin form on submission.
-		$("#addadmin_form").on("submit", function(e){
-			$("#addadmin_form button").prop({disabled:true});
-			
-			var errors = 0;
-			var remoteId = $("#remote_server_id").val();
-			var gameName = $("#gameserver_name").val();
-			var gameIp = $("#gameserver_ip").val();
-			var gamePort = $("#gameserver_port").val();
-			var addSteamid = $("#addSteamid").val();
-			var immunity = $("#immunity").val();
-			
-			// Set the message divs back to defaults.
-			$("#invalid_server").removeClass('show').addClass('hide');
-			$("#invalid_steamid_admin").removeClass('show').addClass('hide');
-			$("#invalid_response_admin").removeClass('show').addClass('hide');
-			$("#invalid_immunity").removeClass('show').addClass('hide');
-			$("#addadmin_response").removeClass('show').addClass('hide');
-			
-			if(remoteId.length === 0 || gameName.length === 0 || gameIp.length === 0 || gamePort.length === 0){
-				$("#invalid_server").removeClass('hide').addClass('show');
-				++errors;
-			}
-			
-			if(!(addSteamid.match(/^STEAM_[01]:[01]:\d+$/))){
-				$("#invalid_steamid_admin").removeClass('hide').addClass('show');
-				++errors;
-			}
-			
-			if(immunity.length > 2 || isNaN(immunity)){
-				$("#invalid_immunity").removeClass('hide').addClass('show');
-				++errors;
-			}
-			
-			if(errors === 0){
-				$.post("modules/util/addadmin_helper.php", $("#addadmin_form").serialize(), function(postCommand){
-					$("#addadmin_response").removeClass('hide').addClass('show').html(postCommand);
-					$("#addadmin_form button").prop({disabled:false});
-				}).fail(function(){
-					$("#invalid_response_admin").removeClass('hide').addClass('show');
-					$("#addadmin_form button").prop({disabled:false});
-				});
-			}else{
-				$("#addadmin_form button").prop({disabled:false});
-			}
-			
-			e.preventDefault();
-		}); // add_admin form handling
-		
-		// ----- Steam Converter -----
-		$("#steam_converter").on("submit", function(e){
-			$("#steam_converter button").prop({disabled:true});
-			$.post("modules/util/steamid_converter.php", $("#steam_converter").serialize(), function(steam_data){
-				var json = $.parseJSON(steam_data);
-				
-				if(json.length === 0){
-					$("#steam_info").removeClass('show').addClass('hide');
-					$("#invalid_steamid").removeClass('hide').addClass('show');
-					$("#invalid_response").removeClass('show').addClass('hide');
-					
-					$("#steam_converter button").prop({disabled:false});
-				}else{
-					$("#steam_info").removeClass('hide').addClass('show');
-					$("#invalid_steamid").removeClass('show').addClass('hide');
-					$("#invalid_response").removeClass('show').addClass('hide');
-					
-					$("#steamLink").html('<b>Profile Link:</b> ' + json.steamProfile);
-					$("#steamId").html('<b>Legacy ID:</b> ' + json.steamId);
-					$("#steamId3").html('<b>SteamID3:</b> ' + json.steamId3);
-					$("#steamId64").html('<b>SteamID64:</b> ' + json.communityId);
-					
-					$("#steam_converter button").prop({disabled:false});
-				}
-			}).fail(function(){
-				$("#invalid_steamid").removeClass('show').addClass('hide');
-				$("#steam_info").removeClass('show').addClass('hide');
-				$("#invalid_response").removeClass('hide').addClass('show');
-			});
-			e.preventDefault();
-		}); // ./end steam_converter form handling.
-		
-		$("#your-address").click(function(){
-			$("#remote_target").val($("#your-address").text());
-		});
-	});
-</script>
+<div id="translation" 
+data-target_empty="<?=get_lang('target_empty')?>"
+data-command_empty="<?=get_lang('command_empty')?>"
+data-agent_invalid="<?=get_lang('agent_invalid')?>"
+data-post_failed="<?=get_lang('post_failed')?>"
+data-select_server="<?=get_lang('select_server')?>"
+data-select_server_option="<?=get_lang('select_server_option')?>"
+data-select_agent="<?=get_lang('select_agent')?>" ></div>
 <?php
 }
 ?>

+ 74 - 66
modules/util/util_config.php

@@ -2,7 +2,7 @@
 /*
  *
  * OGP - Open Game Panel
- * Copyright (C) 2008 - 2017 The OGP Development Team
+ * Copyright (C) 2008 - 2018 The OGP Development Team
  *
  * http://www.opengamepanel.org/
  *
@@ -22,70 +22,78 @@
  *
  */
 
-	// The session variable that OGP assigns for signed in users.
-	$sessionName = 'opengamepanel_web';
-	
-	// Define commands, user permissions (via *role* => true/false), and what they're referred to on each OS.
-	// Include arguements here. They cannot be passed in the text input field.
-	$availableCommands	=	array(
-		// 'title' also needs to be specified in the translation files with the same values - as this is what shows on the select list. ex:
-		array(
-			'title'		=>	'ping',
-			'linux'		=>	'ping -c 4',	// By default, ping runs indefinitely on Linux - so set the count to 4; same as Windows default.
-			'windows'	=>	'ping',
-			
-			// Default: Ping is available to all user roles.
-			'subuser'	=>	true,
-			'user'		=>	true,
-			'admin'		=>	true,
-		),
+// Define commands, user permissions (via *role* => true/false), and what they're referred to on each OS.
+// Include arguements here. They cannot be passed in the text input field.
+$availableCommands	=	array(
+	// 'title' also needs to be specified in the translation files with the same values - as this is what shows on the select list. ex:
+	array(
+		'title'		=>	'ping',
+		'linux'		=>	'ping -c 4',	// By default, ping runs indefinitely on Linux - so set the count to 4; same as Windows default.
+		'windows'	=>	'ping',
 		
-		array(
-			'title'		=>	'traceroute',
-			'linux'		=>	'traceroute',
-			'windows'	=>	'tracert',
-			
-			// Default: Traceroute is only available to admins.
-			'subuser'	=>	false,
-			'user'		=>	false,
-			'admin'		=>	true,
-		),
-	);
-	
-	// An array of characters which should never be passed to exec()
-	$blockedCharacters	= '"#$%^&*()+=[]\';,\\/{}|:<>?~';
-	
-	// Should we log attempted form manipulation (ie, editing the form to execute a command the user doesn't have access to) ...
-	// ... and attempted multi-command input? (ie, ;cd /;ls)
-	$logMaliciousUsage = true;
-	
-	// Should we log successfully executed commands...?
-	// Could spam the logs - so probably set this to false.
-	$logAllUsage = false;
+		// Default: Ping is available to all user roles.
+		'subuser'	=>	true,
+		'user'		=>	true,
+		'admin'		=>	true,
+	),
 	
-	// Games which Sourcemod supports.
-	// Needs to be exactly what OGP reports as the game_name.
-	$supportedGames = array(
-		'Counter Strike Global Offensive',
-		'Counter Strike Source',
-		'Day of Defeat Source',
-		'Dystopia',
-		'Garrys Mod',
-		'Half-Life 2: Deathmatch',
-		'Hidden: Source',
-		'Pirates, Vikings and Knights II',
-		'Team Fortress 2',
-		'Team Fortress 2 Beta',
-		'Left 4 Dead',
-		'Left 4 Dead 2',
-	);
-	
-	// Simple array of where admins are stored depending on the admin mod.
-	// mod.name => file.location
-	$adminFiles = array(
-		'sourcemod'	=>	'addons/sourcemod/configs/admins_simple.ini',
-	);
-	
-	// Flags that sub-users need to add admins to owned parent game-servers.
-	// This should just be the same as allow_file_management and allow_ftp - as they'll be able to add admins anyway with those flags.
-	$subuserAdminManagement = 'ft';
+	array(
+		'title'		=>	'traceroute',
+		'linux'		=>	'traceroute',
+		'windows'	=>	'tracert',
+		
+		// Default: Traceroute is only available to admins.
+		'subuser'	=>	false,
+		'user'		=>	false,
+		'admin'		=>	true,
+	),
+);
+
+// An array of characters which should never be passed to exec()
+$blockedCharacters	= '"#$%^&*()+=[]\';,\\/{}|:<>?~';
+
+// Should we log attempted form manipulation (ie, editing the form to execute a command the user doesn't have access to) ...
+// ... and attempted multi-command input? (ie, ;cd /;ls)
+$logMaliciousUsage = true;
+
+// Should we log successfully executed commands...?
+// Could spam the logs - so probably set this to false.
+$logAllUsage = false;
+
+// Games which Sourcemod supports.
+// Needs to be exactly what OGP reports as the game_name.
+$supportedGames = array(
+	'Counter Strike Global Offensive',
+	'Counter Strike Source',
+	'Day of Defeat Source',
+	'Dystopia',
+	'Garrys Mod',
+	'Half-Life 2: Deathmatch',
+	'Hidden: Source',
+	'Pirates, Vikings and Knights II',
+	'Team Fortress 2',
+	'Team Fortress 2 Beta',
+	'Left 4 Dead',
+	'Left 4 Dead 2'
+);
+
+// Games which amx mod supports.
+// Needs to be exactly what OGP reports as the game_name.
+$amx_supportedGames = array(
+	'Counter-Strike',
+	'Counter-Strike Condition Zero',
+	'Day of Defeat',
+	'Death Match Classic',
+	'Team Fortress Classic'
+);
+
+// Simple array of where admins are stored depending on the admin mod.
+// mod.name => file.location
+$adminFiles = array(
+	'sourcemod'	=>	'addons/sourcemod/configs/admins_simple.ini',
+	'amx_mod'	=>	'addons/amxmodx/configs/users.ini',
+);
+
+// Flags that sub-users need to add admins to owned parent game-servers.
+// This should just be the same as allow_file_management and allow_ftp - as they'll be able to add admins anyway with those flags.
+$subuserAdminManagement = 'ft';