public function main($id, $mode) { global $db, $user, $src_admin_path, $src_root_path, $phpEx, $template, $request, $cache, $auth, $config; $this->db = $db; $this->user = $user; $this->template = $template; $this->request = $request; $this->cache = $cache; $this->auth = $auth; $this->config = $config; $this->src_root_path = $src_root_path; $this->php_ext = $phpEx; $this->default_style = $config['default_style']; $this->styles_path = $this->src_root_path . $this->styles_path_absolute . '/'; $this->u_base_action = append_sid("{$src_admin_path}index.{$this->php_ext}", "i={$id}"); $this->s_hidden_fields = array('mode' => $mode); $this->user->add_lang('acp/styles'); $this->tpl_name = 'acp_styles'; $this->page_title = 'ACP_CAT_STYLES'; $this->mode = $mode; $action = $this->request->variable('action', ''); $post_actions = array('install', 'activate', 'deactivate', 'uninstall'); foreach ($post_actions as $key) { if ($this->request->is_set_post($key)) { $action = $key; } } // The uninstall action uses confirm_box() to verify the validity of the request, // so there is no need to check for a valid token here. if (in_array($action, $post_actions) && $action != 'uninstall') { $is_valid_request = check_link_hash($request->variable('hash', ''), $action) || check_form_key('styles_management'); if (!$is_valid_request) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } } if ($action != '') { $this->s_hidden_fields['action'] = $action; } $this->template->assign_vars(array('U_ACTION' => $this->u_base_action, 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields))); // Execute actions switch ($action) { case 'install': $this->action_install(); return; case 'uninstall': $this->action_uninstall(); return; case 'activate': $this->action_activate(); return; case 'deactivate': $this->action_deactivate(); return; case 'details': $this->action_details(); return; default: $this->frontend(); } }
/** * Fill in the plupload configuration options in the template * * @param \src\cache\service $cache * @param \src\template\template $template * @param string $s_action The URL to submit the POST data to * @param int $forum_id The ID of the forum * @param int $max_files Maximum number of files allowed. 0 for unlimited. * * @return null */ public function configure(\src\cache\service $cache, \src\template\template $template, $s_action, $forum_id, $max_files) { $filters = $this->generate_filter_string($cache, $forum_id); $chunk_size = $this->get_chunk_size(); $resize = $this->generate_resize_string(); $template->assign_vars(array('S_RESIZE' => $resize, 'S_PLUPLOAD' => true, 'FILTERS' => $filters, 'CHUNK_SIZE' => $chunk_size, 'S_PLUPLOAD_URL' => htmlspecialchars_decode($s_action), 'MAX_ATTACHMENTS' => $max_files, 'ATTACH_ORDER' => $this->config['display_order'] ? 'asc' : 'desc', 'L_TOO_MANY_ATTACHMENTS' => $this->user->lang('TOO_MANY_ATTACHMENTS', $max_files))); $this->user->add_lang('plupload'); }
/** * Wrapper for \acp_modules::get_module_infos() * * @param string $class Module Class * @param string $basename Module Basename * @return array Module Information * @throws \src\db\migration\exception */ protected function get_module_info($class, $basename) { if (!class_exists('acp_modules')) { include $this->src_root_path . 'includes/acp/acp_modules.' . $this->php_ext; $this->user->add_lang('acp/modules'); } $acp_modules = new \acp_modules(); $module = $acp_modules->get_module_infos($basename, $class, true); if (empty($module)) { throw new \src\db\migration\exception('MODULE_INFO_FILE_NOT_EXIST', $class, $basename); } return array_pop($module); }
/** * Obtains the latest version information * * @param bool $force_update Ignores cached data. Defaults to false. * @param bool $force_cache Force the use of the cache. Override $force_update. * @return string Version info, includes stable and unstable data * @throws \RuntimeException */ public function get_versions($force_update = false, $force_cache = false) { $cache_file = '_versioncheck_' . $this->host . $this->path . $this->file; $info = $this->cache->get($cache_file); if ($info === false && $force_cache) { throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL')); } else { if ($info === false || $force_update) { try { $info = $this->file_downloader->get($this->host, $this->path, $this->file); } catch (\src\exception\runtime_exception $exception) { $prepare_parameters = array_merge(array($exception->getMessage()), $exception->get_parameters()); throw new \RuntimeException(call_user_func_array(array($this->user, 'lang'), $prepare_parameters)); } $error_string = $this->file_downloader->get_error_string(); if (!empty($error_string)) { throw new \RuntimeException($error_string); } $info = json_decode($info, true); // Sanitize any data we retrieve from a server if (!empty($info)) { $json_sanitizer = function (&$value, $key) { $type_cast_helper = new \src\request\type_cast_helper(); $type_cast_helper->set_var($value, $value, gettype($value), true); }; array_walk_recursive($info, $json_sanitizer); } if (empty($info['stable']) && empty($info['unstable'])) { $this->user->add_lang('acp/common'); throw new \RuntimeException($this->user->lang('VERSIONCHECK_FAIL')); } $info['stable'] = empty($info['stable']) ? array() : $info['stable']; $info['unstable'] = empty($info['unstable']) ? $info['stable'] : $info['unstable']; $this->cache->put($cache_file, $info, 86400); // 24 hours } } return $info; }