Steam Workshop'; if (!isset($_GET['home_id-mod_id-ip-port']) || $_GET['home_id-mod_id-ip-port'] === '') { print_failure(get_lang('no_game_servers_assigned')); return; } list($homeId, $modId) = explode('-', $_GET['home_id-mod_id-ip-port']); $isAdmin = $db->isAdmin($_SESSION['user_id']); $homeCfg = $isAdmin ? $db->getGameHome($homeId) : $db->getUserGameHome($_SESSION['user_id'], $homeId); if (!$homeCfg) { print_failure(get_lang('game_home_not_found')); return; } $serverXml = read_server_config(SERVER_CONFIG_LOCATION . '/' . $homeCfg['home_cfg_file']); if ($serverXml === false) { print_failure(get_lang_f('failed_reading_xml_file', SERVER_CONFIG_LOCATION . '/' . $homeCfg['home_cfg_file'])); return; } if (!isset($homeCfg['mods'][$modId]['mod_key'])) { print_failure(get_lang_f('mod_id_does_not_exists_in_home', $modId, $homeId)); return; } $modKey = $homeCfg['mods'][$modId]['mod_key']; $modXml = xml_get_mod($serverXml, $modKey); if (!$modXml) { print_failure(get_lang_f('mod_key_not_found_from_xml', $modKey)); return; } $configStore = new WorkshopConfigStore('modules/steam_workshop/data/configs.json'); $stateStore = new WorkshopStateStore('modules/steam_workshop/data'); $resolver = new WorkshopResolver(); $config = $configStore->get($homeId); if ($config === null) { $config = workshop_build_default_config($homeCfg, $modXml, $settings); $configStore->put($homeId, $config); } $remote = new OGPRemoteLibrary($homeCfg['agent_ip'], $homeCfg['agent_port'], $homeCfg['encryption_key'], $homeCfg['timeout']); if ($remote->status_chk() !== 1) { print_failure(get_lang('remote_server_offline')); return; } $syncService = new WorkshopSyncService($remote, $homeCfg, $configStore, $stateStore, $resolver); $state = $stateStore->get($homeId); $items = $resolver->resolveItems($config); $details = $resolver->fetchItemDetails($items); $message = ''; if (isset($_POST['action'])) { switch ($_POST['action']) { case 'add_item': if (isset($_POST['item_id']) && preg_match('/^[0-9]+$/', $_POST['item_id'])) { $config['workshop_item_ids'][] = $_POST['item_id']; $config['workshop_item_ids'] = array_values(array_unique(array_filter($config['workshop_item_ids'], 'strlen'))); $configStore->put($homeId, $config); $items = $resolver->resolveItems($config); $details = $resolver->fetchItemDetails($items); $message = get_lang('mod_installation_started'); } else { print_failure(get_lang('invalid_mod_id')); } break; case 'add_collection': if (isset($_POST['collection_id']) && preg_match('/^[0-9]+$/', $_POST['collection_id'])) { $config['collection_ids'][] = $_POST['collection_id']; $config['collection_ids'] = array_values(array_unique(array_filter($config['collection_ids'], 'strlen'))); $configStore->put($homeId, $config); $items = $resolver->resolveItems($config); $details = $resolver->fetchItemDetails($items); $message = get_lang('settings_updated'); } else { print_failure(get_lang('invalid_mod_id')); } break; case 'remove_item': if (isset($_POST['item_id'])) { $config['workshop_item_ids'] = array_values(array_filter($config['workshop_item_ids'], function ($id) { return isset($_POST['item_id']) ? ($id !== $_POST['item_id']) : true; })); $configStore->put($homeId, $config); $items = $resolver->resolveItems($config); $details = $resolver->fetchItemDetails($items); $message = get_lang('settings_updated'); } break; case 'sync_now': $result = $syncService->sync($homeId); if ($result->success) { print_success($result->message); } else { print_failure($result->message); } $state = $stateStore->get($homeId); break; } } if ($message !== '') { print_success($message); } echo '
' . get_lang('no_mods_found') . '
'; } else { echo '| ID | ' . get_lang('name') . ' | ' . get_lang('status') . ' | |
|---|---|---|---|
| ' . $id . ' | '; echo '' . $name . ' | '; echo '' . $status . ' | '; echo ''; echo ''; echo ' | '; echo '