/** * Takes a list of tags and returns a list of valid tags * * Tags are transformed to removed tabs and newlines * Tags may be lowercased based on options * Tags matching synomyns will * Duplicate will be eliminated (case insensitive) * Invalid tags will be removed. * * Fetch the valid tags from a list. Filters are length, censorship, perms (if desired). * * @param string|array List of tags to add (comma delimited, or an array as is). If array, ensure there are no commas. * @param array (output) List of errors that happens * @param boolean Whether to expand the error phrase * * @return array List of valid tags */ public static function filter_tag_list($taglist, &$errors, $evalerrors = true) { $options = vB::getDatastore()->getValue('options'); $errors = array(); if (!is_array($taglist)) { $taglist = self::split_tag_list($taglist); } //This seems like a terrible place to put this, but I don't know where else it should go. if ($options['tagmaxlen'] <= 0 or $options['tagmaxlen'] >= 100) { $options['tagmaxlen'] = 100; } $valid_raw = array(); foreach ($taglist as $tagtext) { $tagtext = trim(preg_replace('#[ \\r\\n\\t]+#', ' ', $tagtext)); if (self::is_tag_valid($tagtext, $errors)) { $valid_raw[] = $options['tagforcelower'] ? vbstrtolower($tagtext) : $tagtext; } } $valid_raw = self::convert_synonyms($valid_raw, $errors); // we need to essentially do a case-insensitive array_unique here $valid_unique = array_unique(array_map('vbstrtolower', $valid_raw)); $valid = array(); foreach (array_keys($valid_unique) as $key) { $valid[] = $valid_raw["{$key}"]; } $valid_unique = array_values($valid_unique); // make the keys jive with $valid //if requested compose the error messages to strings if ($evalerrors) { $errors = fetch_error_array($errors); } return $valid; }
$template_un = $vbulletin->GPC['template']; $vbulletin->GPC['template'] = compile_template($vbulletin->GPC['template'], $errors); // error checking on conditionals if (empty($vbulletin->GPC['confirmerrors'])) { if (!empty($errors)) { updatetemplate_print_error_page($template_un, construct_phrase($vbphrase['template_eval_error'], fetch_error_array($errors))); exit; } $errors = check_template_errors($vbulletin->GPC['template']); if (!empty($errors)) { updatetemplate_print_error_page($template_un, construct_phrase($vbphrase['template_eval_error'], fetch_error_array($errors))); exit; } $errors = check_template_conflict_error($vbulletin->GPC['template']); if (!empty($errors)) { updatetemplate_print_error_page($template_un, $errors); exit; } } $old_template = $db->query_first(" SELECT title, styleid, dateline, username, template_un FROM " . TABLE_PREFIX . "template WHERE templateid = " . $vbulletin->GPC['templateid'] . "
/** * Takes a list of tags and returns a list of valid tags * * Tags are transformed to removed tabs and newlines * Tags may be lowercased based on options * Tags matching synomyns will * Duplicate will be eliminated (case insensitive) * Invalid tags will be removed. * * Fetch the valid tags from a list. Filters are length, censorship, perms (if desired). * * @param string|array List of tags to add (comma delimited, or an array as is). If array, ensure there are no commas. * @param array (output) List of errors that happens * @param boolean Whether to expand the error phrase * * @return array List of valid tags */ public static function filter_tag_list($taglist, &$errors, $evalerrors = true) { global $vbulletin; $errors = array(); if (!is_array($taglist)) { $taglist = self::split_tag_list($taglist); } $valid_raw = array(); foreach ($taglist as $tagtext) { $tagtext = trim(preg_replace('#[ \\r\\n\\t]+#', ' ', $tagtext)); if (self::is_tag_valid($tagtext, $errors)) { $valid_raw[] = $vbulletin->options['tagforcelower'] ? vbstrtolower($tagtext) : $tagtext; } } $valid_raw = self::convert_synonyms($valid_raw, $errors); // we need to essentially do a case-insensitive array_unique here $valid_unique = array_unique(array_map('vbstrtolower', $valid_raw)); $valid = array(); foreach (array_keys($valid_unique) as $key) { $valid[] = $valid_raw["{$key}"]; } $valid_unique = array_values($valid_unique); // make the keys jive with $valid //if requested compose the error messages to strings if ($evalerrors) { $errors = fetch_error_array($errors); } return $valid; }
if ($_POST['do'] == 'updatetemplate') { if (!vB::getUserContext()->hasAdminPermission('canadmintemplates')) { print_cp_no_permission(); } $vbulletin->input->clean_array_gpc('p', array('title' => vB_Cleaner::TYPE_STR, 'oldtitle' => vB_Cleaner::TYPE_STR, 'template' => vB_Cleaner::TYPE_NOTRIM, 'group' => vB_Cleaner::TYPE_STR, 'product' => vB_Cleaner::TYPE_STR, 'savehistory' => vB_Cleaner::TYPE_BOOL, 'histcomment' => vB_Cleaner::TYPE_STR, 'string' => vB_Cleaner::TYPE_STR, 'searchstring' => vB_Cleaner::TYPE_STR, 'expandset' => vB_Cleaner::TYPE_NOHTML, 'searchset' => vB_Cleaner::TYPE_NOHTML, 'return' => vB_Cleaner::TYPE_STR, 'confirmerrors' => vB_Cleaner::TYPE_BOOL, 'confirmremoval' => vB_Cleaner::TYPE_BOOL, 'lastedit' => vB_Cleaner::TYPE_UINT, 'hash' => vB_Cleaner::TYPE_STR, 'fromeditconflict' => vB_Cleaner::TYPE_BOOL, 'textonly' => vB_Cleaner::TYPE_BOOL, 'windowScrollTop' => vB_Cleaner::TYPE_UINT, 'textareaScrollTop' => vB_Cleaner::TYPE_UINT)); handle_vbulletin_copyright_removal($vbulletin->GPC, 'updatetemplate'); try { vB_Api::instanceInternal('template')->update($vbulletin->GPC['templateid'], $vbulletin->GPC['title'], $vbulletin->GPC['template'], $vbulletin->GPC['product'], false, $vbulletin->GPC['savehistory'], $vbulletin->GPC['histcomment'], !empty($vbulletin->GPC['confirmerrors']), array('textonly' => $vbulletin->GPC['textonly'])); } catch (vB_Exception_Api $e) { $errors = $e->get_errors(); $error = $errors[0]; if ($error == 'edit_conflict') { $updatetemplate_edit_conflict = true; } else { if ($error[0] == 'template_eval_error' or $error[0] == 'template_compile_error') { updatetemplate_print_error_page($vbulletin->GPC['template'], construct_phrase($vbphrase['template_eval_error'], fetch_error_array($error[1]))); exit; } else { print_stop_message2($error[0]); } } } $args = array('templateid' => $vbulletin->GPC['templateid'], 'group' => $vbulletin->GPC['group'], 'expandset' => $vbulletin->GPC['expandset'], 'searchset' => $vbulletin->GPC['searchset'], 'searchstring' => urlencode($vbulletin->GPC['searchstring'])); if ($vbulletin->GPC['return']) { $args['do'] = 'edit'; $args['windowScrollTop'] = $vbulletin->GPC['windowScrollTop']; $args['textareaScrollTop'] = $vbulletin->GPC['textareaScrollTop']; } else { $args['do'] = 'modify'; } if ($vbulletin->GPC['title'] == $vbulletin->GPC['oldtitle']) {
/** * Takes a list of tags and returns a list of valid tags * * Tags are transformed to removed tabs and newlines * Tags may be lowercased based on options * Tags matching synomyns will * Duplicate will be eliminated (case insensitive) * Invalid tags will be removed. * * Fetch the valid tags from a list. Filters are length, censorship, perms (if desired). * * @param string|array List of tags to add (comma delimited, or an array as is). If array, ensure there are no commas. * @param array (output) List of errors that happens * @param boolean Whether to expand the error phrase * * @return array List of valid tags */ public function filterTagList($taglist, &$errors, $evalerrors = true) { $options = vB::getDatastore()->get_value('options'); $errors = array(); if (!is_array($taglist)) { $taglist = $this->splitTagList($taglist); } //This seems like a terrible place to put this, but I don't know where else it should go. if ($options['tagmaxlen'] <= 0 or $options['tagmaxlen'] >= 100) { $options['tagmaxlen'] = 100; } $validRaw = array(); foreach ($taglist as $tagtext) { $tagtext = trim(preg_replace('#[ \\r\\n\\t]+#', ' ', $tagtext)); if ($this->isTagValid($tagtext, $errors)) { $validRaw[] = $options['tagforcelower'] ? vB_String::vBStrToLower($tagtext) : $tagtext; } } if (empty($validRaw)) { $errors['no_valid_tags'] = 'no_valid_tags_found'; return array(); } $validRaw = $this->convertSynonyms($validRaw, $errors); // we need to essentially do a case-insensitive array_unique here $validUnique = array_unique(array_map('vB_String::vBStrToLower', $validRaw)); $valid = array(); foreach (array_keys($validUnique) as $key) { $valid[] = $validRaw["{$key}"]; } $validUnique = array_values($validUnique); // make the keys jive with $valid //if requested compose the error messages to strings if ($evalerrors) { $errors = fetch_error_array($errors); } return $valid; }