function main($id, $mode) { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $phpbb_seo; // Start the phpbb_seo class if (empty($phpbb_seo)) { include_once $phpbb_root_path . 'phpbb_seo/phpbb_seo_class.' . $phpEx; $phpbb_seo = new phpbb_seo(); } $user->add_lang('mods/acp_phpbb_seo'); $action = request_var('action', ''); $submit = isset($_POST['submit']) ? true : false; $form_key = 'acp_board'; add_form_key($form_key); $display_vars = array(); // --> Zero Dupe if (@isset($phpbb_seo->seo_opt['zero_dupe'])) { $this->multiple_options['zero_dupe']['post_redir_values'] = array('off' => 'off', 'post' => 'post', 'guest' => 'guest', 'all' => 'all'); // do not change $this->multiple_options['zero_dupe']['post_redir_lang'] = array('off' => $user->lang['ACP_ZERO_DUPE_OFF'], 'post' => $user->lang['ACP_ZERO_DUPE_MSG'], 'guest' => $user->lang['ACP_ZERO_DUPE_GUEST'], 'all' => $user->lang['ACP_ZERO_DUPE_ALL']); // do not change } // <-- Mod rewrite selector if ($phpbb_seo->modrtype == 1) { $this->seo_unset_opts = array('cache_layer', 'rem_ids'); } elseif (!$phpbb_seo->seo_opt['cache_layer']) { $this->seo_unset_opts = array('rem_ids'); } $this->modrtype_lang = $this->set_phpbb_seo_links(); $this->multiple_options['modrtype_lang'] = $this->modrtype_lang['titles']; if (@isset($phpbb_seo->seo_opt['modrtype'])) { $this->multiple_options['modrtype_values'] = array(1 => 1, 2 => 2, 3 => 3); // do not change; } // <-- Mod rewrite selector foreach ($this->seo_unset_opts as $opt) { if ($optkey = array_search($opt, $phpbb_seo->cache_config['dynamic_options'])) { unset($phpbb_seo->cache_config['dynamic_options'][$optkey]); } } // We need shorter URLs with Virtual Folder Trick if ($phpbb_seo->seo_opt['virtual_folder']) { $this->lengh_limit = 20; $this->word_limit = 3; } else { $this->lengh_limit = 30; $this->word_limit = 5; } $related_installed = false; switch ($mode) { case 'settings': $this->write_type = 'forum'; $display_vars['title'] = 'ACP_PHPBB_SEO_CLASS'; $user->lang['ACP_PHPBB_SEO_CLASS_EXPLAIN'] = sprintf($user->lang['ACP_PHPBB_SEO_CLASS_EXPLAIN'], $this->modrtype_lang['ulink'], $this->modrtype_lang['uforumlink'], '</p><hr/><p><b>' . $user->lang['ACP_PHPBB_SEO_MODE'] . ' : ' . $this->modrtype_lang['link'] . ' - ' . $phpbb_seo->version . ' ( ' . $this->modrtype_lang['forumlink'] . ' )</b></p><hr/><p>'); $display_vars['vars'] = array(); $i = 2; $display_vars['vars']['legend1'] = 'ACP_PHPBB_SEO_CLASS'; foreach ($phpbb_seo->cache_config['dynamic_options'] as $optionname => $optionvalue) { if (@is_bool($phpbb_seo->seo_opt[$optionvalue])) { if ($optionvalue == 'virtual_root' && !$phpbb_seo->seo_path['phpbb_script']) { continue; } $display_vars['vars'][$optionvalue] = array('lang' => $optionvalue, 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true, 'lang_explain' => $optionvalue . '_explain'); $this->new_config[$optionvalue] = $phpbb_seo->seo_opt[$optionvalue]; } elseif (@isset($this->multiple_options[$optionvalue . '_values'])) { $this->dyn_select[$optionvalue] = $this->multiple_options[$optionvalue . '_values']; $display_vars['vars'][$optionvalue] = array('lang' => $optionvalue, 'validate' => 'string', 'type' => 'select', 'method' => 'select_string', 'explain' => true, 'lang_explain' => $optionvalue . '_explain'); $this->new_config[$optionvalue] = $phpbb_seo->seo_opt[$optionvalue]; } elseif (is_array($optionvalue)) { $display_vars['vars']['legend' . $i] = $optionname; $i++; foreach ($optionvalue as $key => $value) { $this->array_type_cfg[$optionname . '_' . $key] = array('main' => $optionname, 'sub' => $key); if (is_bool($value)) { $display_vars['vars'][$optionname . '_' . $key] = array('lang' => $optionname . '_' . $key, 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true, 'lang_explain' => $optionname . '_' . $key . '_explain'); $this->new_config[$optionname . '_' . $key] = $phpbb_seo->seo_opt[$optionname][$key]; } elseif (@isset($this->multiple_options[$optionname][$key . '_values'])) { $this->dyn_select[$optionname . '_' . $key] = $this->multiple_options[$optionname][$key . '_values']; $display_vars['vars'][$optionname . '_' . $key] = array('lang' => $optionname . '_' . $key, 'validate' => 'string', 'type' => 'select', 'method' => 'select_string', 'explain' => true, 'lang_explain' => $optionname . '_' . $key . '_explain'); $this->new_config[$optionname . '_' . $key] = $phpbb_seo->seo_opt[$optionname][$key]; } else { $display_vars['vars'][$optionname . '_' . $key] = array('lang' => $optionname . '_' . $key, 'validate' => 'string:0:50', 'type' => 'text:50:50', 'explain' => true, 'lang_explain' => $optionname . '_' . $key . '_explain'); $this->new_config[$optionname . '_' . $key] = $phpbb_seo->seo_opt[$optionname][$key]; } } } } break; case 'forum_url': // used for cache $this->write_type = 'forum'; $forbidden = array($phpbb_seo->seo_static['forum'], $phpbb_seo->seo_static['global_announce'], $phpbb_seo->seo_static['user'], $phpbb_seo->seo_static['topic'], $phpbb_seo->seo_static['atopic'], $phpbb_seo->seo_static['utopic'], $phpbb_seo->seo_static['leaders'], $phpbb_seo->seo_static['post'], $phpbb_seo->seo_static['group'], $phpbb_seo->seo_static['npost'], $phpbb_seo->seo_static['index']); if ($phpbb_seo->modrtype == 1 || !$phpbb_seo->seo_opt['cache_layer']) { trigger_error($user->lang['ACP_NO_FORUM_URL'] . preg_replace('`(&|&|\\?)mode=forum_url`i', '', adm_back_link($this->u_action))); break; } $display_vars['title'] = 'ACP_FORUM_URL'; $user->lang['ACP_FORUM_URL_EXPLAIN'] .= '</p><hr/><p><b>' . $user->lang['ACP_PHPBB_SEO_VERSION'] . ' : ' . $this->modrtype_lang['link'] . ' - ' . $phpbb_seo->version . ' ( ' . $this->modrtype_lang['forumlink'] . ' )</b></p><hr/><p>'; $display_vars['vars'] = array(); $display_vars['vars']['legend1'] = 'ACP_FORUM_URL'; $sql = "SELECT forum_id, forum_name\n\t\t\t\t\tFROM " . FORUMS_TABLE . "\n\t\t\t\t\tORDER BY left_id ASC"; $result = $db->sql_query($sql); $forum_url_title = $error_cust = ''; while ($row = $db->sql_fetchrow($result)) { $this->forum_ids[$row['forum_id']] = $row['forum_name']; } $db->sql_freeresult($result); // take care of deleted forums foreach ($phpbb_seo->cache_config['forum'] as $fid => $null) { if (!isset($this->forum_ids[$fid])) { unset($phpbb_seo->cache_config['forum'][$fid]); } } foreach ($this->forum_ids as $forum_id => $forum_name) { $error_cust = ''; // Is the URL cached already ? if (empty($phpbb_seo->cache_config['forum'][$forum_id])) { // Suggest the one from the title $forum_url_title = $phpbb_seo->format_url($forum_name, $phpbb_seo->seo_static['forum']); if (!in_array($forum_url_title, $forbidden)) { if (array_search($forum_url_title, $phpbb_seo->cache_config['forum'])) { $this->new_config['forum_url' . $forum_id] = $forum_url_title . $phpbb_seo->seo_delim['forum'] . $forum_id; $error_cust = '<li> ' . sprintf($user->lang['SEO_ADVICE_DUPE'], $forum_url_title) . '</li>'; } else { $this->new_config['forum_url' . $forum_id] = $forum_url_title . (@$phpbb_seo->cache_config['settings']['rem_ids'] ? '' : $phpbb_seo->seo_delim['forum'] . $forum_id); } } else { $this->new_config['forum_url' . $forum_id] = $forum_url_title . $phpbb_seo->seo_delim['forum'] . $forum_id; $error_cust = '<li> ' . sprintf($user->lang['SEO_ADVICE_RESERVED'], $forum_url_title) . '</li>'; } $title = '<b style="color:red">' . $forum_name . ' - ID ' . $forum_id . '</b>'; $status_msg = '<b style="color:red">' . $user->lang['SEO_CACHE_URL_NOT_OK'] . '</b>'; $status_msg .= '<br/><span style="color:red">' . $user->lang['SEO_CACHE_URL'] . ' :</span> ' . $this->new_config['forum_url' . $forum_id] . $phpbb_seo->seo_ext['forum']; $display_vars['vars']['forum_url' . $forum_id] = array('lang' => $title, 'validate' => 'string', 'type' => 'custom', 'method' => 'forum_url_input', 'explain' => true, 'lang_explain_custom' => $status_msg, 'append' => $this->seo_advices($this->new_config['forum_url' . $forum_id], $forum_id, false, $error_cust)); } else { // Cached $this->new_config['forum_url' . $forum_id] = $phpbb_seo->cache_config['forum'][$forum_id]; $title = '<b style="color:green">' . $forum_name . ' - ID ' . $forum_id . '</b>'; $status_msg = '<span style="color:green">' . $user->lang['SEO_CACHE_URL_OK'] . ' :</span> <b style="color:green">' . $this->new_config['forum_url' . $forum_id] . '</b>'; $status_msg .= '<br/><span style="color:green">' . $user->lang['SEO_CACHE_URL'] . ' :</span> ' . $this->new_config['forum_url' . $forum_id] . $phpbb_seo->seo_ext['forum']; $display_vars['vars']['forum_url' . $forum_id] = array('lang' => $title, 'validate' => 'string:0:100', 'type' => 'custom', 'method' => 'forum_url_input', 'explain' => true, 'lang_explain_custom' => $status_msg, 'append' => $this->seo_advices($this->new_config['forum_url' . $forum_id], $forum_id, true)); } } break; case 'htaccess': $this->write_type = 'htaccess'; $display_vars['title'] = 'ACP_HTACCESS'; $user->lang['ACP_HTACCESS_EXPLAIN'] .= '</p><hr/><p><b>' . $user->lang['ACP_PHPBB_SEO_VERSION'] . ' : ' . $this->modrtype_lang['link'] . ' - ' . $phpbb_seo->version . ' ( ' . $this->modrtype_lang['forumlink'] . ' )</b></p><p>'; $display_vars['vars'] = array(); $display_vars['vars']['legend1'] = 'ACP_HTACCESS'; $display_vars['vars']['save'] = array('lang' => 'SEO_HTACCESS_SAVE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true); $display_vars['vars']['more_options'] = array('lang' => 'SEO_MORE_OPTION', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true); $this->new_config['save'] = false; $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config; $this->new_config['more_options'] = isset($cfg_array['more_options']) ? $cfg_array['more_options'] : false; $this->new_config['slash'] = isset($cfg_array['slash']) ? $cfg_array['slash'] : false; $this->new_config['wslash'] = isset($cfg_array['wslash']) ? $cfg_array['wslash'] : false; $this->new_config['rbase'] = isset($cfg_array['rbase']) ? $cfg_array['rbase'] : false; if ($this->new_config['more_options']) { $display_vars['vars']['slash'] = array('lang' => 'SEO_HTACCESS_SLASH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true); $display_vars['vars']['wslash'] = array('lang' => 'SEO_HTACCESS_WSLASH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true); if ($phpbb_seo->seo_path['phpbb_script'] && !$phpbb_seo->seo_opt['virtual_root']) { $display_vars['vars']['rbase'] = array('lang' => 'SEO_HTACCESS_RBASE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true); } } // Dirty yet simple templating $user->lang['ACP_HTACCESS_EXPLAIN'] .= $this->seo_htaccess(); break; case 'extended': $display_vars = array('title' => 'ACP_SEO_EXTENDED', 'vars' => array('legend1' => 'SEO_EXTERNAL_LINKS', 'seo_ext_links' => array('lang' => 'SEO_EXTERNAL_LINKS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true, 'default' => 1), 'seo_ext_subdomain' => array('lang' => 'SEO_EXTERNAL_SUBDOMAIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true, 'default' => 0), 'seo_ext_classes' => array('lang' => 'SEO_EXTERNAL_CLASSES', 'validate' => 'string', 'type' => 'text:40:250', 'explain' => true, 'default' => ''))); // Related topics if (file_exists($phpbb_root_path . "phpbb_seo/phpbb_seo_related.{$phpEx}")) { $related_installed = true; $user->add_lang('mods/phpbb_seo_related_install'); $display_vars['vars'] += array('legend2' => 'RELATED_TOPICS', 'seo_related' => array('lang' => 'SEO_RELATED', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true, 'append' => !empty($config['seo_related']) ? '<br/>' . (!empty($config['seo_related_fulltext']) ? $user->lang['FULLTEXT_INSTALLED'] : $user->lang['FULLTEXT_NOT_INSTALLED']) : '', 'default' => 0), 'seo_related_check_ignore' => array('lang' => 'SEO_RELATED_CHECK_IGNORE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true, 'default' => 0), 'seo_related_limit' => array('lang' => 'SEO_RELATED_LIMIT', 'validate' => 'int:2:25', 'type' => 'text:3:4', 'explain' => true, 'default' => 5), 'seo_related_allforums' => array('lang' => 'SEO_RELATED_ALLFORUMS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true, 'default' => 0)); } // dynamic meta tag mod if (class_exists('seo_meta')) { $display_vars['vars'] += array('legend3' => 'SEO_META', 'seo_meta_title' => array('lang' => 'SEO_META_TITLE', 'validate' => 'string:0:225', 'type' => 'text:40:250', 'explain' => true, 'default' => $config['sitename']), 'seo_meta_desc' => array('lang' => 'SEO_META_DESC', 'validate' => 'string:0:225', 'type' => 'text:40:250', 'explain' => true, 'default' => $config['site_desc']), 'seo_meta_desc_limit' => array('lang' => 'SEO_META_DESC_LIMIT', 'validate' => 'int:5:40', 'type' => 'text:3:4', 'explain' => true, 'default' => 25), 'seo_meta_bbcode_filter' => array('lang' => 'SEO_META_BBCODE_FILTER', 'validate' => 'string:0:225', 'type' => 'text:40:250', 'explain' => true, 'default' => 'img|url|flash|code'), 'seo_meta_keywords' => array('lang' => 'SEO_META_KEYWORDS', 'validate' => 'string:0:225', 'type' => 'text:40:250', 'explain' => true, 'default' => $config['site_desc']), 'seo_meta_keywords_limit' => array('lang' => 'SEO_META_KEYWORDS_LIMIT', 'validate' => 'int:5:40', 'type' => 'text:3:4', 'explain' => true, 'default' => 15), 'seo_meta_min_len' => array('lang' => 'SEO_META_MIN_LEN', 'validate' => 'int:0:10', 'type' => 'text:3:4', 'explain' => true, 'default' => 2), 'seo_meta_check_ignore' => array('lang' => 'SEO_META_CHECK_IGNORE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true, 'default' => 0), 'seo_meta_lang' => array('lang' => 'SEO_META_LANG', 'validate' => 'lang', 'type' => 'select', 'method' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => true, 'default' => $config['default_lang']), 'seo_meta_copy' => array('lang' => 'SEO_META_COPY', 'validate' => 'string:0:225', 'type' => 'text:40:250', 'explain' => true, 'default' => $config['sitename']), 'seo_meta_file_filter' => array('lang' => 'SEO_META_FILE_FILTER', 'validate' => 'string:0:225', 'type' => 'text:40:250', 'explain' => true, 'default' => 'ucp'), 'seo_meta_get_filter' => array('lang' => 'SEO_META_GET_FILTER', 'validate' => 'string:0:225', 'type' => 'text:40:250', 'explain' => true, 'default' => 'style,hilit,sid'), 'seo_meta_robots' => array('lang' => 'SEO_META_ROBOTS', 'validate' => 'string:0:225', 'type' => 'text:25:150', 'explain' => true, 'default' => 'index,follow'), 'seo_meta_noarchive' => array('lang' => 'SEO_META_NOARCHIVE', 'validate' => 'string:0:225', 'multiple_validate' => 'int', 'type' => 'custom', 'method' => 'select_multiple', 'params' => array('{CONFIG_VALUE}', '{KEY}', $this->forum_select()), 'explain' => true, 'default' => '')); } // Optimal title if (isset($user->lang['Page'])) { $display_vars['vars'] += array('legend4' => 'SEO_PAGE_TITLES', 'seo_append_sitename' => array('lang' => 'SEO_APPEND_SITENAME', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true, 'default' => 0)); } // install if necessary foreach ($display_vars['vars'] as $config_name => $config_setup) { if (strpos($config_name, 'legend') !== false) { continue; } if (!isset($config[$config_name])) { set_config($config_name, $config_setup['default']); unset($display_vars['vars'][$config_name]['default']); } } $this->new_config = $config; break; default: trigger_error('NO_MODE', E_USER_ERROR); break; } $error = array(); $seo_msg = array(); $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config; if ($submit && !check_form_key($form_key)) { $error[] = $user->lang['FORM_INVALID']; } // We validate the complete config if whished validate_config_vars($display_vars['vars'], $cfg_array, $error); // Do not write values if there is an error if (!empty($error)) { $submit = false; } $additional_notes = ''; // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... foreach ($display_vars['vars'] as $config_name => $cfg_setup) { if (!isset($cfg_array[$config_name]) && @$cfg_setup['method'] != 'select_multiple' || strpos($config_name, 'legend') !== false) { continue; } // Handle multiple select options if (!empty($cfg_setup['method']) && $cfg_setup['method'] == 'select_multiple') { if (isset($_POST['multiple_' . $config_name])) { $m_values = utf8_normalize_nfc(request_var('multiple_' . $config_name, array('' => ''))); $validate_int = !empty($cfg_setup['multiple_validate']) && $cfg_setup['multiple_validate'] == 'int' ? true : false; foreach ($m_values as $k => $v) { if ($validate_int) { $v = max(0, (int) $v); } if (empty($v)) { unset($m_values[$k]); } else { $m_values[$k] = $v; } } sort($m_values); $this->new_config[$config_name] = $m_values; $config_value = implode(',', $m_values); if (strlen($config_value) > 255) { $error[] = sprintf($user->lang['SETTING_TOO_LONG'], $user->lang[$cfg_setup['lang']], 255); } $submit = empty($error); } else { if ($submit) { $this->new_config[$config_name] = array(); $config_value = ''; } else { $config_value = $this->new_config[$config_name]; $this->new_config[$config_name] = !empty($config_value) ? explode(',', $config_value) : array(); } } } else { $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; } if ($submit) { // In case we deal with forum URLs if ($mode == 'forum_url' && preg_match('`^forum_url([0-9]+)$`', $config_name, $matches)) { // Check if this is an actual forum_id if (isset($this->forum_ids[$matches[1]])) { $forum_id = intval($matches[1]); $config_value = $phpbb_seo->format_url($config_value, $phpbb_seo->seo_static['forum']); // Remove delim if required while (preg_match('`^[a-z0-9_-]+' . $phpbb_seo->seo_delim['forum'] . '[0-9]+$`i', $config_value)) { $config_value = preg_replace('`^([a-z0-9_-]+)' . $phpbb_seo->seo_delim['forum'] . '[0-9]+$`i', '\\1', $config_value); if (@$phpbb_seo->cache_config['settings']['rem_ids']) { $seo_msg['SEO_ADVICE_DELIM_REM'] = '<li> ' . $user->lang['SEO_ADVICE_DELIM_REM'] . '</li>'; } } // Forums cannot end with the pagination param while (preg_match('`^[a-z0-9_-]+' . $phpbb_seo->seo_delim['start'] . '[0-9]+$`i', $config_value)) { $config_value = preg_replace('`^([a-z0-9_-]+)' . $phpbb_seo->seo_delim['start'] . '[0-9]+$`i', "\\1", $config_value); $seo_msg['SEO_ADVICE_START'] = '<li> ' . $user->lang['SEO_ADVICE_START'] . '</li>'; } // Only update if the value is not a static one for forums if (!in_array($config_value, $forbidden)) { // and updated (sic) if ($config_value != @$phpbb_seo->cache_config['forum'][$forum_id]) { // and if not already set if (!array_search($config_value, $phpbb_seo->cache_config['forum'])) { $phpbb_seo->cache_config['forum'][$forum_id] = $config_value . (@$phpbb_seo->cache_config['settings']['rem_ids'] ? '' : $phpbb_seo->seo_delim['forum'] . $forum_id); } else { $seo_msg['SEO_ADVICE_DUPE_' . $forum_id] = '<li> ' . sprintf($user->lang['SEO_ADVICE_DUPE'], $config_value) . '</li>'; } } } else { $seo_msg['SEO_ADVICE_RESERVED_' . $forum_id] = '<li> ' . sprintf($user->lang['SEO_ADVICE_RESERVED'], $config_value) . '</li>'; } } } elseif ($mode == 'settings') { if (isset($this->array_type_cfg[$config_name]) && isset($phpbb_seo->seo_opt[$this->array_type_cfg[$config_name]['main']][$this->array_type_cfg[$config_name]['sub']])) { if (is_bool($phpbb_seo->seo_opt[$this->array_type_cfg[$config_name]['main']][$this->array_type_cfg[$config_name]['sub']])) { $phpbb_seo->cache_config['settings'][$this->array_type_cfg[$config_name]['main']][$this->array_type_cfg[$config_name]['sub']] = $config_value == 1 ? true : false; } elseif (is_numeric($phpbb_seo->seo_opt[$this->array_type_cfg[$config_name]['main']][$this->array_type_cfg[$config_name]['sub']])) { $phpbb_seo->cache_config['settings'][$this->array_type_cfg[$config_name]['main']][$this->array_type_cfg[$config_name]['sub']] = intval($config_value); } elseif (is_string($phpbb_seo->seo_opt[$this->array_type_cfg[$config_name]['main']][$this->array_type_cfg[$config_name]['sub']])) { $phpbb_seo->cache_config['settings'][$this->array_type_cfg[$config_name]['main']][$this->array_type_cfg[$config_name]['sub']] = $config_value; } } elseif (isset($phpbb_seo->seo_opt[$config_name])) { if (is_bool($phpbb_seo->seo_opt[$config_name])) { $phpbb_seo->cache_config['settings'][$config_name] = $config_value == 1 ? true : false; } elseif (is_numeric($phpbb_seo->seo_opt[$config_name])) { $phpbb_seo->cache_config['settings'][$config_name] = intval($config_value); } elseif (is_string($phpbb_seo->seo_opt[$config_name])) { $phpbb_seo->cache_config['settings'][$config_name] = $config_value; } } // Let's make sure that the proper field was added to the topic table if ($config_name === 'sql_rewrite' && $config_value == 1 && !$phpbb_seo->seo_opt['sql_rewrite']) { if (!class_exists('phpbb_db_tools')) { require $phpbb_root_path . 'includes/db/db_tools.' . $phpEx; } $db_tools = new phpbb_db_tools($db); $db_tools->db->sql_return_on_error(true); if (!$db_tools->sql_column_exists(TOPICS_TABLE, 'topic_url')) { $db_tools->sql_column_add(TOPICS_TABLE, 'topic_url', array('VCHAR', '')); } $additional_notes = sprintf($user->lang['SYNC_TOPIC_URL_NOTE'], '<a href="' . $phpbb_seo->seo_path['phpbb_url'] . 'phpbb_seo/sync_url.' . $phpEx . '" onclick="window.open(this.href); return false;">', '</a>'); if ($db_tools->db->sql_error_triggered) { $error[] = '<b>' . $user->lang['sql_rewrite'] . '</b> : ' . $user->lang['SEO_SQL_ERROR'] . ' [ ' . $db_tools->db->sql_layer . ' ] : ' . $db_tools->db->sql_error_returned['message'] . ' [' . $db_tools->db->sql_error_returned['code'] . ']' . '<br/>' . $user->lang['SEO_SQL_TRY_MANUALLY'] . '<br/>' . $db_tools->db->sql_error_sql; $submit = false; } $db_tools->db->sql_return_on_error(false); } // Let's make sure the proper index is added for the no dupe (in case it is installed and activated) if ($config_name === 'no_dupe_on' && $config_value == 1 && !$phpbb_seo->seo_opt['no_dupe']['on']) { if (!class_exists('phpbb_db_tools')) { require $phpbb_root_path . 'includes/db/db_tools.' . $phpEx; } // in case we already started the phpbb_db_tools class above if (empty($db_tools)) { $db_tools = new phpbb_db_tools($db); } $db_tools->db->sql_return_on_error(true); $indexes = $db_tools->sql_list_index(TOPICS_TABLE); $drop_index_name = 'topic_last_post_id'; $add_index_name = 'topic_lpid'; if (in_array($drop_index_name, $indexes)) { $db_tools->sql_index_drop(TOPICS_TABLE, $drop_index_name); } if (!in_array($add_index_name, $indexes)) { // Try to override some limits - maybe it helps some... @set_time_limit(0); @ini_set('memory_limit', '128M'); $db_tools->sql_create_index(TOPICS_TABLE, $add_index_name, array('topic_last_post_id')); } if ($db_tools->db->sql_error_triggered) { $error[] = '<b>' . $user->lang['no_dupe'] . '</b> : ' . $user->lang['SEO_SQL_ERROR'] . ' [ ' . $db_tools->db->sql_layer . ' ] : ' . $db_tools->db->sql_error_returned['message'] . ' [' . $db_tools->db->sql_error_returned['code'] . ']' . '<br/>' . $user->lang['SEO_SQL_TRY_MANUALLY'] . '<br/>' . $db_tools->db->sql_error_sql; $submit = false; } $db_tools->db->sql_return_on_error(false); } } elseif ($mode == 'extended') { if ($related_installed && $config_name === 'seo_related') { $fulltext = 0; $nothing_to_do = false; if ($db->sql_layer == 'mysql4' || $db->sql_layer == 'mysqli') { $add = $remove = $alter = false; if ($config_value && !$config['seo_related']) { $alter = $add = true; } if (!$config_value && $config['seo_related']) { $alter = $remove = true; } // let's go if ($alter) { // Try to override some limits - maybe it helps some... @set_time_limit(0); @ini_set('memory_limit', '128M'); // use db_tools to check the index if (!class_exists('phpbb_db_tools')) { require $phpbb_root_path . 'includes/db/db_tools.' . $phpEx; } if (empty($db_tools)) { $db_tools = new phpbb_db_tools($db); } $indexes = $db_tools->sql_list_index(TOPICS_TABLE); if (in_array('topic_tft', $indexes)) { $nothing_to_do = $add ? true : false; $fulltext = 1; } else { $nothing_to_do = $remove ? true : false; $fulltext = 0; } // do not use db_tools since it does not support to add FullText indexes if (!$nothing_to_do) { // Here we use quite a basic approach to make sure that the index is not refused for bad reasons if ($add) { $sql = 'ALTER TABLE ' . TOPICS_TABLE . ' ADD FULLTEXT topic_tft (topic_title)'; } else { $sql = 'ALTER TABLE ' . TOPICS_TABLE . ' DROP INDEX topic_tft'; } $db->sql_return_on_error(true); $db->sql_query($sql); if ($db->sql_error_triggered) { $error[] = '<b>' . $user->lang['RELATED_TOPICS'] . '</b> : ' . $user->lang['SEO_SQL_ERROR'] . ' [ ' . $db->sql_layer . ' ] : ' . $db->sql_error_returned['message'] . ' [' . $db->sql_error_returned['code'] . ']' . '<br/>' . $user->lang['SEO_SQL_TRY_MANUALLY'] . '<br/>' . $db->sql_error_sql; $submit = false; $config_value = 0; } // make *sure* about the index ! $indexes = $db_tools->sql_list_index(TOPICS_TABLE); $fulltext = in_array('topic_tft', $indexes) ? 1 : 0; $db->sql_return_on_error(false); } } } if ($alter) { set_config('seo_related_fulltext', $fulltext); } } set_config($config_name, $config_value); } } } if (sizeof($error)) { $submit = false; } if ($submit) { if ($mode == 'htaccess') { if ($this->new_config['save']) { $this->write_cache($this->write_type); add_log('admin', 'SEO_LOG_CONFIG_' . strtoupper($mode)); } } elseif ($mode == 'extended') { add_log('admin', 'SEO_LOG_CONFIG_' . strtoupper($mode)); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } else { if ($this->write_cache($this->write_type)) { ksort($phpbb_seo->cache_config[$this->write_type]); add_log('admin', 'SEO_LOG_CONFIG_' . strtoupper($mode)); $msg = !empty($seo_msg) ? '<br /><h1 style="color:red;text-align:left;">' . $user->lang['SEO_VALIDATE_INFO'] . '</h1><ul style="text-align:left;">' . implode(' ', $seo_msg) . '</ul><br />' : ''; global $msg_long_text; $msg_long_text = $user->lang['SEO_CACHE_MSG_OK'] . $msg . adm_back_link($this->u_action); if ($additional_notes) { $msg_long_text .= "<br/><br/>{$additional_notes}"; } trigger_error(false); } else { trigger_error($user->lang['SEO_CACHE_MSG_FAIL'] . adm_back_link($this->u_action)); } } } $this->tpl_name = 'acp_board'; $this->page_title = $display_vars['title']; $phpbb_seo->seo_end(); $l_title_explain = $user->lang[$display_vars['title'] . '_EXPLAIN']; if ($mode != 'extended') { $l_title_explain .= $mode == 'htaccess' ? '' : $this->check_cache_folder($phpbb_root_path . $phpbb_seo->seo_opt['cache_folder']); } $template->assign_vars(array('L_TITLE' => $user->lang[$display_vars['title']], 'L_TITLE_EXPLAIN' => $l_title_explain, 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action)); // Output relevant page foreach ($display_vars['vars'] as $config_key => $vars) { if (!is_array($vars) && strpos($config_key, 'legend') === false) { continue; } if (strpos($config_key, 'legend') !== false) { $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars)); continue; } $type = explode(':', $vars['type']); $l_explain = ''; if ($vars['explain'] && isset($vars['lang_explain'])) { $l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain']; } elseif ($vars['explain'] && isset($vars['lang_explain_custom'])) { $l_explain = $vars['lang_explain_custom']; } elseif ($vars['explain']) { $l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : ''; } $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars))); unset($display_vars['vars'][$config_key]); } }
function nv_add_index($table, $index_name, $column) { global $db; $phpbb_db_tools = new phpbb_db_tools($db); if ($phpbb_db_tools->sql_column_exists($table, $column)) { $phpbb_db_tools->sql_create_index($table_name, $index_name, $column); } }
function main($id, $mode) { global $db, $user, $template, $cache; global $config, $pbwow_config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; // Some basic includes if (!function_exists('db_theme_data')) { include $phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx; } if (!class_exists('phpbb_db_tools')) { include $phpbb_root_path . 'includes/db/db_tools.' . $phpEx; } $db_tool = new phpbb_db_tools($db); $user->add_lang('mods/lang_pbwow_acp'); if (isset($display_vars['lang'])) { $user->add_lang($display_vars['lang']); } $this->tpl_name = 'acp_pbwow2'; // Some constants $module_version = '2.0.9'; $dbtable = defined('PBWOW2_CONFIG_TABLE') ? PBWOW2_CONFIG_TABLE : ''; $legacy_dbtable = defined('PBWOW_CONFIG_TABLE') ? PBWOW_CONFIG_TABLE : ''; $topics_table = TOPICS_TABLE; $chars_table = defined('PBWOW2_CHARS_TABLE') ? PBWOW2_CHARS_TABLE : ''; $allow_fopen = ini_get('allow_url_fopen') ? true : false; $constantsokay = $dbokay = $legacy_constants = $legacy_db_active = $legacy_topics_mod = false; $style_version = $imageset_version = $template_version = $theme_version = ''; // Check if constants have been set correctly // if yes, check if the config table exists // if yes, load the config variables if ($dbtable == $table_prefix . 'pbwow2_config') { $constantsokay = true; if ($db_tool->sql_table_exists($dbtable)) { $dbokay = true; $pbwow_config = $this->get_pbwow_config(); $this->new_config = $pbwow_config; if (!isset($pbwow_config['pbwow2_version'])) { if (isset($config['pbwow2_version']) && !empty($config['pbwow2_version'])) { $pbwow_config['pbwow2_version'] = $config['pbwow2_version']; } } } } if ($chars_table == $table_prefix . 'pbwow2_chars') { $chars_constokay = true; if ($db_tool->sql_table_exists($chars_table)) { $chars_dbokay = true; } } if ($mode == 'overview') { $cpflist = $this->get_cpf_list(); $style_root = $phpbb_root_path . 'styles/pbwow2/'; if (file_exists($style_root . 'style.cfg')) { $values = parse_cfg_file($style_root . 'style.cfg'); $style_version = isset($values['version']) ? $values['version'] : ''; } if (file_exists($style_root . 'imageset/imageset.cfg')) { $values = parse_cfg_file($style_root . 'imageset/imageset.cfg'); $imageset_version = isset($values['version']) ? $values['version'] : ''; } if (file_exists($style_root . 'template/template.cfg')) { $values = parse_cfg_file($style_root . 'template/template.cfg'); $template_version = isset($values['version']) ? $values['version'] : ''; } if (file_exists($style_root . 'theme/theme.cfg')) { $values = parse_cfg_file($style_root . 'theme/theme.cfg'); $theme_version = isset($values['version']) ? $values['version'] : ''; } $versions = $this->obtain_pbwow_version_info(request_var('versioncheck_force', false), true); // Check if old constants are still being used if (!empty($legacy_dbtable)) { $legacy_constants = true; } // Check if old table still exists if ($db_tool->sql_table_exists($legacy_dbtable) || $db_tool->sql_table_exists($table_prefix . 'pbwow_config')) { $legacy_db_active = true; } // Check if topics table has been modded if ($db_tool->sql_column_exists(TOPICS_TABLE, 'topic_first_poster_rank_img') || $db_tool->sql_column_exists(TOPICS_TABLE, 'topic_first_poster_rank_title')) { $legacy_topics_mod = true; } } /** * Validation types are: * string, int, bool, * script_path (absolute path in url - beginning with / and no trailing slash), * rpath (relative), rwpath (realtive, writeable), path (relative path, but able to escape the root), wpath (writeable) */ switch ($mode) { case 'overview': $display_vars = array('title' => 'ACP_PBWOW2_OVERVIEW_TITLE', 'vars' => array()); break; case 'config': $display_vars = array('title' => 'ACP_PBWOW_CONFIG_TITLE', 'vars' => array('legend1' => 'ACP_PBWOW_LOGO', 'logo_size_width' => array('lang' => 'PBWOW_LOGO_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'logo_size_height' => array('lang' => 'PBWOW_LOGO_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'logo_enable' => array('lang' => 'PBWOW_LOGO_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'logo_src' => array('lang' => 'PBWOW_LOGO_SRC', 'validate' => 'string', 'type' => 'text:20:255', 'explain' => true), 'logo_size' => array('lang' => 'PBWOW_LOGO_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'logo_margins' => array('lang' => 'PBWOW_LOGO_MARGINS', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => true), 'legend2' => 'ACP_PBWOW_TOPBAR', 'topbar_enable' => array('lang' => 'PBWOW_TOPBAR_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'topbar_code' => array('lang' => 'PBWOW_TOPBAR_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'topbar_fixed' => array('lang' => 'PBWOW_TOPBAR_FIXED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend3' => 'ACP_PBWOW_HEADERLINKS', 'headerlinks_enable' => array('lang' => 'PBWOW_HEADERLINKS_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'headerlinks_code' => array('lang' => 'PBWOW_HEADERLINKS_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend4' => 'ACP_PBWOW_NAVMENU', 'navmenu_enable' => array('lang' => 'PBWOW_NAVMENU_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'legend5' => 'ACP_PBWOW_IE6MESSAGE', 'ie6message_enable' => array('lang' => 'PBWOW_IE6MESSAGE_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'ie6message_code' => array('lang' => 'PBWOW_IE6MESSAGE_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend6' => 'ACP_PBWOW_VIDEOBG', 'videobg_enable' => array('lang' => 'PBWOW_VIDEOBG_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'videobg_allpages' => array('lang' => 'PBWOW_VIDEOBG_ALLPAGES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'bg_fixed' => array('lang' => 'PBWOW_BG_FIXED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend7' => 'ACP_PBWOW_BNETCHARS', 'bnetchars_enable' => array('lang' => 'PBWOW_BNETCHARS_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'bnetchars_cachetime' => array('lang' => 'PBWOW_BNETCHARS_CACHETIME', 'validate' => 'int:0', 'type' => 'text:6:6', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), 'bnetchars_timeout' => array('lang' => 'PBWOW_BNETCHARS_TIMEOUT', 'validate' => 'int:0', 'type' => 'text:1:1', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), 'legend8' => 'ACP_PBWOW_TOOLTIPS', 'wowtips_script' => array('lang' => 'PBWOW_WOWTIPS_SCRIPT', 'validate' => 'int', 'type' => 'custom', 'explain' => true, 'method' => 'select_single'), 'd3tips_script' => array('lang' => 'PBWOW_D3TIPS_SCRIPT', 'validate' => 'int', 'type' => 'custom', 'explain' => true, 'method' => 'select_single'), 'zamtips_enable' => array('lang' => 'PBWOW_ZAMTIPS_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'tooltips_region' => array('lang' => 'PBWOW_TOOLTIPS_REGION', 'validate' => 'int', 'type' => 'custom', 'explain' => true, 'method' => 'select_single'), 'tooltips_footer' => array('lang' => 'PBWOW_TOOLTIPS_FOOTER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'tooltips_local' => array('lang' => 'PBWOW_TOOLTIPS_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true))); break; case 'poststyling': $display_vars = array('title' => 'ACP_PBWOW_POSTSTYLING_TITLE', 'vars' => array('legend1' => 'ACP_PBWOW_BLIZZ', 'blizz_enable' => array('lang' => 'PBWOW_BLIZZ_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'blizz_ranks' => array('lang' => 'PBWOW_BLIZZ_RANKS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_ranks'), 'blizz_color' => array('lang' => 'PBWOW_BLIZZ_COLOR', 'validate' => 'string', 'type' => 'text:7:7', 'explain' => true), 'legend2' => 'ACP_PBWOW_PROPASS', 'propass_enable' => array('lang' => 'PBWOW_PROPASS_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'propass_ranks' => array('lang' => 'PBWOW_PROPASS_RANKS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_ranks'), 'propass_color' => array('lang' => 'PBWOW_PROPASS_COLOR', 'validate' => 'string', 'type' => 'text:7:7', 'explain' => true), 'legend3' => 'ACP_PBWOW_RED', 'red_enable' => array('lang' => 'PBWOW_RED_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'red_ranks' => array('lang' => 'PBWOW_RED_RANKS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_ranks'), 'red_color' => array('lang' => 'PBWOW_RED_COLOR', 'validate' => 'string', 'type' => 'text:7:7', 'explain' => true), 'legend4' => 'ACP_PBWOW_GREEN', 'green_enable' => array('lang' => 'PBWOW_GREEN_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'green_ranks' => array('lang' => 'PBWOW_GREEN_RANKS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_ranks'), 'green_color' => array('lang' => 'PBWOW_GREEN_COLOR', 'validate' => 'string', 'type' => 'text:7:7', 'explain' => true))); break; case 'ads': $display_vars = array('title' => 'ACP_PBWOW_ADS_TITLE', 'vars' => array('legend1' => 'ACP_PBWOW_ADS_INDEX', 'ads_index_enable' => array('lang' => 'PBWOW_ADS_INDEX_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'ads_index_code' => array('lang' => 'PBWOW_ADS_INDEX_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend2' => 'ACP_PBWOW_ADS_TOP', 'ads_top_enable' => array('lang' => 'PBWOW_ADS_TOP_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'ads_top_code' => array('lang' => 'PBWOW_ADS_TOP_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend3' => 'ACP_PBWOW_ADS_BOTTOM', 'ads_bottom_enable' => array('lang' => 'PBWOW_ADS_BOTTOM_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'ads_bottom_code' => array('lang' => 'PBWOW_ADS_BOTTOM_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend4' => 'ACP_PBWOW_ADS_SIDE', 'ads_side_enable' => array('lang' => 'PBWOW_ADS_SIDE_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'ads_side_code' => array('lang' => 'PBWOW_ADS_SIDE_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend5' => 'ACP_PBWOW_TRACKING', 'tracking_enable' => array('lang' => 'PBWOW_TRACKING_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'tracking_code' => array('lang' => 'PBWOW_TRACKING_CODE', 'type' => 'textarea:6:6', 'explain' => true))); break; } $action = request_var('action', ''); $submit = isset($_POST['submit']) ? true : false; $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config; $error = array(); // We validate the complete config if we want validate_config_vars($display_vars['vars'], $cfg_array, $error); // Do not write values if there is an error if (sizeof($error)) { $submit = false; } // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... and then write to config foreach ($display_vars['vars'] as $config_name => $null) { if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) { continue; } $this->new_config[$config_name] = $config_value = $cfg_array[$config_name]; if ($submit) { $this->set_pbwow_config($config_name, $config_value); } } if ($submit) { if ($action == 'refresh_topic_ranks' && $legacy_topics_mod == true) { $this->refresh_topic_ranks(); $cache->purge(); } if ($action == 'create_topic_ranks' && $legacy_topics_mod == false) { $db_tool->sql_column_add($topics_table, 'topic_first_poster_rank_img', array('VCHAR', '')); $db_tool->sql_column_add($topics_table, 'topic_first_poster_rank_title', array('VCHAR', '')); add_log('admin', 'Topics MOD installed', $user->lang['ACP_PBWOW2_' . strtoupper($mode)]); trigger_error('Topics MOD installed' . adm_back_link($this->u_action)); } if (($action == 'drop_topic_ranks' || $action == 'remove_legacy') && $legacy_topics_mod == true) { $db_tool->sql_column_remove($topics_table, 'topic_first_poster_rank_img'); $db_tool->sql_column_remove($topics_table, 'topic_first_poster_rank_title'); add_log('admin', 'Topics MOD uninstalled', $user->lang['ACP_PBWOW2_' . strtoupper($mode)]); trigger_error('Topics MOD uninstalled' . adm_back_link($this->u_action)); } if ($action == 'refresh_all_themes') { $this->refresh_all_themes(); $cache->purge(); add_log('admin', 'LOG_THEME_REFRESHED', $user->lang['ACP_PBWOW2_' . strtoupper($mode)]); trigger_error('All theme data refreshed' . adm_back_link($this->u_action)); } // Get data from select boxes and store in DB if ($mode == 'poststyling') { $this->store_select_options('blizz_ranks'); $this->store_select_options('propass_ranks'); $this->store_select_options('red_ranks'); $this->store_select_options('green_ranks'); add_log('admin', 'LOG_PBWOW_CONFIG', $user->lang['ACP_PBWOW2_' . strtoupper($mode)]); $cache->purge(); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } if ($mode == ('config' || 'ads')) { $this->store_select_options('wowtips_script'); $this->store_select_options('d3tips_script'); $this->store_select_options('tooltips_region'); add_log('admin', 'LOG_PBWOW_CONFIG', $user->lang['ACP_PBWOW2_' . strtoupper($mode)]); $cache->purge(); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } } $this->page_title = $display_vars['title']; $title_explain = $user->lang[$display_vars['title'] . '_EXPLAIN']; $template->assign_vars(array('L_TITLE' => $user->lang[$display_vars['title']], 'L_TITLE_EXPLAIN' => $title_explain, 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'S_CONSTANTSOKAY' => $constantsokay ? true : false, 'PBWOW_DBTABLE' => $dbtable, 'S_DBOKAY' => $dbokay ? true : false, 'L_PBWOW_DB_GOOD' => sprintf($user->lang['PBWOW_DB_GOOD'], $dbtable), 'L_PBWOW_DB_BAD' => sprintf($user->lang['PBWOW_DB_BAD'], $dbtable), 'L_PBWOW_RANKS_CREATE_EXPLAIN' => sprintf($user->lang['PBWOW_RANKS_CREATE_EXPLAIN'], $topics_table, $topics_table), 'L_PBWOW_CHARSDB_GOOD' => sprintf($user->lang['PBWOW_CHARSDB_GOOD'], $chars_table), 'L_PBWOW_CHARSDB_BAD' => sprintf($user->lang['PBWOW_CHARSDB_BAD'], $chars_table), 'TOPICS_TABLE' => $topics_table, 'U_ACTION' => $this->u_action)); if ($mode == 'overview') { $template->assign_vars(array('S_INDEX' => true, 'DB_VERSION' => isset($pbwow_config['pbwow2_version']) ? $pbwow_config['pbwow2_version'] : '', 'MODULE_VERSION' => isset($module_version) ? $module_version : '', 'STYLE_VERSION' => $style_version, 'IMAGESET_VERSION' => $imageset_version, 'TEMPLATE_VERSION' => $template_version, 'THEME_VERSION' => $theme_version, 'S_CHECK_V' => empty($versions) ? false : true, 'DB_VERSION_V' => isset($versions['db_version']['version']) ? $versions['db_version']['version'] : '', 'MODULE_VERSION_V' => isset($versions['module_version']['version']) ? $versions['module_version']['version'] : '', 'ATEMPLATE_VERSION_V' => isset($versions['atemplate_version']['version']) ? $versions['atemplate_version']['version'] : '', 'STYLE_VERSION_V' => isset($versions['style_version']['version']) ? $versions['style_version']['version'] : '', 'IMAGESET_VERSION_V' => isset($versions['imageset_version']['version']) ? $versions['imageset_version']['version'] : '', 'TEMPLATE_VERSION_V' => isset($versions['template_version']['version']) ? $versions['template_version']['version'] : '', 'THEME_VERSION_V' => isset($versions['theme_version']['version']) ? $versions['theme_version']['version'] : '', 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'), 'S_ALLOW_FOPEN' => $allow_fopen, 'S_CPF_ON_MEMBERLIST' => $config['load_cpf_memberlist'] == 1 ? true : false, 'S_CPF_ON_VIEWPROFILE' => $config['load_cpf_viewprofile'] == 1 ? true : false, 'S_CPF_ON_VIEWTOPIC' => $config['load_cpf_viewtopic'] == 1 ? true : false, 'S_CPF_PBGUILD' => isset($cpflist['pbguild']) && $cpflist['pbguild']['field_no_view'] == 0 ? true : false, 'S_CPF_PBREALM' => isset($cpflist['pbrealm']) && $cpflist['pbrealm']['field_no_view'] == 0 ? true : false, 'S_CPF_PBLEVEL' => isset($cpflist['pblevel']) && $cpflist['pblevel']['field_no_view'] == 0 ? true : false, 'S_CPF_PBRACE' => isset($cpflist['pbrace']) && $cpflist['pbrace']['field_no_view'] == 0 ? true : false, 'S_CPF_PBGENDER' => isset($cpflist['pbgender']) && $cpflist['pbgender']['field_no_view'] == 0 ? true : false, 'S_CPF_PBCLASS' => isset($cpflist['pbclass']) && $cpflist['pbclass']['field_no_view'] == 0 ? true : false, 'S_CPF_PBPVPRANK' => isset($cpflist['pbpvprank']) && $cpflist['pbpvprank']['field_no_view'] == 0 ? true : false, 'S_CPF_PBARMORYCHARLINK' => isset($cpflist['pbarmorycharlink']) && $cpflist['pbarmorycharlink']['field_no_view'] == 0 ? true : false, 'S_CPF_PBARMORYGUILDLINK' => isset($cpflist['pbarmoryguildlink']) && $cpflist['pbarmoryguildlink']['field_no_view'] == 0 ? true : false, 'S_CPF_PBDCLASS' => isset($cpflist['pbdclass']) && $cpflist['pbguild']['pbdclass'] == 0 ? true : false, 'S_CPF_PBDGENDER' => isset($cpflist['pbdgender']) && $cpflist['pbguild']['pbdgender'] == 0 ? true : false, 'S_CPF_PBDFOLLOWER' => isset($cpflist['pbdfollower']) && $cpflist['pbguild']['pbdfollower'] == 0 ? true : false, 'S_BNETCHARS_ACTIVE' => isset($pbwow_config['bnetchars_enable']) && $pbwow_config['bnetchars_enable'] ? true : false, 'S_BNETCHARS_CONSTOKAY' => $chars_constokay ? true : false, 'S_BNETCHARS_DBOKAY' => $chars_dbokay ? true : false, 'S_CPF_PBBNETHOST' => isset($cpflist['pbbnethost']) && $cpflist['pbbnethost']['field_no_view'] == 0 ? true : false, 'S_CPF_PBBNETREALM' => isset($cpflist['pbbnetrealm']) && $cpflist['pbbnetrealm']['field_no_view'] == 0 ? true : false, 'S_CPF_PBBNETNAME' => isset($cpflist['pbbnetname']) && $cpflist['pbbnetname']['field_no_view'] == 0 ? true : false, 'S_CPF_PBNETAVATAR' => isset($cpflist['pbbnetavatar']) && $cpflist['pbbnetavatar']['field_no_view'] == 0 ? true : false, 'S_LEGACY_CONSTANTS' => $legacy_constants, 'S_LEGACY_DB_ACTIVE' => $legacy_db_active, 'S_LEGACY_TOPICS_MOD' => $legacy_topics_mod)); } // Output relevant page foreach ($display_vars['vars'] as $config_key => $vars) { if (!is_array($vars) && strpos($config_key, 'legend') === false) { continue; } if (strpos($config_key, 'legend') !== false) { $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars)); continue; } $type = explode(':', $vars['type']); $l_explain = ''; if ($vars['explain'] && isset($vars['lang_explain'])) { $l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain']; } else { if ($vars['explain']) { $l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : ''; } } $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars); if (empty($content)) { continue; } $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content)); unset($display_vars['vars'][$config_key]); } }
/** * 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; if (!sizeof($this->errors)) { add_log('admin', 'SEO_LOG_' . strtoupper($mode), $phpbb_seo->version); } else { 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__); } $this->page_title = $user->lang['STAGE_FINAL']; if (!class_exists('phpbb_db_tools')) { include $phpbb_root_path . 'includes/db/db_tools.' . $phpEx; } $db_tools = new phpbb_db_tools($db); $indexes = $db_tools->sql_list_index(TOPICS_TABLE); $drop_index_name = 'topic_last_post_id'; $add_index_name = 'topic_lpid'; if ($mode == 'install_phpbb_seo') { if (!$db_tools->sql_column_exists(TOPICS_TABLE, 'topic_url')) { $db_tools->sql_column_add(TOPICS_TABLE, 'topic_url', array('VCHAR', '')); } if (in_array($drop_index_name, $indexes)) { $db_tools->sql_index_drop(TOPICS_TABLE, $drop_index_name); } if (!in_array($add_index_name, $indexes)) { $db_tools->sql_create_index(TOPICS_TABLE, $add_index_name, array('topic_last_post_id')); } $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_INSTALL_CONGRATS_EXPLAIN'], $this->modrtype_lang['ulink'], $phpbb_seo->version); } else { $purge_topic_table = false; if ($purge_topic_table) { if ($db_tools->sql_column_exists(TOPICS_TABLE, 'topic_url')) { $db_tools->sql_column_remove(TOPICS_TABLE, 'topic_url'); } } if (in_array($drop_index_name, $indexes)) { $db_tools->sql_index_drop(TOPICS_TABLE, $drop_index_name); } if (in_array($add_index_name, $indexes)) { $db_tools->sql_index_drop(TOPICS_TABLE, $add_index_name); } $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['ulink'], $phpbb_seo->version); } $cache->purge(); $template->assign_vars(array('TITLE' => $title, 'BODY' => $body, 'L_SUBMIT' => $user->lang['SEO_FINAL_' . strtoupper($mode)], 'U_ACTION' => $submit_action)); }
/** * Check whether the location field exists. */ function mybb_user_from_col_exists() { global $src_db, $convert, $phpbb_root_path, $phpEx; if (!class_exists('phpbb_db_tools')) { include($phpbb_root_path . 'includes/db/db_tools.' . $phpEx); } $db_tools = new phpbb_db_tools($src_db); return $db_tools->sql_column_exists($convert->src_table_prefix . 'userfields', 'fid1'); }