Log in

View Full Version : Script to unpack template.xml files


AlexanderT
04-03-2004, 09:50 AM
I wrote a small script that extracts all templates from a template.xml.

This script can be quite useful for everyone who prefers to upgrade hacks manually and who needs to compare template changes.

Why extract into .html files first?
Comparing two xml files is not so useful, because the order in which templates are stored into the .xml file could have changed.

Output looks like this:
Working on 'vbulletin-style.xml'.

Extracting .alt1, .alt1Active.html...
Extracting .alt2, .alt2Active.html...
Extracting .alt3.html...
Extracting .button.html...
...

!/usr/bin/perl -w

unless( @ARGV == 1 ) {
die <<EOF;

VBULLETIN V3.0 TEMPLATE EXTRACTOR 0.1
haxored by AlexanderT
-------------------------------------

This script parses vBulletin V3.0
template.xml files and extracts
individual templates (as .html).

USAGE:
extract.pl filename

EOF
}

($file) = @ARGV;
open(INPUT, "<", glob($file)) or die "Couldn't open '$file' for reading.\nError: $!\n\n";
print "\n VBULLETIN V3.0 TEMPLATE EXTRACTOR 0.1\n";
print " haxored by AlexanderT\n";
print " -------------------------------------\n\n";
print "Working on '$file'.\n\n";


local $/ = undef;
while (<INPUT>) {
while (m#<template name="([^"]*)[^>]*><!\[CDATA\[(.*?)]]></template>#gis) {
print("Extracting $1.html...\n");
open(OUTFILE, ">", "$1.html");
print OUTFILE $2;
close(OUTFILE);
}
}
print "\ndone.\n\n";
close(INPUT);

Dean C
04-03-2004, 12:28 PM
Isn't this perl? This code looks very odd :p

AlexanderT
04-03-2004, 12:47 PM
Heh yes, that is perl. You have to run it from console. Btw, I fixed the script, it now fully unpacks vbulletin-style.xml (and others) as well :P

smsmasters
04-09-2004, 08:32 AM
How do u run this? Where do I upload it to?

AlexanderT
04-09-2004, 11:40 AM
This is a perl script which you run from console. I run FreeBSD here, and have Perl installed by default. If you have Windows, you must install something like Activeperl (free) or some WAMP system.