/** * gym_set_default( $mode, $module, $action, $submit = false, $silent = false, $uninstall = false ) * Set default values for modules */ function gym_set_default($mode, $module, $action, $submit = false, $silent = false, $uninstall = false) { global $user, $phpbb_root_path, $phpEx; $post_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : array(); $this->new_config['reset_all'] = $reset_all = isset($post_array['reset_all']) ? $post_array['reset_all'] : false; if ($silent) { $reset_all = true; } if ($submit) { if ($mode === 'main') { // Reset all seting for all output and all modules foreach ($this->modes as $output_mode) { // List the output modes $this->gym_get_modules($output_mode); foreach ($this->gym_modules[$output_mode] as $type_module) { // List modules from each output mode if (!empty($post_array[$output_mode . '_' . $type_module . '_reset']) || $reset_all) { // Grabb the data $this->gym_module_acp($output_mode, $type_module); foreach ($this->gym_modules_acp[$output_mode][$type_module]['info']['actions'] as $module_action) { foreach ($this->gym_modules_acp[$output_mode][$type_module][$module_action]['default'] as $module_config => $default_value) { // In the end list possible options for this module's option set // Update config if ($uninstall) { rem_gym_config($module_config, $this->gym_config); } else { set_gym_config($module_config, $default_value, $output_mode, $this->gym_config); } } } } } } } elseif ($module === 'main') { // Only looking for one output type modules foreach ($this->gym_modules[$mode] as $type_module) { // add the output types modules if (!empty($post_array[$mode . '_' . $type_module . '_reset']) || $reset_all) { // Grabb the data $this->gym_module_acp($mode, $type_module); foreach ($this->gym_modules_acp[$mode][$type_module]['info']['actions'] as $module_action) { foreach ($this->gym_modules_acp[$mode][$type_module][$module_action]['default'] as $module_config => $default_value) { // Update config if ($uninstall) { rem_gym_config($module_config, $this->gym_config); } else { set_gym_config($module_config, $default_value, $mode, $this->gym_config); } } } } } } else { // Only reset this module config $this->gym_module_acp($mode, $module); // Allow modules with no acp if (!empty($this->gym_modules_acp[$mode][$module]['info'])) { foreach ($this->gym_modules_acp[$mode][$module]['info']['actions'] as $module_action) { foreach ($this->gym_modules_acp[$mode][$module][$module_action]['default'] as $module_config => $default_value) { if (!empty($post_array[$mode . '_' . $module . '_' . $module_action . '_reset']) || $reset_all) { // Update config if ($uninstall) { rem_gym_config($module_config, $this->gym_config); } else { set_gym_config($module_config, $default_value, $mode, $this->gym_config); } } } } } } $this->clear_all_cache(); unset($post_array); if (!$silent) { trigger_error($user->lang['CONFIG_UPDATED'] . $this->back_to_prev()); } else { return; } } // Adjust language variable a bit $user->lang['GYM_RESET'] = sprintf($user->lang['GYM_RESET'], $user->lang[strtoupper($mode)]); $user->lang['GYM_RESET_EXPLAIN'] = sprintf($user->lang['GYM_RESET_EXPLAIN'], $user->lang[strtoupper($mode)]); $display_vars = array('title' => 'GYM_RESET'); $i = 1; if ($mode === 'main') { // Reset all seting for all output and all modules foreach ($this->modes as $output_mode) { // List the output types modules $this->gym_get_modules($output_mode); $display_vars['vars']['legend' . $i] = strtoupper($output_mode); $i++; foreach ($this->gym_modules[$output_mode] as $type_module) { // Then the modules // Grabb the data $this->gym_module_acp($output_mode, $type_module); // Then the associated language files if any if (!empty($this->gym_modules_acp[$output_mode][$type_module]['info']['lang_file'])) { $user->add_lang('gym_sitemaps/acp/' . $this->gym_modules_acp[$output_mode][$type_module]['info']['lang_file']); } $var_key = $output_mode . '_' . $type_module . '_reset'; $this->new_config[$var_key] = 0; $display_vars['vars'][$var_key] = array('lang' => strtoupper($var_key), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true); } } } elseif ($module === 'main') { // Only looking for one output type modules foreach ($this->gym_modules[$mode] as $type_module) { // add the output types modules // Grabb the data $this->gym_module_acp($mode, $type_module); $display_vars['vars']['legend' . $i] = strtoupper($mode . '_' . $type_module); $i++; $var_key = $mode . '_' . $type_module . '_reset'; $this->new_config[$var_key] = 0; $display_vars['vars'][$var_key] = array('lang' => strtoupper($var_key), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true); } } else { // Only reset this module config $this->gym_module_acp($mode, $module); $display_vars['vars']['legend' . $i] = strtoupper($mode . '_' . $module) . '_RESET'; $i++; // Grabb the data foreach ($this->gym_modules_acp[$mode][$module]['info']['actions'] as $module_action) { if (!empty($this->gym_modules_acp[$mode][$module][$module_action]['display_vars']['vars'])) { $var_key = $mode . '_' . $module . '_' . $module_action . '_reset'; $this->new_config[$var_key] = 0; $display_vars['vars'][$var_key] = array('lang' => strtoupper($var_key), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true); } } } $display_vars['vars']['legend' . $i] = 'GYM_RESET_ALL'; $i++; $display_vars['vars']['reset_all'] = array('lang' => 'GYM_RESET_ALL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true); return $display_vars; }
/** * Sends an email to the board administrator with their password and some useful links */ function final_stage($mode, $sub) { global $auth, $config, $db, $user, $template, $user, $phpbb_root_path, $phpEx, $phpbb_seo, $cache; $update_info = ''; if (!sizeof($this->errors)) { if ($mode != 'uninstall_gym_sitemaps') { set_gym_config('gym_version', $this->version, 'main', $this->old_config); $this->config_report[] = "SET <b>gym_version</b> to {$this->version}"; set_config('gym_installed', 1); } else { set_config('gym_installed', 0); } add_log('admin', 'SEO_LOG_' . strtoupper($mode), $this->version); } else { set_config('gym_installed', 0); add_log('admin', 'SEO_LOG_' . strtoupper($mode) . '_FAIL', $this->errors); $cache->purge(); $this->p_master->error($user->lang['SEO_ERROR_INSTALL'] . '<br/><pre>' . implode('<br/>', $this->errors) . '</pre>', __LINE__, __FILE__); } $cache->purge(); $this->page_title = $user->lang['STAGE_FINAL']; if ($mode != 'uninstall_gym_sitemaps') { if ($mode == 'update_gym_sitemaps') { $key = 'UPDATE'; $lang_key = strpos($user->lang_name, 'fr') !== false ? 'FR' : ''; if ($update_infos = @file("./docs/update_from_last{$lang_key}.txt")) { foreach ($update_infos as $line) { $line = str_replace(array("\r", "\n"), '', utf8_htmlspecialchars(is_utf8($line) ? $line : utf8_recode($line, 'iso-8859-1'))); $update_info .= (preg_match('`^#`', $line) ? "<b style=\"color:blue;\">{$line}</b>" : $line) . '<br/>'; } } } else { $key = 'INSTALL'; } $submit_action = append_sid($phpbb_root_path . 'adm/index.' . $phpEx . '?sid=' . $user->session_id); $title = $user->lang['SEO_INSTALL_CONGRATS']; $body = sprintf($user->lang["SEO_{$key}_CONGRATS_EXPLAIN"], $this->modrtype_lang['link'], $this->version) . '<br/>' . implode('<br/>', $this->config_report) . "<br/><br/><hr/><pre>{$update_info}</pre>"; } else { $submit_action = append_sid($phpbb_root_path . 'index.' . $phpEx); $title = $user->lang['UN_SEO_INSTALL_CONGRATS']; $body = sprintf($user->lang['UN_SEO_INSTALL_CONGRATS_EXPLAIN'], $this->modrtype_lang['link'], $this->version); } $template->assign_vars(array('TITLE' => $title, 'BODY' => $body, 'L_SUBMIT' => $user->lang['SEO_FINAL_' . strtoupper($mode)], 'U_ACTION' => $submit_action)); }