Unofficial vBulletin Conversation Backup


This isn't available for demonstration. The source code follows.
Feel free to use this -
This can backup a conversation.
Some notes:
+As a quick alternative to this script, if you're part of a conversation, you can get the full list of VMs by typing some VM for the conversation and then clicking "Go Advanced" - all the VMs will be on the page. Or, if you're viewing a conversation, you can add "&pp=50" to the url to increase VMs to 50 per page (maximum).
+I haven't tested this script on deleted VMs, they may cause the script to chuck an error.
+The data is stored as a multidimensional array in $data_array - if you're just simply backing up, then I recommend to just JSON_encode (it's better than serialize) it and put it in a file.
This is where the vbulletin forum is, for example, '' (don't forget the trailing slash).
This is the timezone for reading the formatted timestamps (which have a timezone difference) and converting them into UNIX timestamps (which don't). See
'converse' is to backup a conversation between two people,
'member' is to backup all vms on one person's page.
>u AND u2
When using converse, specify the two users you want the conversation from.
When using member, specify the user you want all of the vms from (vms sent to that user, that is).
PLEASE NOTE! You cannot user a normal username, you need a user NUMBER.

header('Content-Type: text/plain');

exit('Expecting parameter forum');

$_GET['timezone'] = 'Australia/Sydney';

if($_GET['mode'] == 'converse' || !$_GET['mode']){
if(!$_GET['u'])exit('Expecting parameter u');
if(!$_GET['u2'])exit('Expecting parameter u2');
$formattedurl = $_GET['forum'].'converse.php?pp=50&u='.$_GET['u'].'&u2='.$_GET['u2'];

if($_GET['mode'] == 'member'){
if(!$_GET['u'])exit('Expecting parameter u');
$formattedurl = $_GET['forum'].'member.php?'.$_GET['u'];


function getElementById($area, $id){
$xpath = new DOMXPath($area);
return $xpath->query("//*[@id='$id']")->item(0);

function getElementsByClassName($area, $ClassName) {
$Elements = $area->getElementsByTagName("*");
for($i=0;$i<$Elements->length;$i++){if(in_array($ClassName, explode(' ', $Elements->item($i)->attributes->getNamedItem('class')->nodeValue)))$Matched[]=$Elements->item($i);}
return $Matched;

function innerHTML($el) {
$doc = new DOMDocument();
$doc->appendChild($doc->importNode($el, TRUE));
$html = trim($doc->saveHTML());
$tag = $el->nodeName;
return preg_replace('@^<' . $tag . '[^>]*>|$@', '', $html);


$doc = new DOMDocument();
$htm = file_get_contents($formattedurl);

if(stripos($htm, 'vBulletin Message')!==false) exit ('Permissions error');



$classes = getElementsByClassName($doc,'first_last');
$classes = $classes[0]->firstChild;
$regexp = preg_match('/page=(?:[0-9]*)/', $classes->getAttribute('href'), $maxpages);
$maxpages = substr($maxpages[0],5);



$doc = new DOMDocument();
$htm = file_get_contents($formattedurl.'&page='.$n);

if(stripos($htm, 'vBulletin Message')!==false) exit ('Permissions error');


$curpage = getElementById($doc, 'message_list')->getElementsByTagName('li');

foreach($curpage as $message){

$textnode = $message->getElementsByTagName('blockquote')->item(0);
$text = trim(innerHTML($textnode));

$usernode = getElementsByClassName($message, 'username');
$username = innerHTML($usernode[0]);
$regexp = preg_match('/member\.php\?(?:[0-9]*)/', $usernode[0]->getAttribute('href'), $userid);
$userid = substr($userid[0],11);

date_default_timezone_set($_GET['timezone']); //Set the proper timezone of the timestamps being read
$datetimenode = getElementsByClassName($message, 'postdate');
$datetime = trim(innerHTML($datetimenode[0]));
$datetime = str_replace('','',str_replace('','',$datetime));
$datetime = str_replace('Today',date("m-d-y"),$datetime);
$datetime = str_replace('Yesterday',date("m-d-y",time()-86400),$datetime);
$datetime = str_replace('-','/',$datetime); //This is so strtotime reads it properly as a MONTH/DAY/YEAR
$timestamp = strtotime($datetime);

$vmnumber = substr($message->getAttribute('id'),9);

$data_array[] = array('vmnumber' => $vmnumber, 'username' => $username, 'userid' => $userid, 'text' => $text, 'timestamp' => $timestamp);




Leave a Reply

Your email address will not be published. Required fields are marked *