本文整理汇总了PHP中vB_XML_Parser类的典型用法代码示例。如果您正苦于以下问题:PHP vB_XML_Parser类的具体用法?PHP vB_XML_Parser怎么用?PHP vB_XML_Parser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vB_XML_Parser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_language
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;
}
示例2: fetch_podcast_categoryarray
/**
* 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;
}
示例3: build_bbcode_video
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 = '" . $vbulletin->db->escape_string($vbulletin->userinfo['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 = '" . $vbulletin->db->escape_string($vbulletin->userinfo['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");
}
}
示例4: build_bbcode_video
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;
}
示例5: getXmlHooks
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;
}
示例6: __construct
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;
}
}
}
}
}
示例7: 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;
}
示例8: 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 = ''") . ")"
);
//.........这里部分代码省略.........
示例9: print_dots_start
if ($do == "importoptions") {
$vbulletin->input->clean_gpc('f', 'uploadedfile', TYPE_FILE);
$vbulletin->input->clean_gpc('p', 'serverfile', TYPE_FILE);
print_dots_start($vbphrase['ame_importing']);
if (file_exists($vbulletin->GPC['uploadedfile']['tmp_name'])) {
$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']);
示例10: 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;
}
示例11: fetch
/**
* 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;
}
示例12: fetch_product_list
// #############################################################################
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) {
示例13: generateStyle
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;
}
示例14: exec_queries
$explain[] = $upgrade_phrases['upgrade_300b3.php']['insert_phrases_nonstandard_groups'];
}
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'];
示例15: 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
//.........这里部分代码省略.........