$args['windowScrollTop'] = $vbulletin->GPC['windowScrollTop']; $args['textareaScrollTop'] = $vbulletin->GPC['textareaScrollTop']; } else { $args['do'] = 'modify'; } if ($vbulletin->GPC['title'] == $vbulletin->GPC['oldtitle']) { if ($vbulletin->GPC['return']) { print_cp_redirect2('template', $args); } else { $_REQUEST['do'] = 'modify'; $vbulletin->GPC['expandset'] = $vbulletin->GPC['dostyleid']; } //$vbulletin->GPC['searchstring'] = $string ? $string : $vbulletin->GPC['searchstring']; $vbulletin->GPC['searchset'] = $vbulletin->GPC['dostyleid']; } else { print_rebuild_style($vbulletin->GPC['dostyleid'], '', 0, 0, 0, 0); print_cp_redirect2('template', $args, 1); } } // ############################################################################# // edit form for an existing template if ($_REQUEST['do'] == 'edit') { function edit_get_merged_text($templateid) { global $vbphrase; $templates = fetch_templates_for_merge($templateid); $new = $templates["new"]; $custom = $templates["custom"]; $origin = $templates["origin"]; require_once DIR . '/includes/class_merge.php'; $merge = new vB_Text_Merge_Threeway($origin['template_un'], $new['template_un'], $custom['template_un']);
?> '; } }); //--> </script> <?php } // ############################################################################# // kill a template and update template id caches for dependent styles if ($_POST['do'] == 'kill') { $vbulletin->input->clean_array_gpc('p', array('group' => TYPE_STR)); $template = $db->query_first("SELECT styleid, title FROM " . TABLE_PREFIX . "template WHERE templateid = " . $vbulletin->GPC['templateid']); if ($template['styleid']) { $db->query_write("DELETE FROM " . TABLE_PREFIX . "template WHERE templateid=" . $vbulletin->GPC['templateid']); print_rebuild_style($template['styleid'], '', 0, 0, 0, 0); } if (strpos($template['title'], 'bbcode_') === 0) { // begins with bbcode_ - empty the post parsed cache $vbulletin->db->query_write("TRUNCATE TABLE " . TABLE_PREFIX . "postparsed"); } ?> <script type="text/javascript"> <!-- // refresh the opening window (used for the revert updated default templates action) if (window.opener && String(window.opener.location).indexOf("template.php?do=findupdates") != -1) { window.opener.window.location = window.opener.window.location; }
} // update css if ($vbulletin->GPC['dowhat']['css']) { build_special_templates($vbulletin->GPC['css'], 'css', 'css'); } // update replacements if ($vbulletin->GPC['dowhat']['replacements'] and is_array($vbulletin->GPC['replacement']) and !empty($vbulletin->GPC['replacement'])) { $temp = $vbulletin->GPC['replacement']; $vbulletin->GPC['replacement'] = array(); foreach ($temp as $key => $replacebits) { $vbulletin->GPC['replacement']["{$replacebits['find']}"] = $replacebits['replace']; $vbulletin->GPC['delete']['replacement']["{$replacebits['find']}"] = $vbulletin->GPC['delete']['replacement']["{$key}"]; } build_special_templates($vbulletin->GPC['replacement'], 'replacement', 'replacement'); } print_rebuild_style($vbulletin->GPC['dostyleid'], iif($vbulletin->GPC['dostyleid'] == -1, $vbphrase['master_style'], $style['title']), $vbulletin->GPC['dowhat']['css'], $vbulletin->GPC['dowhat']['stylevars'], $vbulletin->GPC['dowhat']['replacements'], $vbulletin->GPC['dowhat']['posteditor']); print_cp_redirect("css.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit" . "&dostyleid=" . $vbulletin->GPC['dostyleid'] . "&group=" . $vbulletin->GPC['group'] . "&dowhat=" . $vbulletin->GPC['passthru_dowhat'] . "&colorPickerType=" . $vbulletin->GPC['colorPickerType'], 1); } // ###################### Start Choose What to Edit ####################### if ($_REQUEST['do'] == 'edit') { $vbulletin->input->clean_array_gpc('r', array('dostyleid' => TYPE_INT, 'group' => TYPE_STR, 'dowhat' => TYPE_STR)); if ($vbulletin->GPC['dostyleid'] == 0 or $vbulletin->GPC['dostyleid'] < -1) { $vbulletin->GPC['dostyleid'] = 1; } if (!empty($vbulletin->GPC['dowhat'])) { $_REQUEST['do'] = 'doedit'; } else { if ($vbulletin->GPC['dostyleid'] == -1) { $style = array('styleid' => -1, 'title' => $vbphrase['master_style']); } else { $style = $db->query_first("\n\t\t\t\tSELECT styleid, title\n\t\t\t\tFROM " . TABLE_PREFIX . "style\n\t\t\t\tWHERE styleid = " . $vbulletin->GPC['dostyleid']);
/** * Updates the setting table based on data passed in then rebuilds the datastore. * Only entries in the array are updated (allows partial updates). * * @param array Array of settings. Format: [setting_name] = new_value */ function save_settings($settings) { global $vbulletin, $vbphrase, $stylevar; $varnames = array(); foreach (array_keys($settings) as $varname) { $varnames[] = $vbulletin->db->escape_string($varname); } $oldsettings = $vbulletin->db->query_read("\n\t\tSELECT value, varname, datatype, optioncode\n\t\tFROM " . TABLE_PREFIX . "setting\n\t\tWHERE varname IN ('" . implode("', '", $varnames) . "')\n\t\tORDER BY varname\n\t"); while ($oldsetting = $vbulletin->db->fetch_array($oldsettings)) { switch ($oldsetting['varname']) { // ************************************************** case 'bbcode_html_colors': $settings['bbcode_html_colors'] = serialize($settings['bbcode_html_colors']); break; // ************************************************** // ************************************************** case 'styleid': $vbulletin->db->query_write("\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "style\n\t\t\t\t\tSET userselect = 1\n\t\t\t\t\tWHERE styleid = " . $settings['styleid'] . "\n\t\t\t\t"); break; // ************************************************** // ************************************************** case 'banemail': build_datastore('banemail', $settings['banemail']); $settings['banemail'] = ''; break; // ************************************************** // ************************************************** case 'editormodes': $vbulletin->input->clean_array_gpc('p', array('fe' => TYPE_UINT, 'qr' => TYPE_UINT, 'qe' => TYPE_UINT)); $settings['editormodes'] = serialize(array('fe' => $vbulletin->GPC['fe'], 'qr' => $vbulletin->GPC['qr'], 'qe' => $vbulletin->GPC['qe'])); break; // ************************************************** // ************************************************** case 'cookiepath': case 'cookiedomain': if ($settings[$oldsetting['varname'] . '_other'] and $settings[$oldsetting['varname'] . '_value']) { $settings[$oldsetting['varname']] = $settings[$oldsetting['varname'] . '_value']; } break; // ************************************************** // ************************************************** default: ($hook = vBulletinHook::fetch_hook('admin_options_processing')) ? eval($hook) : false; if ($oldsetting['optioncode'] == 'multiinput') { $store = array(); foreach ($settings["{$oldsetting['varname']}"] as $value) { if ($value != '') { $store[] = $value; } } $settings["{$oldsetting['varname']}"] = serialize($store); } else { if (preg_match('#^usergroup:[0-9]+$#', $oldsetting['optioncode'])) { // serialize the array of usergroup inputs if (!is_array($settings["{$oldsetting['varname']}"])) { $settings["{$oldsetting['varname']}"] = array(); } $settings["{$oldsetting['varname']}"] = array_map('intval', $settings["{$oldsetting['varname']}"]); $settings["{$oldsetting['varname']}"] = serialize($settings["{$oldsetting['varname']}"]); } } } $newvalue = validate_setting_value($settings["{$oldsetting['varname']}"], $oldsetting['datatype']); // this is a strict type check because we want '' to be different from 0 // some special cases below only use != checks to see if the logical value has changed if (strval($oldsetting['value']) !== strval($newvalue)) { switch ($oldsetting['varname']) { case 'activememberdays': case 'activememberoptions': if ($oldsetting['value'] != $newvalue) { $vbulletin->options["{$oldsetting['varname']}"] = $newvalue; require_once DIR . '/includes/functions_databuild.php'; build_birthdays(); } break; case 'showevents': case 'showholidays': if ($oldsetting['value'] != $newvalue) { $vbulletin->options["{$oldsetting['varname']}"] = $newvalue; require_once DIR . '/includes/functions_calendar.php'; build_events(); } break; case 'languageid': if ($oldsetting['value'] != $newvalue) { $vbulletin->options['languageid'] = $newvalue; require_once DIR . '/includes/adminfunctions_language.php'; build_language($vbulletin->options['languageid']); } break; case 'cpstylefolder': $admindm =& datamanager_init('Admin', $vbulletin, ERRTYPE_CP); $admindm->set_existing($vbulletin->userinfo); $admindm->set('cssprefs', $newvalue); $admindm->save(); unset($admindm); break; case 'storecssasfile': if (!is_demo_mode() and $oldsetting['value'] != $newvalue) { $vbulletin->options['storecssasfile'] = $newvalue; require_once DIR . '/includes/adminfunctions_template.php'; print_rebuild_style(-1, '', 1, 0, 0, 0); } break; case 'loadlimit': update_loadavg(); break; case 'view_tagcloud_as_usergroup': build_datastore('tagcloud', serialize(''), 1); break; case 'censorwords': case 'codemaxlines': if ($oldsetting['value'] != $newvalue) { $vbulletin->db->query_write("TRUNCATE TABLE " . TABLE_PREFIX . "postparsed"); if ($vbulletin->options['templateversion'] >= '3.6') { $vbulletin->db->query_write("TRUNCATE TABLE " . TABLE_PREFIX . "sigparsed"); } } ($hook = vBulletinHook::fetch_hook('admin_options_processing_censorcode')) ? eval($hook) : false; break; default: ($hook = vBulletinHook::fetch_hook('admin_options_processing_build')) ? eval($hook) : false; } if (is_demo_mode() and in_array($oldsetting['varname'], array('storecssasfile', 'attachfile', 'usefileavatar', 'errorlogdatabase', 'errorlogsecurity', 'safeupload', 'tmppath'))) { continue; } $vbulletin->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "setting\n\t\t\t\tSET value = '" . $vbulletin->db->escape_string($newvalue) . "'\n\t\t\t\tWHERE varname = '" . $vbulletin->db->escape_string($oldsetting['varname']) . "'\n\t\t\t"); } } build_options(); }
print_submit_row($vbphrase['save']); } // *********************** insert ********************* if ($_POST['do'] == 'insert') { $vbulletin->input->clean_array_gpc('p', array('findtext' => TYPE_STR, 'replacetext' => TYPE_STR)); $vbulletin->GPC['findtext'] = strtolower($vbulletin->GPC['findtext']); if ($vbulletin->GPC['findtext'] === '') { print_stop_message('please_complete_required_fields'); } if ($existing = $db->query_first("\n\t\tSELECT templateid, styleid, title, template\n\t\tFROM " . TABLE_PREFIX . "template\n\t\tWHERE styleid = " . $vbulletin->GPC['dostyleid'] . "\n\t\t\tAND templatetype = 'replacement'\n\t\t\tAND title = '" . $db->escape_string($vbulletin->GPC['findtext']) . "'\n\t")) { print_stop_message('replacement_already_exists', htmlspecialchars($existing['title']), htmlspecialchars($existing['template']), "replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&dostyleid={$existing['styleid']}&templateid={$existing['templateid']}"); } else { /*insert query*/ $db->query_write("\n\t\t\tINSERT INTO " . TABLE_PREFIX . "template\n\t\t\t\t(styleid, templatetype, title, template)\n\t\t\tVALUES\n\t\t\t\t(" . $vbulletin->GPC['dostyleid'] . ", 'replacement', '" . $db->escape_string($vbulletin->GPC['findtext']) . "', '" . $db->escape_string($vbulletin->GPC['replacetext']) . "')\n\t\t"); $style = $db->query_first("SELECT styleid, title FROM " . TABLE_PREFIX . "style WHERE styleid = " . $vbulletin->GPC['dostyleid']); print_rebuild_style($vbulletin->GPC['dostyleid'], iif($vbulletin->GPC['dostyleid'] == -1, MASTERSTYLE, $style['title']), 0, 0, 1, 0); print_cp_redirect("replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=modify", 1); } } // *********************** add ********************* if ($_REQUEST['do'] == 'add') { print_form_header('replacement', 'insert'); print_table_header($vbphrase['add_new_replacement_variable']); print_style_chooser_row('dostyleid', $vbulletin->GPC['dostyleid'], MASTERSTYLE, $vbphrase['style'], iif($vbulletin->debug == 1, 1, 0)); print_input_row("{$vbphrase['search_for_text']} <dfn>({$vbphrase['case_insensitive']})</dfn>", 'findtext', ''); print_textarea_row($vbphrase['replace_with_text'], 'replacetext', '', 5, 50); print_submit_row($vbphrase['save']); } // *********************** modify ********************* if ($_REQUEST['do'] == 'modify') { // ###################### Start displayreplacements #######################
$db->query_write(" REPLACE INTO " . TABLE_PREFIX . "template (styleid, title, template, template_un, dateline, username, product, version) VALUES ( 0, '" . $db->escape_string($title) . "', '" . $db->escape_string(compile_template($gridinfo['gridhtml_backup'])) . "', '" . $db->escape_string($gridinfo['gridhtml_backup']) . "', " . TIMENOW . ", '" . $db->escape_string($vbulletin->userinfo['username']) . "', 'vbcms', '" . $db->escape_string($vbulletin->options['templateversion']) . "' ) "); print_rebuild_style(-1, '', 0, 0, 0, 0); define('CP_REDIRECT', 'cms_admin.php?do=grid'); print_stop_message('saved_grid_successfully'); } if ($_REQUEST['do'] == 'layout') { ?> <script type="text/javascript"> function js_jump(id, obj) { task = obj.options[obj.selectedIndex].value; switch (task) { case 'edit':
/** * Reads XML grids file and imports data from it into the database * * @param string XML data * @param boolean Allow overwriting of existing grids with same name */ function xml_import_grid($xml = false, $allowoverwrite = false) { // $GLOBALS['path'] needs to be passed into this function or reference $vbulletin->GPC['path'] global $vbulletin, $vbphrase; print_dots_start('<b>' . $vbphrase['importing_grid'] . "</b>, $vbphrase[please_wait]", ':', 'dspan'); require_once(DIR . '/includes/class_xml.php'); $xmlobj = new vB_XML_Parser($xml, $vbulletin->GPC['path']); if ($xmlobj->error_no == 1) { print_dots_stop(); print_stop_message('no_xml_and_no_path'); } else if ($xmlobj->error_no == 2) { print_dots_stop(); print_stop_message('please_ensure_x_file_is_located_at_y', 'vbulletin-grid.xml', $vbulletin->GPC['path']); } if(!$arr = $xmlobj->parse()) { print_dots_stop(); print_stop_message('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line()); } if (!$arr['grid']) { print_dots_stop(); print_stop_message('invalid_file_specified'); } $grids = array(); $gridq = $vbulletin->db->query_read(" SELECT gridid FROM " . TABLE_PREFIX . "cms_grid "); while ($grid = $vbulletin->db->fetch_array($gridq)) { $grids[] = $grid['gridid']; } if (!is_array($arr['grid'][0])) { $arr['grid'] = array($arr['grid']); } require_once(DIR . '/includes/adminfunctions_template.php'); $newgrids = array(); foreach($arr['grid'] AS $grid) { $vbulletin->db->query_write(" " . ($allowoverwrite ? "REPLACE" : "INSERT IGNORE") . " INTO " . TABLE_PREFIX . "cms_grid (title, auxheader, auxfooter, addcolumn, addcolumnsnap, addcolumnsize, gridcolumns, gridhtml) VALUES ( '" . $vbulletin->db->escape_string($grid['name']) . "', " . intval($grid['auxheader']) . ", " . intval($grid['auxfooter']) . ", " . intval($grid['addcolumn']) . ", " . intval($grid['addcolumnsnap']) . ", " . intval($grid['addcolumnsize']) . ", " . intval($grid['gridcolumns']) . ", '" . $vbulletin->db->escape_string($grid['value']) . "' ) "); if ($gridid = $vbulletin->db->insert_id()) { $title = "vbcms_grid_$gridid"; $vbulletin->db->query_write(" REPLACE INTO " . TABLE_PREFIX . "template (styleid, title, template, template_un, dateline, username, product, version) VALUES ( 0, '" . $vbulletin->db->escape_string($title) . "', '" . $vbulletin->db->escape_string(compile_template($grid["value"])) . "', '" . $vbulletin->db->escape_string($grid["value"]) . "', " . TIMENOW . ", '" . $vbulletin->vbulletin->userinfo['username'] . "', 'vbcms', '" . $vbulletin->db->escape_string($vbulletin->options['templateversion']) . "' ) "); } } $newgrids = array(); $gridq = $vbulletin->db->query_read(" SELECT gridid FROM " . TABLE_PREFIX . "cms_grid "); while ($grid = $vbulletin->db->fetch_array($gridq)) { $newgrids[] = $grid['gridid']; } $removetemplates = array_diff($grids, $newgrids); $templates = array(); foreach ($removetemplates AS $gridid) { $templates[] = "vbcms_grid_$gridid"; } if (!empty($templates)) { $vbulletin->db->query_write(" DELETE FROM " . TABLE_PREFIX . "template WHERE title IN ('" . implode("', '", $templates) . "') AND templatetype = 'template' AND styleid = 0 "); } print_rebuild_style(-1, '', 0, 0, 0, 0); print_dots_stop(); }
$svinstance->set_child('same', $vbulletin->GPC['stylevar'][$stylevarid]['same']); break; default: die("Failed to find " . $dfns[$stylevarid]['datatype']); // attempt to set the simple types as is, might be glitchy... $svinstance->set_child($dfns[$stylevarid]['datatype'], $vbulletin->GPC['stylevar'][$stylevarid]); break; } $svinstance->build(); $svinstance->save(); } } foreach (array_keys($vbulletin->GPC['stylevar']) as $stylevar) { $stylevars[] = 'stylevarid[]=' . $stylevar; } print_rebuild_style($vbulletin->GPC['dostyleid']); define('CP_REDIRECT', 'stylevar.php?do=fetchstylevareditor&dostyleid=' . $vbulletin->GPC['dostyleid'] . '&' . implode('&', $stylevars)); print_stop_message('stylevar_saved_successfully'); } if ($_REQUEST['do'] == 'fetchstylevareditor') { $vbulletin->input->clean_array_gpc('r', array('stylevarid' => TYPE_ARRAY_NOHTML)); if (count($vbulletin->GPC['stylevarid']) == 0) { // nothing to show, exit now exit; } else { cache_styles(); $stylevarids = $vbulletin->GPC['stylevarid']; } $stylevarids_sql = "'" . implode("', '", array_map(array(&$db, 'escape_string'), $stylevarids)) . "'"; $stylevars_result = $db->query_read("\r\n\t\tSELECT stylevardfn.*, stylevar.styleid AS stylevarstyleid, stylevar.value\r\n\t\tFROM " . TABLE_PREFIX . "stylevardfn AS stylevardfn\r\n\t\tLEFT JOIN " . TABLE_PREFIX . "stylevar AS stylevar ON(stylevardfn.stylevarid = stylevar.stylevarid)\r\n\t\tWHERE stylevardfn.stylevarid IN (" . $stylevarids_sql . ")\r\n\t\tORDER BY stylevardfn.stylevargroup, stylevardfn.stylevarid\r\n\t"); while ($sv = $vbulletin->db->fetch_array($stylevars_result)) {
/** * Updates the setting table based on data passed in then rebuilds the datastore. * Only entries in the array are updated (allows partial updates). * * @param array Array of settings. Format: [setting_name] = new_value * */ function save_settings($settings) { global $vbulletin, $vbphrase; //a few variables to track changes for processing after all variables are updated. $rebuildstyle = false; $templatecachepathchanged = false; $oldtemplatepath = null; $newtemplatepath = null; $userContext = vB::getUserContext(); $cleaner = vB::getCleaner(); $canAdminAll = $userContext->hasAdminPermission('canadminsettingsall'); $oldsettings = vB::getDbAssertor()->assertQuery('vBAdmincp:getCurrentSettings', array('varname' => array_keys($settings))); foreach ($oldsettings as $oldsetting) { //check the setting and group permissions if (!empty($oldsetting['adminperm']) and !$userContext->hasAdminPermission($oldsetting['adminperm']) or !empty($oldsetting['groupperm']) and !$userContext->hasAdminPermission($oldsetting['groupperm'])) { throw new vB_Exception_Api('no_permission'); } switch ($oldsetting['varname']) { // ************************************************** case 'bbcode_html_colors': $settings['bbcode_html_colors'] = serialize($settings['bbcode_html_colors']); break; // ************************************************** // ************************************************** case 'styleid': vB::getDbAssertor()->assertQuery('vBForum:style', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, 'userselect' => 1, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'styleid', 'value' => $settings['styleid'], 'operator' => vB_dB_Query::OPERATOR_EQ)))); break; // ************************************************** // ************************************************** case 'banemail': vB::getDatastore()->build('banemail', $settings['banemail']); $settings['banemail'] = ''; break; // ************************************************** // ************************************************** case 'editormodes': $vbulletin->input->clean_array_gpc('p', array('fe' => vB_Cleaner::TYPE_UINT, 'qr' => vB_Cleaner::TYPE_UINT, 'qe' => vB_Cleaner::TYPE_UINT)); $settings['editormodes'] = serialize(array('fe' => $vbulletin->GPC['fe'], 'qr' => $vbulletin->GPC['qr'], 'qe' => $vbulletin->GPC['qe'])); break; // ************************************************** // ************************************************** case 'attachresizes': $vbulletin->input->clean_array_gpc('p', array('attachresizes' => vB_Cleaner::TYPE_ARRAY_UINT)); $value = @unserialize($oldsetting['value']); $invalidate = array(); if ($value[vB_Api_Filedata::SIZE_ICON] != $vbulletin->GPC['attachresizes'][vB_Api_Filedata::SIZE_ICON]) { $invalidate[] = vB_Api_Filedata::SIZE_ICON; } if ($value[vB_Api_Filedata::SIZE_THUMB] != $vbulletin->GPC['attachresizes'][vB_Api_Filedata::SIZE_THUMB]) { $invalidate[] = vB_Api_Filedata::SIZE_THUMB; } if ($value[vB_Api_Filedata::SIZE_SMALL] != $vbulletin->GPC['attachresizes'][vB_Api_Filedata::SIZE_SMALL]) { $invalidate[] = vB_Api_Filedata::SIZE_SMALL; } if ($value[vB_Api_Filedata::SIZE_MEDIUM] != $vbulletin->GPC['attachresizes'][vB_Api_Filedata::SIZE_MEDIUM]) { $invalidate[] = vB_Api_Filedata::SIZE_MEDIUM; } if ($value[vB_Api_Filedata::SIZE_LARGE] != $vbulletin->GPC['attachresizes'][vB_Api_Filedata::SIZE_LARGE]) { $invalidate[] = vB_Api_Filedata::SIZE_LARGE; } if (!empty($invalidate)) { vB::getDbAssertor()->update('vBForum:filedataresize', array('reload' => 1), array('resize_type' => $invalidate)); } $settings['attachresizes'] = serialize(array(vB_Api_Filedata::SIZE_ICON => $vbulletin->GPC['attachresizes'][vB_Api_Filedata::SIZE_ICON], vB_Api_Filedata::SIZE_THUMB => $vbulletin->GPC['attachresizes'][vB_Api_Filedata::SIZE_THUMB], vB_Api_Filedata::SIZE_SMALL => $vbulletin->GPC['attachresizes'][vB_Api_Filedata::SIZE_SMALL], vB_Api_Filedata::SIZE_MEDIUM => $vbulletin->GPC['attachresizes'][vB_Api_Filedata::SIZE_MEDIUM], vB_Api_Filedata::SIZE_LARGE => $vbulletin->GPC['attachresizes'][vB_Api_Filedata::SIZE_LARGE])); break; case 'thumbquality': if ($oldsetting['value'] != $settings['thumbquality']) { vB::getDbAssertor()->update('vBForum:filedataresize', array('reload' => 1), vB_dB_Query::CONDITION_ALL); } break; // ************************************************** // ************************************************** case 'cookiepath': case 'cookiedomain': if ($settings[$oldsetting['varname'] . '_other'] and $settings[$oldsetting['varname'] . '_value']) { $settings[$oldsetting['varname']] = $settings[$oldsetting['varname'] . '_value']; } break; // ************************************************** // ************************************************** default: // Legacy Hook 'admin_options_processing' Removed // if ($oldsetting['optioncode'] == 'multiinput') { $store = array(); foreach ($settings["{$oldsetting['varname']}"] as $value) { if ($value != '') { $store[] = $value; } } $settings["{$oldsetting['varname']}"] = serialize($store); } else { if (preg_match('#^(usergroup|forum)s?:([0-9]+|all|none)$#', $oldsetting['optioncode'])) { // serialize the array of usergroup inputs if (!is_array($settings["{$oldsetting['varname']}"])) { $settings["{$oldsetting['varname']}"] = array(); } $settings["{$oldsetting['varname']}"] = array_map('intval', $settings["{$oldsetting['varname']}"]); $settings["{$oldsetting['varname']}"] = serialize($settings["{$oldsetting['varname']}"]); } } } $newvalue = validate_setting_value($settings["{$oldsetting['varname']}"], $oldsetting['datatype']); if ($canAdminAll and isset($_POST['adminperm_' . $oldsetting[varname]])) { $newAdminPerm = substr($cleaner->clean($_POST['adminperm_' . $oldsetting[varname]], vB_Cleaner::TYPE_STR), 0, 32); } else { $newAdminPerm = $oldsetting['adminperm']; } // this is a strict type check because we want '' to be different from 0 // some special cases below only use != checks to see if the logical value has changed if ($oldsetting['value'] === NULL or strval($oldsetting['value']) !== strval($newvalue) or strval($oldsetting['adminperm']) !== strval($newAdminPerm)) { switch ($oldsetting['varname']) { case 'cache_templates_as_files': if (!is_demo_mode()) { $templatecachepathchanged = true; } break; case 'template_cache_path': if (!is_demo_mode()) { $oldtemplatepath = strval($oldsetting['value']); $newtemplatepath = $newvalue; } break; case 'languageid': if ($oldsetting['value'] != $newvalue) { vB::getDatastore()->setOption('languageid', $newvalue, false); require_once DIR . '/includes/adminfunctions_language.php'; build_language($newvalue); } break; case 'cpstylefolder': $admindm =& datamanager_init('Admin', $vbulletin, vB_DataManager_Constants::ERRTYPE_CP); $admindm->set_existing(vB::getCurrentSession()->fetch_userinfo()); $admindm->set('cssprefs', $newvalue); $admindm->save(); unset($admindm); break; case 'attachthumbssize': if ($oldsetting['value'] != $newvalue) { $rebuildstyle = true; } case 'storecssasfile': if (!is_demo_mode() and $oldsetting['value'] != $newvalue) { vB::getDatastore()->setOption('storecssasfile', $newvalue, false); $rebuildstyle = true; } break; case 'loadlimit': update_loadavg(); break; case 'tagcloud_usergroup': build_datastore('tagcloud', serialize(''), 1); break; case 'censorwords': case 'codemaxlines': case 'url_nofollow': case 'url_nofollow_whitelist': if ($oldsetting['value'] != $newvalue) { if (vB::getDatastore()->getOption('templateversion') >= '3.6') { vB::getDbAssertor()->assertQuery('truncateTable', array('table' => 'sigparsed')); } } // Legacy Hook 'admin_options_processing_censorcode' Removed // break; case 'album_recentalbumdays': if ($oldsetting['value'] > $newvalue) { require_once DIR . '/includes/functions_album.php'; exec_rebuild_album_updates(); } default: // Legacy Hook 'admin_options_processing_build' Removed // } if (is_demo_mode() and in_array($oldsetting['varname'], array('cache_templates_as_files', 'template_cache_path', 'storecssasfile', 'attachfile', 'usefileavatar', 'errorlogdatabase', 'errorlogsecurity', 'safeupload', 'tmppath'))) { continue; } $updateSetting = vB::getDbAssertor()->assertQuery('setting', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, 'value' => $newvalue, 'adminperm' => $newAdminPerm, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'varname', 'value' => $oldsetting['varname'], 'operator' => vB_dB_Query::OPERATOR_EQ)))); } } if (!isset($oldsetting)) { return false; } vB::getDatastore()->build_options(); if (defined('DEV_AUTOEXPORT') and DEV_AUTOEXPORT) { require_once DIR . '/includes/functions_filesystemxml.php'; $xml = get_settings_export_xml('vbulletin'); autoexport_write_file_with_backup(DIR . '/install/vbulletin-settings.xml', $xml); } //handle changes for cache_templates_as_files and template_cache_path //we do it here because there are interactions between them and we don't //want to redo the chache changes twice if both are changed. $api = vB_Api::instanceInternal('template'); if ($templatecachepathchanged or !is_null($oldtemplatepath) and !is_null($newtemplatepath)) { if (vB::getDatastore()->getOption('cache_templates_as_files')) { if (!is_null($oldtemplatepath)) { //temporarily set the datastore path to the old value to clear it. vB::getDatastore()->setOption('template_cache_path', $oldtemplatepath, false); $api->deleteAllTemplateFiles(); vB::getDatastore()->setOption('template_cache_path', $newtemplatepath, false); } $api->saveAllTemplatesToFile(); } else { //we we changed directories and the cache is off, delete from the old directory if (!is_null($oldtemplatepath)) { vB::getDatastore()->setOption('template_cache_path', $oldtemplatepath, false); $api->deleteAllTemplateFiles(); vB::getDatastore()->setOption('template_cache_path', $newtemplatepath, false); } else { $api->deleteAllTemplateFiles(); } } } if ($rebuildstyle) { require_once DIR . '/includes/adminfunctions_template.php'; print_rebuild_style(-1, '', 1, 0, 0, 0); } return true; }
if ($vbulletin->GPC['dostyleid'] != -1 and $vbulletin->GPC['dostyleid'] != -2 and $style = $db->query_first("SELECT type, styleid, parentid, parentlist, title FROM " . TABLE_PREFIX . "style WHERE styleid = " . $vbulletin->GPC['dostyleid'])) { if (!$style['parentlist']) { $style['parentlist'] = $style['type'] == 'mobile' ? -2 : -1; } $stylevars = $db->query_read("\n\t\t\tSELECT DISTINCT s1.stylevarid\n\t\t\tFROM " . TABLE_PREFIX . "stylevar AS s1\n\t\t\tINNER JOIN " . TABLE_PREFIX . "stylevar AS s2 ON\n\t\t\t\t(s2.styleid IN ({$style['parentlist']}) AND s2.styleid <> {$style['styleid']} AND s2.stylevarid = s1.stylevarid)\n\t\t\tWHERE s1.styleid = {$style['styleid']}\n\t\t"); if ($db->num_rows($stylevars) == 0) { print_stop_message('nothing_to_do'); } else { $deletestylevars = array(); while ($stylevar = $db->fetch_array($stylevars)) { $deletestylevars[] = "'" . $stylevar['stylevarid'] . "'"; } $db->free_result($stylevars); if (!empty($deletestylevars)) { $db->query_write("DELETE FROM " . TABLE_PREFIX . "stylevar WHERE styleid = {$style['styleid']} AND stylevarid IN(" . implode(',', $deletestylevars) . ")"); print_rebuild_style($style['styleid']); } print_cp_redirect("stylevar.php?" . $vbulletin->session->vars['sessionurl'] . "do=modify&dostyleid={$style['styleid']}", 1); } } else { print_stop_message('invalid_style_specified'); } } // ############################################################################# // revert all StyleVars in a style if ($_REQUEST['do'] == 'revertall') { if ($vbulletin->GPC['dostyleid'] != -1 and $vbulletin->GPC['dostyleid'] != -2 and $style = $db->query_first("SELECT type, styleid, title, parentlist FROM " . TABLE_PREFIX . "style WHERE styleid = " . $vbulletin->GPC['dostyleid'])) { if (!$style['parentlist']) { $style['parentlist'] = $style['type'] == 'mobile' ? -2 : -1; } $stylevars = $db->query_read("\n\t\t\tSELECT DISTINCT s1.stylevarid\n\t\t\tFROM " . TABLE_PREFIX . "stylevar AS s1\n\t\t\tINNER JOIN " . TABLE_PREFIX . "stylevar AS s2 ON\n\t\t\t\t(s2.styleid IN ({$style['parentlist']}) AND s2.styleid <> {$style['styleid']} AND s2.stylevarid = s1.stylevarid)\n\t\t\tWHERE s1.styleid = {$style['styleid']}\n\t\t");
if ($existing = $db->query_first("\n\t\tSELECT templateid, styleid, title, template\n\t\tFROM " . TABLE_PREFIX . "template\n\t\tWHERE styleid = " . $vbulletin->GPC['dostyleid'] . "\n\t\t\tAND templatetype = 'replacement'\n\t\t\tAND title = '" . $db->escape_string($vbulletin->GPC['findtext']) . "'\n\t")) { print_stop_message('replacement_already_exists', htmlspecialchars_uni($existing['title']), htmlspecialchars_uni($existing['template']), "replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&dostyleid={$existing['styleid']}&templateid={$existing['templateid']}"); } else { /*insert query*/ $db->query_write("\n\t\t\tINSERT INTO " . TABLE_PREFIX . "template\n\t\t\t\t(styleid, templatetype, title, template)\n\t\t\tVALUES\n\t\t\t\t(" . $vbulletin->GPC['dostyleid'] . ", 'replacement', '" . $db->escape_string($vbulletin->GPC['findtext']) . "', '" . $db->escape_string($vbulletin->GPC['replacetext']) . "')\n\t\t"); $style = $db->query_first("SELECT styleid, title FROM " . TABLE_PREFIX . "style WHERE styleid = " . $vbulletin->GPC['dostyleid']); if ($vbulletin->GPC['dostyleid'] == -1) { $title = $vbphrase['master_style']; } else { if ($vbulletin->GPC['dostyleid'] == -2) { $title = $vbphrase['mobile_master_style']; } else { $title = $style['title']; } } print_rebuild_style($vbulletin->GPC['dostyleid'], $title, 0, 0, 1, 0); print_cp_redirect("replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=modify", 1); } } // *********************** add ********************* if ($_REQUEST['do'] == 'add') { print_form_header('replacement', 'insert'); print_table_header($vbphrase['add_new_replacement_variable']); print_style_chooser_row('dostyleid', $vbulletin->GPC['dostyleid'], $vbphrase['master_style'], $vbphrase['style'], $vbulletin->debug == 1 ? 1 : 0); print_input_row("{$vbphrase['search_for_text']} <dfn>({$vbphrase['case_insensitive']})</dfn>", 'findtext', ''); print_textarea_row($vbphrase['replace_with_text'], 'replacetext', '', 5, 50); print_submit_row($vbphrase['save']); } // *********************** modify ********************* if ($_REQUEST['do'] == 'modify') { // ###################### Start displayreplacements #######################