Steam Workshop';
define('CONFIGS', "modules/steam_workshop/game_configs/");
if(isset($_GET['home_id-mod_id-ip-port']) && $_GET['home_id-mod_id-ip-port'] != "")
list($home_id, $mod_id, $ip, $port) = explode("-", $_GET['home_id-mod_id-ip-port']);
else
{
print_failure(get_lang('no_game_servers_assigned'));
return;
}
if(!isset($_POST['uninstall']))
{
echo "
";
}
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
if($isAdmin)
$home_cfg = $db->getGameHome($home_id);
else
$home_cfg = $db->getUserGameHome($_SESSION['user_id'],$home_id);
if($home_cfg)
{
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_cfg['home_cfg_file']);
if($server_xml === FALSE)
{
print_failure(get_lang_f('failed_reading_xml_file', SERVER_CONFIG_LOCATION."/".$home_cfg['home_cfg_file']));
return;
}
if(!isset($home_cfg['mods'][$mod_id]['mod_key']))
{
print_failure(get_lang_f('mod_id_does_not_exists_in_home', $mod_id, $home_id));
return;
}
$modkey = $home_cfg['mods'][$mod_id]['mod_key'];
$mod_xml = xml_get_mod($server_xml, $modkey);
if (!$mod_xml)
{
print_failure(get_lang_f('mod_key_not_found_from_xml', $modkey));
return;
}
preg_match('/(linux|win)(32|64)?/i', $home_cfg['game_key'], $matches);
if(!isset($matches[1]))
{
print_failure(get_lang_f('unable_to_get_os_from_game_key', $home_cfg['game_key']));
return;
}
if(strtolower($matches[1]) == 'linux')
$os = "Linux";
elseif(strtolower($matches[1]) == 'win')
$os = "Windows";
if(!isset($os))
{
print_failure(get_lang_f('unable_to_get_os_from_game_key', $home_cfg['game_key']));
return;
}
$xml_file = CONFIGS.$mod_xml->installer_name."_".$os.".xml";
if(!file_exists($xml_file))
{
print_failure(get_lang('no_workshop_configuration_available_for_this_game'));
return;
}
$dom = new DOMDocument();
if ( @$dom->load($xml_file) === FALSE )
{
print_failure(get_lang('workshop_configuration_file_has_bad_format'));
return;
}
$xml = simplexml_load_file($xml_file);
if($xml !== false)
{
$remote = new OGPRemoteLibrary($home_cfg['agent_ip'],$home_cfg['agent_port'],$home_cfg['encryption_key'], $home_cfg['timeout']);
if($remote->status_chk() !== 1)
{
print_failure(get_lang('remote_server_offline'));
}
if(isset($_POST['uninstall']) and isset($_POST['mod_string']))
{
$output = "";
foreach($_POST['mod_string'] as $mod_string)
{
$result = remove_mod($home_cfg, $remote, $xml, $mod_string);
if($result !== FALSE)
$output .= $result."\n";
else
$output .= get_lang_f('failed_uninstalling_mod', $mod_string)."\n";
}
echo "$output
";
echo "".get_lang('back')."";
}
else
{
$mods = get_installed_mods($home_cfg, $remote, $xml);
if($mods and count($mods) > 0)
{
$ft = new FormTable();
$ft->start_form("?m=steam_workshop&p=uninstall&home_id-mod_id-ip-port=".$_GET['home_id-mod_id-ip-port'], "post", "autocomplete=\"off\"");
$ft->start_table();
echo '';
foreach($mods as $mod_id => $mod_name)
echo " ";
echo ' |
';
$ft->end_table();
$ft->add_button("submit", "uninstall", get_lang('uninstall_mods'));
$ft->end_form();
}
else
{
print_failure(get_lang('there_are_no_mods_installed_on_this_game_server'));
return;
}
}
}
else
{
print_failure(get_lang('workshop_configuration_file_has_bad_format'));
return;
}
}
else
{
print_failure(get_lang('game_home_not_found'));
return;
}
}
?>