本文整理汇总了PHP中vB_XML_Parser::error_string方法的典型用法代码示例。如果您正苦于以下问题:PHP vB_XML_Parser::error_string方法的具体用法?PHP vB_XML_Parser::error_string怎么用?PHP vB_XML_Parser::error_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB_XML_Parser
的用法示例。
在下文中一共展示了vB_XML_Parser::error_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* 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;
}
示例2: array
if (file_exists($vbulletin->GPC['serverfile'])) {
$xml = file_read($vbulletin->GPC['serverfile']);
} else {
print_stop_message('no_file_uploaded_and_no_local_file_found');
}
}
print_dots_start('<b>' . $vbphrase['importing_plugins'] . "</b>, {$vbphrase['please_wait']}", ':', 'dspan');
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());
}
if (!$arr['plugin']) {
print_dots_stop();
if (!empty($arr['productid'])) {
print_stop_message('this_file_appears_to_be_a_product');
} else {
print_stop_message('invalid_file_specified');
}
}
if (!is_array($arr['plugin'][0])) {
$arr['plugin'] = array($arr['plugin']);
}
$maxid = $db->query_first("SELECT MAX(pluginid) AS max FROM " . TABLE_PREFIX . "plugin");
foreach ($arr['plugin'] as $plugin) {
unset($plugin['devkey']);
示例3: xml_import_style
/**
* 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
//.........这里部分代码省略.........
示例4: xml_import_style
/**
* 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 = ''") . ")"
);
//.........这里部分代码省略.........
示例5: get_svn_data
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;
}
示例6: parseFile
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;
}
示例7: xml_restore_settings
/**
* 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();
}
示例8: unset
/**
* Step #6 - Import Navigation XML
*
*/
function step_6()
{
require_once DIR . '/includes/class_xml.php';
require_once DIR . '/includes/adminfunctions_plugin.php';
$this->show_message($this->phrase['final']['import_navigation']);
if (!($xml = file_read(DIR . '/install/vbulletin-navigation.xml'))) {
$this->add_error(sprintf($this->phrase['vbphrase']['file_not_found'], 'vbulletin-navigation.xml'), self::PHP_TRIGGER_ERROR, true);
return;
}
$xmlobj = new vB_XML_Parser($xml);
if (!($navdata = $xmlobj->parse())) {
$this->add_error(sprintf($this->phrase['vbphrase']['xml_error_x_at_line_y'], $xmlobj->error_string(), $xmlobj->error_line()), self::PHP_TRIGGER_ERROR, true);
return;
}
unset($xmlobj);
$this->show_message(sprintf($this->phrase['vbphrase']['importing_file'], 'vbulletin-navigation.xml'));
$info = array('process' => VB_AREA, 'username' => 'System-' . VB_AREA, 'version' => $navdata['version'], 'productid' => substr(preg_replace('#[^a-z0-9_]#', '', strtolower($navdata['productid'])), 0, 25));
import_navigation($navdata, $info);
$this->show_message($this->phrase['core']['import_done']);
}
示例9: xml_import_language
/**
* 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) {
//.........这里部分代码省略.........
示例10: install_product
/**
* 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);
}
//.........这里部分代码省略.........
示例11: xml_import_grid
/**
* 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
//.........这里部分代码省略.........
示例12: xml_restore_settings
/**
* 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)
{
$newsettings = array();
$vbphrase = vB_Api::instanceInternal('phrase')->fetch(array('please_wait', 'importing_settings'));
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_message2('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_message2('invalid_file_specified');
}
$product = empty($newsettings['product']) ? 'vbulletin' : $newsettings['product'];
foreach ($newsettings['setting'] as $setting) {
// Loop to update all the settings
$conditions = array(array('field' => 'varname', 'value' => $setting['varname'], 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'product', 'value' => $product, 'operator' => vB_dB_Query::OPERATOR_EQ));
if ($blacklist) {
$conditions[] = array('field' => 'blacklist', 'value' => 0, 'operator' => vB_dB_Query::OPERATOR_EQ);
}
vB::getDbAssertor()->assertQuery('setting', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, 'value' => $setting['value'], vB_dB_Query::CONDITIONS_KEY => $conditions));
}
unset($newsettings);
// rebuild the options array
vB::getDatastore()->build_options();
// stop the 'dots' counter feedback
print_dots_stop();
}
示例13: install_product
/**
* Installs a product from the xml text
*
* This function depends on the vb class loader, which requires that the
* framework init is called.
*
* @return bool True if the product requires a template merge, false otherwise
*/
function install_product($xml, $allow_overwrite = false, $verbose = true)
{
global $vbphrase;
global $vbulletin;
$assertor = vB::getDbAssertor();
require_once DIR . '/includes/class_bitfield_builder.php';
require_once DIR . '/includes/class_xml.php';
//share some code with the main xml style import
require_once DIR . '/includes/adminfunctions_template.php';
if ($verbose) {
print_dots_start('<b>' . $vbphrase['importing_product'] . "</b>, {$vbphrase['please_wait']}", ':', 'dspan');
}
$xmlobj = new vB_XML_Parser($xml);
if ($xmlobj->error_no() == 1) {
if ($verbose) {
print_dots_stop();
}
throw new vB_Exception_AdminStopMessage('no_xml_and_no_path');
}
if (!($arr = $xmlobj->parse())) {
if ($verbose) {
print_dots_stop();
}
throw new vB_Exception_AdminStopMessage(array('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line()));
}
// ############## general product information
$info = array('productid' => substr(preg_replace('#[^a-z0-9_]#', '', strtolower($arr['productid'])), 0, 25), 'title' => $arr['title'], 'description' => $arr['description'], 'version' => $arr['version'], 'active' => $arr['active'], 'url' => $arr['url'], 'versioncheckurl' => $arr['versioncheckurl']);
if (!$info['productid']) {
if ($verbose) {
print_dots_stop();
}
throw new vB_Exception_AdminStopMessage('invalid_file_specified');
}
if (strtolower($info['productid']) == 'vbulletin') {
if ($verbose) {
print_dots_stop();
}
throw new vB_Exception_AdminStopMessage(array('product_x_installed_no_overwrite', 'vBulletin'));
}
// check for bitfield conflicts on install
$bitfields = vB_Bitfield_Builder::return_data();
if (!$bitfields) {
$bfobj =& vB_Bitfield_Builder::init();
if ($bfobj->errors) {
if ($verbose) {
print_dots_stop();
}
throw new vB_Exception_AdminStopMessage(array('bitfield_conflicts_x', '<li>' . implode('</li><li>', $bfobj->errors) . '</li>'));
}
}
// get system version info
$system_versions = array('php' => PHP_VERSION, 'vbulletin' => $vbulletin->options['templateversion'], 'products' => fetch_product_list(true));
$mysql_version = $assertor->getRow('mysqlVersion');
$system_versions['mysql'] = $mysql_version['version'];
// ############## import dependencies
if (isset($arr['dependencies']['dependency']) and is_array($arr['dependencies']['dependency'])) {
$dependencies =& $arr['dependencies']['dependency'];
if (!isset($dependencies[0])) {
$dependencies = array($dependencies);
}
$dependency_errors = array();
$ignore_dependency_errors = array();
// let's check the dependencies
foreach ($dependencies as $dependency) {
// if we get an error, we haven't met this dependency
// if we go through without a problem, we have automatically met
// all dependencies for this "class" (mysql, php, vb, a specific product, etc)
$this_dependency_met = true;
// build a phrase for the version compats -- will look like (minver / maxver)
if ($dependency['minversion']) {
$compatible_phrase = construct_phrase($vbphrase['compatible_starting_with_x'], htmlspecialchars_uni($dependency['minversion']));
} else {
$compatible_phrase = '';
}
if ($dependency['maxversion']) {
$incompatible_phrase = construct_phrase($vbphrase['incompatible_with_x_and_greater'], htmlspecialchars_uni($dependency['maxversion']));
} else {
$incompatible_phrase = '';
}
if ($compatible_phrase or $incompatible_phrase) {
$required_version_info = "({$compatible_phrase}";
if ($compatible_phrase and $incompatible_phrase) {
$required_version_info .= ' / ';
}
$required_version_info .= "{$incompatible_phrase})";
}
// grab the appropriate installed version string
if ($dependency['dependencytype'] == 'product') {
// group dependencies into types -- individual products get their own group
$dependency_type_key = "product-{$dependency['parentproductid']}";
// undocumented feature -- you can put a producttitle attribute in a dependency so the id isn't displayed
$parent_product_title = !empty($dependency['producttitle']) ? $dependency['producttitle'] : $dependency['parentproductid'];
//.........这里部分代码省略.........
示例14: xml_import_style
/**
* 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)
* @param int|null
* @param int 0 = normal import, 1 = style generator
* @param string Import Filename
*
* @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, $importtype = 0, $filename = 'vbulletin-style.xml')
{
// $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', $filename, $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());
}
if (!$styleid) {
if ($parentid == -1 or $parentid == -2) {
$styleid = $parentid;
} else {
$style = $vbulletin->db->query_first("\n\t\t\t\tSELECT IF(type = 'standard', -1, -2) AS mastertype\n\t\t\t\tFROM " . TABLE_PREFIX . "style\n\t\t\t\tWHERE styleid = {$parentid}\n\t\t\t");
$styleid = $style['mastertype'];
}
}
$version = $parsed_xml['vbversion'];
$master = $parsed_xml['type'] == 'master' ? true : false;
$mobilemaster = $parsed_xml['type'] == 'mobilemaster' ? true : false;
$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 and !$mobilemaster) {
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 or $mobilemaster) {
$styleid = $master ? -1 : -2;
$specialstyleid = $master ? -10 : -20;
$import_data = @unserialize(fetch_adminutil_text("master_style_import_{$product}_{$specialstyleid}"));
if (!empty($import_data) and TIMENOW - $import_data['last_import'] <= 30) {
print_dots_stop();
if ($master) {
print_stop_message('must_wait_x_seconds_master_style_import', vb_number_format($import_data['last_import'] + 30 - TIMENOW));
} else {
print_stop_message('must_wait_x_seconds_mobile_master_style_import', vb_number_format($import_data['last_import'] + 30 - TIMENOW));
}
}
$stylename = $master ? $vbphrase['master_style'] : $vbphrase['mobile_master_style'];
// overwrite master style
if (VB_AREA != 'Upgrade' and VB_AREA != 'Install') {
echo "<h3>{$stylename}</h3>\n<p>{$vbphrase['please_wait']}</p>";
vbflush();
}
$vbulletin->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "template\n\t\t\t\tWHERE styleid = {$specialstyleid} AND (product = '" . $vbulletin->db->escape_string($product) . "'" . ($product == 'vbulletin' ? " OR product = ''" : "") . ")");
$vbulletin->db->query_write("\n\t\t\t\tUPDATE " . TABLE_PREFIX . "template\n\t\t\t\tSET styleid = {$specialstyleid} WHERE styleid = {$styleid} AND (product = '" . $vbulletin->db->escape_string($product) . "'" . ($product == 'vbulletin' ? " OR product = ''" : "") . ")");
} else {
if ($styleid == -1 or $styleid == -2) {
$type = $styleid == -1 ? 'standard' : 'mobile';
// creating a new style
$test = $vbulletin->db->query_first("\n\t\t\t\t\tSELECT styleid FROM " . TABLE_PREFIX . "style\n\t\t\t\t\tWHERE\n\t\t\t\t\t\ttitle = '" . $vbulletin->db->escape_string($title) . "'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\ttype = '{$type}'\n\t\t\t\t");
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("\n\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "style\n\t\t\t\t\t\t(title, parentid, displayorder, userselect, type)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . $vbulletin->db->escape_string($title) . "', {$parentid}, {$displayorder}, " . ($userselect ? 1 : 0) . ", '{$type}')\n\t\t\t\t\t");
$styleid = $vbulletin->db->insert_id($styleresult);
}
//.........这里部分代码省略.........
示例15: get_svn_data
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;
}