PDA

View Full Version : style xml file parsing issue!


AN-net
09-26-2005, 10:29 PM
i get this error:

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


my code is:

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($parser, XML_OPTION_CASE_FOLDING, 0);
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, 04:01 AM
Are you sure the xml-file is correct?

AN-net
09-27-2005, 07:41 PM
i did add one little thing to it>_>

AN-net
09-28-2005, 10:20 PM
ok well did me adding action="xxx" to the <template> tag break the parser?

Marco van Herwaarden
09-29-2005, 03:21 AM
Difficult to say without seeing the XML-file.

AN-net
09-30-2005, 01:42 AM
here is the xml file i am using

Marco van Herwaarden
09-30-2005, 03: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, 09:46 AM
this is for vbulletin 3.0.x and there are only style importers not just template importers.

deathemperor
09-30-2005, 05: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:


// 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, 09:24 PM
what if i wanted this to overwrite existing templates?

deathemperor
10-01-2005, 01:07 AM
it then should be install in the MASTER STYLE.

AN-net
10-01-2005, 01: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, 02: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, 10:23 AM
well of these templates are custom since they are not standard with vbulletin.

deathemperor
10-02-2005, 03: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, 07: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, 08: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, 09:43 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.
any code for reverting or removing templates?

AN-net
10-05-2005, 01:02 AM
bump!!!

Guest190829
10-05-2005, 01:38 AM
any code for reverting or removing templates?

SQL Queries?

deathemperor
10-05-2005, 04:19 PM
bump!!!

I suggest you use this function to remove the templates
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, 06:42 PM
I suggest you use this function to remove the templates
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, 02:38 PM
sorry I can't help you with that.

why do you want that action param for ?

AN-net
10-06-2005, 08:22 PM
never mind, now that i realize what replacement really does i no longer need that param:D