public function main($id, $mode) { global $cache, $user, $template, $config, $phpEx, $phpbb_admin_path, $phpbb_root_path; $user->add_lang(array('mods/dkp_admin', 'mods/dkp_common', 'mods/dkp_gameworld')); $template->assign_vars(array('BP_VERS' => $config['bbdkp_gameworld_version'])); $this->page_title = $user->lang['WORLDPROGRESS'] . ' ' . $config['bbdkp_gameworld_version']; $this->game_id = request_var('displaygame', request_var('game_id', '')); $this->igame = new games\Game(); $this->igame->game_id = $this->game_id; $this->igame->Get(); $this->gmlink = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld") . '"><h3>' . $user->lang['RETURN_DKPINDEX'] . '</h3></a>'; $this->zonelink = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=zonebase&game_id=" . $this->game_id) . '"><h3>' . $user->lang['RETURN_DKPINDEX'] . '</h3></a>'; $this->bosslink = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=bossbase&game_id=" . $this->game_id) . '"><h3>' . $user->lang['RETURN_DKPINDEX'] . '</h3></a>'; foreach ($this->games as $id => $gamename) { $template->assign_block_vars('game_row', array('VALUE' => $id, 'SELECTED' => $id == $this->game_id ? ' selected="selected"' : '', 'OPTION' => $gamename)); } switch ($mode) { case 'gameworldconfig': $submit = isset($_POST['submitsettings']) ? true : false; if ($submit) { set_config('bbdkp_boss_hidenonkilled', isset($_POST['hidenewboss']) ? 1 : 0); set_config('bbdkp_zone_photo', request_var('headertype', 0), 0); set_config('bbdkp_zone_style', request_var('zonestyle', 0)); set_config('bbdkp_zone_progress', request_var('zoneprogress', 0)); set_config('bbdkp_boss_hidenewzone', isset($_POST['hidenewzone']) ? 1 : 0); set_config('bbdkp_zone_block_show', isset($_POST['blockprogressbar']) ? 1 : 0); set_config('bbdkp_portal_bossprogress', request_var('show_bosspblock', 0), true); $cache->destroy('config'); trigger_error($user->lang['ADMIN_UPDATE_GAMEWORLD_SUCCESS'] . $this->gmlink, E_USER_NOTICE); } // display list of games $listgames = new \bbdkp\controller\games\Game(); $gamelist = $listgames->listgames(); foreach ($gamelist as $this->game_id => $game) { $template->assign_block_vars('gamerow', array('ID' => $game['id'], 'NAME' => $game['name'], 'GAME_ID' => $game['game_id'], 'U_VIEW_GAME' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&mode=editgames&" . URI_GAME . '=' . $game['game_id']), 'U_VIEW_ZONES' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=zonebase&" . URI_GAME . '=' . $game['game_id']), 'U_VIEW_BOSSES' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=bossbase&" . URI_GAME . '=' . $game['game_id']), 'VIEWZONES' => sprintf($user->lang['VIEWZONES'], $game['name']), 'VIEWBOSSES' => sprintf($user->lang['VIEWBOSSES'], $game['name']), 'STATUS' => $game['status'])); } // display the list of zones $bp_styles['0'] = $user->lang['BP_STYLE_BP']; $bp_styles['1'] = $user->lang['BP_STYLE_BPS']; $bp_styles['2'] = $user->lang['BP_STYLE_RP3R']; foreach ($bp_styles as $value => $option) { $template->assign_block_vars('style_row', array('VALUE' => $value, 'SELECTED' => $config['bbdkp_zone_style'] == $value ? ' selected="selected"' : '', 'OPTION' => $option)); } $arrvals = array('GAME_ID' => $this->game_id, 'F_CONFIG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=gameworldconfig"), 'BP_HIDENONKIBOSS' => $config['bbdkp_boss_hidenonkilled'] == 1 ? 'checked="checked"' : '', 'HEADER_SEL_SEPIA' => $config['bbdkp_zone_photo'] == 0 ? 'selected="selected"' : '', 'HEADER_SEL_BLUE' => $config['bbdkp_zone_photo'] == 1 ? 'selected="selected"' : '', 'HEADER_SEL_NONE' => $config['bbdkp_zone_photo'] == 2 ? 'selected="selected"' : '', 'BP_SHOWSB' => $config['bbdkp_zone_progress'] == 1 ? 'checked="checked"' : '', 'BP_HIDENEWZONE' => $config['bbdkp_boss_hidenewzone'] == 1 ? 'checked="checked"' : '', 'BP_BLOCKSHOWPROGRESSBAR' => $config['bbdkp_zone_block_show'] == 1 ? ' checked="checked"' : '', 'S_BP_SHOW' => true, 'SHOW_BOSS_YES_CHECKED' => $config['bbdkp_portal_bossprogress'] == '1' ? ' checked="checked"' : '', 'SHOW_BOSS_NO_CHECKED' => $config['bbdkp_portal_bossprogress'] == '0' ? ' checked="checked"' : ''); $template->assign_vars($arrvals); $this->tpl_name = 'dkp/acp_gameworld'; break; case 'zonebase': if (isset($_GET['move_up'])) { $this->Zonebase_move('up'); } if (isset($_GET['move_down'])) { $this->Zonebase_move('down'); } if (isset($_POST['bpadd'])) { $this->ShowAddZonebase(); } if (isset($_GET['edit'])) { $this->ShowEditZonebase(); } // user pressed the submit button in the add/edit zone screen if (isset($_POST['addnew'])) { $this->AddNewZonebase(); } if (isset($_POST['zoneparam'])) { $this->UpdateZonebase(); } // user pressed the red cross if (isset($_GET['delete'])) { $this->DeleteZonebase(); } $iZone = new games\Zone($this->game_id); $data = $iZone->GetAllZones(); $numzones = count($data); $start = request_var('start', 0); $arrvals = array('GAME_ID' => $this->game_id, 'GAMELOGO' => $phpbb_root_path . 'images/bbdkp/gameworld/' . $this->game_id . '/' . $this->game_id . '.png', 'GAMENAME' => $this->igame->getName(), 'ZONEBASEURL' => $this->igame->getZonebaseurl(), 'U_BACK1' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=zonebase&game_id=" . $this->game_id), 'U_BACK2' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=gameworldconfig"), 'PAGINATION' => generate_pagination(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=zonebase&game_id=" . $this->game_id), $numzones, 30, $start, true), 'PAGE_NUMBER' => on_page($numzones, 2, $start)); $template->assign_vars($arrvals); $i = 0; $j = 0; foreach ($data as $row) { $i += 1; if ($i >= $start) { $j += 1; //show max 10 zones per page if ($j <= 30) { $template->assign_block_vars('gamezone', array('ZONE_ID' => $row['id'], 'ZONE_SEQUENCE' => $row['sequence'], 'ZONE_NAME' => $row['name'], 'ZONE_NAME_SHORT' => $row['name_short'], 'ZONE_IMAGENAME' => $row['imagename'], 'ZONE_WEBID' => $row['webid'], 'ZONE_URL' => sprintf($this->igame->getZonebaseurl(), $row['webid']), 'ZONE_SHOW' => $row['showzone'] == 1 ? 'checked="checked"' : '', 'U_EDIT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=zonebase&edit=1&id={$row['id']}&game_id=" . $this->game_id), 'U_DELETE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=zonebase&delete=1&id={$row['id']}&game_id=" . $this->game_id), 'U_MOVE_UP' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=zonebase&move_up=1&id={$row['id']}&game_id=" . $this->game_id), 'U_MOVE_DOWN' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=zonebase&move_down=1&id={$row['id']}&game_id=" . $this->game_id))); } } } $this->page_title = $user->lang['RP_ZONE']; $this->tpl_name = 'dkp/acp_gameworld_zonebase'; break; case 'bossbase': if (isset($_POST['bpadd'])) { $this->ShowAddBoss(); } if (isset($_POST['addnew'])) { $this->AddUpdateBoss(); } if (isset($_GET['edit'])) { $this->EditBoss(); } if (isset($_GET['delete'])) { $this->DeleteBoss(); } if (isset($_POST['bpsave'])) { $this->UpdateBossList(); } $izone = new games\Zone($this->game_id); $zonelist = $izone->GetAllZones(); $numzones = count($zonelist); $start = request_var('start', 0); $arrvals = array('GAME_ID' => $this->game_id, 'GAMELOGO' => $phpbb_root_path . 'images/bbdkp/gameworld/' . $this->game_id . '/' . $this->game_id . '.png', 'GAMENAME' => $this->igame->getName(), 'BOSSBASEURL' => $this->igame->getBossbaseurl(), 'F_CONFIG' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=bossbase"), 'U_BACK1' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=bossbase&game_id=" . $this->game_id), 'U_BACK2' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=gameworldconfig"), 'PAGINATION' => generate_pagination(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=bossbase&game_id=" . $this->game_id), $numzones, 3, $start, true), 'PAGE_NUMBER' => on_page($numzones, 2, $start)); $template->assign_vars($arrvals); $iboss = new games\Boss($this->game_id); $i = 0; $j = 0; foreach ($zonelist as $row) { $i += 1; if ($i >= $start) { $j += 1; //show max 3 zones per page if ($j <= 3) { $template->assign_block_vars('zone', array('ZONE_NAME' => $row['name'], 'ZONE_IMAGENAME' => $phpbb_root_path . "images/bbdkp/gameworld/" . $this->game_id . "/zones/normal/" . $row['imagename'] . ".jpg")); $bossdata = $iboss->GetAllBosses($row['id']); foreach ($bossdata as $row2) { $template->assign_block_vars('zone.boss', array('BOSS_ID' => $row2['id'], 'BOSS_NAME' => htmlspecialchars($row2['name']), 'BOSS_NAME_SHORT' => htmlspecialchars($row2['name_short']), 'BOSS_IMAGENAME' => $row2['imagename'], 'GAME_ID' => $this->game_id, 'BOSS_WEBID' => $row2['webid'], 'BOSS_URL' => sprintf($this->igame->getBossbaseurl(), $row2['webid']), 'BOSS_URLVIEW' => $phpbb_root_path . "images/bbdkp/icons/view.gif", 'U_EDIT' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=bossbase&edit=1&id={$row2['id']}&game_id=" . $this->game_id), 'U_DELETE' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_gameworld&mode=bossbase&delete=1&id={$row2['id']}&game_id=" . $this->game_id))); } } } } $this->page_title = $user->lang['BOSSPROGRESS']; $this->tpl_name = 'dkp/acp_gameworld_' . $mode; break; } }
/** * main ACP game function * @param int $id the id of the node who parent has to be returned by function * @param int $mode id of the submenu * @access public */ function main($id, $mode) { global $user, $template, $phpbb_admin_path, $phpEx; $form_key = 'acp_dkp_game'; add_form_key($form_key); $this->tpl_name = 'dkp/acp_' . $mode; //list installed games $listgames = new \bbdkp\controller\games\Game(); $sort_order = array(0 => array('id', 'id desc'), 1 => array('game_id', 'game_id desc'), 2 => array('game_name', 'game_name desc')); $current_order = $this->switch_order($sort_order); $sort_index = explode('.', $current_order['uri']['current']); $this->gamelist = $listgames->listgames($current_order['sql']); $installed = array(); foreach ($this->gamelist as $game) { $installed[$game['game_id']] = $game['name']; } switch ($mode) { case 'listgames': $this->link = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&mode=listgames") . '"><h3>' . $user->lang['RETURN_GAMELIST'] . '</h3></a>'; //game dropdown $newpresetgame = isset($_POST['addgame1']) ? true : false; $newcustomgame = isset($_POST['addgame2']) ? true : false; if ($newpresetgame || $newcustomgame) { // ask for permission if (confirm_box(true)) { $editgame = new \bbdkp\controller\games\Game(); $editgame->game_id = request_var('hidden_game_id', ''); $editgame->setName(utf8_normalize_nfc(request_var('hidden_game_name', '', true))); $editgame->install(); // // Logging // $log_action = array('header' => 'L_ACTION_GAME_ADDED', 'L_GAME' => $editgame->game_id); $this->log_insert(array('log_type' => 'L_ACTION_GAME_ADDED', 'log_action' => $log_action)); trigger_error(sprintf($user->lang['ADMIN_INSTALLED_GAME_SUCCESS'], $editgame->getName()) . $this->link, E_USER_NOTICE); } else { // get field content $listgames->game_id = request_var('ngame_id', ''); if ($newpresetgame) { $listgames->setName($listgames->preinstalled_games[$listgames->game_id]); } elseif ($newcustomgame) { $listgames->setName(utf8_normalize_nfc(request_var('ngame_name', '', true))); } $s_hidden_fields = build_hidden_fields(array('addgame1' => $newpresetgame, 'addgame2' => $newcustomgame, 'hidden_game_id' => $listgames->game_id, 'hidden_game_name' => $listgames->getName())); confirm_box(false, sprintf($user->lang['CONFIRM_INSTALL_GAME'], $listgames->getName()), $s_hidden_fields); } } ///template load $can_install_count = 0; //is anything installed ? $not_installed = array(); if (count($installed) > 0) { $not_installed = array_diff($listgames->preinstalled_games, $installed); } else { // brand new install $not_installed = $listgames->preinstalled_games; } foreach ($not_installed as $key => $game) { $can_install_count += 1; $template->assign_block_vars('gamelistrow', array('VALUE' => $key, 'OPTION' => $game, 'SELECTED' => '')); } foreach ($this->gamelist as $game_id => $game) { $template->assign_block_vars('gamerow', array('ID' => $game['id'], 'NAME' => $game['name'], 'GAME_ID' => $game['game_id'], 'U_VIEW_GAME' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&mode=editgames&" . URI_GAME . '=' . $game['game_id']), 'STATUS' => $game['status'])); } $template->assign_vars(array('U_LIST_GAME' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&mode=listgames"), 'CANINSTALL' => $can_install_count == 0 ? false : true, 'O_ID' => $current_order['uri'][0], 'O_GAMEID' => $current_order['uri'][1], 'O_GAMENAME' => $current_order['uri'][2])); $form_key = '30U05YJ4IfeHxY'; add_form_key($form_key); $this->page_title = 'ACP_LISTGAME'; break; case 'editgames': $action = request_var('action', ''); $editgame = new \bbdkp\controller\games\Game(); $editgame->game_id = request_var(URI_GAME, request_var('hidden_game_id', '')); $editgame->Get(); $this->link = '<br /><a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&mode=editgames&" . URI_GAME . "={$editgame->game_id}") . '"><h3>' . $user->lang['RETURN_GAMEVIEW'] . '</h3></a>'; $gamereset = isset($_POST['gamereset']) ? true : false; $gamedelete = isset($_POST['gamedelete']) ? true : false; $gamesettings = isset($_POST['gamesettings']) ? true : false; $template->assign_vars(array('U_BACK' => append_sid("{$phpbb_admin_path}index.{$phpEx}", "i=dkp_game&mode=listgames"))); if ($gamereset) { $this->ResetGame($editgame); } // save game settings if ($gamesettings) { $editgame = $this->SaveGameSettings(); } if ($gamedelete) { $this->DeleteGame($editgame); } $addrole = isset($_POST['showrolesadd']) ? true : false; if ($addrole) { $this->BuildTemplateRole($editgame); break; } if ($action == 'deleterole') { $this->DeleteRole($editgame); break; } elseif ($action == 'editrole') { $this->BuildTemplateRole($editgame); break; } $addfaction = isset($_POST['showfactionadd']) ? true : false; if ($addfaction) { $this->BuildTemplateFaction($editgame); break; } if ($action == 'deletefaction') { $this->DeleteFaction($editgame); break; } elseif ($action == 'editfaction') { $this->BuildTemplateFaction($editgame); break; } $addrace = isset($_POST['showraceadd']) ? true : false; $raceedit = isset($_GET['raceedit']) ? true : false; $racedelete = isset($_GET['racedelete']) ? true : false; if ($raceedit || $addrace) { // Load template for adding/editing if (isset($_GET['id'])) { // edit this race $this->BuildTemplateEditRace($editgame); } else { $this->BuildTemplateAddRace($editgame); } break; } if ($racedelete) { $this->DeleteRace($editgame); break; } $addclass = isset($_POST['showclassadd']) ? true : false; $classedit = isset($_GET['classedit']) ? true : false; $classdelete = isset($_GET['classdelete']) ? true : false; if ($classedit || $addclass) { // Load template for adding/editing if (isset($_GET['id'])) { $this->BuildTemplateEditClass($editgame); } else { $this->BuildTemplateAddClass($editgame); } break; } if ($classdelete) { // user pressed delete class $this->DeleteClass($editgame); break; } $this->showgame($editgame); $this->page_title = 'ACP_ADDGAME'; break; case 'addrole': $role = new \bbdkp\controller\games\Roles(); $role->game_id = request_var('game_id', request_var('hidden_game_id', '')); $editgame = new \bbdkp\controller\games\Game(); $editgame->game_id = $role->game_id; $editgame->Get(); $addnew = isset($_POST['addrole']) ? true : false; $editfaction = isset($_POST['editrole']) ? true : false; if ($addnew) { $this->AddRole($role, $editgame); } if ($editfaction) { $this->EditRole($role, $editgame); } break; case 'addfaction': $faction = new \bbdkp\controller\games\Faction(); $faction->game_id = request_var('game_id', request_var('hidden_game_id', '')); $editgame = new \bbdkp\controller\games\Game(); $editgame->game_id = $faction->game_id; $editgame->Get(); $addnew = isset($_POST['factionadd']) ? true : false; $editfaction = isset($_POST['factionedit']) ? true : false; if ($addnew) { $this->AddFaction($faction, $editgame); } if ($editfaction) { $this->EditFaction($faction, $editgame); } break; case 'addrace': $raceadd = isset($_POST['add']) ? true : false; $raceupdate = isset($_POST['update']) ? true : false; if ($raceadd || $raceupdate) { if (!check_form_key('acp_dkp_game')) { trigger_error('FORM_INVALID'); } } if ($raceadd) { $this->AddRace(); } elseif ($raceupdate) { $this->RaceUpdate(); } $this->page_title = 'ACP_LISTGAME'; break; case 'addclass': // collects data after BuildTemplateEditClass, calls class updater $classadd = isset($_POST['add']) ? true : false; $classupdate = isset($_POST['update']) ? true : false; if ($classadd || $classupdate) { if (!check_form_key('acp_dkp_game')) { trigger_error('FORM_INVALID'); } } if ($classadd) { $this->AddClass(); } elseif ($classupdate) { $this->EditClass(); } $this->page_title = 'ACP_LISTGAME'; break; } }