public static function fetch_language() { static $phrases; if (!$phrases) { require_once DIR . '/includes/class_xml.php'; $languagecode = defined('UPGRADE_LANGUAGE') ? UPGRADE_LANGUAGE : 'en'; $xmlobj = new vB_XML_Parser(false, DIR . '/install/upgrade_language_' . $languagecode . '.xml'); $xml = $xmlobj->parse(defined('UPGRADE_ENCODING') ? UPGRADE_ENCODING : 'ISO-8859-1'); foreach ($xml['group'] as $value) { if (is_array($value['group'])) { // step phrases foreach ($value['group'] as $value2) { if (!$value2['phrase'][0]) { $value2['phrase'] = array($value2['phrase']); } foreach ($value2['phrase'] as $value3) { $step = $value3['step'] ? "_{$value3['step']}" : ''; $phrases[$value['name']][$value2['name']][$value3['name'] . $step] = $value3['value']; } } } else { if (!$value['phrase'][0]) { $value['phrase'] = array($value['phrase']); } foreach ($value['phrase'] as $value2) { $step = $value2['step'] ? "_{$value2['step']}" : ''; $phrases[$value['name']][$value2['name'] . $step] = $value2['value']; } } } $GLOBALS['vbphrase'] =& $phrases['vbphrase']; } return $phrases; }
/** * Fetch array of podcast categories * * @return array Array of categories */ function fetch_podcast_categoryarray($categoryid) { require_once DIR . '/includes/class_xml.php'; $xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/podcast_vbulletin.xml'); $podcastdata = $xmlobj->parse(); $key = 1; $output = array(); if (is_array($podcastdata['category'])) { foreach ($podcastdata['category'] as $cats) { if ($key == $categoryid) { $output[] = htmlspecialchars_uni($cats['name']); break; } $key++; if (is_array($cats['sub']['name'])) { foreach ($cats['sub']['name'] as $subcats) { if ($key == $categoryid) { $output[] = htmlspecialchars_uni($cats['name']); $output[] = htmlspecialchars_uni($subcats); break 2; } $key++; } } } } return $output; }
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"); } }
function build_bbcode_video($checktable = false) { if ($checktable) { try { vB::getDbAssertor()->assertQuery('bbcode_video', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT)); } catch (Exception $e) { return false; } } 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'] = $provider['tagoption']; $items['provider'] = $provider['title']; $items['url'] = $provider['url']; $items['regex_url'] = $provider['regex_url']; $items['regex_scrape'] = $provider['regex_scrape']; $items['embed'] = $provider['embed']; $insert[] = $items; } if (!empty($insert)) { vB::getDbAssertor()->assertQuery('truncateTable', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD, 'table' => 'bbcode_video')); vB::getDbAssertor()->assertQuery('bbcode_video', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_MULTIPLEINSERT, vB_dB_Query::FIELDS_KEY => array('tagoption', 'provider', 'url', 'regex_url', 'regex_scrape', 'embed'), vB_dB_Query::VALUES_KEY => $insert)); } } $firsttag = '<vb:if condition="$provider == \'%1$s\'">'; $secondtag = '<vb:elseif condition="$provider == \'%1$s\'" />'; $template = array(); $bbcodes = vB::getDbAssertor()->assertQuery('bbcode_video', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT), array('field' => array('priority'), 'direction' => array(vB_dB_Query::SORT_ASC))); foreach ($bbcodes as $bbcode) { 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); $exists = vB::getDbAssertor()->getRow('template', array(vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'title', 'value' => 'bbcode_video', 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'product', 'value' => array('', 'vbulletin'), 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'styleid', 'value' => -1, 'operator' => vB_dB_Query::OPERATOR_EQ)))); if ($exists) { try { vB_Api::instanceInternal('template')->update($exists['templateid'], 'bbcode_video', $final, 'vbulletin', false, false, ''); } catch (Exception $e) { return false; } } else { vB_Api::instanceInternal('template')->insert(-1, 'bbcode_video', $final, 'vbulletin'); } return true; }
public function getXmlHooks() { if (!$this->hasPermission()) { return false; } $typelist = array(); $hooklocations = array(); require_once DIR . '/includes/class_xml.php'; $types = $this->assertor->getRows('getHooktypePhrases'); $hookfiles = vB_Api_Product::loadProductXmlList('hooks'); foreach ($types as $type) { $typelist[] = $type['varname']; } $vbphrase = vB_Api::instanceInternal('phrase')->fetch($typelist); foreach ($hookfiles as $file) { if (!preg_match('#hooks_(.*).xml$#i', $file, $matches)) { continue; } $product = $matches[1]; $phrased_product = $products[$product ? $product : 'vbulletin']; if (!$phrased_product) { $phrased_product = $product; } $xmlobj = new vB_XML_Parser(false, $location . $file); $xml = $xmlobj->parse(); if (!is_array($xml['hooktype'][0])) { $xml['hooktype'] = array($xml['hooktype']); } foreach ($xml['hooktype'] as $key => $hooks) { if (!is_numeric($key)) { continue; } $phrased_type = isset($vbphrase["hooktype_{$hooks['type']}"]) ? $vbphrase["hooktype_{$hooks['type']}"] : $hooks['type']; $hooktype = $phrased_type; $hooklocations["#{$hooktype}#"] = $hooktype; if (!is_array($hooks['hook'])) { $hooks['hook'] = array($hooks['hook']); } foreach ($hooks['hook'] as $hook) { $hookid = trim(is_string($hook) ? $hook : $hook['value']); if ($hookid !== '') { $hooklocations[$hookid] = '--- ' . $hookid . ($product != 'vbulletin' ? " ({$phrased_product})" : ''); } } } } return $hooklocations; }
/** * Parse XML * * @param string location of XML */ public function parse($xml) { print_dots_start('<b>' . $this->vbphrase['importing_product'] . "</b>, {$this->vbphrase[please_wait]}", ':', 'dspan'); $this->xmlobj = new vB_XML_Parser($xml); if ($this->xmlobj->error_no == 1) { print_dots_stop(); throw new vB_Exception_AdminStopMessage('no_xml_and_no_path'); } if (!($this->productobj = $this->xmlobj->parse())) { print_dots_stop(); throw new vB_Exception_AdminStopMessage(array('xml_error_x_at_line_y', $this->xmlobj->error_string(), $this->xmlobj->error_line())); } // ############## general product information $this->productinfo['productid'] = substr(preg_replace('#[^a-z0-9_]#', '', strtolower($this->productobj['productid'])), 0, 25); $this->productinfo['title'] = $this->productobj['title']; $this->productinfo['description'] = $this->productobj['description']; $this->productinfo['version'] = $this->productobj['version']; $this->productinfo['active'] = $this->productobj['active']; $this->productinfo['url'] = $this->productobj['url']; $this->productinfo['versioncheckurl'] = $this->productobj['versioncheckurl']; if (!$this->productinfo['productid']) { print_dots_stop(); if (!empty($this->productobj['plugin'])) { throw new vB_Exception_AdminStopMessage('this_file_appears_to_be_a_plugin'); } else { throw new vB_Exception_AdminStopMessage('invalid_file_specified'); } } if (strtolower($this->productinfo['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>')); } } return true; }
protected function __construct() { //We need the usergroups and the permission bitmaps. $usergroups = vB_Api::instanceInternal('usergroup')->fetchUsergroupList($flushcache = false); foreach ($usergroups as $usergroup) { self::$usergroups[$usergroup['usergroupid']] = $usergroup['title']; } $this->permSettings = array('forumpermissions' => array(), 'forumpermissions2' => array(), 'moderatorpermissions' => array(), 'createpermissions' => array()); $parser = new vB_XML_Parser(false, DIR . '/includes/xml/bitfield_vbulletin.xml'); $bitfields = $parser->parse(); foreach ($bitfields['bitfielddefs']['group'] as $topGroup) { if ($topGroup['name'] == 'ugp' or $topGroup['name'] == 'misc') { foreach ($topGroup['group'] as $group) { switch ($group['name']) { case 'forumpermissions': case 'forumpermissions2': case 'moderatorpermissions': foreach ($group['bitfield'] as $fielddef) { if (!empty($fielddef['intperm'])) { continue; } if (in_array($fielddef['name'], self::$bitfieldsUsed[$group['name']])) { $fielddef['used'] = 1; } else { $fielddef['used'] = 0; } $this->permSettings[$group['name']][$fielddef['name']] = $fielddef; } break; case 'createpermissions': foreach ($group['bitfield'] as $fielddef) { $fielddef['used'] = 1; $this->permSettings[$group['name']][$fielddef['name']] = $fielddef; } break; } } } } }
/** * 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 * @param int|null Starting template group index for this run of importing templates (0 based). * Null means all templates (single run) * @paream int|null * * @return array Array of information about the imported style */ function xml_import_style( $xml = false, $styleid = -1, $parentid = -1, $title = '', $anyversion = false, $displayorder = 1, $userselect = true, $startat = null, $perpage = null ) { // $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'); //where is this used? I hate having this random global value in the middle of this function $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(!$parsed_xml = $xmlobj->parse()) { print_dots_stop(); print_stop_message('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line()); } $version = $parsed_xml['vbversion']; $master = ($parsed_xml['type'] == 'master' ? 1 : 0); $title = (empty($title) ? $parsed_xml['name'] : $title); $product = (empty($parsed_xml['product']) ? 'vbulletin' : $parsed_xml['product']); $one_pass = (is_null($startat) AND is_null($perpage)); if (!$one_pass AND (!is_numeric($startat) OR !is_numeric($perpage) OR $perpage <= 0 OR $startat < 0)) { print_dots_stop(); print_stop_message(''); } if ($one_pass OR ($startat == 0)) { // version check $full_product_info = fetch_product_list(true); $product_info = $full_product_info["$product"]; 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); } //Initialize the style -- either init the master, create a new style, or verify the style to overwrite. if ($master) { $import_data = @unserialize(fetch_adminutil_text('master_style_import')); if (!empty($import_data) AND (TIMENOW - $import_data['last_import']) <= 30) { print_dots_stop(); print_stop_message('must_wait_x_seconds_master_style_import', vb_number_format($import_data['last_import'] + 30 - TIMENOW)); } // 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 $test = $vbulletin->db->query_first(" SELECT styleid FROM " . TABLE_PREFIX . "style WHERE title = '" . $vbulletin->db->escape_string($title) . "'" ); if ($test) { 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(" INSERT INTO " . TABLE_PREFIX . "style (title, parentid, displayorder, userselect) VALUES ('" . $vbulletin->db->escape_string($title) . "', $parentid, $displayorder, " . ($userselect ? 1 : 0) . ") "); $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'); } } } } //load the templates if ($arr = $parsed_xml['templategroup']) { if (empty($arr[0])) { $arr = array($arr); } $templates_done = (is_numeric($startat) AND (count($arr) < $startat)); if ($one_pass OR !$templates_done) { if (!$one_pass) { $arr = array_slice($arr, $startat, $perpage); } xml_import_template_groups($styleid, $product, $arr, !$one_pass); } } else { $templates_done = true; } //note that templates may actually be done at this point, but templates_done is //only true if templates were completed in a prior step. If we are doing a multi-pass //process, we don't want to install stylevars in the same pass. We aren't really done //until we hit a pass where the templates are done before processing. $done = ($one_pass OR $templates_done); if ($done) { //load stylevars and definitions // re-import any stylevar definitions if ($master AND !empty($parsed_xml['stylevardfns']['stylevargroup'])) { xml_import_stylevar_definitions($parsed_xml['stylevardfns'], 'vbulletin'); } //if the tag is present but empty we'll end up with a string with whitespace which //is a non "empty" value. if (!empty($parsed_xml['stylevars']) AND is_array($parsed_xml['stylevars'])) { xml_import_stylevars($parsed_xml['stylevars'], $styleid); } if ($master) { xml_import_restore_adsense_templates(); build_adminutil_text('master_style_import', serialize(array('last_import' => TIMENOW))); } print_dots_stop(); } return array( 'version' => $version, 'master' => $master, 'title' => $title, 'product' => $product, 'done' => $done ); }
/** * Returns array of the XML data parsed into array format * * @param string file Filename * @param boolean Process disabled products? * * @return array */ function fetch($file, $layout, $include_disabled = false) { global $vbulletin; $obj =& vB_Bitfield_Builder::init(); $xmlobj = new vB_XML_Parser(false, $file); if (!($xml = $xmlobj->parse())) { // xml parser failed return false; } if (!$include_disabled and $xml['product'] and $xml['product'] != 'vbulletin' and empty($vbulletin->products["{$xml['product']}"])) { // This product is disabled return false; } $tempdata = array(); if (!$layout) { $xmlignore = $xml['ignoregroups']; } $xml = $xml['bitfielddefs']; if (!isset($xml['group'][0])) { $xml['group'] = array($xml['group']); } foreach ($xml['group'] as $bitgroup) { if (!isset($tempdata["{$bitgroup['name']}"])) { // this file as a group with the same name so don't intialise it $tempdata["{$bitgroup['name']}"] = array(); } // deal with actual bitfields if (!isset($bitgroup['group'])) { $tempdata["{$bitgroup['name']}"] = $obj->bitfield_array_convert($bitgroup['bitfield'], $layout); } else { $subdata = array(); if (!isset($bitgroup['group'][0])) { $bitgroup['group'] = array($bitgroup['group']); } foreach ($bitgroup['group'] as $subgroup) { $subdata["{$subgroup['name']}"] = $obj->bitfield_array_convert($subgroup['bitfield'], $layout); } $tempdata["{$bitgroup['name']}"] = $subdata; } } if (!$layout and !empty($xmlignore['group'])) { if (!isset($xmlignore['group'][0])) { $xmlignore['group'] = array($xmlignore['group']); } foreach ($xmlignore['group'] as $title => $moo) { if (!empty($moo['ignoregroups'])) { $moo['layoutperm']['ignoregroups'] = $moo['ignoregroups']; } $tempdata['layout']["{$moo['name']}"] = $moo['layoutperm']; } } $xmlobj = null; return $tempdata; }
public function get_svn_data($template_filenames, $minsvnversion = 1, $skip_revisions = array()) { $template_dir = $this->get_svn_template_source(); // pull data from cache, to reduce what has to be retrieved from the svn server if ($cache = $this->get_svn_data_from_cache($template_dir)) { $data = $cache['data']; $minsvnversion = $cache['minsvnversion']; unset($cache); } $cmd = 'svn log -rHEAD:' . $minsvnversion . ' --xml -v "' . $template_dir . '"'; $text = shell_exec($cmd); $xmlobj = new vB_XML_Parser($text); $parsed_xml = $xmlobj->parse(); if ($parsed_xml === false) { $this->errors[] = sprintf("xml error '%s', on line '%d'", $xmlobj->error_string(), $xmlobj->error_line()); return false; } if (!is_array($parsed_xml)) { // There are no log entries within the <log> tags. It's just \r\n. return false; } $logentries = $this->get_xml_list($parsed_xml['logentry']); $template_dir_basename = basename($template_dir); // highest revision number for cache $max_revision = 1; $update_count = 0; foreach ($logentries as $logentry) { if (in_array($logentry['revision'], $skip_revisions)) { continue; } // highest revision number for cache $max_revision = max($max_revision, $logentry['revision']); $paths = $this->get_xml_list($logentry['paths']['path']); foreach ($paths as $path) { $is_mod = $path['action'] == 'M'; $is_rename = (($path['action'] == 'R' or $path['action'] == 'A') and $path['copyfrom-path']); if ($is_mod or $is_rename) { //make sure that the paths are the same one directory level up. This should cut down //dramatically on the potential for false matches since both paths would have to end in //templates/templatename.ext. This isn't perfect, but reduces the change of conflict //to a level where it realistically won't happen. We can't easily match the paths because //we don't really know how far up we should be checking. If there is a conflict the //only consequence is that we advance the change date in the xml unnecesarily. if (basename(dirname($path['value'])) == $template_dir_basename) { $path_file = basename($path['value']); $is_template = in_array($path_file, $template_filenames, true); $last_updated = strtotime($logentry['date']); $not_cached = !isset($data[$path_file]['lastupdated']); $is_newer = (isset($data[$path_file]['lastupdated']) and $data[$path_file]['lastupdated'] < $last_updated); //if(!array_key_exists($path_file, $data) AND in_array($path_file, $template_filenames)) if ($is_template and ($not_cached or $is_newer)) { $data[$path_file] = array('lastupdated' => $last_updated, 'username' => $logentry['author']); ++$update_count; } } } } } ksort($data); // cache data and highest revision number $this->save_svn_data_to_cache($template_dir, $data, $max_revision, $update_count); return $data; }
public static function parseFile($filepath) { $xmlobj = new vB_XML_Parser(false, $filepath); if ($xmlobj->error_no() == 1 or $xmlobj->error_no() == 2) { throw new Exception("Please ensure that the file {$filepath} exists"); } if (!($parsed_xml = $xmlobj->parse())) { throw new Exception('xml error ' . $xmlobj->error_string() . ', on line ' . $xmlobj->error_line()); } return $parsed_xml; }
/** * Imports a language from a language XML file * * @param string XML language string * @param integer Language to overwrite * @param string Override title for imported language * @param boolean Allow import of language from mismatched vBulletin version * @param boolean Allow user-select of imported language * @param boolean Echo output.. * @param boolean Read charset from XML header */ function xml_import_language($xml = false, $languageid = -1, $title = '', $anyversion = false, $userselect = true, $output = true, $readcharset = false) { global $vbulletin, $vbphrase; print_dots_start('<b>' . $vbphrase['importing_language'] . "</b>, {$vbphrase['please_wait']}", ':', 'dspan'); require_once DIR . '/includes/class_xml.php'; require_once DIR . '/includes/functions_misc.php'; $xmlobj = new vB_XML_Parser($xml, $GLOBALS['path'], $readcharset); 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-language.xml', $GLOBALS['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['phrasetype']) { print_dots_stop(); print_stop_message('invalid_file_specified'); } $title = empty($title) ? $arr['name'] : $title; $version = $arr['vbversion']; $master = $arr['type'] == 'master' ? 1 : 0; $just_phrases = $arr['type'] == 'phrases' ? 1 : 0; if (!empty($arr['settings'])) { $langinfo = $arr['settings']; } $langinfo['product'] = empty($arr['product']) ? 'vbulletin' : $arr['product']; // look for skipped groups $skipped_groups = array(); if (!empty($arr['skippedgroups'])) { $skippedgroups =& $arr['skippedgroups']['skippedgroup']; if (!is_array($skippedgroups[0])) { $skippedgroups = array($skippedgroups); } foreach ($skippedgroups as $skipped) { if (is_array($skipped)) { $skipped_groups[] = $vbulletin->db->escape_string($skipped['value']); } else { $skipped_groups[] = $vbulletin->db->escape_string($skipped); } } } if ($skipped_groups) { $sql_skipped = "AND " . TABLE_PREFIX . "phrase.fieldname NOT IN ('" . implode("', '", $skipped_groups) . "')"; } else { $sql_skipped = ''; } foreach ($langinfo as $key => $val) { $langinfo["{$key}"] = $vbulletin->db->escape_string(trim($val)); } $langinfo['options'] = intval($langinfo['options']); if ($version != $vbulletin->options['templateversion'] and !$anyversion and !$master) { print_dots_stop(); print_stop_message('upload_file_created_with_different_version', $vbulletin->options['templateversion'], $version); } //set up the phrase array $arr = $arr['phrasetype']; if (!is_array($arr[0])) { $arr = array($arr); } //spin through the phrases to check validity. We want to do this *before* we prep for import //so that if we abort do to an error, we haven't made any changes first foreach (array_keys($arr) as $key) { $phraseTypes =& $arr["{$key}"]; foreach ($phraseTypes['phrase'] as $phrase) { if (!validate_string_for_interpolation($phrase['value'])) { print_dots_stop(); print_stop_message('phrase_text_not_safe', $phrase['name']); } } } // prepare for import if ($master) { // lets stop it from dieing cause someone borked a previous update $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "phrase WHERE languageid = -10"); // master style if ($output and VB_AREA != 'Install' and VB_AREA != 'Upgrade') { echo "<h3>{$vbphrase['master_language']}</h3>\n<p>{$vbphrase['please_wait']}</p>"; vbflush(); } $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "phrase SET\n\t\t\t\tlanguageid = -10\n\t\t\tWHERE languageid = -1\n\t\t\t\tAND (product = '" . $vbulletin->db->escape_string($langinfo['product']) . "'" . iif($langinfo['product'] == 'vbulletin', " OR product = ''") . ")\n\t\t\t\t{$sql_skipped}\n\t\t"); $languageid = -1; } else { if ($languageid == 0) { // creating a new language if ($just_phrases) { print_dots_stop(); print_stop_message('language_only_phrases', $title); } else { if ($test = $vbulletin->db->query_first("SELECT languageid FROM " . TABLE_PREFIX . "language WHERE title = '" . $vbulletin->db->escape_string($title) . "'")) { print_dots_stop(); print_stop_message('language_already_exists', $title); } else { echo "<h3><b>" . construct_phrase($vbphrase['creating_a_new_language_called_x'], $title) . "</b></h3>\n<p>{$vbphrase['please_wait']}</p>"; vbflush(); /*insert query*/ $vbulletin->db->query_write("\n\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "language (\n\t\t\t\t\t\ttitle, options, languagecode, charset,\n\t\t\t\t\t\tdateoverride, timeoverride, decimalsep, thousandsep,\n\t\t\t\t\t\tregistereddateoverride, calformat1override, calformat2override, locale, logdateoverride\n\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($title) . "', {$langinfo['options']}, '{$langinfo['languagecode']}', '{$langinfo['charset']}',\n\t\t\t\t\t\t'{$langinfo['dateoverride']}', '{$langinfo['timeoverride']}', '{$langinfo['decimalsep']}', '{$langinfo['thousandsep']}',\n\t\t\t\t\t\t'{$langinfo['registereddateoverride']}', '{$langinfo['calformat1override']}', '{$langinfo['calformat2override']}', '{$langinfo['locale']}', '{$langinfo['logdateoverride']}'\n\t\t\t\t\t)\n\t\t\t\t"); $languageid = $vbulletin->db->insert_id(); } } } else { // overwriting an existing language if ($getlanguage = $vbulletin->db->query_first("SELECT title FROM " . TABLE_PREFIX . "language WHERE languageid = {$languageid}")) { if (!$just_phrases) { echo "<h3><b>" . construct_phrase($vbphrase['overwriting_language_x'], $getlanguage['title']) . "</b></h3>\n<p>{$vbphrase['please_wait']}</p>"; vbflush(); $vbulletin->db->query_write("\n\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "language SET\n\t\t\t\t\t\t\toptions = {$langinfo['options']},\n\t\t\t\t\t\t\tlanguagecode = '{$langinfo['languagecode']}',\n\t\t\t\t\t\t\tcharset = '{$langinfo['charset']}',\n\t\t\t\t\t\t\tlocale = '{$langinfo['locale']}',\n\t\t\t\t\t\t\timagesoverride = '{$langinfo['imagesoverride']}',\n\t\t\t\t\t\t\tdateoverride = '{$langinfo['dateoverride']}',\n\t\t\t\t\t\t\ttimeoverride = '{$langinfo['timeoverride']}',\n\t\t\t\t\t\t\tdecimalsep = '{$langinfo['decimalsep']}',\n\t\t\t\t\t\t\tthousandsep = '{$langinfo['thousandsep']}',\n\t\t\t\t\t\t\tregistereddateoverride = '{$langinfo['registereddateoverride']}',\n\t\t\t\t\t\t\tcalformat1override = '{$langinfo['calformat1override']}',\n\t\t\t\t\t\t\tcalformat2override = '{$langinfo['calformat2override']}',\n\t\t\t\t\t\t\tlogdateoverride = '{$langinfo['logdateoverride']}'\n\t\t\t\t\t\tWHERE languageid = {$languageid}\n\t\t\t\t\t"); $vbulletin->db->query_write("\n\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "phrase, " . TABLE_PREFIX . "phrase AS phrase2\n\t\t\t\t\t\tSET " . TABLE_PREFIX . "phrase.languageid = -11\n\t\t\t\t\t\tWHERE " . TABLE_PREFIX . "phrase.languageid = {$languageid}\n\t\t\t\t\t\t\tAND (" . TABLE_PREFIX . "phrase.product = '" . $vbulletin->db->escape_string($langinfo['product']) . "'" . iif($langinfo['product'] == 'vbulletin', " OR " . TABLE_PREFIX . "phrase.product = ''") . ")\n\t\t\t\t\t\t\tAND (phrase2.product = '" . $vbulletin->db->escape_string($langinfo['product']) . "'" . iif($langinfo['product'] == 'vbulletin', " OR phrase2.product = ''") . ")\n\t\t\t\t\t\t\tAND " . TABLE_PREFIX . "phrase.varname = phrase2.varname\n\t\t\t\t\t\t\tAND phrase2.languageid = 0\n\t\t\t\t\t\t\tAND " . TABLE_PREFIX . "phrase.fieldname = phrase2.fieldname\n\t\t\t\t\t\t\t{$sql_skipped}\n\t\t\t\t\t"); $vbulletin->db->query_write("\n\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "phrase SET\n\t\t\t\t\t\t\tlanguageid = -10\n\t\t\t\t\t\tWHERE languageid = {$languageid}\n\t\t\t\t\t\t\tAND (product = '" . $vbulletin->db->escape_string($langinfo['product']) . "'" . iif($langinfo['product'] == 'vbulletin', " OR product = ''") . ")\n\t\t\t\t\t\t\t{$sql_skipped}\n\t\t\t\t\t"); } } else { print_stop_message('cant_overwrite_non_existent_language'); } } } // get current phrase types $current_phrasetypes = fetch_phrasetypes_array(false); if (!$master) { $globalPhrases = array(); $getphrases = $vbulletin->db->query_read("\n\t\t\tSELECT varname, fieldname\n\t\t\tFROM " . TABLE_PREFIX . "phrase\n\t\t\tWHERE languageid IN (0, -1)\n\t\t"); while ($getphrase = $vbulletin->db->fetch_array($getphrases)) { $globalPhrases["{$getphrase['varname']}~{$getphrase['fieldname']}"] = true; } } // import language // track new phrasetypes $new_phrasetypes = array(); foreach (array_keys($arr) as $key) { $phraseTypes =& $arr["{$key}"]; $sql = array(); $strlen = 0; if ($phraseTypes['fieldname'] == '' or !preg_match('#^[a-z0-9_]+$#i', $phraseTypes['fieldname'])) { continue; } $fieldname = $phraseTypes['fieldname']; if (!is_array($phraseTypes['phrase'][0])) { $phraseTypes['phrase'] = array($phraseTypes['phrase']); } // check if the phrasetype is new if (!isset($current_phrasetypes[$fieldname]) and !empty($phraseTypes['phrase'])) { $new_phrasetypes[] = array('fieldname' => $fieldname, 'title' => $phraseTypes['name']); } // Send some output to the browser inside this loop so certain hosts // don't artificially kill the script. See bug #34585 if ($output) { echo ' '; vbflush(); } foreach ($phraseTypes['phrase'] as $phrase) { if ($master) { $insertLanguageId = -1; } else { if (!isset($globalPhrases["{$phrase['name']}~{$fieldname}"])) { $insertLanguageId = 0; } else { if ($phrase['custom']) { // this is a custom phrase (language 0) -- we don't want it to end up in the custom language continue; } else { $insertLanguageId = $languageid; } } } $sql[] = "\n\t\t\t\t({$insertLanguageId},\n\t\t\t\t'" . $vbulletin->db->escape_string($fieldname) . "',\n\t\t\t\t'" . $vbulletin->db->escape_string($phrase['name']) . "',\n\t\t\t\t'" . $vbulletin->db->escape_string($phrase['value']) . "',\n\t\t\t\t'" . $vbulletin->db->escape_string($langinfo['product']) . "',\n\t\t\t\t'" . $vbulletin->db->escape_string($phrase['username']) . "',\n\t\t\t\t" . intval($phrase['date']) . ",\n\t\t\t\t'" . $vbulletin->db->escape_string($phrase['version']) . "')\n\t\t\t"; $strlen += strlen(end($sql)); if ($strlen > 102400) { // insert max of 100k of phrases at a time /*insert query*/ $vbulletin->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(",\n", $sql)); $sql = array(); $strlen = 0; } // Send some output to the browser inside this loop so certain hosts // don't artificially kill the script. See bug #34585 if ($output) { echo ' '; vbflush(); } } if ($sql) { /*insert query*/ $vbulletin->db->query_write("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "phrase\n\t\t\t\t\t(languageid, fieldname, varname, text, product, username, dateline, version)\n\t\t\t\tVALUES\n\t\t\t\t\t" . implode(",\n", $sql)); } unset($arr["{$key}"], $phraseTypes); } unset($sql, $arr, $current_phrasetypes); // insert any new phrasetypes foreach ($new_phrasetypes as $phrasetype) { add_phrase_type($phrasetype['fieldname'], $phrasetype['title'], $langinfo['product']); } $vbulletin->db->query_write("\n\t\tUPDATE IGNORE " . TABLE_PREFIX . "phrase\n\t\tSET " . TABLE_PREFIX . "phrase.languageid = {$languageid}\n\t\tWHERE " . TABLE_PREFIX . "phrase.languageid = -11\n\t\t\tAND (" . TABLE_PREFIX . "phrase.product = '" . $vbulletin->db->escape_string($langinfo['product']) . "'" . iif($langinfo['product'] == 'vbulletin', " OR " . TABLE_PREFIX . "phrase.product = ''") . ")\n\t\t\t{$sql_skipped}\n\t"); // now delete any phrases that were moved into the temporary language for safe-keeping $vbulletin->db->query_write("\n\t\tDELETE FROM " . TABLE_PREFIX . "phrase\n\t\tWHERE languageid IN (-10, -11)\n\t\t\tAND (product = '" . $vbulletin->db->escape_string($langinfo['product']) . "'" . iif($langinfo['product'] == 'vbulletin', " OR product = ''") . ")\n\t\t\t{$sql_skipped}\n\t"); print_dots_stop(); }
if ($_REQUEST['do'] == 'edit' or $_REQUEST['do'] == 'add') { $products = fetch_product_list(); $hooklocations = array(); require_once DIR . '/includes/class_xml.php'; $handle = opendir(DIR . '/includes/xml/'); while (($file = readdir($handle)) !== false) { if (!preg_match('#^hooks_(.*).xml$#i', $file, $matches)) { continue; } $product = $matches[1]; $phrased_product = $products[$product ? $product : 'vbulletin']; if (!$phrased_product) { $phrased_product = $product; } $xmlobj = new vB_XML_Parser(false, DIR . "/includes/xml/{$file}"); $xml = $xmlobj->parse(); if (!is_array($xml['hooktype'][0])) { // ugly kludge but it works... $xml['hooktype'] = array($xml['hooktype']); } foreach ($xml['hooktype'] as $key => $hooks) { if (!is_numeric($key)) { continue; } $phrased_type = isset($vbphrase["hooktype_{$hooks['type']}"]) ? $vbphrase["hooktype_{$hooks['type']}"] : $hooks['type']; $hooktype = $phrased_product . ' : ' . $phrased_type; if (!is_array($hooks['hook'])) { $hooks['hook'] = array($hooks['hook']); } foreach ($hooks['hook'] as $hook) { $hookid = trim(is_string($hook) ? $hook : $hook['value']);
/** * 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(); }
public static function loadProductXmlListParsed($type = '', $typekey = false) { $list = self::loadProductXmlList($type, $typekey); foreach ($list as $product => $file) { $xmlobj = new vB_XML_Parser(false, $file); $data = $xmlobj->parse(); $list[$product] = $data; } return $list; }
/** * 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; }
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'] . "' ) "); } }
public function get_svn_data($template_filenames, $minsvnversion = 1, $skip_revisions = array()) { $template_dir = $this->get_svn_template_source(); $cmd = 'svn log -rHEAD:' . $minsvnversion . ' --xml -v ' . $template_dir; $text = shell_exec($cmd); $xmlobj = new vB_XML_Parser($text); if (!($parsed_xml = $xmlobj->parse())) { $this->errors[] = sprintf("xml error '%s', on line '%d'", $xmlobj->error_string(), $xmlobj->error_line()); return false; } $logentries = $this->get_xml_list($parsed_xml['logentry']); $template_dir_basename = basename($template_dir); $data = array(); foreach ($logentries as $logentry) { if (in_array($logentry['revision'], $skip_revisions)) { continue; } $paths = $this->get_xml_list($logentry['paths']['path']); foreach ($paths as $path) { $is_mod = $path['action'] == 'M'; $is_rename = (($path['action'] == 'R' or $path['action'] == 'A') and $path['copyfrom-path']); if ($is_mod or $is_rename) { //make sure that the paths are the same one directory level up. This should cut down //dramatically on the potential for false matches since both paths would have to end in //templates/templatename.ext. This isn't perfect, but reduces the change of conflict //to a level where it realistically won't happen. We can't easily match the paths because //we don't really know how far up we should be checking. If there is a conflict the //only consequence is that we advance the change date in the xml unnecesarily. if (basename(dirname($path['value'])) == $template_dir_basename) { $path_file = basename($path['value']); if (!array_key_exists($path_file, $data) and in_array($path_file, $template_filenames)) { $data[$path_file] = array('lastupdated' => strtotime($logentry['date']), 'username' => $logentry['author']); } } } } } return $data; }
public function generateStyle($scheme, $type, $parentid, $title, $displayorder = 1, $userselect = false) { if (!vB::getUserContext()->hasAdminPermission('canadminstyles')) { throw new vB_Exception_Api('no_permission'); } define('NO_IMPORT_DOTS', true); $merge = $scheme['primary']; if (!empty($scheme['secondary'])) { $merge = array_merge($merge, $scheme['secondary']); } if (!empty($scheme['complement'])) { $merge = array_merge($merge, $scheme['complement']); } foreach ($merge as $val) { $hex[] = $val['hex']; } switch ($type) { case 'lps': // Color : Primary and Secondary $sample_file = "style_generator_sample_light.xml"; break; case 'lpt': // White : Similar to the current style $sample_file = "style_generator_sample_white.xml"; break; case 'gry': // Grey :: Primary 3 and Primary 4 only $sample_file = "style_generator_sample_gray.xml"; break; case 'drk': // Dark : Primary 3 and Primary 4 only // Dark : Primary 3 and Primary 4 only default: // Dark : Default to Dark $sample_file = "style_generator_sample_dark.xml"; break; } $xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/' . $sample_file); $styledata = $xmlobj->parse(); if ($title === '') { $title = 'Style ' . time(); } $xml = new vB_XML_Builder(); $xml->add_group('style', array('name' => $title, 'vbversion' => vB::getDatastore()->getOption('templateversion'), 'product' => 'vbulletin', 'type' => 'custom')); $xml->add_group('stylevars'); foreach ($styledata['stylevars']['stylevar'] as $stylevars) { // The XML Parser outputs 2 values for the value field when one is set as an attribute. // The work around for now is to specify the first value (the attribute). In reality // the parser shouldn't add a blank 'value' if it exists as an attribute. if (!empty($stylevars['colCat'])) { list($group, $nr) = explode('-', $stylevars['colCat']); $group = $group == 'sec' ? 'secondary' : 'primary'; $stylevars['value'] = '{"color":"#' . $scheme[$group][$nr]['hex'] . '"}'; } $thisValue = json_decode($stylevars['value'], true); if (strpos($stylevars['name'], '_border') !== false) { // @todo, make this inherit the border style & width from the default style? $thisValue['width'] = 1; $thisValue['units'] = 'px'; $thisValue['style'] = 'solid'; } $xml->add_tag('stylevar', '', array('name' => htmlspecialchars($stylevars['name']), 'value' => base64_encode(serialize($thisValue)))); } // Close stylevar group $xml->close_group(); // Close style group $xml->close_group(); $doc = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n\r\n"; $doc .= $xml->output(); $xml = null; $imported = $this->library->importStyleFromXML($doc, $title, $parentid, -1, true, $displayorder, $userselect, true); $this->buildAllStyles(); //xml_import_style($doc, -1, $parentid, $title, $anyversion, $displayorder, $userselect, null, null, true); return $imported; }
/** * Saves the session into the database by inserting it or updating an existing one. */ function save() { if (defined('SKIP_SESSIONCREATE')) { return; } $cleaned = $this->build_query_array(); // since the sessionhash can be blanked out, lets make sure we pull from "dbsessionhash" $cleaned['sessionhash'] = "'" . $this->registry->db->escape_string($this->vars['dbsessionhash']) . "'"; if ($this->created == true) { if ($this->registry->options['enablespiders']) { require_once DIR . '/includes/class_xml.php'; $xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/spiders_vbulletin.xml'); $spiderdata = $xmlobj->parse(); $spiders = ""; if (is_array($spiderdata['spider'])) { foreach ($spiderdata['spider'] as $spiderling) { $spiders .= ($spiders ? '|' : '') . preg_quote($spiderling['ident'], '#'); } } unset($spiderdata, $xmlobj); //isbot to distinguish between bots and guests in session table VBIV-5766 if (preg_match('#(' . $spiders . ')#si', $cleaned['useragent'])) { $cleaned['isbot'] = true; } } // end VBIV-5766 /*insert query*/ $this->registry->db->query_write("\n\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "session\n\t\t\t\t\t(" . implode(', ', array_keys($cleaned)) . ")\n\t\t\t\tVALUES\n\t\t\t\t\t(" . implode(', ', $cleaned) . ")\n\t\t\t"); } else { // update query unset($this->changes['sessionhash']); // the sessionhash is not updateable $update = array(); foreach ($cleaned as $key => $value) { if (!empty($this->changes["{$key}"])) { $update[] = "{$key} = {$value}"; } } if (sizeof($update) > 0) { // note that $cleaned['sessionhash'] has been escaped as necessary above! $this->registry->db->query_write("\n\t\t\t\t\tUPDATE " . TABLE_PREFIX . "session\n\t\t\t\t\tSET " . implode(', ', $update) . "\n\t\t\t\t\tWHERE sessionhash = {$cleaned['sessionhash']}\n\t\t\t\t"); } } $this->changes = array(); }
$xml = file_read($vbulletin->GPC['uploadedfile']['tmp_name']); } else { if (file_exists($vbulletin->GPC['serverfile'])) { $xml = file_read($vbulletin->GPC['serverfile']); } else { print_dots_stop(); print_stop_message('no_file_uploaded_and_no_local_file_found'); } } require_once DIR . '/includes/class_xml.php'; $xmlobj = new vB_XML_Parser($xml); if ($xmlobj->error_no == 1) { print_dots_stop(); print_stop_message('no_xml_and_no_path'); } if (!($arr = $xmlobj->parse())) { print_dots_stop(); print_stop_message('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line()); } print_dots_stop(); $items = array(); $errors = array(); if (is_array($arr)) { if (sizeof($arr['def'])) { if (!isset($arr['def'][0])) { $arr['def'] = array($arr['def']); } $results = $db->query_read_slave("SELECT providerid id, provider, tagoption, url FROM " . TABLE_PREFIX . "bbcode_video ORDER BY providerid ASC"); while ($result = $db->fetch_array($results)) { $existing["{$result['tagoption']}"] = $result; }
/** * 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(); }
/** * Builds the datastore for the hooks into the database. */ public static function build_datastore(&$dbobject) { $code = array(); $admincode = array(); $adminlocations = array(); require_once DIR . '/includes/class_xml.php'; $handle = opendir(DIR . '/includes/xml/'); while (($file = readdir($handle)) !== false) { if (!preg_match('#^hooks_(.*).xml$#i', $file, $matches)) { continue; } $xmlobj = new vB_XML_Parser(false, DIR . "/includes/xml/{$file}"); $xml = $xmlobj->parse(); if (!is_array($xml['hooktype'][0])) { $xml['hooktype'] = array($xml['hooktype']); } foreach ($xml['hooktype'] as $key => $hooktype) { if (!is_numeric($key)) { continue; } if (!is_array($hooktype['hook'])) { $hooktype['hook'] = array($hooktype['hook']); } foreach ($hooktype['hook'] as $hook) { if (is_array($hook) and !empty($hook['admin']) or !empty($hooktype['admin'])) { $adminlocations[is_string($hook) ? $hook : $hook['value']] = true; } } } } $plugins = $dbobject->query_read("\n\t\t\tSELECT plugin.*,\n\t\t\t\tIF(product.productid IS NULL, 0, 1) AS foundproduct,\n\t\t\t\tIF(plugin.product = 'vbulletin', 1, product.active) AS productactive\n\t\t\tFROM " . TABLE_PREFIX . "plugin AS plugin\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "product AS product ON(product.productid = plugin.product)\n\t\t\tWHERE plugin.active = 1\n\t\t\t\tAND plugin." . "phpcode <> ''\n\t\t\tORDER BY plugin.executionorder ASC\n\t\t"); while ($plugin = $dbobject->fetch_array($plugins)) { if ($plugin['foundproduct'] and !$plugin['productactive']) { continue; } else { if (!empty($adminlocations["{$plugin['hookname']}"])) { $admincode["{$plugin['hookname']}"] .= "{$plugin['phpcode']}\r\n"; } else { $code["{$plugin['hookname']}"] .= "{$plugin['phpcode']}\r\n"; } } } $dbobject->free_result($plugins); build_datastore('pluginlist', serialize($code), 1); build_datastore('pluginlistadmin', serialize($admincode), 1); return true; }
$nav_key = preg_replace('#[^a-z0-9]#i', '', $matches[1]); $navfiles["{$nav_key}"] = $file; } closedir($handle); } if (empty($navfiles['vbulletin'])) { if (is_readable(DIR . '/includes/xml/cpnav_vbulletin.xml')) { $navfiles['vbulletin'] = 'cpnav_vbulletin.xml'; } else { echo construct_phrase($vbphrase['could_not_open_x'], DIR . '/includes/xml/cpnav_vbulletin.xml'); exit; } } foreach ($navfiles as $nav_file => $file) { $xmlobj = new vB_XML_Parser(false, DIR . "/includes/xml/{$file}"); $xml =& $xmlobj->parse(); if ($xml['product'] and empty($vbulletin->products["{$xml['product']}"])) { // attached to a specific product and that product isn't enabled continue; } if (!is_array($xml['navgroup'][0])) { $xml['navgroup'] = array($xml['navgroup']); } foreach ($xml['navgroup'] as $navgroup) { if (!empty($navgroup['debug']) and $vbulletin->debug != 1) { continue; } // do we have access to this group if (empty($navgroup['permissions']) or can_administer($navgroup['permissions'])) { $group_displayorder = intval($navgroup['displayorder']); $group_key = fetch_nav_text($navgroup);
$count = 0; $userinfo = array(); $guests = array(); // get buddylist $buddy = array(); if (trim($vbulletin->userinfo['buddylist'])) { $buddylist = preg_split('/( )+/', trim($vbulletin->userinfo['buddylist']), -1, PREG_SPLIT_NO_EMPTY); foreach ($buddylist as $buddyuserid) { $buddy["{$buddyuserid}"] = 1; } } // Refresh cache if the XML has changed if ($vbulletin->options['enablespiders'] and $lastupdate = @filemtime(DIR . '/includes/xml/spiders_vbulletin.xml') and $lastupdate != $vbulletin->wol_spiders['lu']) { require_once DIR . '/includes/class_xml.php'; $xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/spiders_vbulletin.xml'); $spiderdata = $xmlobj->parse(); $spiders = array(); if (is_array($spiderdata['spider'])) { foreach ($spiderdata['spider'] as $spiderling) { $addresses = array(); $identlower = strtolower($spiderling['ident']); $spiders['agents']["{$identlower}"]['name'] = $spiderling['name']; $spiders['agents']["{$identlower}"]['type'] = $spiderling['type']; if (is_array($spiderling['addresses']['address']) and !empty($spiderling['addresses']['address'])) { if (empty($spiderling['addresses']['address'][0])) { $addresses[0] = $spiderling['addresses']['address']; } else { $addresses = $spiderling['addresses']['address']; } foreach ($addresses as $key => $address) { if (in_array($address['type'], array('range', 'single', 'CIDR'))) {
/** * Perform verification of the payment, this is called from the payment gateway * * @return bool Whether the payment is valid */ function verify_payment() { $this->registry->input->clean_array_gpc('p', array('operation_xml' => TYPE_STR, 'signature' => TYPE_STR)); if (!strlen($this->registry->GPC['operation_xml']) or !strlen($this->registry->GPC['signature'])) { return false; } $operation_xml = base64_decode($this->registry->GPC['operation_xml']); if ($operation_xml === false) { return false; } // check signature $signature = base64_encode(sha1($this->settings['merchant_pass'] . $operation_xml . $this->settings['merchant_pass'], 1)); if ($signature != $this->registry->GPC['signature']) { return false; } // signature passed // parse xml require_once DIR . '/includes/class_xml.php'; $xmlobj = new vB_XML_Parser($operation_xml); $order = $xmlobj->parse('UTF-8'); if ($order === false) { return false; } $this->transaction_id = $order['transaction_id']; if ($this->transaction_id > 0) { $this->paymentinfo = $this->registry->db->query_first("\n SELECT paymentinfo.*, user.username\n FROM " . TABLE_PREFIX . "paymentinfo AS paymentinfo\n INNER JOIN " . TABLE_PREFIX . "user AS user USING (userid)\n WHERE hash = '" . $this->registry->db->escape_string($order['order_id']) . "'\n "); // lets check the values if (!empty($this->paymentinfo)) { $this->paymentinfo['currency'] = strtolower($order['currency']); $this->paymentinfo['amount'] = floatval($order['amount']); $sub = $this->registry->db->query_first("\n SELECT *\n FROM " . TABLE_PREFIX . "subscription\n WHERE subscriptionid = " . $this->paymentinfo['subscriptionid']); $cost = unserialize($sub['cost']); // Check if its a payment or if its a reversal if ($order['status'] == 'success') { if ($this->paymentinfo['amount'] == floatval($cost["{$this->paymentinfo[subscriptionsubid]}"]['cost'][strtolower($order['currency'])])) { $this->type = 1; } else { $this->error_code = 'invalid_payment_amount'; } } else { if ($order['status'] == 'wait_secure') { $this->error_code = 'payment_verification_is_in_progress'; } else { if ($order['status'] == 'failure') { $this->type = 2; $this->error_code = 'payment_failed'; } else { $this->error_code = 'unhandled_payment_status_or_type'; } } } } else { $this->error_code = 'invalid_subscriptionid'; } $status_code = '200 OK'; // LiqPay likes to get told its message has been received (?) if (SAPI_NAME == 'cgi' or SAPI_NAME == 'cgi-fcgi') { header('Status: ' . $status_code); } else { header('HTTP/1.1 ' . $status_code); } return $this->type > 0; } else { $this->error_code = 'authentication_failure'; $this->error = 'Invalid Request'; } $status_code = '503 Service Unavailable'; // LiqPay likes to get told its message has been received (?) if (SAPI_NAME == 'cgi' or SAPI_NAME == 'cgi-fcgi') { header('Status: ' . $status_code); } else { header('HTTP/1.1 ' . $status_code); } return false; }
/** * Restores a settings backup from an XML file * * Call as follows: * $path = './path/to/install/vbulletin-settings.xml'; * xml_import_settings($xml); * * @param mixed Either XML string or boolean false to use $path global variable * @param bool Ignore blacklisted settings */ function xml_restore_settings($xml = false, $blacklist = true) { global $vbulletin, $vbphrase; $newsettings = array(); print_dots_start('<b>' . $vbphrase['importing_settings'] . "</b>, {$vbphrase['please_wait']}", ':', 'dspan'); require_once DIR . '/includes/class_xml.php'; $xmlobj = new vB_XML_Parser($xml, $GLOBALS['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-settings.xml', $GLOBALS['path']); } } if (!($newsettings = $xmlobj->parse())) { print_dots_stop(); print_stop_message('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line()); } if (!$newsettings['setting']) { print_dots_stop(); print_stop_message('invalid_file_specified'); } $product = empty($newsettings['product']) ? 'vbulletin' : $newsettings['product']; foreach ($newsettings['setting'] as $setting) { // Loop to update all the settings $vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "setting\n\t\t\tSET value='" . $vbulletin->db->escape_string($setting['value']) . "'\n\t\t\tWHERE varname ='" . $vbulletin->db->escape_string($setting['varname']) . "'\n\t\t\t\tAND product ='" . $vbulletin->db->escape_string($product) . "'\n\t\t\t\t" . ($blacklist ? "AND blacklist = 0" : "") . "\n\t\t"); } unset($newsettings); // rebuild the $vbulletin->options array build_options(); // stop the 'dots' counter feedback print_dots_stop(); }
} exec_queries(); } // ############################################################################# // Settings #2 if ($vbulletin->GPC['step'] == 27) { $vb2settings = array('addheaders', 'address', 'addtemplatename', 'allowbbcode', 'allowbbimagecode', 'allowchangestyles', 'allowduplicates', 'allowdynimg', 'allowhtml', 'allowimgsizefailure', 'allowkeepbannedemail', 'allowmultiregs', 'allowregistration', 'allowsignatures', 'allowsmilies', 'allowvbcodebuttons', 'allowwildcards', 'attachextensions', 'avatarallowupload', 'avatarallowwebsite', 'avatarcustomposts', 'avatarenabled', 'avatarmaxdimension', 'avatarmaxsize', 'banemail', 'banip', 'bbactive', 'bbclosedreason', 'bbtitle', 'bburl', 'calallowbbcode', 'calallowhtml', 'calallowsmilies', 'calbbimagecode', 'calbirthday', 'calendarenabled', 'calformat1', 'calformat2', 'calshowbirthdays', 'calStart', 'caltitlelength', 'censorchar', 'censorwords', 'checknewpm', 'companyname', 'contactuslink', 'cookiedomain', 'cookiepath', 'cookietimeout', 'copyrighttext', 'ctAdmin', 'ctCensorMod', 'ctCensorWords', 'ctDays', 'ctEitherOr', 'ctEnable', 'ctMaxChars', 'ctPosts', 'dateformat', 'displayemails', 'displayloggedin', 'editthreadtitlelimit', 'edittimelimit', 'enableaccess', 'enablebanning', 'enablecensor', 'enableemail', 'enablefloodcheck', 'enablememberlist', 'enablepms', 'enablesearches', 'faxnumber', 'floodchecktime', 'forumdisplaydepth', 'forumhomedepth', 'gziplevel', 'gzipoutput', 'hideprivateforums', 'highlightadmin', 'hometitle', 'homeurl', 'hotnumberposts', 'hotnumberviews', 'ignoremods', 'illegalusernames', 'inboxname', 'linktopages', 'loadlimit', 'logip', 'maxattachheight', 'maxattachsize', 'maxattachwidth', 'maximages', 'maxmultipage', 'maxpolloptions', 'maxposts', 'maxsearchlength', 'maxthreads', 'maxuserlength', 'memberAllGood', 'memberlistperpage', 'minsearchlength', 'minuserlength', 'moderatenewmembers', 'movedthreadprefix', 'newuseremail', 'nocacheheaders', 'noeditedbytime', 'numavatarshigh', 'numavatarswide', 'offtext', 'ontext', 'pagenavpages', 'pmcancelkill', 'pmcancelledword', 'pmfloodtime', 'pmmaxchars', 'pmquota', 'pollthreadprefix', 'postmaxchars', 'postorder', 'privacyurl', 'privallowbbcode', 'privallowbbimagecode', 'privallowhtml', 'privallowicons', 'privallowsmilies', 'registereddateformat', 'requireuniqueemail', 'safeupload', 'searchfloodtime', 'searchperpage', 'secureemail', 'sentitemsname', 'sessionlimit', 'showbirthdays', 'showdeficon', 'showdots', 'showeditedby', 'showeditedbyadmin', 'showforumdescription', 'showforumusers', 'showlocks', 'showonline', 'showvotes', 'smcolumns', 'smtotal', 'spellchecklang', 'stickythreadprefix', 'stopshouting', 'templateversion', 'timeformat', 'timeoffset', 'tmppath', 'updatelastpost', 'usecoppa', 'useforumjump', 'usehotthreads', 'usememberlistadvsearch', 'usereferrer', 'usermaxposts', 'verifyemail', 'viewattachedimages', 'votechange', 'webmasteremail', 'WOLenable', 'WOLguests', 'WOLrefresh', 'WOLresolve', 'wordwrap', 'usefileavatar'); // ############################################################################### // MAKE A LIST OF THE SETTINGS THAT WILL BE INCOMING FROM THE XML SETTINGS FILE AND // REMOVE ANY SETTINGS THAT WILL CAUSE A DUPLICATE KEY MYSQL ERROR ON IMPORT // (THEIR VALUES WILL BE RETAINED IN THE DATASTORE FOR NOW, SO THIS IS NO PROBLEM) // ############################################################################### require_once DIR . '/includes/class_xml.php'; require_once DIR . '/includes/functions_misc.php'; $xmlobj = new vB_XML_Parser(false, DIR . '/install/vbulletin-settings.xml'); $arr = $xmlobj->parse(); foreach ($arr['settinggroup'] as $group) { foreach ($group['setting'] as $setting) { $vb3options[] = $setting['varname']; } } // now query the existing options to find out which should be // zapped and which need to be translated into the new system... $settings = $db->query_read("\n\t\tSELECT setting.*\n\t\tFROM setting LEFT JOIN settinggroup USING(settinggroupid)\n\t\tORDER BY settinggroup.displayorder, setting.displayorder\n\t"); $phrases = array(); while ($setting = $db->fetch_array($settings)) { $vb2options["{$setting['varname']}"] = $setting['value']; if (!in_array($setting['varname'], $vb2settings) and !in_array($setting['varname'], $vb3options)) { $nonvolatilevars[] = $setting['varname']; $settinggroupid = $setting['settinggroupid']; $phrases[] = "(" . PHRASETYPEID_SETTING . ", 0, '" . $db->escape_string("setting_{$setting['varname']}_title") . "', '" . $db->escape_string($setting['title']) . "')";
function xml_import_help_topics($xml = false) { global $vbulletin, $vbphrase; print_dots_start('<b>' . $vbphrase['importing_admin_help'] . "</b>, {$vbphrase['please_wait']}", ':', 'dspan'); require_once DIR . '/includes/class_xml.php'; $xmlobj = new vB_XML_Parser($xml, $GLOBALS['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-adminhelp.xml', $GLOBALS['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['helpscript']) { print_dots_stop(); print_stop_message('invalid_file_specified'); } $product = empty($arr['product']) ? 'vbulletin' : $arr['product']; $has_phrases = !empty($arr['hasphrases']); $arr = $arr['helpscript']; if ($product == 'vbulletin') { $product_sql = "product IN ('vbulletin', '')"; } else { $product_sql = "product = '" . $vbulletin->db->escape_string($product) . "'"; } $vbulletin->db->query_write("\n\t\tDELETE FROM " . TABLE_PREFIX . "adminhelp\n\t\tWHERE {$product_sql}\n\t\t\t AND volatile = 1\n\t"); if ($has_phrases) { $vbulletin->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "phrase\n\t\t\tWHERE {$product_sql}\n\t\t\t\tAND fieldname = 'cphelptext'\n\t\t\t\tAND languageid = -1\n\t\t"); } // Deal with single entry if (!is_array($arr[0])) { $arr = array($arr); } foreach ($arr as $helpscript) { $help_sql = array(); $phrase_sql = array(); $help_sql_len = 0; $phrase_sql_len = 0; // Deal with single entry if (!is_array($helpscript['helptopic'][0])) { $helpscript['helptopic'] = array($helpscript['helptopic']); } foreach ($helpscript['helptopic'] as $topic) { $help_sql[] = "\n\t\t\t\t('" . $vbulletin->db->escape_string($helpscript['name']) . "',\n\t\t\t\t'" . $vbulletin->db->escape_string($topic['act']) . "',\n\t\t\t\t'" . $vbulletin->db->escape_string($topic['opt']) . "',\n\t\t\t\t" . intval($topic['disp']) . ",\n\t\t\t\t1,\n\t\t\t\t'" . $vbulletin->db->escape_string($product) . "')\n\t\t\t"; $help_sql_len += strlen(end($help_sql)); if ($has_phrases) { $phrase_name = fetch_help_phrase_short_name(array('script' => $helpscript['name'], 'action' => $topic['act'], 'optionname' => $topic['opt'])); if (isset($topic['text']['value'])) { $phrase_sql[] = "\n\t\t\t\t\t\t(-1,\n\t\t\t\t\t\t'cphelptext',\n\t\t\t\t\t\t'{$phrase_name}_text',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['text']['value']) . "',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($product) . "',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['text']['username']) . "',\n\t\t\t\t\t\t" . intval($topic['text']['date']) . ",\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['text']['version']) . "')\n\t\t\t\t\t"; $phrase_sql_len += strlen(end($phrase_sql)); } if (isset($topic['title']['value'])) { $phrase_sql[] = "\n\t\t\t\t\t\t(-1,\n\t\t\t\t\t\t'cphelptext',\n\t\t\t\t\t\t'{$phrase_name}_title',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['title']['value']) . "',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($product) . "',\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['title']['username']) . "',\n\t\t\t\t\t\t" . intval($topic['title']['date']) . ",\n\t\t\t\t\t\t'" . $vbulletin->db->escape_string($topic['title']['version']) . "')\n\t\t\t\t\t"; $phrase_sql_len += strlen(end($phrase_sql)); } } if ($phrase_sql_len > 102400) { // insert max of 100k of phrases at a time /*insert query*/ $vbulletin->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(",\n", $phrase_sql)); $phrase_sql = array(); $phrase_sql_len = 0; } if ($help_sql_len > 102400) { // insert max of 100k of phrases at a time /*insert query*/ $vbulletin->db->query_write("\n\t\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "adminhelp\n\t\t\t\t\t\t(script, action, optionname, displayorder, volatile, product)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t" . implode(",\n\t", $help_sql)); $help_sql = array(); $help_sql_len = 0; } } if ($help_sql) { /*insert query*/ $vbulletin->db->query_write("\n\t\t\t\tREPLACE INTO " . TABLE_PREFIX . "adminhelp\n\t\t\t\t\t(script, action, optionname, displayorder, volatile, product)\n\t\t\t\tVALUES\n\t\t\t\t\t" . implode(",\n\t", $help_sql)); } if ($phrase_sql) { /*insert query*/ $vbulletin->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(",\n", $phrase_sql)); } } // stop the 'dots' counter feedback print_dots_stop(); require_once DIR . '/includes/adminfunctions_language.php'; build_language(); }
$xml = file_read($vbulletin->GPC['stylefile']['tmp_name']); $startat = null; $perpage = null; } else { $serverfile = vB5_Route_Admincp::resolvePath(urldecode($vbulletin->GPC['serverfile'])); if (file_exists($serverfile)) { $xml = file_read($serverfile); $startat = $vbulletin->GPC['startat']; $perpage = 10; } else { print_stop_message2('no_file_uploaded_and_no_local_file_found_gerror'); } } // themes check. $xmlobj = new vB_XML_Parser($xml); $parsedXML = $xmlobj->parse(); if (!empty($parsedXML['guid'])) { // it's a theme! // if overwrite isn't set, let's check if the theme already exists, and redirect to a overwrite confirmation page. if (empty($vbulletin->GPC['overwrite'])) { $existingTheme = vB::getDbAssertor()->getRow('style', array('guid' => $parsedXML['guid'])); if (!empty($existingTheme)) { // Redirect to a page to request overwrite. $args = array(); $args['do'] = 'confirmoverwrite'; unset($fields['do']); $args['overwritestyleid'] = $existingTheme['styleid']; unset($fields['overwritestyleid']); foreach ($fields as $name => $type) { // This was copy pasted from below if ($type == vB_Cleaner::TYPE_STR) {