public function go() { if (isset($_GET["action"]) && $_GET["action"] == "del") { $id = $_GET['id']; $challenge = ChallengeBackend::getChallenge($id); $pkg_name = $challenge[0]->pkg_name; self::rrmdir(HACKADEMIC_PATH . "challenges/" . $pkg_name); ChallengeBackend::deleteChallenge($id); $this->addSuccessMessage("Challenge has been deleted succesfully"); } else { if (isset($_GET['action']) && $_GET['action'] == "add") { $this->addSuccessMessage("Challenge has been added succesfully. You can enable the challenge now."); if (isset($_SESSION['challenge_arr'])) { unset($_SESSION['challenge_arr']); } } } if (isset($_GET['limit']) && $_GET['limit'] != "") { $limit = $_GET['limit']; } else { $limit = 25; } $total_pages = ChallengeBackend::getNumberOfChallenges(); $targetpage = SOURCE_ROOT_PATH . "admin/pages/challengemanager.php"; $stages = 3; $page = 0; if (isset($_GET['page'])) { $page = $_GET['page']; } if ($page) { $start = ($page - 1) * $limit; } else { $start = 0; } // Initial page num setup if ($page == 0) { $page = 1; } $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages / $limit); $LastPagem1 = $lastpage - 1; $pagination = array('lastpage' => $lastpage, 'page' => $page, 'targetpage' => $targetpage, 'prev' => $prev, 'next' => $next, 'stages' => $stages, 'last_page_m1' => $LastPagem1); if (isset($_GET['search']) && isset($_GET['category']) && $_GET['search'] != '' && $_GET['category'] != '') { $challenges = ChallengeBackend::getNchallenges($start, $limit, $_GET['search'], $_GET['category']); } else { $challenges = ChallengeBackend::getNchallenges($start, $limit); } $this->addToView('challenges', $challenges); $this->addToView('total_pages', $total_pages); $this->addToView('pagination', $pagination); $this->setViewTemplate('challengemanager.tpl'); $this->generateView(); }