/** * @return array * @throws \ErrorException */ protected function loadApplets() { // Load Applets from DB $applet_data = $this->db->conn()->query(<<<SQL SELECT `applet_include`, `applet_file`, `applet_output` FROM `{$this->db->getPrefix()}applets` WHERE `applet_active` = 1 SQL ); $applet_data = $applet_data->fetchAll(\PDO::FETCH_ASSOC); // Write Applets into Array & get Applet Template $new_applet_data = array(); foreach ($applet_data as $entry) { // prepare data $entry['applet_file'] .= '.php'; settype($entry['applet_output'], 'boolean'); // include applets & load template if ($entry['applet_include'] == 1) { $entry['applet_template'] = $this->loadApplet($entry['applet_file'], $entry['applet_output'], array()); } $new_applet_data[$entry['applet_file']] = $entry; } // Return Content return $new_applet_data; }
/** * @return mixed * @throws \ErrorException */ protected function detectPage() { // security functions if (!isset($_REQUEST['go'])) { $_REQUEST['go'] = null; } $go = $_REQUEST['go']; // get page-data from database $acp_arr = $this->db->conn()->prepare(<<<SQL SELECT `page_id`, `page_file`, P.`group_id` AS `group_id`, `menu_id` FROM `{$this->db->getPrefix()}admin_cp` P, `{$this->db->getPrefix()}admin_groups` G WHERE P.`group_id` = G.`group_id` AND P.`page_id` = ? AND P.`page_int_sub_perm` != 1 SQL ); $acp_arr->execute(array($go)); $acp_arr = $acp_arr->fetch(\PDO::FETCH_ASSOC); // if page exists if (!empty($acp_arr)) { // if page is start page if ($acp_arr['group_id'] == -1) { $acp_arr['menu_id'] = $acp_arr['page_file']; $acp_arr['page_file'] = $acp_arr['page_id'] . '.php'; } //if popup if ($acp_arr['group_id'] == 'popup') { define('POPUP', true); $title = $this->text['menu']->get('page_title_' . $acp_arr['page_id']); } else { define('POPUP', false); $title = $this->text['menu']->get('group_' . $acp_arr['group_id']) . ' » ' . $this->text['menu']->get('page_title_' . $acp_arr['page_id']); } // get the page-data $PAGE_DATA_ARR = createpage($title, has_perm($acp_arr['page_id']), $acp_arr['page_file'], $acp_arr['menu_id']); } else { $PAGE_DATA_ARR['created'] = false; define('POPUP', false); } // logout if ($PAGE_DATA_ARR['created'] === false && $go == 'logout') { setcookie('login', '', time() - 3600, '/'); $_SESSION = array(); $PAGE_DATA_ARR = createpage($this->text['menu']->get("admin_logout_text"), true, 'admin_logout.php', 'dash'); } elseif ($PAGE_DATA_ARR['created'] === false && ($go == 'login' || empty($go))) { $go = 'login'; $PAGE_DATA_ARR = createpage($this->text['menu']->get("admin_login_text"), true, 'admin_login.php', 'dash'); } elseif ($PAGE_DATA_ARR['created'] === false) { $go = '404'; $PAGE_DATA_ARR = createpage($this->text['menu']->get("admin_error_page_title"), true, 'admin_404.php', 'error'); } // Get Special Page Lang-Text-Files $page_lang = new Lang($this->config->config('language_text'), 'admin/' . substr($PAGE_DATA_ARR['file'], 0, -4)); $common_lang = $this->text['admin']; // initialise template system $PAGE_DATA_ARR['template'] = new \adminpage($PAGE_DATA_ARR['file'], $page_lang, $common_lang); // Define Constant define('ACP_GO', $go); return $PAGE_DATA_ARR; }
/** * @param UriInterface $uri * @return UriInterface * @throws \ErrorException */ protected function forward_aliases(UriInterface $uri) { // strip beginning / $path = substr($uri->getPath(), 1); $aliases = $this->db->conn()->prepare(<<<SQL SELECT `alias_go`, `alias_forward_to` FROM `{$this->db->getPrefix()}aliases` WHERE `alias_active` = 1 AND `alias_go` = ? SQL ); $aliases->execute(array($path)); $aliases = $aliases->fetchAll(\PDO::FETCH_ASSOC); foreach ($aliases as $alias) { if ($path == $alias['alias_go']) { $path = $alias['alias_forward_to']; } } return $uri->withPath('/' . $path); }