vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   style xml file parsing issue! (https://vborg.vbsupport.ru/showthread.php?t=96968)

AN-net 09-26-2005 09:29 PM

style xml file parsing issue!
 
i get this error:
Code:

Warning: xml_parse(): 17 is not a valid XML Parser resource in /admincp/journalupgrade2.php on line 99
my code is:
PHP Code:

print_form_header("journalupgrade" $upgradingto ".php"'stepthree');
            
print_table_header("vB Journal Upgrade: " $versions[$currentversion-1] ." to " $versions[$nextversion-1] . "(Step 2/3)");
            require_once(
'./includes/adminfunctions_template.php');
            if (!(
$xml file_read('./'.$admincpdir.'/vbj_templates_upgrade' $upgradingto '.xml')))
            {
                
print_description_row("<b>Can Not Find Journal Template File</b>(vbj_templates_upgrade" $upgradingto ".xml)");
            }
            else
            {
                
$intemplate 0;
                
$counter 0;
                
$curtag '';
                
$arr = array();
                
                
$parser xml_parser_create();
                
xml_parser_set_option($parserXML_OPTION_CASE_FOLDING0);
                
xml_set_element_handler($parser'xml_parse_style_otag''xml_parse_style_ctag');
                
xml_set_character_data_handler($parser'xml_parse_style_cdata');
                
xml_parser_free($parser);
                
/*
                if (!@xml_parse($parser, $xml))
                {
                    print_description_row("<b>Can Not Parse Journal Template File</b>(vbj_templates_upgrade" . $upgradingto . ".xml)");
                }
                */
                
xml_parse($parser$xml);
                
                
                require_once(
'./includes/functions_xml.php');
                foreach(
$arr AS $title => $template)
                {
                    
$title addslashes($title);
                    
$template['template'] = addslashes(xml_unescape_cdata($template['template']));
                    
$template['username'] = addslashes(xml_unescape_cdata($template['username']));
                    
print_r($template);
            
                    if (
$template['templatetype'] != 'template')
                    {
                        
// template is a special template
                        
$querybits[] = "($styleid, '$template[templatetype]', '$title', '$template[template]', '', $template[dateline], '$template[username]', '" addslashes($template['version']) . "')";
                    }
                    else
                    {
                        
// template is a standard template
                        
$querybits[] = "($styleid, '$template[templatetype]', '$title', '" addslashes(compile_template(stripslashes($template['template']))) . "', '$template[template]', $template[dateline], '$template[username]', '" addslashes($template['version']) . "')";
                    }
                }
            }
            
print_submit_row("Continue on to Step 3 of 3"0); 


Marco van Herwaarden 09-27-2005 03:01 AM

Are you sure the xml-file is correct?

AN-net 09-27-2005 06:41 PM

i did add one little thing to it>_>

AN-net 09-28-2005 09:20 PM

ok well did me adding action="xxx" to the <template> tag break the parser?

Marco van Herwaarden 09-29-2005 02:21 AM

Difficult to say without seeing the XML-file.

AN-net 09-30-2005 12:42 AM

1 Attachment(s)
here is the xml file i am using

Marco van Herwaarden 09-30-2005 02:39 AM

I guess i didn't good read the original error message.

Aren't you calling xml_parse_free to early? I guess the parser resource is already freed and don't exist anymore when you call xml_parse().

PS What vB version is this for? Why don't you use the buildin vB xml functions?

AN-net 09-30-2005 08:46 AM

this is for vbulletin 3.0.x and there are only style importers not just template importers.

deathemperor 09-30-2005 04:42 PM

then why don't you use the vbulletin function to import style ?

it's xml_import_style() btw.

ok this is what I did:

PHP Code:

    // Install templates
    
require_once(DIR '/includes/adminfunctions_template.php');
    
// +++++++++
    // XML Temps
    // +++++++++

    
if (!($xml file_read('./'.$vbulletin->datastore->registry->config[Misc][admincpdir].'/jukebox.xml')))
    {
        
print_form_header('jukebox_install''start');
        
print_table_header("Jukebox 1.1 Installation");
        
construct_hidden_code('caction''4');
        
print_description_row("Error. jukebox.xml located in directory '".$vbulletin->datastore->registry->config[Misc][admincpdir]."' was not found. Please make sure it is uploaded then press the submit button below");
        
print_submit_row("Add Templates"0);
    } 
    else 
    {
        
$All_Styles $vbulletin->db->query("select styleid from " TABLE_PREFIX "style where parentid < 0"); // Grab master styles only
        
while($SID $vbulletin->db->fetch_array($All_Styles))
        {
            
$ID[] = $SID['styleid'];
        }
        foreach(
$ID as $StyleID)
        {
            
xml_import_style($xml$StyleID, -1''1);
        }
        
define('NO_POST_EDITOR_BUILD'true);
        
build_all_styles();
    } 

credit goes to Zero Tolerance.

AN-net 09-30-2005 08:24 PM

what if i wanted this to overwrite existing templates?

deathemperor 10-01-2005 12:07 AM

it then should be install in the MASTER STYLE.

AN-net 10-01-2005 12:58 AM

well im gonna install it in all styles but can i overwrite templates already existing with new template data?

also i added a variable called action to the <template> tag but it does not get parsed>_>

deathemperor 10-01-2005 01:45 AM

templates will be override if they are not customized, installing in master style means install in all styles and you can check for updated templates by using Updated Templates function.

AN-net 10-01-2005 09:23 AM

well of these templates are custom since they are not standard with vbulletin.

deathemperor 10-02-2005 02:32 PM

as long as they are put in the master style it will not be treated as custom templates

AN-net 10-02-2005 06:54 PM

ok but since this is an upgrader script and so and so already has these templates installed as custom templates not in the master style, will this overwrite those custom templates not in the master style?

deathemperor 10-03-2005 07:18 AM

no, it will not overwrite the custom templates, but you can ask users to do so buy check for updated templates and then revert. or simply remove those templates first and then insert the new ones.

AN-net 10-03-2005 08:43 AM

Quote:

Originally Posted by deathemperor
no, it will not overwrite the custom templates, but you can ask users to do so buy check for updated templates and then revert. or simply remove those templates first and then insert the new ones.

any code for reverting or removing templates?

AN-net 10-05-2005 12:02 AM

bump!!!

Guest190829 10-05-2005 12:38 AM

Quote:

Originally Posted by AN-net
any code for reverting or removing templates?

SQL Queries?

deathemperor 10-05-2005 03:19 PM

Quote:

Originally Posted by AN-net
bump!!!

I suggest you use this function to remove the templates
PHP Code:

function template_delete($title)
{
    global 
$DB_site;
    
$DB_site->query("DELETE FROM " TABLE_PREFIX "template WHERE title = '$title'");


of course you will have to enter all the title of the templates you want to remove.

it's easier in vb3.5...

AN-net 10-05-2005 05:42 PM

Quote:

Originally Posted by deathemperor
I suggest you use this function to remove the templates
PHP Code:

function template_delete($title)
{
    global 
$DB_site;
    
$DB_site->query("DELETE FROM " TABLE_PREFIX "template WHERE title = '$title'");


of course you will have to enter all the title of the templates you want to remove.

it's easier in vb3.5...

ty, yeah 3.5 will be easier but i promised backward compatiability for this version ;)

edit:
how about reading that action="" thing i added to the <template> tag? because the parser does not seem to read it.

deathemperor 10-06-2005 01:38 PM

sorry I can't help you with that.

why do you want that action param for ?

AN-net 10-06-2005 07:22 PM

never mind, now that i realize what replacement really does i no longer need that param:D


All times are GMT. The time now is 04:32 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03138 seconds
  • Memory Usage 1,809KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (4)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (24)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete