当前位置: 首页>>代码示例>>PHP>>正文


PHP vB_XML_Parser::error_no方法代码示例

本文整理汇总了PHP中vB_XML_Parser::error_no方法的典型用法代码示例。如果您正苦于以下问题:PHP vB_XML_Parser::error_no方法的具体用法?PHP vB_XML_Parser::error_no怎么用?PHP vB_XML_Parser::error_no使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vB_XML_Parser的用法示例。


在下文中一共展示了vB_XML_Parser::error_no方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:48,代码来源:class_upgrade_product.php

示例2: parse_xml_from_file

 /**
  * Takes a the file name of an xml file, and parses it into an xml object
  *
  * @param	string - file name (including path) of the xml file
  *
  * @return	array - parsed xml object of the file
  */
 protected function parse_xml_from_file($filename)
 {
     $xmlobj = new vB_XML_Parser(false, $filename);
     if ($xmlobj->error_no() == 1 or $xmlobj->error_no() == 2) {
         $this->errors[] = "Please ensure that the file {$filename} exists";
         return false;
     }
     if (!($parsed_xml = $xmlobj->parse())) {
         $this->errors[] = 'xml error ' . $xmlobj->error_string() . ', on line ' . $xmlobj->error_line();
         return false;
     }
     return $parsed_xml;
 }
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:20,代码来源:class_filesystemxml_template.php

示例3: 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;
 }
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:11,代码来源:import.php

示例4: 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
*
* @return	Returns false if the custom language was not imported (used in final_upgrade) OR
*			returns the languageid if, if the custom language import was successful (also used in final_upgrade)
*/
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_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-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_message2('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'];
    }
    $officialcustom = false;
    //Check custom language revision. See also VBV-9215.
    if (!$master and $arr['product'] == 'vbulletin' and !empty($arr['revision']) and !empty($arr['vblangcode'])) {
        $test = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "language WHERE vblangcode = '" . $vbulletin->db->escape_string($arr['vblangcode']) . "'");
        if ($test['languageid']) {
            if (intval($test['revision']) >= intval($arr['revision'])) {
                // Same or newer language revision has been installed
                // We shouldn't print_stop_message() as the upgrader may continue processing other custom languages
                return false;
            }
            $languageid = $test['languageid'];
        }
        $langinfo['revision'] = intval($arr['revision']);
        $langinfo['vblangcode'] = trim($arr['vblangcode']);
        $officialcustom = true;
    } else {
        $langinfo['revision'] = 0;
        $langinfo['vblangcode'] = '';
    }
    $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)) {
            $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']);
    $langinfo['revision'] = intval($langinfo['revision']);
    if ($version != $vbulletin->options['templateversion'] and !$master) {
        if (strtok($version, '.') != strtok($vbulletin->options['templateversion'], '.')) {
            print_dots_stop();
            print_stop_message('upload_file_created_with_different_major_version', $vbulletin->options['templateversion'], $version);
        }
        if (!$anyversion) {
            print_dots_stop();
            print_stop_message('upload_file_created_with_different_version', $vbulletin->options['templateversion'], $version);
        }
    }
//.........这里部分代码省略.........
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:101,代码来源:adminfunctions_language.php

示例5: 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();
}
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:49,代码来源:adminfunctions_options.php

示例6: 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'];
//.........这里部分代码省略.........
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:101,代码来源:adminfunctions_product.php

示例7: getCanCreate

 /**
  * Lists the content types the current user can create at a node.
  *
  * @param	int		the nodeid to be checked
  *
  * @return	mixed	array of contenttypes
  */
 public function getCanCreate($nodeid)
 {
     /** The create permissions are quite complex. The things that need to be considered are:
      *
      * - createpermissions from the permissions table.
      * - canpostnew, canreply, and cancomment.
      * - datastore postcommentthreads, which disables only commments- not starters or reply
      * - the commentperms, which has a different meaning in a blog or social group compared to a regular forum
      * - for attach and photo types, they look like a comment or reply if not on a thread, but aren't disabled by the comment setting above.
      * - for gallery, attach, and photo types, the global canpostattachment forum permission.
      * - the channel, which may be closed.
      * - forums in which the user can only reply to their own content.
      * - the 'canadminforums' admin permission, which allows creating channels
      **/
     static $bf_ugp = array();
     //if we've already gotten for this node, we're done.
     if (isset($this->canCreateTypes[$nodeid])) {
         return $this->canCreateTypes[$nodeid];
     }
     //make sure we have the bitfield array. We can't just access the datastore because we need to
     // have permissions before the datastore is available, especially during
     // install.
     if (empty($bf_ugp)) {
         $bf_ugp = vB::getDatastore()->getValue('bf_ugp_createpermissions');
         if (empty($bf_ugp)) {
             //This can happen during upgrade
             $xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/bitfield_vbulletin.xml');
             if ($xmlobj->error_no() == 1 or $xmlobj->error_no() == 2) {
                 throw new Exception("You are missing the " . DIR . "/includes/xml/bitfield_vbulletin.xml file. Please replace it");
             }
             $bitfields = $xmlobj->parse();
             foreach ($bitfields['bitfielddefs']['group'] as $group) {
                 if ($group['name'] == 'ugp') {
                     foreach ($group['group'] as $ugp) {
                         if ($ugp['name'] == 'createpermissions') {
                             foreach ($ugp['bitfield'] as $createPerm) {
                                 $bf_ugp[$createPerm['name']] = $createPerm['value'];
                             }
                             break;
                         }
                     }
                 }
             }
         }
     }
     $createPerms = array();
     $nodeLib = vB_Library::instance('node');
     // get the node record
     $node = $nodeLib->getNode($nodeid);
     //See if comments are enabled.
     $canalways = $this->getChannelPermission('forumpermissions2', 'canalwayspostnew', $nodeid);
     if ($canalways) {
         $commentsEnabled = true;
     } else {
         if (!$node['showpublished']) {
             //If the user doesn't have canalwayspost and the node isn't published, don't allow posting.
             return false;
         }
         $commentsEnabled = (bool) vB::getDatastore()->getOption('postcommentthreads');
     }
     //if comments have been globally disabled and the node is not a starter or channel, we can't post
     if (!$commentsEnabled and $node['starter'] > 0 and $node['starter'] != $node['nodeid']) {
         //We'll check later and see if the user can post an attachment or photo.
         $attachOnly = true;
     } else {
         $attachOnly = false;
     }
     // @TODO: This is wrong, see VBV-6725
     //If this user is superadmin, just grant them everything except maybe the image types.
     if ($this->userIsSuperAdmin) {
         foreach ($bf_ugp as $type => $bitfield) {
             if ($attachOnly and $node['userid'] != $this->userid and ($type == 'vbforum_attach' or $type != 'vbforum_photo')) {
                 $createPerms[$key] = 0;
             } else {
                 $createPerms[$type] = 1;
             }
         }
         return $createPerms;
     }
     $types = vB_Types::instance();
     $canAttach = $this->hasPermission('forumpermissions', 'canpostattachment');
     $channelType = $types->getContentTypeId('vBForum_Channel');
     //This user isn't superadmin and we don't already have this, so we need to calculate it
     foreach ($bf_ugp as $type => $bitfield) {
         $createPerms[$type] = 0;
     }
     //if this or a parent has nodeoptions[OPTION_ALLOW_POST] = 0, we are done.
     if (!empty($this->noComments) and (array_key_exists($nodeid, $this->noComments) or array_key_exists($node['parentid'], $this->noComments) or array_key_exists($node['starter'], $this->noComments))) {
         $this->canCreateTypes[$nodeid] = false;
         return false;
     }
     //if this is NOT a channel we need to test the channel.
     if ($node['contenttypeid'] != $channelType) {
//.........这里部分代码省略.........
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:101,代码来源:usercontext.php

示例8: xml_import_help_topics

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_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-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_message2('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();
}
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:91,代码来源:adminfunctions_help.php

示例9: xml_import_style

/**
* Reads XML style file and imports data from it into the database
*
* @param	string	$xml		XML data
* @param	integer	$styleid	Style ID
* @param	integer	$parentid	Parent style ID
* @param	string	$title		New style title
* @param	boolean	$anyversion	Allow vBulletin version mismatch
* @param	integer	$displayorder	Display order for new style
* @param	boolean	$userselct	Allow user selection of new style
* @param  	int|null	$startat	Starting template group index for this run of importing templates (0 based). Null means all templates (single run)
* @param  	int|null	$perpage	Number of templates to import at a time
* @param	boolean	$scilent		Run silently (do not echo)
* @param	array|boolean	$parsed_xml	Parsed array of XML data. If provided the function will ignore $xml and use the provided, already parsed data.
*
* @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, $scilent = false, $parsed_xml = false)
{
    // $GLOBALS['path'] needs to be passed into this function or reference $vbulletin->GPC['path']
    //checking the root node name
    if (!empty($xml)) {
        $r = new XMLReader();
        if ($r->xml($xml)) {
            if ($r->read()) {
                $node_name = $r->name;
                if ($node_name != 'style') {
                    print_stop_message2('file_uploaded_not_in_right_format_error');
                }
            } else {
                //can not read the document
                print_stop_message2('file_uploaded_unreadable');
            }
        } else {
            //can not open the xml
            print_stop_message2('file_uploaded_unreadable');
        }
    }
    global $vbulletin;
    if (!$scilent) {
        $vbphrase = vB_Api::instanceInternal('phrase')->fetch(array('importing_style', 'please_wait', 'creating_a_new_style_called_x'));
        print_dots_start('<b>' . $vbphrase['importing_style'] . "</b>, {$vbphrase['please_wait']}", ':', 'dspan');
    }
    require_once DIR . '/includes/class_xml.php';
    if (empty($parsed_xml)) {
        //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) {
            if ($scilent) {
                throw new vB_Exception_AdminStopMessage('no_xml_and_no_path');
            }
            print_dots_stop();
            print_stop_message2('no_xml_and_no_path');
        } else {
            if ($xmlobj->error_no() == 2) {
                if ($scilent) {
                    throw new vB_Exception_AdminStopMessage(array('please_ensure_x_file_is_located_at_y', 'vbulletin-style.xml', $vbulletin->GPC['path']));
                }
                print_dots_stop();
                print_stop_message2(array('please_ensure_x_file_is_located_at_y', 'vbulletin-style.xml', $vbulletin->GPC['path']));
            }
        }
        if (!($parsed_xml = $xmlobj->parse())) {
            if ($scilent) {
                throw new vB_Exception_AdminStopMessage(array('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line()));
            }
            print_dots_stop();
            print_stop_message2(array('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)) {
        if ($scilent) {
            throw new vB_Exception_AdminStopMessage('');
        }
        print_dots_stop();
        print_stop_message2('');
    }
    $outputtext = '';
    if ($one_pass or $startat == 0) {
        require_once DIR . '/includes/adminfunctions.php';
        // version check
        $full_product_info = fetch_product_list(true);
        $product_info = $full_product_info["{$product}"];
        if ($version != $product_info['version'] and !$anyversion and !$master) {
            if ($scilent) {
                throw new vB_Exception_AdminStopMessage(array('upload_file_created_with_different_version', $product_info['version'], $version));
            }
            print_dots_stop();
            print_stop_message2(array('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) {
                if ($scilent) {
//.........这里部分代码省略.........
开发者ID:cedwards-reisys,项目名称:nexus-web,代码行数:101,代码来源:adminfunctions_template.php


注:本文中的vB_XML_Parser::error_no方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。