Hmm no answer yet … BUT here is a script for everyone how wants to do the same … But I give no warranty for anything !!!
That one who makes use of this, does it on it’‘s own risk. of course isn’'t it
Have tried to indent it here, but does not work , and haven’'t found a Code BB-Tag
Have fun with your wildfire server!
The Script creates a xml file and prompts for download which can be imported by the current import / export plugin.
Just create a file, e.g. wildfire.php, put the code inside this and up it onto your server. Then call it with your favourite browser.
You will be prompted to type in your Jabber Database, your Jabber Database user and its password, and the realm which you want to export from
the jabberd2 database. After this press send and after a minute or so you will be prompted to download a file called export.xml. This file can then directly be uploaded and imported via the wildfire current import / export plugin.
This works for jabberd2 configured with MySQL.
Ciao Ephraim
<?php
function GetVar($name, $default = "") {
return ( isset($_POST[$name]) ? $_POST[$name] :
( isset($_GET[$name]) ? $_GET[$name] :
$default));
}
function MyEntities($string) {
$string = str_replace("&", "&", $string);
$string = str_replace("<", "<", $string);
$string = str_replace(">", ">", $string);
$string = str_replace("''", "'", $string);
$string = str_replace("\"", """, $string);
return $string;
}
if(GetVar("action") == "export") {
$realm = GetVar("realm");
$con = mysql_connect(GetVar("server"), GetVar("user"), GetVar("pw"));
if($con) {
mysql_select_db(GetVar("db"));
$query = "SELECT ar.username as username, ar.realm as realm, ar.password as pw, ri.jid as jid, ";
$query .= "ri.name as contact, ri.to as sub, ri.from as recv, ri.ask as ask, rg.group as groupname ";
$query .= "FROM `authreg` as ar ";
$query .= "JOIN `roster-items` as ri on CONCAT(ar.username, ''@'', ar.realm) = ri.`collection-owner` ";
$query .= "LEFT OUTER JOIN `roster-groups` as rg on ri.`collection-owner` = rg.`collection-owner` AND ri.jid = rg.jid ";
$query .= "WHERE ar.realm = ''$realm'' ";
$query .= "ORDER BY ar.username";
$result = mysql_query($query, $con);
if($result) {
$content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<Wildfire>\n";
$lastUser = "";
while($row = mysql_fetch_object($result)) {
if($row->username != $lastUser) {
if($lastUser != "") {
$content .= "\t\t</Roster>\n";
$content .= "\t</User>\n";
}
$lastUser = $row->username;
$content .= "\t<User>\n";
$content .= "\t\t<Username>$lastUser</Username>\n";
$content .= "\t\t<Password>".MyEntities($row->pw)."</Password>\n";
$content .= "\t\t<Email></Email>\n";
$content .= "\t\t<Name></Name>\n";
$content .= "\t\t<CreationDate>".time()."</CreationDate>\n";
$content .= "\t\t<ModifiedDate>".time()."</ModifiedDate>\n";
$content .= "\t\t<Roster>\n";
}
$content .= "\t\t\t<Item jid=\"".$row->jid."\" askstatus=\"".($row->ask == 0 ? -1 : 0)."\" recvstatus=\"".($row->recv == 0 ? 1 : -1)."\" substatus=\"".($row->sub == 1 ? 3 : 0)."\" name=\"".MyEntities($row->contact)."\">\n";
if($row->groupname != "")
$content .= "\t\t\t\t<Group>".MyEntities($row->groupname)."</Group>\n";
else
$content .= "\t\t\t\t<Group></Group>\n";
$content .= "\t\t\t</Item>\n";
} if($lastUser != "") {
$content .= "\t\t</Roster>\n";
$content .= "\t</User>\n";
}
$content .= "</Wildfire>\n";
header(''Content-type: application/force-download'');
header(''Content-Transfer-Encoding: Binary'');
header(''Content-length: ''.strlen($content)*2);
header(''Content-disposition: attachment; filename=export.xml'');
echo utf8_encode($content);
}
else {
echo "Nothing found with realm $realm.<br/>MySQL reported this error:<br/>".mysql_error($con);
}
}
}else {?>
<form method="post" action="">
Jabber Domain (jabber.example.org, the realm): <input name="realm"/><br/>
MySQL Server Host: <input name="server" value="localhost"/><br/>
MySQL Server Db: <input name="db" value="jabberd2"/><br/>
MySQL Server User: <input name="user" value="jabberd2"/><br/>
MySQL Server Password: <input type="password" name="pw" value=""/><br/>
<input type="submit" name="action" value="export"/>
</form>
<?
}
?>
Message was edited by: Ephraim
null
Message was edited by: Ephraim