function createadcells($x_adcode) { global $addelimiter, $vbulletin, $vbphrase; if (strpos($x_adcode, '</if>') !== False || strpos($x_adcode, '$') !== False) { eval('$x_adcode = "' . compile_template($x_adcode) . '";'); } $x_adcoded = explode($addelimiter, $x_adcode); foreach ($x_adcoded as $x_adcode) { $cell++; $total++; if ($total != count($x_adcoded)) { $x_adcode_cells .= '<td class="alt1" style="width:' . 100 / $vbulletin->options['adintegrate_sponsors_rows'] . '%">' . $x_adcode . '</td>'; if ($cell == $vbulletin->options['adintegrate_sponsors_rows']) { $x_adcode_cells .= '</tr><tr>'; $cell = '0'; } } else { $colspan = $total % ($vbulletin->options['adintegrate_sponsors_rows'] + $cell); if ($colspan == '1') { $colspan = '2'; } $x_adcode_cells .= '<td class="alt1" colspan="' . $colspan . '">' . $x_adcode . '</td>'; } } return $x_adcode_cells; }
function build_bbcode_video($checktable = false) { global $vbulletin; if ($checktable) { $vbulletin->db->hide_errors(); $vbulletin->db->query_write("SELECT url FROM " . TABLE_PREFIX . "bbcode_video LIMIT 1"); $vbulletin->db->show_errors(); if ($vbulletin->db->errno()) { return; } } require_once DIR . '/includes/class_xml.php'; $xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/bbcode_video_vbulletin.xml'); $data = $xmlobj->parse(); if (is_array($data['provider'])) { $insert = array(); foreach ($data['provider'] as $provider) { $items = array(); $items['tagoption'] = "'" . $vbulletin->db->escape_string($provider['tagoption']) . "'"; $items['provider'] = "'" . $vbulletin->db->escape_string($provider['title']) . "'"; $items['url'] = "'" . $vbulletin->db->escape_string($provider['url']) . "'"; $items['regex_url'] = "'" . $vbulletin->db->escape_string($provider['regex_url']) . "'"; $items['regex_scrape'] = "'" . $vbulletin->db->escape_string($provider['regex_scrape']) . "'"; $items['embed'] = "'" . $vbulletin->db->escape_string($provider['embed']) . "'"; $insert[] = implode(", ", $items); } if (!empty($insert)) { $vbulletin->db->query_write("TRUNCATE TABLE " . TABLE_PREFIX . "bbcode_video"); $vbulletin->db->query_write("\n\t\t\t\tINSERT INTO " . TABLE_PREFIX . "bbcode_video\n\t\t\t\t\t(tagoption, provider, url, regex_url, regex_scrape, embed)\n\t\t\t\tVALUES\n\t\t\t\t\t(" . implode("), (", $insert) . ")\n\t\t\t"); } } $firsttag = '<vb:if condition="$provider == \'%1$s\'">'; $secondtag = '<vb:elseif condition="$provider == \'%1$s\'" />'; $template = array(); $bbcodes = $vbulletin->db->query_read("\n\t\tSELECT\n\t\t\ttagoption, embed\n\t\tFROM " . TABLE_PREFIX . "bbcode_video\n\t\tORDER BY priority\n\t"); while ($bbcode = $vbulletin->db->fetch_array($bbcodes)) { if (empty($template)) { $template[] = sprintf($firsttag, $bbcode['tagoption']); } else { $template[] = sprintf($secondtag, $bbcode['tagoption']); } $template[] = $bbcode['embed']; } $template[] = "</vb:if>"; $final = implode("\r\n", $template); $vbulletin->db->query_write("\n\t\tDELETE FROM " . TABLE_PREFIX . "template\n\t\tWHERE\n\t\t\ttitle = 'bbcode_video'\n\t\t\tAND\n\t\t\tproduct IN ('', 'vbulletin')\n\t\t\tAND\n\t\t\tstyleid = 0\n\t"); require_once DIR . '/includes/adminfunctions_template.php'; if ($exists = $vbulletin->db->query_first_slave("\n\t\tSELECT templateid\n\t\tFROM " . TABLE_PREFIX . "template\n\t\tWHERE\n\t\t\ttitle = 'bbcode_video'\n\t\t\t\tAND\n\t\t\tproduct IN ('', 'vbulletin')\n\t\t\t\tAND\n\t\t\tstyleid = -1\n\t\t")) { $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "template\n\t\t\tSET\n\t\t\t\ttemplate = '" . $vbulletin->db->escape_string(compile_template($final)) . "',\n\t\t\t\ttemplate_un = '" . $vbulletin->db->escape_string($final) . "',\n\t\t\t\tdateline = " . TIMENOW . ",\n\t\t\t\tusername = '******'username']) . "',\n\t\t\t\tversion = '" . $vbulletin->options['templateversion'] . "'\n\t\t\tWHERE\n\t\t\t\ttemplateid = {$exists['templateid']}\n\t\t"); } else { $vbulletin->db->query_write("\n\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t(template, template_un, dateline, username, templatetype, styleid, title, product, version)\n\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t'" . $vbulletin->db->escape_string(compile_template($final)) . "',\n\t\t\t\t\t'" . $vbulletin->db->escape_string($final) . "',\n\t\t\t\t\t" . TIMENOW . ",\n\t\t\t\t\t'" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\t\t'template',\n\t\t\t\t\t'-1',\n\t\t\t\t\t'bbcode_video',\n\t\t\t\t\t'vbulletin',\n\t\t\t\t\t'" . $vbulletin->options['templateversion'] . "'\n\t\t\t\t)\n\t\t"); } if ($exists = $vbulletin->db->query_first_slave("\n\t\tSELECT templateid\n\t\tFROM " . TABLE_PREFIX . "template\n\t\tWHERE\n\t\t\ttitle = 'bbcode_video'\n\t\t\t\tAND\n\t\t\tproduct IN ('', 'vbulletin')\n\t\t\t\tAND\n\t\t\tstyleid = -2\n\t\t")) { $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "template\n\t\t\tSET\n\t\t\t\ttemplate = '" . $vbulletin->db->escape_string(compile_template($final)) . "',\n\t\t\t\ttemplate_un = '" . $vbulletin->db->escape_string($final) . "',\n\t\t\t\tdateline = " . TIMENOW . ",\n\t\t\t\tusername = '******'username']) . "',\n\t\t\t\tversion = '" . $vbulletin->options['templateversion'] . "'\n\t\t\tWHERE\n\t\t\t\ttemplateid = {$exists['templateid']}\n\t\t"); } else { $vbulletin->db->query_write("\n\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t(template, template_un, dateline, username, templatetype, styleid, title, product, version)\n\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t'" . $vbulletin->db->escape_string(compile_template($final)) . "',\n\t\t\t\t\t'" . $vbulletin->db->escape_string($final) . "',\n\t\t\t\t\t" . TIMENOW . ",\n\t\t\t\t\t'" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\t\t'template',\n\t\t\t\t\t'-2',\n\t\t\t\t\t'bbcode_video',\n\t\t\t\t\t'vbulletin',\n\t\t\t\t\t'" . $vbulletin->options['templateversion'] . "'\n\t\t\t\t)\n\t\t"); } }
/** * Step #1 * */ function step_1() { $doads = array('thread_first_post_content' => 1, 'thread_last_post_content' => 1); require_once DIR . '/includes/adminfunctions_template.php'; $ads = $this->db->query_read("\n\t\t\tSELECT adlocation, COUNT( * ) AS count\n\t\t\tFROM " . TABLE_PREFIX . "ad\n\t\t\tWHERE\n\t\t\t\tadlocation IN ('" . implode('\', \'', array_keys($doads)) . "')\n\t\t\t\t\tAND\n\t\t\t\tactive = 1\n\t\t\tGROUP BY\n\t\t\t\tadlocation\n\t\t"); while ($ad = $this->db->fetch_array($ads)) { unset($doads[$ad['adlocation']]); } $count = 0; foreach (array_keys($doads) as $ad) { $count++; $template_un = ''; $template = compile_template($template_un); // This template should never be false since it goes in empty but to be consistent if ($template === false) { $this->show_message(sprintf($this->phrase['vbphrase']['compile_template_x_failed'], 'ad_' . $ad)); } else { $this->run_query(sprintf($this->phrase['core']['altering_x_table'], 'template', $count, count($doads)), "UPDATE " . TABLE_PREFIX . "template\n\t\t\t\t\tSET\n\t\t\t\t\t\ttemplate = '" . $this->db->escape_string($template) . "',\n\t\t\t\t\t\ttemplate_un = '',\n\t\t\t\t\t\tdateline = " . TIMENOW . "\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tstyleid IN (-1,0)\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\ttitle = 'ad_" . $this->db->escape_string($ad) . "'\n\t\t\t\t\t"); } } if (!$count) { $this->skip_message(); } }
function build_bbcode_video() { global $vbulletin; require_once(DIR . '/includes/class_xml.php'); $xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/bbcode_video_vbulletin.xml'); $data = $xmlobj->parse(); if (is_array($data['provider'])) { $insert = array(); foreach ($data['provider'] AS $provider) { $items = array(); $items['tagoption'] = "'" . $vbulletin->db->escape_string($provider['tagoption']) . "'"; $items['provider'] = "'" . $vbulletin->db->escape_string($provider['title']) . "'"; $items['url'] = "'" . $vbulletin->db->escape_string($provider['url']) . "'"; $items['regex_url'] = "'" . $vbulletin->db->escape_string($provider['regex_url']) . "'"; $items['regex_scrape'] = "'" . $vbulletin->db->escape_string($provider['regex_scrape']) . "'"; $items['embed'] = "'" . $vbulletin->db->escape_string($provider['embed']) . "'"; $insert[] = implode(", ", $items); } if (!empty($insert)) { $vbulletin->db->query_write("TRUNCATE TABLE " . TABLE_PREFIX . "bbcode_video"); $vbulletin->db->query_write(" INSERT INTO " . TABLE_PREFIX . "bbcode_video (tagoption, provider, url, regex_url, regex_scrape, embed) VALUES (" . implode("), (", $insert) . ") "); } } $firsttag = '<vb:if condition="$provider == \'%1$s\'">'; $secondtag = '<vb:elseif condition="$provider == \'%1$s\'" />'; $template = array(); $bbcodes = $vbulletin->db->query_read(" SELECT tagoption, embed FROM " . TABLE_PREFIX . "bbcode_video ORDER BY priority "); while ($bbcode = $vbulletin->db->fetch_array($bbcodes)) { if (empty($template)) { $template[] = sprintf($firsttag, $bbcode['tagoption']); } else { $template[] = sprintf($secondtag, $bbcode['tagoption']); } $template[] = $bbcode['embed']; } $template[] = "</vb:if>"; $final = implode("\r\n", $template); require_once(DIR . '/includes/adminfunctions_template.php'); if ($exists = $vbulletin->db->query_first_slave(" SELECT templateid FROM " . TABLE_PREFIX . "template WHERE title = 'bbcode_video' AND product IN ('', 'vbulletin') AND styleid = -1 ")) { $vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "template SET template = '" . $vbulletin->db->escape_string(compile_template($final)) . "', template_un = '" . $vbulletin->db->escape_string($final) . "', dateline = " . TIMENOW . ", username = '******'username']) . "', version = '" . $vbulletin->options['templateversion'] . "' WHERE templateid = $exists[templateid] "); } else { $vbulletin->db->query_write(" REPLACE INTO " . TABLE_PREFIX . "template (template, template_un, dateline, username, templatetype, styleid, title, product, version) VALUES ( '" . $vbulletin->db->escape_string(compile_template($final)) . "', '" . $vbulletin->db->escape_string($final) . "', " . TIMENOW . ", '" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "', 'template', '-1', 'bbcode_video', 'vbulletin', '" . $vbulletin->options['templateversion'] . "' ) "); } }
require_once DIR . '/includes/functions_ranks.php'; build_ranks(); // rebuild the smilie cache -- something has changed in 3.5 that this fixes build_image_cache('smilie'); // rebuild the options for the new aggressive email ban option/ // since it defaults to off but 3.0.x users are used to it being on, // put it on for upgrades $db->query_write("\n\t\tREPLACE INTO " . TABLE_PREFIX . "setting\n\t\t\t(varname, grouptitle, value, defaultvalue, optioncode, displayorder, advanced, volatile)\n\t\tVALUES\n\t\t\t('aggressiveemailban', 'banning', '0', '0', 'yesno', 31, 0, 1)\n\t"); build_options(); // rebuild the forum perms for the new can view thread content perm build_forum_permissions(); // rebuild any custom templates for new variables require_once DIR . '/includes/adminfunctions_template.php'; $customs = $db->query_read("\n\t\tSELECT templateid, template_un\n\t\tFROM " . TABLE_PREFIX . "template\n\t\tWHERE styleid <> -1 AND templatetype = 'template'\n\t"); while ($custom = $db->fetch_array($customs)) { $newtemplate = compile_template($custom['template_un']); $db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "template SET\n\t\t\t\ttemplate = '" . $db->escape_string($newtemplate) . "'\n\t\t\tWHERE templateid = {$custom['templateid']}\n\t\t"); } // tell log_upgrade_step() that the script is done define('SCRIPTCOMPLETE', true); } // ############################################################################# print_next_step(); print_upgrade_footer(); // ###################### Start updateattachmenttypes ####################### function build_attachment_types() { global $vbulletin; $data = array(); $types = $vbulletin->db->query_read("\n\t\tSELECT extension, size, height, width, enabled, thumbnail, newwindow\n\t\tFROM " . TABLE_PREFIX . "attachmenttype\n\t\tORDER BY extension\n\t"); while ($type = $vbulletin->db->fetch_array($types)) {
/** * Step #94 - add YUI to headinclude so things don't suddenly just stop working * */ function step_94() { require_once DIR . '/includes/adminfunctions_template.php'; $skip = true; $templates = $this->db->query_read("\n\t\t\tSELECT *\n\t\t\tFROM " . TABLE_PREFIX . "template\n\t\t\tWHERE styleid > 0\n\t\t\t\tAND title IN ('headinclude')\n\t\t"); while ($template = $this->db->fetch_array($templates)) { if (strpos($template['template_un'], '$stylevar[yuipath]') !== false) { continue; } $template['template_un'] = str_replace('<script type="text/javascript">' . "\r\n" . '<!--' . "\r\n" . 'var SESSIONURL = "$session[sessionurl_js]";', '<script type="text/javascript" src="$stylevar[yuipath]/yahoo-dom-event/yahoo-dom-event.js?v=$vboptions[simpleversion]"></script>' . "\n" . '<script type="text/javascript" src="$stylevar[yuipath]/connection/connection-min.js?v=$vboptions[simpleversion]"></script>' . "\n" . '<script type="text/javascript">' . "\n" . '<!--' . "\n" . 'var SESSIONURL = "$session[sessionurl_js]";', $template['template_un']); // check in case it was newlines only if (strpos($template['template_un'], '$stylevar[yuipath]') === false) { $template['template_un'] = str_replace('<script type="text/javascript">' . "\n" . '<!--' . "\n" . 'var SESSIONURL = "$session[sessionurl_js]";', '<script type="text/javascript" src="$stylevar[yuipath]/yahoo-dom-event/yahoo-dom-event.js?v=$vboptions[simpleversion]"></script>' . "\n" . '<script type="text/javascript" src="$stylevar[yuipath]/connection/connection-min.js?v=$vboptions[simpleversion]"></script>' . "\n" . '<script type="text/javascript">' . "\n" . '<!--' . "\n" . 'var SESSIONURL = "$session[sessionurl_js]";', $template['template_un']); } $compiled_template = compile_template($template['template_un']); if ($compiled_template === false) { $this->show_message(sprintf($this->phrase['vbphrase']['compile_template_x_failed'], $template['title'])); } else { $this->run_query(sprintf($this->phrase['vbphrase']['apply_critical_template_change_to_x'], $template['title'], $template['styleid']), "UPDATE " . TABLE_PREFIX . "template SET\n\t\t\t\t\t\ttemplate = '" . $this->db->escape_string($compiled_template) . "',\n\t\t\t\t\t\ttemplate_un = '" . $this->db->escape_string($template['template_un']) . "'\n\t\t\t\t\tWHERE templateid = {$template['templateid']}\n\t\t\t\t"); } $skip = false; } if ($skip) { $this->skip_message(); } }
'; } }); //--> </script> <?php } // ############################################################################# // simple update query for an existing template if ($_POST['do'] == 'updatetemplate') { $vbulletin->input->clean_array_gpc('p', array('title' => TYPE_STR, 'oldtitle' => TYPE_STR, 'template' => TYPE_NOTRIM, 'group' => TYPE_STR, 'product' => TYPE_STR, 'savehistory' => TYPE_BOOL, 'histcomment' => TYPE_STR, 'string' => TYPE_STR, 'searchstring' => TYPE_STR, 'expandset' => TYPE_NOHTML, 'searchset' => TYPE_NOHTML, 'return' => TYPE_STR, 'confirmerrors' => TYPE_BOOL, 'lastedit' => TYPE_UINT)); // remove escaped CDATA (just in case user is pasting template direct from an XML editor // where the CDATA tags will have been escaped by our escaper... // $template = xml_unescape_cdata($template); $template_un = $vbulletin->GPC['template']; $vbulletin->GPC['template'] = compile_template($vbulletin->GPC['template']); // error checking on conditionals if (empty($vbulletin->GPC['confirmerrors'])) { $errors = check_template_errors($vbulletin->GPC['template']); if (!empty($errors)) { print_form_header('template', 'updatetemplate', 0, 1, '', '75%'); construct_hidden_code('confirmerrors', 1); construct_hidden_code('title', $vbulletin->GPC['title']); construct_hidden_code('template', $template_un); construct_hidden_code('templateid', $vbulletin->GPC['templateid']); construct_hidden_code('group', $vbulletin->GPC['group']); construct_hidden_code('searchstring', $vbulletin->GPC['searchstring']); construct_hidden_code('dostyleid', $vbulletin->GPC['dostyleid']); construct_hidden_code('product', $vbulletin->GPC['product']); construct_hidden_code('savehistory', intval($vbulletin->GPC['savehistory'])); construct_hidden_code('histcomment', $vbulletin->GPC['histcomment']);
if ($comp and $sort and $ad_swap = $db->query_first("SELECT adid, displayorder FROM " . TABLE_PREFIX . "ad WHERE displayorder {$comp} {$ad_orig['displayorder']} ORDER BY displayorder {$sort}, title ASC LIMIT 1")) { $db->query_write("\r\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "ad\r\n\t\t\t\t\tSET displayorder = CASE adid\r\n\t\t\t\t\t\tWHEN {$ad_orig['adid']} THEN {$ad_swap['displayorder']}\r\n\t\t\t\t\t\tWHEN {$ad_swap['adid']} THEN {$ad_orig['displayorder']}\r\n\t\t\t\t\t\tELSE displayorder END\r\n\t\t\t\t\tWHERE adid IN({$ad_orig['adid']}, {$ad_swap['adid']})\r\n\t\t\t\t"); // tell the datastore to update $changes = true; } } } //update the ad templates if ($changes) { require_once DIR . '/includes/functions_ad.php'; require_once DIR . '/includes/adminfunctions_template.php'; foreach ($changed_locations as $location) { // same as above, we're not telling user errors here, because they already confirmed the error else where $template = wrap_ad_template(build_ad_template($location), $location); $template_un = $template; $template = compile_template($template); $db->query_write("\r\n\t\t\t\tUPDATE " . TABLE_PREFIX . "template SET\r\n\t\t\t\t\ttemplate = '" . $db->escape_string($template) . "',\r\n\t\t\t\t\ttemplate_un = '" . $db->escape_string($template_un) . "',\r\n\t\t\t\t\tdateline = " . TIMENOW . ",\r\n\t\t\t\t\tusername = '******'username']) . "'\r\n\t\t\t\tWHERE\r\n\t\t\t\t\ttitle = 'ad_" . $db->escape_string($location) . "'\r\n\t\t\t\t\tAND styleid IN (-1,0)\r\n\t\t\t"); } } $_REQUEST['do'] = 'modify'; } // ############################################################################# // list existing ads if ($_REQUEST['do'] == 'modify') { print_form_header('ad', 'quickupdate'); print_column_style_code(array('width:100%', 'white-space:nowrap')); print_table_header($vbphrase['ad_manager']); $ad_result = $db->query("SELECT * FROM " . TABLE_PREFIX . "ad ORDER BY displayorder, title"); $ad_count = $db->num_rows($ad_result); if ($ad_count) { print_description_row('<label><input type="checkbox" id="allbox" checked="checked" />' . $vbphrase['toggle_active_status_for_all'] . '</label><input type="image" src="../' . $vbulletin->options['cleargifurl'] . '" name="normalsubmit" />', false, 2, 'thead" style="font-weight:normal; padding:0px 4px 0px 4px');
construct_hidden_code('product', $vbulletin->GPC['product']); construct_hidden_code('savehistory', intval($vbulletin->GPC['savehistory'])); construct_hidden_code('histcomment', $vbulletin->GPC['histcomment']); print_table_header($vbphrase['vbulletin_message']); print_description_row($error); print_submit_row($vbphrase['continue'], 0, 2, $vbphrase['go_back']); print_cp_footer(); } // remove escaped CDATA (just in case user is pasting template direct from an XML editor // where the CDATA tags will have been escaped by our escaper... // $template = xml_unescape_cdata($template); $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;
/** * Step #4 - special case for who's online: a form that should be get * */ function step_4() { require_once DIR . '/includes/adminfunctions_template.php'; $skip = true; $templates = $this->db->query_read("\n\t\t\tSELECT *\n\t\t\tFROM " . TABLE_PREFIX . "template\n\t\t\tWHERE styleid > 0\n\t\t\t\tAND title IN ('WHOSONLINE')\n\t\t"); while ($template = $this->db->fetch_array($templates)) { if (strpos($template['template_un'], '<form action="online.php" method="get">') !== false) { continue; } $template['template_un'] = str_replace('<form action="online.php" method="post">', '<form action="online.php" method="get">', $template['template_un']); $compiled_template = compile_template($template['template_un']); $skip = false; if ($compiled_template === false) { $this->show_message(sprintf($this->phrase['vbphrase']['compile_template_x_failed'], $template['title'])); } else { $this->run_query(sprintf($this->phrase['vbphrase']['apply_critical_template_change_to_x'], $template['title'], $template['styleid']), "UPDATE " . TABLE_PREFIX . "template SET\n\t\t\t\t\t\ttemplate = '" . $this->db->escape_string($compiled_template) . "',\n\t\t\t\t\t\ttemplate_un = '" . $this->db->escape_string($template['template_un']) . "'\n\t\t\t\t\tWHERE templateid = {$template['templateid']}\n\t\t\t\t"); } } if ($skip) { $this->skip_message(); } }
/** * Step #12 - rebuild ads that use the is_date criterion #36100 or browsing forum criteria #34416 * */ function step_12() { $this->show_message($this->phrase['version']['403']['rebuilding_ad_criteria']); $ad_result = $this->db->query_read("\n\t\t\tSELECT ad.*\n\t\t\tFROM " . TABLE_PREFIX . "ad AS ad\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "adcriteria AS adcriteria ON(adcriteria.adid = ad.adid)\n\t\t\tWHERE adcriteria.criteriaid IN('is_date', 'browsing_forum_x', 'browsing_forum_x_and_children')\n\t\t"); if ($this->db->num_rows($ad_result) > 0) { $ad_cache = array(); $ad_locations = array(); while ($ad = $this->db->fetch_array($ad_result)) { $ad_cache["{$ad['adid']}"] = $ad; $ad_locations[] = $ad['adlocation']; } require_once DIR . '/includes/functions_ad.php'; require_once DIR . '/includes/adminfunctions_template.php'; foreach ($ad_locations as $location) { $template = wrap_ad_template(build_ad_template($location), $location); $template_un = $template; $template = compile_template($template); if (template === false) { $this->show_message(sprintf($this->phrase['vbphrase']['compile_template_x_failed'], 'ad_' . $location)); } else { $this->run_query(sprintf($this->phrase['vbphrase']['update_table'], TABLE_PREFIX . 'templatehistory'), "\n\t\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "template SET\n\t\t\t\t\t\t\t\ttemplate = '" . $this->db->escape_string($template) . "',\n\t\t\t\t\t\t\t\ttemplate_un = '" . $this->db->escape_string($template_un) . "',\n\t\t\t\t\t\t\t\tdateline = " . TIMENOW . ",\n\t\t\t\t\t\t\t\tusername = '******'username']) . "'\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\ttitle = 'ad_" . $this->db->escape_string($location) . "'\n\t\t\t\t\t\t\t\tAND styleid IN (-1,0)\n\t\t\t\t\t\t"); } } build_all_styles(); } }
WHERE layout.gridid = " . intval($gridinfo['gridid']) . " AND lw.layoutcolumn > $count "); require_once(DIR . '/includes/adminfunctions_template.php'); $title = "vbcms_grid_$gridinfo[gridid]"; $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') {
/** * 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(); }
/** * Called when a merge succeeds (no conflicts). * * @param string Final merged text * @param array Array of template info. Record returned by data method. */ protected function merge_success($merged_text, $template_info) { global $vbphrase; $db = $this->registry->db; $db->query_write("\n\t\t\tINSERT INTO " . TABLE_PREFIX . "templatehistory\n\t\t\t\t(styleid, title, template, dateline, username, version)\n\t\t\tVALUES\n\t\t\t\t('" . $template_info['styleid'] . "',\n\t\t\t\t'" . $db->escape_string($template_info['title']) . "',\n\t\t\t\t'" . $db->escape_string($template_info['customtext']) . "',\n\t\t\t\t{$template_info['dateline']},\n\t\t\t\t'" . $db->escape_string($template_info['username']) . "',\n\t\t\t\t'" . $db->escape_string($template_info['version']) . "')\n\t\t"); $savedtemplateid = $db->insert_id(); $db->query_write("\n\t\t\tREPLACE INTO " . TABLE_PREFIX . "templatemerge\n\t\t\t\t(templateid, template, version, savedtemplateid)\n\t\t\tVALUES\n\t\t\t\t({$template_info['templateid']},\n\t\t\t\t'" . $db->escape_string($template_info['oldmastertext']) . "',\n\t\t\t\t'" . $db->escape_string($template_info['oldmasterversion']) . "',\n\t\t\t\t" . intval($savedtemplateid) . "\n\t\t\t\t)\n\t\t"); vB::getDbAssertor()->update('template', array('styleid' => $template_info['styleid'], 'templatetype' => 'template', 'title' => $template_info['title'], 'template' => compile_template($merged_text), 'template_un' => $merged_text, 'dateline' => vB::getRequest()->getTimeNow(), 'username' => !empty($vbphrase['system']) ? $vbphrase['system'] : 'System', 'version' => $this->merge_version, 'product' => $template_info['product'], 'mergestatus' => 'merged'), array('templateid' => $template_info["templateid"])); if ($this->show_output) { return $this->output_merge_success($merged_text, $template_info); } }
/** * Installs a product from the xml text * * This function depends on the vb class loader, which requires that the * framework init is called. * * @return bool True if the product requires a template merge, false otherwise */ function install_product($xml, $allow_overwrite = false, $verbose = true) { global $vbphrase; global $vbulletin; $assertor = vB::getDbAssertor(); require_once DIR . '/includes/class_bitfield_builder.php'; require_once DIR . '/includes/class_xml.php'; //share some code with the main xml style import require_once DIR . '/includes/adminfunctions_template.php'; if ($verbose) { print_dots_start('<b>' . $vbphrase['importing_product'] . "</b>, {$vbphrase['please_wait']}", ':', 'dspan'); } $xmlobj = new vB_XML_Parser($xml); if ($xmlobj->error_no() == 1) { if ($verbose) { print_dots_stop(); } throw new vB_Exception_AdminStopMessage('no_xml_and_no_path'); } if (!($arr = $xmlobj->parse())) { if ($verbose) { print_dots_stop(); } throw new vB_Exception_AdminStopMessage(array('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line())); } // ############## general product information $info = array('productid' => substr(preg_replace('#[^a-z0-9_]#', '', strtolower($arr['productid'])), 0, 25), 'title' => $arr['title'], 'description' => $arr['description'], 'version' => $arr['version'], 'active' => $arr['active'], 'url' => $arr['url'], 'versioncheckurl' => $arr['versioncheckurl']); if (!$info['productid']) { if ($verbose) { print_dots_stop(); } throw new vB_Exception_AdminStopMessage('invalid_file_specified'); } if (strtolower($info['productid']) == 'vbulletin') { if ($verbose) { print_dots_stop(); } throw new vB_Exception_AdminStopMessage(array('product_x_installed_no_overwrite', 'vBulletin')); } // check for bitfield conflicts on install $bitfields = vB_Bitfield_Builder::return_data(); if (!$bitfields) { $bfobj =& vB_Bitfield_Builder::init(); if ($bfobj->errors) { if ($verbose) { print_dots_stop(); } throw new vB_Exception_AdminStopMessage(array('bitfield_conflicts_x', '<li>' . implode('</li><li>', $bfobj->errors) . '</li>')); } } // get system version info $system_versions = array('php' => PHP_VERSION, 'vbulletin' => $vbulletin->options['templateversion'], 'products' => fetch_product_list(true)); $mysql_version = $assertor->getRow('mysqlVersion'); $system_versions['mysql'] = $mysql_version['version']; // ############## import dependencies if (isset($arr['dependencies']['dependency']) and is_array($arr['dependencies']['dependency'])) { $dependencies =& $arr['dependencies']['dependency']; if (!isset($dependencies[0])) { $dependencies = array($dependencies); } $dependency_errors = array(); $ignore_dependency_errors = array(); // let's check the dependencies foreach ($dependencies as $dependency) { // if we get an error, we haven't met this dependency // if we go through without a problem, we have automatically met // all dependencies for this "class" (mysql, php, vb, a specific product, etc) $this_dependency_met = true; // build a phrase for the version compats -- will look like (minver / maxver) if ($dependency['minversion']) { $compatible_phrase = construct_phrase($vbphrase['compatible_starting_with_x'], htmlspecialchars_uni($dependency['minversion'])); } else { $compatible_phrase = ''; } if ($dependency['maxversion']) { $incompatible_phrase = construct_phrase($vbphrase['incompatible_with_x_and_greater'], htmlspecialchars_uni($dependency['maxversion'])); } else { $incompatible_phrase = ''; } if ($compatible_phrase or $incompatible_phrase) { $required_version_info = "({$compatible_phrase}"; if ($compatible_phrase and $incompatible_phrase) { $required_version_info .= ' / '; } $required_version_info .= "{$incompatible_phrase})"; } // grab the appropriate installed version string if ($dependency['dependencytype'] == 'product') { // group dependencies into types -- individual products get their own group $dependency_type_key = "product-{$dependency['parentproductid']}"; // undocumented feature -- you can put a producttitle attribute in a dependency so the id isn't displayed $parent_product_title = !empty($dependency['producttitle']) ? $dependency['producttitle'] : $dependency['parentproductid']; $parent_product = $system_versions['products']["{$dependency['parentproductid']}"]; if (!$parent_product) { // required product is not installed $dependency_errors["{$dependency_type_key}"] = construct_phrase($vbphrase['product_x_must_be_installed'], htmlspecialchars_uni($parent_product_title), $required_version_info); continue; // can't do version checks if the product isn't installed } else { if ($parent_product['active'] == 0) { // product is installed, but inactive $dependency_errors["{$dependency_type_key}-inactive"] = construct_phrase($vbphrase['product_x_must_be_activated'], htmlspecialchars_uni($parent_product_title)); $this_dependency_met = false; // allow version checks to continue } } $sys_version_str = $parent_product['version']; $version_incompatible_phrase = 'product_incompatible_version_x_product_y'; } else { $dependency_type_key = $dependency['dependencytype']; $parent_product_title = ''; $sys_version_str = $system_versions["{$dependency['dependencytype']}"]; $version_incompatible_phrase = 'product_incompatible_version_x_' . $dependency['dependencytype']; } // if no version string, we are trying to do an unsupported dep check if ($sys_version_str == '') { continue; } $sys_version = fetch_version_array($sys_version_str); // error if installed version < minversion if ($dependency['minversion']) { $dep_version = fetch_version_array($dependency['minversion']); for ($i = 0; $i <= 5; $i++) { if ($sys_version["{$i}"] < $dep_version["{$i}"]) { // installed version is too old $dependency_errors["{$dependency_type_key}"] = construct_phrase($vbphrase["{$version_incompatible_phrase}"], htmlspecialchars_uni($sys_version_str), $required_version_info, $parent_product_title); $this_dependency_met = false; break; } else { if ($sys_version["{$i}"] > $dep_version["{$i}"]) { break; } } } } // error if installed version >= maxversion if ($dependency['maxversion']) { $dep_version = fetch_version_array($dependency['maxversion']); $all_equal = true; for ($i = 0; $i <= 5; $i++) { if ($sys_version["{$i}"] > $dep_version["{$i}"]) { // installed version is newer than the maxversion $dependency_errors["{$dependency_type_key}"] = construct_phrase($vbphrase["{$version_incompatible_phrase}"], htmlspecialchars_uni($sys_version_str), $required_version_info, $parent_product_title); $this_dependency_met = false; break; } else { if ($sys_version["{$i}"] < $dep_version["{$i}"]) { // not every part is the same and since we've got less we can exit $all_equal = false; break; } else { if ($sys_version["{$i}"] != $dep_version["{$i}"]) { // not every part is the same $all_equal = false; } } } } if ($all_equal == true) { // installed version is same as the max version, which is the first incompat version $dependency_errors["{$dependency_type_key}"] = construct_phrase($vbphrase["{$version_incompatible_phrase}"], htmlspecialchars_uni($sys_version_str), $required_version_info, $parent_product_title); $this_dependency_met = false; } } if ($this_dependency_met) { // we met 1 dependency for this type -- this emulates or'ing together groups $ignore_dependency_errors["{$dependency_type_key}"] = true; } } // for any group we met a dependency for, ignore any errors we might // have gotten for the group foreach ($ignore_dependency_errors as $dependency_type_key => $devnull) { unset($dependency_errors["{$dependency_type_key}"]); } if ($dependency_errors) { $dependency_errors = array_unique($dependency_errors); $dependency_errors = '<ol><li>' . implode('</li><li>', $dependency_errors) . '</li></ol>'; if ($verbose) { print_dots_stop(); } throw new vB_Exception_AdminStopMessage(array('dependencies_not_met_x', $dependency_errors)); } } // look to see if we already have this product installed if ($existingprod = $assertor->getRow('product', array('productid' => $info['productid']))) { if (!$allow_overwrite) { if ($verbose) { print_dots_stop(); } throw new vB_Exception_AdminStopMessage(array('product_x_installed_no_overwrite', $info['title'])); } $active = $existingprod['active']; // not sure what we're deleting, so rebuild everything $rebuild = array('templates' => true, 'hooks' => true, 'phrases' => true, 'options' => true, 'cron' => true); $installed_version = $existingprod['version']; } else { $active = $info['active'] ? 1 : 0; $rebuild = array('templates' => false, 'hooks' => false, 'phrases' => false, 'options' => false, 'cron' => false); $installed_version = null; } // ############## import install/uninstall code if (isset($arr['codes']['code']) and is_array($arr['codes']['code'])) { $codes =& $arr['codes']['code']; if (!isset($codes[0])) { $codes = array($codes); } // run each of the codes foreach ($codes as $code) { // Run if: code version is * (meaning always run), no version // previously installed, or if the code is for a newer version // than is currently installed if ($code['version'] == '*' or $installed_version === null or is_newer_version($code['version'], $installed_version)) { eval($code['installcode']); } } // Clear routes from datastore build_datastore('routes', serialize(array()), 1); //assume that the product may have installed content types and purge the content type cache vB_Cache::instance()->purge('vb_types.types'); } // dependencies checked, install code run. Now clear out the old product info; // settings should be retained in memory already delete_product($info['productid'], false, true); if (is_array($codes)) { // we've now run all the codes, if execution is still going // then it's going to complete fully, so insert the codes $productCodes = array(); foreach ($codes as $code) { /* insert query */ $productCodes[] = array('productid' => $info['productid'], 'version' => $code['version'], 'installcode' => $code['installcode'], 'uninstallcode' => $code['uninstallcode']); } $assertor->insertMultiple('productcode', array('productid', 'version', 'installcode', 'uninstallcode'), $productCodes); } if (is_array($dependencies)) { // dependencies met, codes run -- now we can insert the dependencies into the DB $productDependencies = array(); foreach ($dependencies as $dependency) { /* insert query */ $productDependencies[] = array('productid' => $info['productid'], 'dependencytype' => $dependency['dependencytype'], 'parentproductid' => $dependency['parentproductid'], 'minversion' => $dependency['minversion'], 'maxversion' => $dependency['maxversion']); } $assertor->insertMultiple('productdependency', array('productid', 'dependencytype', 'parentproductid', 'minversion', 'maxversion'), $productDependencies); } /* insert query */ $assertor->insert('product', array('productid' => $info['productid'], 'title' => $info['title'], 'description' => $info['description'], 'version' => $info['version'], 'active' => intval($active), 'url' => $info['url'], 'versioncheckurl' => $info['versioncheckurl'])); // ############## import templates if (isset($arr['templates']['template']) and is_array($arr['templates']['template'])) { $querybits = array(); $querytemplates = 0; $templates =& $arr['templates']['template']; if (!isset($templates[0])) { $templates = array($templates); } foreach ($templates as $template) { $title = $template['name']; $template['template'] = $template['value']; $template['username'] = $template['username']; $template['templatetype'] = $template['templatetype']; $template['date'] = intval($template['date']); if ($template['templatetype'] != 'template') { // template is a special template $querybits[] = array('styleid' => -1, 'templatetype' => $template['templatetype'], 'title' => $title, 'template' => $template['template'], 'template_un' => '', 'dateline' => $template['date'], 'username' => $template['username'], 'version' => $template['version'], 'product' => $info['productid']); } else { // template is a standard template $querybits[] = array('styleid' => -1, 'templatetype' => $template['templatetype'], 'title' => $title, 'template' => compile_template($template['value']), 'template_un' => $template['template'], 'dateline' => $template['date'], 'username' => $template['username'], 'version' => $template['version'], 'product' => $info['productid']); } if (++$querytemplates % 20 == 0) { /*insert query*/ $assertor->assertQuery('replaceValues', array('values' => $querybits, 'table' => 'template')); $querybits = array(); } // Send some output to the browser inside this loop so certain hosts // don't artificially kill the script. See bug #34585 if (VB_AREA != 'Upgrade' and VB_AREA != 'Install') { echo ' '; vbflush(); } } // insert any remaining templates if (!empty($querybits)) { /*insert query*/ $assertor->assertQuery('replaceValues', array('values' => $querybits, 'table' => 'template')); } unset($querybits); $rebuild['templates'] = true; } // ############## import stylevars if (isset($arr['stylevardfns']['stylevargroup']) and is_array($arr['stylevardfns']['stylevargroup'])) { xml_import_stylevar_definitions($arr['stylevardfns'], $info['productid']); } if (!empty($arr['stylevars']) and is_array($arr['stylevars']) and is_array($arr['stylevars']['stylevar'])) { xml_import_stylevars($arr['stylevars'], -1); } // ############## import hooks if (isset($arr['hooks']['hook']) and is_array($arr['hooks']['hook'])) { $hooks =& $arr['hooks']['hook']; if (!isset($hooks[0])) { $hooks = array($hooks); } foreach ($hooks as $hook) { $hook['product'] = $info['productid']; $assertor->insert('hook', $hook); } $rebuild['hooks'] = true; } // ############## import phrases if (isset($arr['phrases']['phrasetype']) and is_array($arr['phrases']['phrasetype'])) { require_once DIR . '/includes/adminfunctions_language.php'; $master_phrasetypes = array(); $master_phrasefields = array(); foreach (vB_Api::instanceInternal('phrase')->fetch_phrasetypes(false) as $phrasetype) { $master_phrasefields["{$phrasetype['fieldname']}"] = true; } $phrasetypes =& $arr['phrases']['phrasetype']; if (!isset($phrasetypes[0])) { $phrasetypes = array($phrasetypes); } foreach ($phrasetypes as $phrasetype) { if (empty($phrasetype['phrase'])) { continue; } if ($phrasetype['fieldname'] == '' or !preg_match('#^[a-z0-9_]+$#i', $phrasetype['fieldname'])) { continue; } $fieldname = $master_phrasefields["{$phrasetype['fieldname']}"]; if (!$fieldname) { $assertor->assertQuery('installProductPhraseTypeInsert', array('fieldname' => $phrasetype['fieldname'], 'title' => $phrasetype['name'], 'editrows' => 3, 'product' => $info['productid'])); // need to add the column to the language table as well $assertor->assertQuery('addLanguageFromPackage', array('fieldname' => $phrasetype['fieldname'])); } $phrases =& $phrasetype['phrase']; if (!isset($phrases[0])) { $phrases = array($phrases); } $sql = array(); foreach ($phrases as $phrase) { $sql[] = array('languageid' => -1, 'fieldname' => $phrasetype['fieldname'], 'varname' => $phrase['name'], 'text' => $phrase['value'], 'product' => $info['productid'], 'username' => $phrase['username'], 'dateline' => $phrase['date'], 'version' => $phrase['version']); } /*insert query*/ $assertor->assertQuery('replaceValues', array('values' => $sql, 'table' => 'phrase')); } $rebuild['phrases'] = true; } // ############## import settings if (isset($arr['options']['settinggroup']) and is_array($arr['options']['settinggroup'])) { $settinggroups =& $arr['options']['settinggroup']; if (!isset($settinggroups[0])) { $settinggroups = array($settinggroups); } foreach ($settinggroups as $group) { if (empty($group['setting'])) { continue; } // create the setting group if it doesn't already exist $check = $assertor->assertQuery('settinggroup', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'grouptitle' => $group['name'])); if ($check->valid()) { $current = $check->current(); if ($group['adminperm'] != $current['adminperm'] or $group['displayorder'] != $current['displayorder']) { $assertor->assertQuery('settinggroup', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, 'grouptitle' => $group['name'], 'displayorder' => $group['displayorder'], 'adminperm' => $group['adminperm'])); } } else { /*insert query*/ $assertor->assertQuery('settinggroup', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_INSERTIGNORE, 'grouptitle' => $group['name'], 'displayorder' => $group['displayorder'], 'volatile' => 1, 'product' => $info['productid'], 'adminperm' => $group['adminperm'])); } $settings =& $group['setting']; if (!isset($settings[0])) { $settings = array($settings); } $setting_bits = array(); foreach ($settings as $setting) { if (isset($vbulletin->options["{$setting['varname']}"])) { $newvalue = $vbulletin->options["{$setting['varname']}"]; } else { $newvalue = $setting['defaultvalue']; } $setting_bits[] = array('varname' => $setting['varname'], 'grouptitle' => $group['name'], 'value' => trim($newvalue), 'defaultvalue' => trim($setting['defaultvalue']), 'datatype' => trim($setting['datatype']), 'optioncode' => $setting['optioncode'], 'displayorder' => $setting['displayorder'], 'advanced' => intval($setting['advanced']), 'volatile' => 1, 'validationcode' => $setting['validationcode'], 'blacklist' => $setting['blacklist'], 'ispublic' => intval($setting['public']), 'product' => $info['productid'], 'adminperm' => empty($setting['adminperm']) ? '' : $setting['adminperm']); } /*insert query*/ $assertor->assertQuery('replaceValues', array('values' => $setting_bits, 'table' => 'setting')); } $rebuild['options'] = true; } // ############## import admin help if (isset($arr['helptopics']['helpscript']) and is_array($arr['helptopics']['helpscript'])) { $help_scripts =& $arr['helptopics']['helpscript']; if (!isset($help_scripts[0])) { $help_scripts = array($help_scripts); } foreach ($help_scripts as $help_script) { // Deal with single entry if (!is_array($help_script['helptopic'][0])) { $help_script['helptopic'] = array($help_script['helptopic']); } $help_sql = array(); foreach ($help_script['helptopic'] as $topic) { $helpsql[] = array('script' => $help_script['name'], 'action' => $topic['act'], 'optionname' => $topic['opt'], 'displayorder' => intval($topic['disp']), 'volatile' => 1, 'product' => $info['productid']); } if (!empty($helpsql)) { /*insert query*/ $assertor->assertQuery('replaceValues', array('values' => $helpsql, 'table' => 'adminhelp')); } } } // ############## import cron if (isset($arr['cronentries']['cron']) and is_array($arr['cronentries']['cron'])) { require_once DIR . '/includes/functions_cron.php'; $cron_entries =& $arr['cronentries']['cron']; if (!isset($cron_entries[0])) { $cron_entries = array($cron_entries); } foreach ($cron_entries as $cron) { $cron['varname'] = preg_replace('#[^a-z0-9_]#i', '', $cron['varname']); if (!$cron['varname']) { continue; } $cron['active'] = $cron['active'] ? 1 : 0; $cron['loglevel'] = $cron['loglevel'] ? 1 : 0; $scheduling = $cron['scheduling']; $scheduling['weekday'] = intval($scheduling['weekday']); $scheduling['day'] = intval($scheduling['day']); $scheduling['hour'] = intval($scheduling['hour']); $scheduling['minute'] = explode(',', preg_replace('#[^0-9,-]#i', '', $scheduling['minute'])); if (count($scheduling['minute']) == 0) { $scheduling['minute'] = array(0); } else { $scheduling['minute'] = array_map('intval', $scheduling['minute']); } /*insert query*/ $cronSql[] = array('weekday' => $scheduling['weekday'], 'day' => $scheduling['day'], 'hour' => $scheduling['hour'], 'minute' => serialize($scheduling['minute']), 'filename' => $cron['filename'], 'loglevel' => $cron['loglevel'], 'active' => $cron['active'], 'varname' => $cron['varname'], 'volatile' => 1, 'product' => $info['productid']); $cronid = $assertor->assertQuery('replaceValues', array('values' => $cronSql, 'table' => 'cron', 'returnId' => true)); if ($cronid) { build_cron_item($cronid); } $rebuild['cron'] = true; } } // ############## import faq if (isset($arr['faqentries']['faq']) and is_array($arr['faqentries']['faq'])) { $faq_entries =& $arr['faqentries']['faq']; if (!isset($faq_entries[0])) { $faq_entries = array($faq_entries); } $sql = array(); foreach ($faq_entries as $faq) { $sql[] = array('faqname' => $faq['faqname'], 'faqparent' => $faq['faqparent'], 'displayorder' => intval($faq['displayorder']), 'volatile' => 1, 'product' => $info['productid']); } if ($sql) { /*insert query*/ $assertor->assertQuery('replaceValues', array('values' => $sql, 'table' => 'faq')); } } // ############## import widgets if (isset($arr['widgets']['widget']) and is_array($arr['widgets']['widget'])) { $widgetImporter = new vB_Xml_Import_Widget($info['productid']); $widgetImporter->importFromParsedXML($arr['widgets']); } // ############## import pagetemplates if (isset($arr['pagetemplates']['pagetemplate']) and is_array($arr['pagetemplates']['pagetemplate'])) { $pageTemplateImporter = new vB_Xml_Import_PageTemplate($info['productid']); $pageTemplateImporter->importFromParsedXML($arr['pagetemplates']); } // ############## import page if (isset($arr['pages']['page']) and is_array($arr['pages']['page'])) { $pageImporter = new vB_Xml_Import_Page($info['productid']); $pageImporter->importFromParsedXML($arr['pages']); } // ############## import channels if (isset($arr['channels']['channel']) and is_array($arr['channels']['channel'])) { $channelImporter = new vB_Xml_Import_Channel($info['productid']); $channelImporter->importFromParsedXML($arr['channels']); } // ############## import routes if (isset($arr['routes']['route']) and is_array($arr['routes']['route'])) { $routeImporter = new vB_Xml_Import_Route($info['productid']); $routeImporter->importFromParsedXML($arr['routes']); } if (isset($routeImporter)) { // update pages and channels with new route ids if (isset($pageImporter)) { $pageImporter->updatePageRoutes(); } if (isset($channelImporter)) { $channelImporter->updateChannelRoutes(); } } // Check if the hook system is disabled. If it is, enable it. if (!$vbulletin->options['enablehooks']) { $assertor->update('setting', array('value' => 1), array('varname' => 'enablehooks')); $rebuild['options'] = true; } // Now rebuild everything we need... if ($rebuild['hooks']) { vB_Api::instanceInternal("Hook")->buildHookDatastore(); } if ($rebuild['templates']) { if ($error = build_all_styles(0, 0, '', false, $verbose)) { return $error; } } if ($rebuild['phrases']) { require_once DIR . '/includes/adminfunctions_language.php'; build_language(); } if ($rebuild['options']) { vB::getDatastore()->build_options(); } if ($rebuild['cron']) { require_once DIR . '/includes/functions_cron.php'; build_cron_next_run(); } build_product_datastore(); // build bitfields to remove/add this products bitfields vB_Bitfield_Builder::save(); if ($verbose) { print_dots_stop(); } $info['need_merge'] = ($rebuild['templates'] and $installed_version); return $info; }
function xml_import_templates($templates, $masterstyleid, $info, &$rebuild) { global $vbulletin; $querybits = array(); $querytemplates = 0; if (!isset($templates[0])) { $templates = array($templates); } foreach ($templates as $template) { $title = $vbulletin->db->escape_string($template['name']); $template['template'] = $vbulletin->db->escape_string($template['value']); $template['username'] = $vbulletin->db->escape_string($template['username']); $template['templatetype'] = $vbulletin->db->escape_string($template['templatetype']); $template['date'] = intval($template['date']); if ($template['templatetype'] != 'template') { // template is a special template $querybits[] = "({$masterstyleid}, '{$template['templatetype']}', '{$title}', '{$template['template']}', '', {$template['date']}, '{$template['username']}', '" . $vbulletin->db->escape_string($template['version']) . "', '" . $vbulletin->db->escape_string($info['productid']) . "')"; } else { // template is a standard template $querybits[] = "({$masterstyleid}, '{$template['templatetype']}', '{$title}', '" . $vbulletin->db->escape_string(compile_template($template['value'])) . "', '{$template['template']}', {$template['date']}, '{$template['username']}', '" . $vbulletin->db->escape_string($template['version']) . "', '" . $vbulletin->db->escape_string($info['productid']) . "')"; } if (++$querytemplates % 20 == 0) { /*insert query*/ $vbulletin->db->query_write("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t\t(styleid, templatetype, title, template, template_un, dateline, username, version, product)\n\t\t\t\tVALUES\n\t\t\t\t\t" . implode(',', $querybits) . "\n\t\t\t"); $querybits = array(); } // Send some output to the browser inside this loop so certain hosts // don't artificially kill the script. See bug #34585 if (VB_AREA != 'Upgrade' and VB_AREA != 'Install') { echo ' '; vbflush(); } } // insert any remaining templates if (!empty($querybits)) { /*insert query*/ $vbulletin->db->query_write("\n\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t(styleid, templatetype, title, template, template_un, dateline, username, version, product)\n\t\t\tVALUES\n\t\t\t\t" . implode(',', $querybits) . "\n\t\t"); } unset($querybits); $rebuild['templates'] = true; }
/** * Handles importing of templates into memory for a given project. * @param VDE_Project */ protected function _handleTemplates($project) { require_once DIR . '/includes/adminfunctions_template.php'; foreach ($project->getTemplates() as $template => $content) { $this->_registry->templatecache[$template] = compile_template($content); } }
print_confirmation($vbphrase['confirm_unflatten_grid'], 'cms_admin', 'grid_dounflatten', array('gridid' => $gridinfo['gridid'])); } if ($_REQUEST['do'] == 'grid_dounflatten') { $vbulletin->input->clean_array_gpc('r', array('gridid' => TYPE_UINT)); $gridinfo = $db->query_first("\r\n\t\tSELECT * FROM " . TABLE_PREFIX . "cms_grid\r\n\t\tWHERE\r\n\t\t\tgridid = " . $vbulletin->GPC['gridid'] . "\r\n\t\t\t\tAND\r\n\t\t\tflattened = 1\r\n\t"); if (!$gridinfo) { print_stop_message('invalid_x_specified', 'gridid'); } $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "cms_grid\r\n\t\tSET\r\n\t\t\tgridhtml = gridhtml_backup,\r\n\t\t\tgridhtml_backup = '',\r\n\t\t\tflattened = 0\r\n\t\tWHERE gridid = " . intval($gridinfo['gridid']) . "\r\n\t"); preg_match_all('#\\$column\\[(\\d+)\\]#si', $gridinfo['gridhtml_backup'], $matches); $count = count($matches[1]); $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "cms_layout\r\n\t\tSET contentcolumn = {$count}\r\n\t\tWHERE\r\n\t\t\tgridid = " . intval($gridinfo['gridid']) . "\r\n\t\t\t\tAND\r\n\t\t\tcontentcolumn > {$count}\r\n\t"); $db->query_write("\r\n\t\tUPDATE " . TABLE_PREFIX . "cms_layoutwidget AS lw\r\n\t\tINNER JOIN " . TABLE_PREFIX . "cms_layout AS layout ON (lw.layoutid = layout.layoutid)\r\n\t\tSET lw.layoutcolumn = {$count}\r\n\t\tWHERE\r\n\t\t\tlayout.gridid = " . intval($gridinfo['gridid']) . "\r\n\t\t\t\tAND\r\n\t\t\tlw.layoutcolumn > {$count}\r\n\t"); require_once DIR . '/includes/adminfunctions_template.php'; $title = "vbcms_grid_{$gridinfo['gridid']}"; $db->query_write("\r\n\t\tREPLACE INTO " . TABLE_PREFIX . "template\r\n\t\t\t(styleid, title, template, template_un, dateline, username, product, version)\r\n\t\tVALUES\r\n\t\t\t(\r\n\t\t\t\t0,\r\n\t\t\t\t'" . $db->escape_string($title) . "',\r\n\t\t\t\t'" . $db->escape_string(compile_template($gridinfo['gridhtml_backup'])) . "',\r\n\t\t\t\t'" . $db->escape_string($gridinfo['gridhtml_backup']) . "',\r\n\t\t\t\t" . TIMENOW . ",\r\n\t\t\t\t'" . $db->escape_string($vbulletin->userinfo['username']) . "',\r\n\t\t\t\t'vbcms',\r\n\t\t\t\t'" . $db->escape_string($vbulletin->options['templateversion']) . "'\r\n\t\t\t)\r\n\t"); 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': window.location = "cms_admin.php?<?php echo $vbulletin->session->vars['sessionurl_js'];
AND active = 1 GROUP BY adlocation "); while ($ad = $db->fetch_array($ads)) { unset($doads[$ad['adlocation']]); } $count = 0; foreach (array_keys($doads) AS $ad) { $count++; $template_un = ''; $template = compile_template($template_un); $upgrade->run_query( sprintf($upgrade_phrases['upgrade_300b3.php']['altering_x_table'], 'template', $count, count($doads)), "UPDATE " . TABLE_PREFIX . "template SET template = '" . $db->escape_string($template) . "', template_un = '', dateline = " . TIMENOW . " WHERE styleid IN (-1,0) AND title = 'ad_" . $db->escape_string($ad) . "' " ); }
/** * Installs a product from the xml text * * This function depends on the vb class loader, which requires that the * framework init is called. * * @return bool True if the product requires a template merge, false otherwise */ function install_product($xml, $allow_overwrite) { global $vbphrase; global $vbulletin; global $db; require_once(DIR . '/includes/class_bitfield_builder.php'); require_once(DIR . '/includes/class_xml.php'); require_once(DIR . '/includes/class_block.php'); //share some code with the main xml style import require_once(DIR . '/includes/adminfunctions_template.php'); print_dots_start('<b>' . $vbphrase['importing_product'] . "</b>, $vbphrase[please_wait]", ':', 'dspan'); $xmlobj = new vB_XML_Parser($xml); if ($xmlobj->error_no == 1) { print_dots_stop(); throw new vB_Exception_AdminStopMessage('no_xml_and_no_path'); } if(!$arr = $xmlobj->parse()) { print_dots_stop(); throw new vB_Exception_AdminStopMessage( array('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line())); } // ############## general product information $info = array( 'productid' => substr(preg_replace('#[^a-z0-9_]#', '', strtolower($arr['productid'])), 0, 25), 'title' => $arr['title'], 'description' => $arr['description'], 'version' => $arr['version'], 'active' => $arr['active'], 'url' => $arr['url'], 'versioncheckurl' => $arr['versioncheckurl'] ); if (!$info['productid']) { print_dots_stop(); if (!empty($arr['plugin'])) { throw new vB_Exception_AdminStopMessage('this_file_appears_to_be_a_plugin'); } else { throw new vB_Exception_AdminStopMessage('invalid_file_specified'); } } if (strtolower($info['productid']) == 'vbulletin') { print_dots_stop(); throw new vB_Exception_AdminStopMessage(array('product_x_installed_no_overwrite', 'vBulletin')); } // check for bitfield conflicts on install $bitfields = vB_Bitfield_Builder::return_data(); if (!$bitfields) { $bfobj =& vB_Bitfield_Builder::init(); if ($bfobj->errors) { print_dots_stop(); throw new vB_Exception_AdminStopMessage(array( 'bitfield_conflicts_x', '<li>' . implode('</li><li>', $bfobj->errors) . '</li>' )); } } // get system version info $system_versions = array( 'php' => PHP_VERSION, 'vbulletin' => $vbulletin->options['templateversion'], 'products' => fetch_product_list(true) ); $mysql_version = $db->query_first("SELECT VERSION() AS version"); $system_versions['mysql'] = $mysql_version['version']; // ############## import dependencies if (is_array($arr['dependencies']['dependency'])) { $dependencies =& $arr['dependencies']['dependency']; if (!isset($dependencies[0])) { $dependencies = array($dependencies); } $dependency_errors = array(); $ignore_dependency_errors = array(); // let's check the dependencies foreach ($dependencies AS $dependency) { // if we get an error, we haven't met this dependency // if we go through without a problem, we have automatically met // all dependencies for this "class" (mysql, php, vb, a specific product, etc) $this_dependency_met = true; // build a phrase for the version compats -- will look like (minver / maxver) if ($dependency['minversion']) { $compatible_phrase = construct_phrase( $vbphrase['compatible_starting_with_x'], htmlspecialchars_uni($dependency['minversion']) ); } else { $compatible_phrase = ''; } if ($dependency['maxversion']) { $incompatible_phrase = construct_phrase( $vbphrase['incompatible_with_x_and_greater'], htmlspecialchars_uni($dependency['maxversion']) ); } else { $incompatible_phrase = ''; } if ($compatible_phrase OR $incompatible_phrase) { $required_version_info = "($compatible_phrase"; if ($compatible_phrase AND $incompatible_phrase) { $required_version_info .= ' / '; } $required_version_info .= "$incompatible_phrase)"; } // grab the appropriate installed version string if ($dependency['dependencytype'] == 'product') { // group dependencies into types -- individual products get their own group $dependency_type_key = "product-$dependency[parentproductid]"; // undocumented feature -- you can put a producttitle attribute in a dependency so the id isn't displayed $parent_product_title = (!empty($dependency['producttitle']) ? $dependency['producttitle'] : $dependency['parentproductid']); $parent_product = $system_versions['products']["$dependency[parentproductid]"]; if (!$parent_product) { // required product is not installed $dependency_errors["$dependency_type_key"] = construct_phrase( $vbphrase['product_x_must_be_installed'], htmlspecialchars_uni($parent_product_title), $required_version_info ); continue; // can't do version checks if the product isn't installed } else if ($parent_product['active'] == 0) { // product is installed, but inactive $dependency_errors["{$dependency_type_key}-inactive"] = construct_phrase( $vbphrase['product_x_must_be_activated'], htmlspecialchars_uni($parent_product_title) ); $this_dependency_met = false; // allow version checks to continue } $sys_version_str = $parent_product['version']; $version_incompatible_phrase = 'product_incompatible_version_x_product_y'; } else { $dependency_type_key = $dependency['dependencytype']; $parent_product_title = ''; $sys_version_str = $system_versions["$dependency[dependencytype]"]; $version_incompatible_phrase = 'product_incompatible_version_x_' . $dependency['dependencytype']; } // if no version string, we are trying to do an unsupported dep check if ($sys_version_str == '') { continue; } $sys_version = fetch_version_array($sys_version_str); // error if installed version < minversion if ($dependency['minversion']) { $dep_version = fetch_version_array($dependency['minversion']); for ($i = 0; $i <= 5; $i++) { if ($sys_version["$i"] < $dep_version["$i"]) { // installed version is too old $dependency_errors["$dependency_type_key"] = construct_phrase( $vbphrase["$version_incompatible_phrase"], htmlspecialchars_uni($sys_version_str), $required_version_info, $parent_product_title ); $this_dependency_met = false; break; } else if ($sys_version["$i"] > $dep_version["$i"]) { break; } } } // error if installed version >= maxversion if ($dependency['maxversion']) { $dep_version = fetch_version_array($dependency['maxversion']); $all_equal = true; for ($i = 0; $i <= 5; $i++) { if ($sys_version["$i"] > $dep_version["$i"]) { // installed version is newer than the maxversion $dependency_errors["$dependency_type_key"] = construct_phrase( $vbphrase["$version_incompatible_phrase"], htmlspecialchars_uni($sys_version_str), $required_version_info, $parent_product_title ); $this_dependency_met = false; break; } else if ($sys_version["$i"] < $dep_version["$i"]) { // not every part is the same and since we've got less we can exit $all_equal = false; break; } else if ($sys_version["$i"] != $dep_version["$i"]) { // not every part is the same $all_equal = false; } } if ($all_equal == true) { // installed version is same as the max version, which is the first incompat version $dependency_errors["$dependency_type_key"] = construct_phrase( $vbphrase["$version_incompatible_phrase"], htmlspecialchars_uni($sys_version_str), $required_version_info, $parent_product_title ); $this_dependency_met = false; } } if ($this_dependency_met) { // we met 1 dependency for this type -- this emulates or'ing together groups $ignore_dependency_errors["$dependency_type_key"] = true; } } // for any group we met a dependency for, ignore any errors we might // have gotten for the group foreach ($ignore_dependency_errors AS $dependency_type_key => $devnull) { unset($dependency_errors["$dependency_type_key"]); } if ($dependency_errors) { $dependency_errors = array_unique($dependency_errors); $dependency_errors = '<ol><li>' . implode('</li><li>', $dependency_errors) . '</li></ol>'; print_dots_stop(); throw new vB_Exception_AdminStopMessage( array('dependencies_not_met_x', $dependency_errors)); } } // look to see if we already have this product installed if ($existingprod = $db->query_first(" SELECT * FROM " . TABLE_PREFIX . "product WHERE productid = '" . $db->escape_string($info['productid']) . "'" )) { if (!$allow_overwrite) { print_dots_stop(); throw new vB_Exception_AdminStopMessage( array('product_x_installed_no_overwrite', $info['title'])); } $active = $existingprod['active']; // not sure what we're deleting, so rebuild everything $rebuild = array( 'templates' => true, 'plugins' => true, 'phrases' => true, 'options' => true, 'cron' => true ); $installed_version = $existingprod['version']; } else { $active = ($info['active'] ? 1 : 0); $rebuild = array( 'templates' => false, 'plugins' => false, 'phrases' => false, 'options' => false, 'cron' => false ); $installed_version = null; } // ############## import install/uninstall code if (is_array($arr['codes']['code'])) { $codes =& $arr['codes']['code']; if (!isset($codes[0])) { $codes = array($codes); } // run each of the codes foreach ($codes AS $code) { // Run if: code version is * (meaning always run), no version // previously installed, or if the code is for a newer version // than is currently installed if ($code['version'] == '*' OR $installed_version === null OR is_newer_version($code['version'], $installed_version)) { eval($code['installcode']); } } // Clear routes from datastore build_datastore('routes', serialize(array()), 1); //assume that the product may have installed content types and purge the content type cache vB_Cache::instance()->purge('vb_types.types'); } // dependencies checked, install code run. Now clear out the old product info; // settings should be retained in memory already delete_product($info['productid'], false, true); if (is_array($codes)) { // we've now run all the codes, if execution is still going // then it's going to complete fully, so insert the codes foreach ($codes AS $code) { /* insert query */ $db->query_write(" INSERT INTO " . TABLE_PREFIX . "productcode (productid, version, installcode, uninstallcode) VALUES ('" . $db->escape_string($info['productid']) . "', '" . $db->escape_string($code['version']) . "', '" . $db->escape_string($code['installcode']) . "', '" . $db->escape_string($code['uninstallcode']) . "') "); } } if (is_array($dependencies)) { // dependencies met, codes run -- now we can insert the dependencies into the DB foreach ($dependencies AS $dependency) { /* insert query */ $db->query_write(" INSERT INTO " . TABLE_PREFIX . "productdependency (productid, dependencytype, parentproductid, minversion, maxversion) VALUES ('" . $db->escape_string($info['productid']) . "', '" . $db->escape_string($dependency['dependencytype']) . "', '" . $db->escape_string($dependency['parentproductid']) . "', '" . $db->escape_string($dependency['minversion']) . "', '" . $db->escape_string($dependency['maxversion']) . "') "); } } /* insert query */ $db->query_write(" INSERT INTO " . TABLE_PREFIX . "product (productid, title, description, version, active, url, versioncheckurl) VALUES ('" . $db->escape_string($info['productid']) . "', '" . $db->escape_string($info['title']) . "', '" . $db->escape_string($info['description']) . "', '" . $db->escape_string($info['version']) . "', " . intval($active) . ", '" . $db->escape_string($info['url']) . "', '" . $db->escape_string($info['versioncheckurl']) . "') "); // ############## import templates if (is_array($arr['templates']['template'])) { $querybits = array(); $querytemplates = 0; $templates =& $arr['templates']['template']; if (!isset($templates[0])) { $templates = array($templates); } foreach ($templates AS $template) { $title = $db->escape_string($template['name']); $template['template'] = $db->escape_string($template['value']); $template['username'] = $db->escape_string($template['username']); $template['templatetype'] = $db->escape_string($template['templatetype']); $template['date'] = intval($template['date']); if ($template['templatetype'] != 'template') { // template is a special template $querybits[] = "(-1, '$template[templatetype]', '$title', '$template[template]', '', $template[date], '$template[username]', '" . $db->escape_string($template['version']) . "', '" . $db->escape_string($info['productid']) . "')"; } else { // template is a standard template $querybits[] = "(-1, '$template[templatetype]', '$title', '" . $db->escape_string(compile_template($template['value'])) . "', '$template[template]', $template[date], '$template[username]', '" . $db->escape_string($template['version']) . "', '" . $db->escape_string($info['productid']) . "')"; } if (++$querytemplates % 20 == 0) { /*insert query*/ $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "template (styleid, templatetype, title, template, template_un, dateline, username, version, product) VALUES " . implode(',', $querybits) . " "); $querybits = array(); } // Send some output to the browser inside this loop so certain hosts // don't artificially kill the script. See bug #34585 echo ' '; vbflush(); } // insert any remaining templates if (!empty($querybits)) { /*insert query*/ $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "template (styleid, templatetype, title, template, template_un, dateline, username, version, product) VALUES " . implode(',', $querybits) . " "); } unset($querybits); $rebuild['templates'] = true; } // ############## import stylevars if (is_array($arr['stylevardfns']['stylevargroup'])) { xml_import_stylevar_definitions($arr['stylevardfns'], $info['productid']); } if (is_array($arr['stylevars']['stylevar'])) { xml_import_stylevars($arr['stylevars'], -1); } // ############## import hooks/plugins if (is_array($arr['plugins']['plugin'])) { $plugins =& $arr['plugins']['plugin']; if (!isset($plugins[0])) { $plugins = array($plugins); } foreach ($plugins AS $plugin) { $plugin['product'] = $info['productid']; unset($plugin['devkey']); $db->query_write(fetch_query_sql($plugin, 'plugin')); } $rebuild['plugins'] = true; } // ############## import phrases if (is_array($arr['phrases']['phrasetype'])) { require_once(DIR . '/includes/adminfunctions_language.php'); $master_phrasetypes = array(); $master_phrasefields = array(); foreach(fetch_phrasetypes_array(false) as $phrasetype) { $master_phrasefields["$phrasetype[fieldname]"] = true; } $phrasetypes =& $arr['phrases']['phrasetype']; if (!isset($phrasetypes[0])) { $phrasetypes = array($phrasetypes); } foreach ($phrasetypes AS $phrasetype) { if (empty($phrasetype['phrase'])) { continue; } if ($phrasetype['fieldname'] == '' OR !preg_match('#^[a-z0-9_]+$#i', $phrasetype['fieldname'])) // match a-z, A-Z, 0-9,_ only { continue; } $fieldname = $master_phrasefields["$phrasetype[fieldname]"]; if (!$fieldname) { $db->query_write(" INSERT IGNORE INTO " . TABLE_PREFIX . "phrasetype (fieldname, title, editrows, product) VALUES ('" . $db->escape_string($phrasetype['fieldname']) . "', '" . $db->escape_string($phrasetype['name']) . "', 3, '" . $db->escape_string($info['productid']) . "') "); // need to add the column to the language table as well require_once(DIR . '/includes/class_dbalter.php'); $db_alter = new vB_Database_Alter_MySQL($db); if ($db_alter->fetch_table_info('language')) { $db_alter->add_field(array( 'name' => "phrasegroup_$phrasetype[fieldname]", 'type' => 'mediumtext' )); } } $phrases =& $phrasetype['phrase']; if (!isset($phrases[0])) { $phrases = array($phrases); } $sql = array(); foreach ($phrases AS $phrase) { $sql[] = " (-1, '" . $db->escape_string($phrasetype['fieldname']) . "', '" . $db->escape_string($phrase['name']) . "', '" . $db->escape_string($phrase['value']) . "', '" . $db->escape_string($info['productid']) . "', '" . $db->escape_string($phrase['username']) . "', " . intval($phrase['date']) . ", '" . $db->escape_string($phrase['version']) . "') "; } /*insert query*/ $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "phrase (languageid, fieldname, varname, text, product, username, dateline, version) VALUES " . implode(',', $sql) ); } $rebuild['phrases'] = true; } // ############## import settings if (is_array($arr['options']['settinggroup'])) { $settinggroups =& $arr['options']['settinggroup']; if (!isset($settinggroups[0])) { $settinggroups = array($settinggroups); } foreach ($settinggroups AS $group) { if (empty($group['setting'])) { continue; } // create the setting group if it doesn't already exist /*insert query*/ $db->query_write(" INSERT IGNORE INTO " . TABLE_PREFIX . "settinggroup (grouptitle, displayorder, volatile, product) VALUES ('" . $db->escape_string($group['name']) . "', " . intval($group['displayorder']) . ", 1, '" . $db->escape_string($info['productid']) . "') "); $settings =& $group['setting']; if (!isset($settings[0])) { $settings = array($settings); } $setting_bits = array(); foreach ($settings AS $setting) { if (isset($vbulletin->options["$setting[varname]"])) { $newvalue = $vbulletin->options["$setting[varname]"]; } else { $newvalue = $setting['defaultvalue']; } $setting_bits[] = "( '" . $db->escape_string($setting['varname']) . "', '" . $db->escape_string($group['name']) . "', '" . $db->escape_string(trim($newvalue)) . "', '" . $db->escape_string(trim($setting['defaultvalue'])) . "', '" . $db->escape_string(trim($setting['datatype'])) . "', '" . $db->escape_string($setting['optioncode']) . "', " . intval($setting['displayorder']) . ", " . intval($setting['advanced']) . ", 1, '" . $db->escape_string($setting['validationcode']) . "', " . intval($setting['blacklist']) . ", '" . $db->escape_string($info['productid']) . "'\n\t)"; } /*insert query*/ $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "setting (varname, grouptitle, value, defaultvalue, datatype, optioncode, displayorder, advanced, volatile, validationcode, blacklist, product) VALUES " . implode(",\n\t", $setting_bits) ); } $rebuild['options'] = true; } // ############## import admin help if (is_array($arr['helptopics']['helpscript'])) { $help_scripts =& $arr['helptopics']['helpscript']; if (!isset($help_scripts[0])) { $help_scripts = array($help_scripts); } foreach ($help_scripts AS $help_script) { // Deal with single entry if (!is_array($help_script['helptopic'][0])) { $help_script['helptopic'] = array($help_script['helptopic']); } $help_sql = array(); foreach ($help_script['helptopic'] AS $topic) { $helpsql[] = " ('" . $db->escape_string($help_script['name']) . "', '" . $db->escape_string($topic['act']) . "', '" . $db->escape_string($topic['opt']) . "', " . intval($topic['disp']) . ", 1, '" . $db->escape_string($info['productid']) . "') "; } if (!empty($helpsql)) { /*insert query*/ $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "adminhelp (script, action, optionname, displayorder, volatile, product) VALUES " . implode(",\n\t", $helpsql) ); } } } // ############## import cron if (is_array($arr['cronentries']['cron'])) { require_once(DIR . '/includes/functions_cron.php'); $cron_entries =& $arr['cronentries']['cron']; if (!isset($cron_entries[0])) { $cron_entries = array($cron_entries); } foreach ($cron_entries AS $cron) { $cron['varname'] = preg_replace('#[^a-z0-9_]#i', '', $cron['varname']); if (!$cron['varname']) { continue; } $cron['active'] = ($cron['active'] ? 1 : 0); $cron['loglevel'] = ($cron['loglevel'] ? 1 : 0); $scheduling = $cron['scheduling']; $scheduling['weekday'] = intval($scheduling['weekday']); $scheduling['day'] = intval($scheduling['day']); $scheduling['hour'] = intval($scheduling['hour']); $scheduling['minute'] = explode(',', preg_replace('#[^0-9,-]#i', '', $scheduling['minute'])); if (count($scheduling['minute']) == 0) { $scheduling['minute'] = array(0); } else { $scheduling['minute'] = array_map('intval', $scheduling['minute']); } /*insert query*/ $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "cron (weekday, day, hour, minute, filename, loglevel, active, varname, volatile, product) VALUES ($scheduling[weekday], $scheduling[day], $scheduling[hour], '" . $db->escape_string(serialize($scheduling['minute'])) . "', '" . $db->escape_string($cron['filename']) . "', $cron[loglevel], $cron[active], '" . $db->escape_string($cron['varname']) . "', 1, '" . $db->escape_string($info['productid']) . "') "); $cronid = $db->insert_id(); // replace either inserts, or deletes+inserts if ($cronid) { build_cron_item($cronid); } $rebuild['cron'] = true; } } // ############## import faq if (is_array($arr['faqentries']['faq'])) { $faq_entries =& $arr['faqentries']['faq']; if (!isset($faq_entries[0])) { $faq_entries = array($faq_entries); } $sql = array(); foreach ($faq_entries AS $faq) { $sql[] = " ('" . $db->escape_string($faq['faqname']) . "', '" . $db->escape_string($faq['faqparent']) . "', " . intval($faq['displayorder']) . ", 1, '" . $db->escape_string($info['productid']) . "') "; } if ($sql) { /*insert query*/ $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "faq (faqname, faqparent, displayorder, volatile, product) VALUES " . implode(',', $sql) . " "); } } // Check if the plugin system is disabled. If it is, enable it. if (!$vbulletin->options['enablehooks']) { $db->query_write(" UPDATE " . TABLE_PREFIX . "setting SET value = '1' WHERE varname = 'enablehooks' "); $rebuild['options'] = true; } // Now rebuild everything we need... if ($rebuild['plugins']) { vBulletinHook::build_datastore($db); if ($active) { $plugin_data = $db->query_read(" SELECT * FROM " . TABLE_PREFIX . "datastore WHERE title IN ('pluginlist', 'pluginlistadmin') "); while ($plugin_info = $db->fetch_array($plugin_data)) { if ($plugin_info['title'] == 'pluginlist') { $vbulletin->pluginlist = unserialize($plugin_info['data']); } else if ($plugin_info['title'] == 'pluginlistadmin') { $vbulletin->pluginlistadmin = unserialize($plugin_info['data']); } } // enable any hooks -- this is mainly necessary for importing templates (template_safe_functions hook) if (!defined('DISABLE_HOOKS')) { if (!empty($vbulletin->pluginlistadmin) AND is_array($vbulletin->pluginlistadmin)) { $vbulletin->pluginlist = array_merge($vbulletin->pluginlist, $vbulletin->pluginlistadmin); unset($vbulletin->pluginlistadmin); } vBulletinHook::set_pluginlist($vbulletin->pluginlist); } } } if ($rebuild['templates']) { build_all_styles(); } if ($rebuild['phrases']) { require_once(DIR . '/includes/adminfunctions_language.php'); build_language(); } if ($rebuild['options']) { build_options(); } if ($rebuild['cron']) { require_once(DIR . '/includes/functions_cron.php'); build_cron_next_run(); } build_product_datastore(); // build bitfields to remove/add this products bitfields vB_Bitfield_Builder::save($db); // reload block types $blockmanager = vB_BlockManager::create($vbulletin); $blockmanager->reloadBlockTypes(); print_dots_stop(); $info['need_merge'] = ($rebuild['templates'] AND $installed_version); return $info; }
/** * Called when a merge succeeds (no conflicts). * * @param string Final merged text * @param array Array of template info. Record returned by data method. */ protected function merge_success($merged_text, $template_info) { global $vbphrase; $db = $this->registry->db; $db->query_write(" INSERT INTO " . TABLE_PREFIX . "templatehistory (styleid, title, template, dateline, username, version) VALUES ($template_info[styleid], '" . $db->escape_string($template_info['title']) . "', '" . $db->escape_string($template_info['customtext']) . "', $template_info[dateline], '" . $db->escape_string($template_info['username']) . "', '" . $db->escape_string($template_info['version']) . "') "); $savedtemplateid = $db->insert_id(); $db->query_write(" REPLACE INTO " . TABLE_PREFIX . "templatemerge (templateid, template, version, savedtemplateid) VALUES ($template_info[templateid], '" . $db->escape_string($template_info['oldmastertext']) . "', '" . $db->escape_string($template_info['oldmasterversion']) . "', " . intval($savedtemplateid) . " ) "); $db->query_write(" UPDATE " . TABLE_PREFIX . "template SET styleid = $template_info[styleid], templatetype = 'template', title = '" . $db->escape_string($template_info['title']) . "', template = '" . $db->escape_string(compile_template($merged_text)) . "', template_un = '" . $db->escape_string($merged_text) . "', dateline = " . TIMENOW . ", username = '******'system']) ? $vbphrase['system'] : 'System') . "', version = '" . $db->escape_string($this->merge_version) . "', product = '" . $db->escape_string($template_info['product']) . "', mergestatus = 'merged' WHERE templateid = " . intval($template_info["templateid"]) ); if ($this->show_output) { $this->output_merge_success($merged_text, $template_info); } }
/** * Called when a merge succeeds (no conflicts). * * @param string Final merged text * @param array Array of template info. Record returned by data method. */ protected function merge_success($merged_text, $template_info) { global $vbphrase; $db = $this->registry->db; $db->query_write("\n\t\t\tINSERT INTO " . TABLE_PREFIX . "templatehistory\n\t\t\t\t(styleid, title, template, dateline, username, version)\n\t\t\tVALUES\n\t\t\t\t({$template_info['styleid']},\n\t\t\t\t'" . $db->escape_string($template_info['title']) . "',\n\t\t\t\t'" . $db->escape_string($template_info['customtext']) . "',\n\t\t\t\t{$template_info['dateline']},\n\t\t\t\t'" . $db->escape_string($template_info['username']) . "',\n\t\t\t\t'" . $db->escape_string($template_info['version']) . "')\n\t\t"); $savedtemplateid = $db->insert_id(); $db->query_write("\n\t\t\tREPLACE INTO " . TABLE_PREFIX . "templatemerge\n\t\t\t\t(templateid, template, version, savedtemplateid)\n\t\t\tVALUES\n\t\t\t\t({$template_info['templateid']},\n\t\t\t\t'" . $db->escape_string($template_info['oldmastertext']) . "',\n\t\t\t\t'" . $db->escape_string($template_info['oldmasterversion']) . "',\n\t\t\t\t" . intval($savedtemplateid) . "\n\t\t\t\t)\n\t\t"); $db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "template SET\n\t\t\t\tstyleid = {$template_info['styleid']},\n\t\t\t\ttemplatetype = 'template',\n\t\t\t\ttitle = '" . $db->escape_string($template_info['title']) . "',\n\t\t\t\ttemplate = '" . $db->escape_string(compile_template($merged_text)) . "',\n\t\t\t\ttemplate_un = '" . $db->escape_string($merged_text) . "',\n\t\t\t\tdateline = " . TIMENOW . ",\n\t\t\t\tusername = '******'system']) ? $vbphrase['system'] : 'System') . "',\n\t\t\t\tversion = '" . $db->escape_string($this->merge_version) . "',\n\t\t\t\tproduct = '" . $db->escape_string($template_info['product']) . "',\n\t\t\t\tmergestatus = 'merged'\n\t\t\tWHERE\n\t\t\t\ttemplateid = " . intval($template_info["templateid"])); if ($this->show_output) { return $this->output_merge_success($merged_text, $template_info); } }
function xml_import_template_groups($styleid, $product, $templategroup_array, $output_group_name) { global $vbulletin, $vbphrase; $safe_product = $vbulletin->db->escape_string($product); $querytemplates = 0; foreach ($templategroup_array AS $templategroup) { if (empty($templategroup['template'][0])) { $tg = array($templategroup['template']); } else { $tg = &$templategroup['template']; } if ($output_group_name) { echo '<p>' . construct_phrase($vbphrase['template_group_x'], $templategroup['name']) . '</p>'; vbflush(); } foreach($tg AS $template) { $title = $vbulletin->db->escape_string($template['name']); $template['username'] = $vbulletin->db->escape_string($template['username']); $template['version'] = $vbulletin->db->escape_string($template['version']); if ($template['templatetype'] != 'template') { // template is a special template == not compiled. $uncompiled = ''; $compiled = $vbulletin->db->escape_string($template['value']); } else { //template is a regular template, do the compile and save the original. $uncompiled = $vbulletin->db->escape_string($template['value']); $compiled = $vbulletin->db->escape_string(compile_template($template['value'])); } $querybits[] = "($styleid, '$template[templatetype]', '$title', '$compiled', '$uncompiled', " . "$template[date], '$template[username]', '$template[version]', " . "'$safe_product')"; if (++$querytemplates % 20 == 0) { /*insert query*/ $vbulletin->db->query_write(" REPLACE INTO " . TABLE_PREFIX . "template (styleid, templatetype, title, template, template_un, dateline, username, version, product) VALUES " . implode(',', $querybits) . " "); $querybits = array(); } // Send some output to the browser inside this loop so certain hosts // don't artificially kill the script. See bug #34585 echo ' '; vbflush(); } } // insert any remaining templates if (!empty($querybits)) { /*insert query*/ $vbulletin->db->query_write(" REPLACE INTO " . TABLE_PREFIX . "template (styleid, templatetype, title, template, template_un, dateline, username, version, product) VALUES " . implode(',', $querybits) . " "); $querybits = array(); } }
/** * Convert template text into tempcode format. * * @param string The template text * @param integer The position we are looking at in the text * @param boolean Whether this text is infact a directive, about to be put in the context of a wider template * @param ID_TEXT The codename of the template (e.g. foo) * @param ?ID_TEXT The theme it is for (NULL: current theme) * @param ?ID_TEXT The language it is for (NULL: current language) * @param boolean Whether to tolerate errors * @return mixed The converted/compiled template as tempcode, OR if a directive, encoded directive information */ function template_to_tempcode($text, $symbol_pos = 0, $inside_directive = false, $codename = '', $theme = NULL, $lang = NULL, $tolerate_errors = false) { if (is_null($theme)) { $theme = isset($GLOBALS['FORUM_DRIVER']) ? $GLOBALS['FORUM_DRIVER']->get_theme() : 'default'; } if (is_null($lang)) { $lang = user_lang(); } list($parts, $preprocessable_bits) = compile_template(substr($text, $symbol_pos), $codename, $theme, $lang, $tolerate_errors); if (count($parts) == 0) { return new ocp_tempcode(); } $myfunc = 'tcpfunc_' . ($codename == '' ? fast_uniqid() : $codename); $funcdef = build_closure_function($myfunc, $parts); $ret = new ocp_tempcode(array($funcdef, array(array($myfunc, array(), TC_KNOWN, '', '')))); // Parameters will be bound in later. $ret->preprocessable_bits = array_merge($ret->preprocessable_bits, $preprocessable_bits); $ret->codename = $codename; return $ret; }
} } $upgrade->run_query(sprintf($vbphrase['update_table'], TABLE_PREFIX . 'paymentapi'), "UPDATE " . TABLE_PREFIX . "paymentapi SET currency = 'usd,gbp,eur,aud,cad' WHERE classname = 'moneybookers'"); // add YUI to headinclude so things don't suddenly just stop working require_once DIR . '/includes/adminfunctions_template.php'; $templates = $db->query_read("\n\t\tSELECT *\n\t\tFROM " . TABLE_PREFIX . "template\n\t\tWHERE styleid > 0\n\t\t\tAND title IN ('headinclude')\n\t"); while ($template = $db->fetch_array($templates)) { if (strpos($template['template_un'], '$stylevar[yuipath]') !== false) { continue; } $template['template_un'] = str_replace('<script type="text/javascript">' . "\r\n" . '<!--' . "\r\n" . 'var SESSIONURL = "$session[sessionurl_js]";', '<script type="text/javascript" src="$stylevar[yuipath]/yahoo-dom-event/yahoo-dom-event.js?v=$vboptions[simpleversion]"></script>' . "\n" . '<script type="text/javascript" src="$stylevar[yuipath]/connection/connection-min.js?v=$vboptions[simpleversion]"></script>' . "\n" . '<script type="text/javascript">' . "\n" . '<!--' . "\n" . 'var SESSIONURL = "$session[sessionurl_js]";', $template['template_un']); // check in case it was newlines only if (strpos($template['template_un'], '$stylevar[yuipath]') === false) { $template['template_un'] = str_replace('<script type="text/javascript">' . "\n" . '<!--' . "\n" . 'var SESSIONURL = "$session[sessionurl_js]";', '<script type="text/javascript" src="$stylevar[yuipath]/yahoo-dom-event/yahoo-dom-event.js?v=$vboptions[simpleversion]"></script>' . "\n" . '<script type="text/javascript" src="$stylevar[yuipath]/connection/connection-min.js?v=$vboptions[simpleversion]"></script>' . "\n" . '<script type="text/javascript">' . "\n" . '<!--' . "\n" . 'var SESSIONURL = "$session[sessionurl_js]";', $template['template_un']); } $compiled_template = compile_template($template['template_un']); $upgrade->run_query(sprintf($vbphrase['apply_critical_template_change_to_x'], $template['title'], $template['styleid']), "UPDATE " . TABLE_PREFIX . "template SET\n\t\t\t\ttemplate = '" . $db->escape_string($compiled_template) . "',\n\t\t\t\ttemplate_un = '" . $db->escape_string($template['template_un']) . "'\n\t\t\tWHERE templateid = {$template['templateid']}\n\t\t"); } $upgrade->run_query(sprintf($upgrade_phrases['upgrade_300b3.php']['altering_x_table'], 'setting', 1, 1), "UPDATE " . TABLE_PREFIX . "setting SET value = 'GDttf' WHERE varname = 'regimagetype' AND value = 'GD'"); if ($db->query_first("SELECT varname FROM " . TABLE_PREFIX . "setting WHERE varname = 'regimagetype' AND value IN ('GDttf', 'GD')")) { require_once DIR . '/includes/adminfunctions_options.php'; if ($gdinfo['freetype'] != 'freetype') { // they won't be able to use the simple text version and they don't have FreeType support, so no image verification $upgrade->run_query(sprintf($vbphrase['update_table'], TABLE_PREFIX . 'setting'), "INSERT IGNORE INTO " . TABLE_PREFIX . "setting\n\t\t\t\t\t(varname, grouptitle, value, volatile, product)\n\t\t\t\tVALUES\n\t\t\t\t\t('hv_type', 'version', '0', 1, 'vbulletin')"); $upgrade->run_query(sprintf($vbphrase['update_table'], TABLE_PREFIX . "adminmessage"), "INSERT INTO " . TABLE_PREFIX . "adminmessage\n\t\t\t\t\t(varname, dismissable, script, action, execurl, method, dateline, status)\n\t\t\t\tVALUES\n\t\t\t\t\t('after_upgrade_37_image_verification_disabled', 1, 'verify.php', '', 'verify.php', 'get', " . TIMENOW . ", 'undone')\n\t\t\t\t"); } } $upgrade->execute(); build_forum_permissions(); } // #############################################################################
$query[] = "ALTER IGNORE TABLE template\n\t\tADD UNIQUE title (title, styleid)"; $explain[] = sprintf($vbphrase['alter_table_step_x'], 'template', 3, 3); exec_queries(); $db->hide_errors(); $db->query_write("ALTER TABLE template ADD version varchar(30) NOT NULL DEFAULT ''"); $db->show_errors(); // There was a script here to store templates in the new format. Well, I'm only partially doing that. The above ALTER // adds a column that stores an unprocessed version of the template. So if you need the script that populates that field // correctly, let me know since it's too big to post here. echo "<p>{$upgrade_phrases['upgrade_300b3.php']['updating_template_format']}</p>"; $db->query_write("UPDATE template SET template_un = template"); $temps = $db->query_read("SELECT templateid, title, template FROM template WHERE title <> 'options'"); echo "<ul>\n"; while ($temp = $db->fetch_array($temps)) { echo_flush("\t<li>" . sprintf($upgrade_phrases['upgrade_300b3.php']['updating_template_x'], htmlspecialchars($temp['title'])) . "... "); $template = compile_template($temp['template']); $db->query_write("UPDATE template SET template='" . $db->escape_string($template) . "' WHERE templateid={$temp['templateid']}"); echo "{$vbphrase['ok']}</li>\n"; } echo "</ul>\n"; } // ############################################################################# // User Reputation Levels -- Feel free to change these if ($vbulletin->GPC['step'] == 32) { $query[] = "INSERT INTO reputationlevel (reputationlevelid, minimumreputation, level) VALUES\n\t\t\t(1, -999999, '{$upgrade_phrases['upgrade_300b3.php']['reputation_-999999']}'),\n\t\t\t(2, -50, '{$upgrade_phrases['upgrade_300b3.php']['reputation_-50']}'),\n\t\t\t(3, -10, '{$upgrade_phrases['upgrade_300b3.php']['reputation_-10']}'),\n\t\t\t(4, 0, '{$upgrade_phrases['upgrade_300b3.php']['reputation_0']}'),\n\t\t\t(5, 10, '{$upgrade_phrases['upgrade_300b3.php']['reputation_10']}'),\n\t\t\t(6, 50, '{$upgrade_phrases['upgrade_300b3.php']['reputation_50']}'),\n\t\t\t(7, 150, '{$upgrade_phrases['upgrade_300b3.php']['reputation_150']}'),\n\t\t\t(8, 250, '{$upgrade_phrases['upgrade_300b3.php']['reputation_250']}'),\n\t\t\t(9, 350, '{$upgrade_phrases['upgrade_300b3.php']['reputation_350']}'),\n\t\t\t(10, 450, '{$upgrade_phrases['upgrade_300b3.php']['reputation_450']}'),\n\t\t\t(11, 550, '{$upgrade_phrases['upgrade_300b3.php']['reputation_550']}'),\n\t\t\t(12, 650, '{$upgrade_phrases['upgrade_300b3.php']['reputation_650']}'),\n\t\t\t(13, 1000, '{$upgrade_phrases['upgrade_300b3.php']['reputation_1000']}'),\n\t\t\t(14, 1500, '{$upgrade_phrases['upgrade_300b3.php']['reputation_1500']}'),\n\t\t\t(15, 2000, '{$upgrade_phrases['upgrade_300b3.php']['reputation_2000']}')\n\t\t\t"; $explain[] = $upgrade_phrases['upgrade_300b3.php']['populating_reputation_levels']; $query[] = "UPDATE user SET reputationlevelid = 4"; $explain[] = $upgrade_phrases['upgrade_300b3.php']['set_reputation_to_neutral']; exec_queries(); } // #############################################################################
/** * Reads XML style file and imports data from it into the database * * @param string XML data * @param integer Style ID * @param integer Parent style ID * @param string New style title * @param boolean Allow vBulletin version mismatch * @param integer Display order for new style * @param boolean Allow user selection of new style */ function xml_import_style($xml = false, $styleid = -1, $parentid = -1, $title = '', $anyversion = false, $displayorder = 1, $userselect = true) { // $GLOBALS['path'] needs to be passed into this function or reference $vbulletin->GPC['path'] global $vbulletin, $vbphrase; print_dots_start('<b>' . $vbphrase['importing_style'] . "</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-style.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['templategroup']) { print_dots_stop(); print_stop_message('invalid_file_specified'); } $version = $arr['vbversion']; $master = $arr['type'] == 'master' ? 1 : 0; $title = empty($title) ? $arr['name'] : $title; $product = empty($arr['product']) ? 'vbulletin' : $arr['product']; $arr = $arr['templategroup']; if (empty($arr[0])) { $arr = array($arr); } $full_product_info = fetch_product_list(true); $product_info = $full_product_info["{$product}"]; // version check if ($version != $product_info['version'] and !$anyversion and !$master) { print_dots_stop(); print_stop_message('upload_file_created_with_different_version', $product_info['version'], $version); } if ($master) { // overwrite master style echo "<h3>{$vbphrase['master_style']}</h3>\n<p>{$vbphrase['please_wait']}</p>"; vbflush(); $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "template WHERE styleid = -10 AND (product = '" . $vbulletin->db->escape_string($product) . "'" . iif($product == 'vbulletin', " OR product = ''") . ")"); $vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "template SET styleid = -10 WHERE styleid = -1 AND (product = '" . $vbulletin->db->escape_string($product) . "'" . iif($product == 'vbulletin', " OR product = ''") . ")"); $styleid = -1; } else { if ($styleid == -1) { // creating a new style if ($test = $vbulletin->db->query_first("SELECT styleid FROM " . TABLE_PREFIX . "style WHERE title = '" . $vbulletin->db->escape_string($title) . "'")) { print_dots_stop(); print_stop_message('style_already_exists', $title); } else { echo "<h3><b>" . construct_phrase($vbphrase['creating_a_new_style_called_x'], $title) . "</b></h3>\n<p>{$vbphrase['please_wait']}</p>"; vbflush(); /*insert query*/ $styleresult = $vbulletin->db->query_write("\n\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "style\n\t\t\t\t\t(title, parentid, displayorder, userselect)\n\t\t\t\t\tVALUES\n\t\t\t\t\t('" . $vbulletin->db->escape_string($title) . "', {$parentid}, {$displayorder}, " . ($userselect ? 1 : 0) . ")\n\t\t\t\t"); $styleid = $vbulletin->db->insert_id($styleresult); } } else { // overwriting an existing style if ($getstyle = $vbulletin->db->query_first("SELECT title FROM " . TABLE_PREFIX . "style WHERE styleid = {$styleid}")) { echo "<h3><b>" . construct_phrase($vbphrase['overwriting_style_x'], $getstyle['title']) . "</b></h3>\n<p>{$vbphrase['please_wait']}</p>"; vbflush(); } else { print_dots_stop(); print_stop_message('cant_overwrite_non_existent_style'); } } } // types array... $types = array($vbphrase['template'], $vbphrase['stylevar'], $vbphrase['css'], $vbphrase['replacement_variable']); $querybits = array(); $querytemplates = 0; foreach ($arr as $templategroup) { if (empty($templategroup['template'][0])) { $tg = array($templategroup['template']); } else { $tg =& $templategroup['template']; } foreach ($tg as $template) { $title = $vbulletin->db->escape_string($template['name']); $template['template'] = $vbulletin->db->escape_string($template['value']); $template['username'] = $vbulletin->db->escape_string($template['username']); if ($template['templatetype'] != 'template') { // template is a special template $querybits[] = "({$styleid}, '{$template['templatetype']}', '{$title}', '{$template['template']}', '', {$template['date']}, '{$template['username']}', '" . $vbulletin->db->escape_string($template['version']) . "', '" . $vbulletin->db->escape_string($product) . "')"; } else { // template is a standard template $querybits[] = "({$styleid}, '{$template['templatetype']}', '{$title}', '" . $vbulletin->db->escape_string(compile_template($template['value'])) . "', '{$template['template']}', {$template['date']}, '{$template['username']}', '" . $vbulletin->db->escape_string($template['version']) . "', '" . $vbulletin->db->escape_string($product) . "')"; } if (++$querytemplates % 20 == 0) { /*insert query*/ $vbulletin->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t\t(styleid, templatetype, title, template, template_un, dateline, username, version, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t" . implode(',', $querybits) . "\n\t\t\t\t"); $querybits = array(); } } } // insert any remaining templates if (!empty($querybits)) { /*insert query*/ $vbulletin->db->query_write("\n\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t(styleid, templatetype, title, template, template_un, dateline, username, version, product)\n\t\t\tVALUES\n\t\t\t" . implode(',', $querybits) . "\n\t\t"); } unset($querybits); // now delete any templates that were moved into the temporary styleset for safe-keeping $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "template WHERE styleid = -10 AND (product = '" . $vbulletin->db->escape_string($product) . "'" . iif($product == 'vbulletin', " OR product = ''") . ")"); print_dots_stop(); }
$templates =& $arr['templates']['template']; if (!isset($templates[0])) { $templates = array($templates); } foreach ($templates as $template) { $title = $db->escape_string($template['name']); $template['template'] = $db->escape_string($template['value']); $template['username'] = $db->escape_string($template['username']); $template['templatetype'] = $db->escape_string($template['templatetype']); $template['date'] = intval($template['date']); if ($template['templatetype'] != 'template') { // template is a special template $querybits[] = "(-1, '{$template['templatetype']}', '{$title}', '{$template['template']}', '', {$template['date']}, '{$template['username']}', '" . $db->escape_string($template['version']) . "', '" . $db->escape_string($info['productid']) . "')"; } else { // template is a standard template $querybits[] = "(-1, '{$template['templatetype']}', '{$title}', '" . $db->escape_string(compile_template($template['value'])) . "', '{$template['template']}', {$template['date']}, '{$template['username']}', '" . $db->escape_string($template['version']) . "', '" . $db->escape_string($info['productid']) . "')"; } if (++$querytemplates % 20 == 0) { /*insert query*/ $db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t\t\t(styleid, templatetype, title, template, template_un, dateline, username, version, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(',', $querybits) . "\n\t\t\t\t"); $querybits = array(); } } // insert any remaining templates if (!empty($querybits)) { /*insert query*/ $db->query_write("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t\t(styleid, templatetype, title, template, template_un, dateline, username, version, product)\n\t\t\t\tVALUES\n\t\t\t\t\t" . implode(',', $querybits) . "\n\t\t\t"); } unset($querybits); $rebuild['templates'] = true; }
/** * Everything that comes after the install - no reason to break this up into chunks at present * */ public function post_install() { // dependencies checked, install code run. Now clear out the old product info; // settings should be retained in memory already delete_product($this->productinfo['productid'], false, true); $codes =& $this->productobj['codes']['code']; if (!isset($codes[0])) { $codes = array($codes); } if (is_array($codes)) { // we've now run all the codes, if execution is still going // then it's going to complete fully, so insert the codes foreach ($codes as $code) { /* insert query */ $this->db->query_write("\n\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "productcode\n\t\t\t\t\t\t(productid, version, installcode, uninstallcode)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . $this->db->escape_string($this->productinfo['productid']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($code['version']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($code['installcode']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($code['uninstallcode']) . "')\n\t\t\t\t"); } } if (is_array($this->productobj['dependencies']['dependency'])) { $dependencies =& $this->productobj['dependencies']['dependency']; if (!isset($dependencies[0])) { $dependencies = array($dependencies); } // dependencies met, codes run -- now we can insert the dependencies into the DB foreach ($dependencies as $dependency) { /* insert query */ $this->db->query_write("\n\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "productdependency\n\t\t\t\t\t\t(productid, dependencytype, parentproductid, minversion, maxversion)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . $this->db->escape_string($this->productinfo['productid']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($dependency['dependencytype']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($dependency['parentproductid']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($dependency['minversion']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($dependency['maxversion']) . "')\n\t\t\t\t"); } } /* insert query */ $this->db->query_write("\n\t\t\tINSERT INTO " . TABLE_PREFIX . "product\n\t\t\t\t(productid, title, description, version, active, url, versioncheckurl)\n\t\t\tVALUES\n\t\t\t\t('" . $this->db->escape_string($this->productinfo['productid']) . "',\n\t\t\t\t'" . $this->db->escape_string($this->productinfo['title']) . "',\n\t\t\t\t'" . $this->db->escape_string($this->productinfo['description']) . "',\n\t\t\t\t'" . $this->db->escape_string($this->productinfo['version']) . "',\n\t\t\t\t" . intval($this->active) . ",\n\t\t\t\t'" . $this->db->escape_string($this->productinfo['url']) . "',\n\t\t\t\t'" . $this->db->escape_string($this->productinfo['versioncheckurl']) . "')\n\t\t"); // ############## import templates if (!empty($this->productobj['templates']['template']) and is_array($this->productobj['templates']['template'])) { $querybits = array(); $querytemplates = 0; $templates =& $this->productobj['templates']['template']; if (!isset($templates[0])) { $templates = array($templates); } foreach ($templates as $template) { $title = $this->db->escape_string($template['name']); $template['template'] = $this->db->escape_string($template['value']); $template['username'] = $this->db->escape_string($template['username']); $template['templatetype'] = $this->db->escape_string($template['templatetype']); $template['date'] = intval($template['date']); if ($template['templatetype'] != 'template') { // template is a special template $querybits[] = "(-1, '{$template['templatetype']}', '{$title}', '{$template['template']}', '', {$template['date']}, '{$template['username']}', '" . $this->db->escape_string($template['version']) . "', '" . $this->db->escape_string($this->productinfo['productid']) . "')"; } else { // template is a standard template $querybits[] = "(-1, '{$template['templatetype']}', '{$title}', '" . $this->db->escape_string(compile_template($template['value'])) . "', '{$template['template']}', {$template['date']}, '{$template['username']}', '" . $this->db->escape_string($template['version']) . "', '" . $this->db->escape_string($this->productinfo['productid']) . "')"; } if (++$querytemplates % 20 == 0) { /*insert query*/ $this->db->query_write("\n\t\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t\t\t\t(styleid, templatetype, title, template, template_un, dateline, username, version, product)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t" . implode(',', $querybits) . "\n\t\t\t\t\t"); $querybits = array(); } if (!defined('SUPPRESS_KEEPALIVE_ECHO')) { echo ' '; vbflush(); } } // insert any remaining templates if (!empty($querybits)) { /*insert query*/ $this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t\t\t(styleid, templatetype, title, template, template_un, dateline, username, version, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(',', $querybits) . "\n\t\t\t\t"); } unset($querybits); $rebuild['templates'] = true; } if (is_array($this->productobj['templates_mobile']['template'])) { $querybits = array(); $querytemplates = 0; $templates =& $this->productobj['templates_mobile']['template']; if (!isset($templates[0])) { $templates = array($templates); } foreach ($templates as $template) { $title = $this->db->escape_string($template['name']); $template['template'] = $this->db->escape_string($template['value']); $template['username'] = $this->db->escape_string($template['username']); $template['templatetype'] = $this->db->escape_string($template['templatetype']); $template['date'] = intval($template['date']); if ($template['templatetype'] != 'template') { // template is a special template $querybits[] = "(-2, '{$template['templatetype']}', '{$title}', '{$template['template']}', '', {$template['date']}, '{$template['username']}', '" . $this->db->escape_string($template['version']) . "', '" . $this->db->escape_string($this->productinfo['productid']) . "')"; } else { // template is a standard template $querybits[] = "(-2, '{$template['templatetype']}', '{$title}', '" . $this->db->escape_string(compile_template($template['value'])) . "', '{$template['template']}', {$template['date']}, '{$template['username']}', '" . $this->db->escape_string($template['version']) . "', '" . $this->db->escape_string($this->productinfo['productid']) . "')"; } if (++$querytemplates % 20 == 0) { /*insert query*/ $this->db->query_write("\n\t\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t\t\t\t(styleid, templatetype, title, template, template_un, dateline, username, version, product)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t" . implode(',', $querybits) . "\n\t\t\t\t\t"); $querybits = array(); } if (!defined('SUPPRESS_KEEPALIVE_ECHO')) { echo ' '; vbflush(); } } // insert any remaining templates if (!empty($querybits)) { /*insert query*/ $this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t\t\t(styleid, templatetype, title, template, template_un, dateline, username, version, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(',', $querybits) . "\n\t\t\t\t"); } unset($querybits); $rebuild['templates'] = true; } // ############## import stylevars if (!empty($this->productobj['stylevardfns']['stylevargroup']) and is_array($this->productobj['stylevardfns']['stylevargroup'])) { xml_import_stylevar_definitions($this->productobj['stylevardfns'], $this->productinfo['productid'], -1); } if (!empty($this->productobj['stylevars']['stylevar']) and is_array($this->productobj['stylevars']['stylevar'])) { xml_import_stylevars($this->productobj['stylevars'], -1); } if (is_array($this->productobj['stylevardfns_mobile']['stylevargroup'])) { xml_import_stylevar_definitions($this->productobj['stylevardfns_mobile'], $this->productinfo['productid'], -2); } if (is_array($this->productobj['stylevars_mobile']['stylevar'])) { xml_import_stylevars($this->productobj['stylevars_mobile'], -2); } // ############## import hooks/plugins if (is_array($this->productobj['plugins']['plugin'])) { $plugins =& $this->productobj['plugins']['plugin']; if (!isset($plugins[0])) { $plugins = array($plugins); } foreach ($plugins as $plugin) { $plugin['product'] = $this->productinfo['productid']; unset($plugin['devkey']); $this->db->query_write(fetch_query_sql($plugin, 'plugin')); } $rebuild['plugins'] = true; } // ############## import phrases if (is_array($this->productobj['phrases']['phrasetype'])) { require_once DIR . '/includes/adminfunctions_language.php'; $master_phrasetypes = array(); $master_phrasefields = array(); foreach (fetch_phrasetypes_array(false) as $phrasetype) { $master_phrasefields["{$phrasetype['fieldname']}"] = true; } $phrasetypes =& $this->productobj['phrases']['phrasetype']; if (!isset($phrasetypes[0])) { $phrasetypes = array($phrasetypes); } foreach ($phrasetypes as $phrasetype) { if (empty($phrasetype['phrase'])) { continue; } if ($phrasetype['fieldname'] == '' or !preg_match('#^[a-z0-9_]+$#i', $phrasetype['fieldname'])) { continue; } $fieldname = $master_phrasefields["{$phrasetype['fieldname']}"]; if (!$fieldname) { $this->db->query_write("\n\t\t\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "phrasetype\n\t\t\t\t\t\t\t(fieldname, title, editrows, product)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('" . $this->db->escape_string($phrasetype['fieldname']) . "',\n\t\t\t\t\t\t\t'" . $this->db->escape_string($phrasetype['name']) . "',\n\t\t\t\t\t\t\t3,\n\t\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t\t"); // need to add the column to the language table as well require_once DIR . '/includes/class_dbalter.php'; $this->db_alter = new vB_Database_Alter_MySQL($this->db); if ($this->db_alter->fetch_table_info('language')) { $this->db_alter->add_field(array('name' => "phrasegroup_{$phrasetype['fieldname']}", 'type' => 'mediumtext')); } } $phrases =& $phrasetype['phrase']; if (!isset($phrases[0])) { $phrases = array($phrases); } $sql = array(); foreach ($phrases as $phrase) { $sql[] = "\n\t\t\t\t\t\t(-1,\n\t\t\t\t\t\t'" . $this->db->escape_string($phrasetype['fieldname']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($phrase['name']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($phrase['value']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($phrase['username']) . "',\n\t\t\t\t\t\t" . intval($phrase['date']) . ",\n\t\t\t\t\t\t'" . $this->db->escape_string($phrase['version']) . "')\n\t\t\t\t\t"; } /*insert query*/ $this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "phrase\n\t\t\t\t\t\t(languageid, fieldname, varname, text, product, username, dateline, version)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(',', $sql)); } $rebuild['phrases'] = true; } // ############## import settings if (is_array($this->productobj['options']['settinggroup'])) { $settinggroups =& $this->productobj['options']['settinggroup']; if (!isset($settinggroups[0])) { $settinggroups = array($settinggroups); } foreach ($settinggroups as $group) { if (empty($group['setting'])) { continue; } // create the setting group if it doesn't already exist /*insert query*/ $this->db->query_write("\n\t\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "settinggroup\n\t\t\t\t\t\t(grouptitle, displayorder, volatile, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . $this->db->escape_string($group['name']) . "',\n\t\t\t\t\t\t" . intval($group['displayorder']) . ",\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t"); $settings =& $group['setting']; if (!isset($settings[0])) { $settings = array($settings); } $setting_bits = array(); foreach ($settings as $setting) { if (isset($this->registry->options["{$setting['varname']}"])) { $newvalue = $this->registry->options["{$setting['varname']}"]; } else { $newvalue = $setting['defaultvalue']; } $setting_bits[] = "(\n\t\t\t\t\t\t'" . $this->db->escape_string($setting['varname']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($group['name']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string(trim($newvalue)) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string(trim($setting['defaultvalue'])) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string(trim($setting['datatype'])) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($setting['optioncode']) . "',\n\t\t\t\t\t\t" . intval($setting['displayorder']) . ",\n\t\t\t\t\t\t" . intval($setting['advanced']) . ",\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escape_string($setting['validationcode']) . "',\n\t\t\t\t\t\t" . intval($setting['blacklist']) . ",\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "'\n\t)"; } /*insert query*/ $this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "setting\n\t\t\t\t\t\t(varname, grouptitle, value, defaultvalue, datatype, optioncode, displayorder, advanced, volatile, validationcode, blacklist, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(",\n\t", $setting_bits)); } $rebuild['options'] = true; } // ############## import admin help if (!empty($this->productobj['helptopics']['helpscript']) and is_array($this->productobj['helptopics']['helpscript'])) { $help_scripts =& $this->productobj['helptopics']['helpscript']; if (!isset($help_scripts[0])) { $help_scripts = array($help_scripts); } foreach ($help_scripts as $help_script) { // Deal with single entry if (!is_array($help_script['helptopic'][0])) { $help_script['helptopic'] = array($help_script['helptopic']); } $help_sql = array(); foreach ($help_script['helptopic'] as $topic) { $helpsql[] = "\n\t\t\t\t\t\t('" . $this->db->escape_string($help_script['name']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($topic['act']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($topic['opt']) . "',\n\t\t\t\t\t\t" . intval($topic['disp']) . ",\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t\t"; } if (!empty($helpsql)) { /*insert query*/ $this->db->query_write("\n\t\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "adminhelp\n\t\t\t\t\t\t\t(script, action, optionname, displayorder, volatile, product)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t" . implode(",\n\t", $helpsql)); } } } // ############## import cron if (!empty($this->productobj['cronentries']['cron']) and is_array($this->productobj['cronentries']['cron'])) { require_once DIR . '/includes/functions_cron.php'; $cron_entries =& $this->productobj['cronentries']['cron']; if (!isset($cron_entries[0])) { $cron_entries = array($cron_entries); } foreach ($cron_entries as $cron) { $cron['varname'] = preg_replace('#[^a-z0-9_]#i', '', $cron['varname']); if (!$cron['varname']) { continue; } $cron['active'] = $cron['active'] ? 1 : 0; $cron['loglevel'] = $cron['loglevel'] ? 1 : 0; $scheduling = $cron['scheduling']; $scheduling['weekday'] = intval($scheduling['weekday']); $scheduling['day'] = intval($scheduling['day']); $scheduling['hour'] = intval($scheduling['hour']); $scheduling['minute'] = explode(',', preg_replace('#[^0-9,-]#i', '', $scheduling['minute'])); if (count($scheduling['minute']) == 0) { $scheduling['minute'] = array(0); } else { $scheduling['minute'] = array_map('intval', $scheduling['minute']); } /*insert query*/ $this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "cron\n\t\t\t\t\t\t(weekday, day, hour, minute, filename, loglevel, active, varname, volatile, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t({$scheduling['weekday']},\n\t\t\t\t\t\t{$scheduling['day']},\n\t\t\t\t\t\t{$scheduling['hour']},\n\t\t\t\t\t\t'" . $this->db->escape_string(serialize($scheduling['minute'])) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($cron['filename']) . "',\n\t\t\t\t\t\t{$cron['loglevel']},\n\t\t\t\t\t\t{$cron['active']},\n\t\t\t\t\t\t'" . $this->db->escape_string($cron['varname']) . "',\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t"); $cronid = $this->db->insert_id(); // replace either inserts, or deletes+inserts if ($cronid) { build_cron_item($cronid); } $rebuild['cron'] = true; } } // ############## import faq if (!empty($this->productobj['faqentries']['faq']) and is_array($this->productobj['faqentries']['faq'])) { $faq_entries =& $this->productobj['faqentries']['faq']; if (!isset($faq_entries[0])) { $faq_entries = array($faq_entries); } $sql = array(); foreach ($faq_entries as $faq) { $sql[] = "\n\t\t\t\t\t('" . $this->db->escape_string($faq['faqname']) . "',\n\t\t\t\t\t'" . $this->db->escape_string($faq['faqparent']) . "',\n\t\t\t\t\t" . intval($faq['displayorder']) . ",\n\t\t\t\t\t1,\n\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t"; } if ($sql) { /*insert query*/ $this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "faq\n\t\t\t\t\t\t(faqname, faqparent, displayorder, volatile, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(',', $sql) . "\n\t\t\t\t"); } } $this->productinfo['process'] = VB_AREA; $this->productinfo['username'] = '******' . VB_AREA; import_navigation($this->productobj, $this->productinfo); $products = fetch_product_list(true); // Check if the plugin system is disabled. If it is, enable it if this product isn't installed. if (!$this->registry->options['enablehooks'] and !$products[$this->productinfo['productid']]) { $this->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "setting\n\t\t\t\tSET value = '1'\n\t\t\t\tWHERE varname = 'enablehooks'\n\t\t\t"); $rebuild['options'] = true; } // Now rebuild everything we need... if ($rebuild['plugins']) { vBulletinHook::build_datastore($this->db); if ($this->active) { $plugin_data = $this->db->query_read("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM " . TABLE_PREFIX . "datastore\n\t\t\t\t\tWHERE title IN ('pluginlist', 'pluginlistadmin')\n\t\t\t\t"); while ($plugin_info = $this->db->fetch_array($plugin_data)) { if ($plugin_info['title'] == 'pluginlist') { $this->registry->pluginlist = unserialize($plugin_info['data']); } else { if ($plugin_info['title'] == 'pluginlistadmin') { $this->registry->pluginlistadmin = unserialize($plugin_info['data']); } } } // enable any hooks -- this is mainly necessary for importing templates (template_safe_functions hook) if (!defined('DISABLE_HOOKS') and VB_AREA != 'Upgrade') { if (!empty($this->registry->pluginlistadmin) and is_array($this->registry->pluginlistadmin)) { $this->registry->pluginlist = array_merge($this->registry->pluginlist, $this->registry->pluginlistadmin); unset($this->registry->pluginlistadmin); } vBulletinHook::set_pluginlist($this->registry->pluginlist, $vbulletin->options['hookerrors']); } } } if ($rebuild['templates']) { if ($error = build_all_styles(0, 0, '', false, 'standard')) { return $error; } if ($error = build_all_styles(0, 0, '', false, 'mobile')) { return $error; } } if ($rebuild['phrases']) { require_once DIR . '/includes/adminfunctions_language.php'; build_language(); } if ($rebuild['options']) { build_options(); } if ($rebuild['cron']) { require_once DIR . '/includes/functions_cron.php'; build_cron_next_run(); } build_product_datastore(); build_activitystream_datastore(); // build bitfields to remove/add this products bitfields vB_Bitfield_Builder::save($this->db); // reload block types $blockmanager = vB_BlockManager::create($this->registry); $blockmanager->reloadBlockTypes(); print_dots_stop(); $this->productinfo['need_merge'] = ($rebuild['templates'] and $installed_version); return $this->productinfo; }
/** * Everything that comes after the install - no reason to break this up into chunks at present * */ public function post_install() { // dependencies checked, install code run. Now clear out the old product info; // settings should be retained in memory already delete_product($this->productinfo['productid'], false, true); $codes =& $this->productobj['codes']['code']; if (!isset($codes[0])) { $codes = array($codes); } if (is_array($codes)) { // we've now run all the codes, if execution is still going // then it's going to complete fully, so insert the codes foreach ($codes as $code) { /* insert query */ $this->db->query_write("\n\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "productcode\n\t\t\t\t\t\t(productid, version, installcode, uninstallcode)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . $this->db->escape_string($this->productinfo['productid']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($code['version']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($code['installcode']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($code['uninstallcode']) . "')\n\t\t\t\t"); } } if (is_array($this->productobj['dependencies']['dependency'])) { $dependencies =& $this->productobj['dependencies']['dependency']; if (!isset($dependencies[0])) { $dependencies = array($dependencies); } // dependencies met, codes run -- now we can insert the dependencies into the DB foreach ($dependencies as $dependency) { /* insert query */ $this->db->query_write("\n\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "productdependency\n\t\t\t\t\t\t(productid, dependencytype, parentproductid, minversion, maxversion)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . $this->db->escape_string($this->productinfo['productid']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($dependency['dependencytype']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($dependency['parentproductid']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($dependency['minversion']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($dependency['maxversion']) . "')\n\t\t\t\t"); } } /* insert query */ $this->db->query_write("\n\t\t\tINSERT INTO " . TABLE_PREFIX . "product\n\t\t\t\t(productid, title, description, version, active, url, versioncheckurl)\n\t\t\tVALUES\n\t\t\t\t('" . $this->db->escape_string($this->productinfo['productid']) . "',\n\t\t\t\t'" . $this->db->escape_string($this->productinfo['title']) . "',\n\t\t\t\t'" . $this->db->escape_string($this->productinfo['description']) . "',\n\t\t\t\t'" . $this->db->escape_string($this->productinfo['version']) . "',\n\t\t\t\t" . intval($this->active) . ",\n\t\t\t\t'" . $this->db->escape_string($this->productinfo['url']) . "',\n\t\t\t\t'" . $this->db->escape_string($this->productinfo['versioncheckurl']) . "')\n\t\t"); // ############## import templates if (is_array($this->productobj['templates']['template'])) { $querybits = array(); $querytemplates = 0; $templates =& $this->productobj['templates']['template']; if (!isset($templates[0])) { $templates = array($templates); } foreach ($templates as $template) { $querybit = array('styleid' => '-1', 'title' => $template['name'], 'template' => $template['templatetype'] == 'template' ? compile_template($template['value']) : $template['value'], 'template_un' => $template['templatetype'] == 'template' ? $template['value'] : '', 'dateline' => $template['date'], 'username' => $template['username'], 'version' => $template['version'], 'product' => $template['productid']); $querybit['templatetype'] = $template['templatetype']; $querybits[] = $querybit; if (++$querytemplates % 20 == 0) { /*insert query*/ vB::getDbAssertor()->assertQuery('replaceTemplates', array('querybits' => $querybits)); $querybits = array(); } if (!defined('SUPPRESS_KEEPALIVE_ECHO')) { echo ' '; vbflush(); } } // insert any remaining templates if (!empty($querybits)) { /*insert query*/ vB::getDbAssertor()->assertQuery('replaceTemplates', array('querybits' => $querybits)); } unset($querybits); $rebuild['templates'] = true; } // ############## import stylevars if (isset($this->productobj['stylevardfns']['stylevargroup']) and is_array($this->productobj['stylevardfns']['stylevargroup'])) { xml_import_stylevar_definitions($this->productobj['stylevardfns'], $this->productinfo['productid']); } if (isset($this->productobj['stylevars']['stylevar']) and is_array($this->productobj['stylevars']['stylevar'])) { xml_import_stylevars($this->productobj['stylevars'], -1); } // ############## import hooks if (is_array($this->productobj['hooks']['hook'])) { $hooks =& $this->productobj['hooks']['hook']; if (!isset($hooks[0])) { $hooks = array($hooks); } foreach ($hooks as $hook) { $hook['product'] = $this->productinfo['productid']; $this->db->query_write(fetch_query_sql($hook, 'hook')); } $rebuild['hooks'] = true; } // ############## import phrases if (is_array($this->productobj['phrases']['phrasetype'])) { $master_phrasetypes = array(); $master_phrasefields = array(); foreach (vB_Api::instanceInternal('phrase')->fetch_phrasetypes(false) as $phrasetype) { $master_phrasefields["{$phrasetype['fieldname']}"] = true; } $phrasetypes = vB_Api::instanceInternal('phrase')->fetch_phrasetypes(false); if (!isset($phrasetypes[0])) { $phrasetypes = array($phrasetypes); } foreach ($phrasetypes as $phrasetype) { if (empty($phrasetype['phrase'])) { continue; } if ($phrasetype['fieldname'] == '' or !preg_match('#^[a-z0-9_]+$#i', $phrasetype['fieldname'])) { continue; } $fieldname = $master_phrasefields["{$phrasetype['fieldname']}"]; if (!$fieldname) { $this->db->query_write("\n\t\t\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "phrasetype\n\t\t\t\t\t\t\t(fieldname, title, editrows, product)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('" . $this->db->escape_string($phrasetype['fieldname']) . "',\n\t\t\t\t\t\t\t'" . $this->db->escape_string($phrasetype['name']) . "',\n\t\t\t\t\t\t\t3,\n\t\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t\t"); // need to add the column to the language table as well require_once DIR . '/includes/class_dbalter.php'; $this->db_alter = new vB_Database_Alter_MySQL($this->db); if ($this->db_alter->fetch_table_info('language')) { $this->db_alter->add_field(array('name' => "phrasegroup_{$phrasetype['fieldname']}", 'type' => 'mediumtext')); } } $phrases =& $phrasetype['phrase']; if (!isset($phrases[0])) { $phrases = array($phrases); } $sql = array(); foreach ($phrases as $phrase) { $sql[] = "\n\t\t\t\t\t\t(-1,\n\t\t\t\t\t\t'" . $this->db->escape_string($phrasetype['fieldname']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($phrase['name']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($phrase['value']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($phrase['username']) . "',\n\t\t\t\t\t\t" . intval($phrase['date']) . ",\n\t\t\t\t\t\t'" . $this->db->escape_string($phrase['version']) . "')\n\t\t\t\t\t"; } /*insert query*/ $this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "phrase\n\t\t\t\t\t\t(languageid, fieldname, varname, text, product, username, dateline, version)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(',', $sql)); } $rebuild['phrases'] = true; } // ############## import settings if (is_array($this->productobj['options']['settinggroup'])) { $settinggroups =& $this->productobj['options']['settinggroup']; if (!isset($settinggroups[0])) { $settinggroups = array($settinggroups); } foreach ($settinggroups as $group) { if (empty($group['setting'])) { continue; } // create the setting group if it doesn't already exist /*insert query*/ $this->db->query_write("\n\t\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "settinggroup\n\t\t\t\t\t\t(grouptitle, displayorder, volatile, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . $this->db->escape_string($group['name']) . "',\n\t\t\t\t\t\t" . intval($group['displayorder']) . ",\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t"); $settings =& $group['setting']; if (!isset($settings[0])) { $settings = array($settings); } $setting_bits = array(); foreach ($settings as $setting) { if (isset($this->registry->options["{$setting['varname']}"])) { $newvalue = $this->registry->options["{$setting['varname']}"]; } else { $newvalue = $setting['defaultvalue']; } $setting_bits[] = "(\n\t\t\t\t\t\t'" . $this->db->escape_string($setting['varname']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($group['name']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string(trim($newvalue)) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string(trim($setting['defaultvalue'])) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string(trim($setting['datatype'])) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($setting['optioncode']) . "',\n\t\t\t\t\t\t" . intval($setting['displayorder']) . ",\n\t\t\t\t\t\t" . intval($setting['advanced']) . ",\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escape_string($setting['validationcode']) . "',\n\t\t\t\t\t\t" . intval($setting['blacklist']) . ",\n\t\t\t\t\t\t" . intval($setting['public']) . ",\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "'\n\t)"; } /*insert query*/ $this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "setting\n\t\t\t\t\t\t(varname, grouptitle, value, defaultvalue, datatype, optioncode, displayorder, advanced, volatile, validationcode, blacklist, ispublic, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(",\n\t", $setting_bits)); } $rebuild['options'] = true; } // ############## import admin help if (isset($this->productobj['helptopics']['helpscript']) and is_array($this->productobj['helptopics']['helpscript'])) { $help_scripts =& $this->productobj['helptopics']['helpscript']; if (!isset($help_scripts[0])) { $help_scripts = array($help_scripts); } foreach ($help_scripts as $help_script) { // Deal with single entry if (!is_array($help_script['helptopic'][0])) { $help_script['helptopic'] = array($help_script['helptopic']); } $help_sql = array(); foreach ($help_script['helptopic'] as $topic) { $helpsql[] = "\n\t\t\t\t\t\t('" . $this->db->escape_string($help_script['name']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($topic['act']) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($topic['opt']) . "',\n\t\t\t\t\t\t" . intval($topic['disp']) . ",\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t\t"; } if (!empty($helpsql)) { /*insert query*/ $this->db->query_write("\n\t\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "adminhelp\n\t\t\t\t\t\t\t(script, action, optionname, displayorder, volatile, product)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t" . implode(",\n\t", $helpsql)); } } } // ############## import cron if (isset($this->productobj['cronentries']['cron']) and is_array($this->productobj['cronentries']['cron'])) { require_once DIR . '/includes/functions_cron.php'; $cron_entries =& $this->productobj['cronentries']['cron']; if (!isset($cron_entries[0])) { $cron_entries = array($cron_entries); } foreach ($cron_entries as $cron) { $cron['varname'] = preg_replace('#[^a-z0-9_]#i', '', $cron['varname']); if (!$cron['varname']) { continue; } $cron['active'] = $cron['active'] ? 1 : 0; $cron['loglevel'] = $cron['loglevel'] ? 1 : 0; $scheduling = $cron['scheduling']; $scheduling['weekday'] = intval($scheduling['weekday']); $scheduling['day'] = intval($scheduling['day']); $scheduling['hour'] = intval($scheduling['hour']); $scheduling['minute'] = explode(',', preg_replace('#[^0-9,-]#i', '', $scheduling['minute'])); if (count($scheduling['minute']) == 0) { $scheduling['minute'] = array(0); } else { $scheduling['minute'] = array_map('intval', $scheduling['minute']); } /*insert query*/ $this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "cron\n\t\t\t\t\t\t(weekday, day, hour, minute, filename, loglevel, active, varname, volatile, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t({$scheduling['weekday']},\n\t\t\t\t\t\t{$scheduling['day']},\n\t\t\t\t\t\t{$scheduling['hour']},\n\t\t\t\t\t\t'" . $this->db->escape_string(serialize($scheduling['minute'])) . "',\n\t\t\t\t\t\t'" . $this->db->escape_string($cron['filename']) . "',\n\t\t\t\t\t\t{$cron['loglevel']},\n\t\t\t\t\t\t{$cron['active']},\n\t\t\t\t\t\t'" . $this->db->escape_string($cron['varname']) . "',\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t"); $cronid = $this->db->insert_id(); // replace either inserts, or deletes+inserts if ($cronid) { build_cron_item($cronid); } $rebuild['cron'] = true; } } // ############## import faq if (isset($this->productobj['faqentries']['faq']) and is_array($this->productobj['faqentries']['faq'])) { $faq_entries =& $this->productobj['faqentries']['faq']; if (!isset($faq_entries[0])) { $faq_entries = array($faq_entries); } $sql = array(); foreach ($faq_entries as $faq) { $sql[] = "\n\t\t\t\t\t('" . $this->db->escape_string($faq['faqname']) . "',\n\t\t\t\t\t'" . $this->db->escape_string($faq['faqparent']) . "',\n\t\t\t\t\t" . intval($faq['displayorder']) . ",\n\t\t\t\t\t1,\n\t\t\t\t\t'" . $this->db->escape_string($this->productinfo['productid']) . "')\n\t\t\t\t"; } if ($sql) { /*insert query*/ $this->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "faq\n\t\t\t\t\t\t(faqname, faqparent, displayorder, volatile, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(',', $sql) . "\n\t\t\t\t"); } } // ############## import widgets /* Copied from adminfinctions_product.php At some point we need to get rid of this product install duplication */ if (isset($this->productobj['widgets']['widget']) and is_array($this->productobj['widgets']['widget'])) { $widgets =& $this->productobj['widgets']['widget']; if (!isset($widgets[0])) { $widgets = array($widgets); } $assertor = vB::getDbAssertor(); foreach ($widgets as $widget) { $existing = $assertor->getRow('widget', array('guid' => $widget['guid'], 'product' => $info['productid'])); if ($existing['widgetid']) { $data = $widget + $existing; unset($data['definitions']); $data['isthirdparty'] = 1; $data['product'] = $info['productid']; $result = $assertor->update('widget', $data, array('widgetid' => $existing['widgetid'])); $wdfs_old = $assertor->getRows('widgetdefinition', array('widgetid' => $existing['widgetid'])); $assertor->delete('widgetdefinition', array('widgetid' => $existing['widgetid'])); $index_old = array(); foreach ($wdfs_old as $key => $definition) { $index_old[$key] = $definition['name']; } $wdfs_new =& $widget['definitions']['definition']; if (!isset($wdfs_new[0])) { $wdfs_new = array($wdfs_new); } foreach ($wdfs_new as &$definition) { if ($key_old = array_search($definition['name'], $index_old)) { $definition = $definition + $wdfs_old[$key_old]; } $data = $definition; $data['product'] = $info['productid']; $data['widgetid'] = $existing['widgetid']; $assertor->insert('widgetdefinition', $data); } } else { $data = $widget; $data['isthirdparty'] = 1; $data['product'] = $info['productid']; unset($data['definitions']); $result = $assertor->insert('widget', $data); $widgetid = is_array($result) ? array_pop($result) : $result; if ($widgetid and is_array($widget['definitions']['definition'])) { $definitions =& $widget['definitions']['definition']; if (!isset($definitions[0])) { $definitions = array($definitions); } foreach ($definitions as $definition) { $data = $definition; $data['widgetid'] = $widgetid; $data['product'] = $info['productid']; $assertor->insert('widgetdefinition', $data); } } } } } $products = fetch_product_list(true); // Check if the plugin system is disabled. If it is, enable it if this product isn't installed. if (!$this->registry->options['enablehooks'] and !$products[$this->productinfo['productid']]) { $this->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "setting\n\t\t\t\tSET value = '1'\n\t\t\t\tWHERE varname = 'enablehooks'\n\t\t\t"); $rebuild['options'] = true; } // Now rebuild everything we need... if ($rebuild['hooks']) { vB_Api::instanceInternal("Hook")->buildHookDatastore(); } if ($rebuild['templates']) { if ($error = build_all_styles(0, 0, '')) { return $error; } } if ($rebuild['phrases']) { require_once DIR . '/includes/adminfunctions_language.php'; build_language(); } if ($rebuild['options']) { vB::getDatastore()->build_options(); } if ($rebuild['cron']) { require_once DIR . '/includes/functions_cron.php'; build_cron_next_run(); } build_product_datastore(); // build bitfields to remove/add this products bitfields vB_Bitfield_Builder::save($this->db); print_dots_stop(); $this->productinfo['need_merge'] = ($rebuild['templates'] and $installed_version); return $this->productinfo; }