Miranda IM Database Reader
Current version: 0.01.0, Last updated: 04/01/2006
Wudi <wudicgi-at-yahoo.de>, MSN Space

NAME

Miranda IM Database Reader

SYNOPSIS

// Exports all chat history
$export = array();
$MIMDBReader = new MIMDBReader();
$MIMDBReader->open('profile.dat');
$contacts = $MIMDBReader->getAllContacts();
foreach ($contacts as $c_offset => $contact) {
    $export[] = $contact['settings'][$contact['protocol']]['Nick'] . ' (' . $contact['protocol'] . ')';
    $export[] = '';
    $events = $MIMDBReader->getEventsAfterOffset($contact['offsets']['firstEvent']);
    foreach ($events as $event) {
        $export[] = date('Y-m-d H:i:s', $event['timestamp']) . ' ' . (($event['flags']==2)?'Sent':'Recv') .  ' ' . $event['text'];
    }
    $export[] = '';
}
file_put_contents('export.txt', implode("\r\n", $export));

DESCRIPTION

MIM DB Reader is a PHP class that allows you to read the database of Miranda IM. So you can get some useful information such as contact settings and chat history.

CLASS METHODS

bool open ( string filename )

Opens a database file (and read the header). Returns TRUE on success, or FALSE on failure.

array getHeader ( )

Returns the header of database.

array(
  signature => signature of struct (Miranda ICQ DB\x00\x1A)
  version => version of database (this version is 0x00000700)
  ofsFileEnd => offset of the end of the database
  slackSpace => the space that have been wasted
  contactCount => number of contacts
  ofsFirstContact => offset of the first contact
  ofsUser => 
  ofsFirstModule => offset of the first module
)

array getModuleByOffset ( int offset )

Returns module by offset.

array(
  signature => signature of struct (0x4DDECADE)
  ofsNext => offset of the next module
  cbModuleName => length of the module name
  moduleName => module name
)

array getContactByOffset ( int offset )

Returns contact by offset.

array(
  signature => signature of struct (0x43DECADE)
  ofsNext => offset of the next contact
  ofsFirstSettings => offset of the first settings
  eventCount => number of events
  ofsFirstEvent => offset of the first event
  ofsLastEvent => offset of the last event
  ofsFirstUnreadEvent => offset of the first unread event
  timestampFirstUnread => timestamp of the first unread event
)

array getContactSettingsByOffset ( int offset )

Returns contact settings by offset.

array(
  signature => signature of struct (0x53DECADE)
  ofsNext => offset of the next contact settings
  ofsModule => offset of the module which owns this settings
  cbBlob => length of the blob
  settings => settings that read from the blob, array (key=>value)
)

array getEventByOffset ( int offset )

Returns event by offset.

array(
  signature => signature of struct (0x45DECADE)
  ofsPrev => offset of the previous event
  ofsNext => offset of the next event
  ofsModule => offset of the module which owns this event
  timestamp => timestamp of the event
  flags => the flag of the event (sent or read)
  eventType => module-defined event type
  cbBlob => length of the blob
  blob => the blob (module-defined formatting)
)

array getAllContacts ( )

Returns all of the contacts.

array(
  array(
    protocol => name of the module which owns this contact
    offsets => array(
      contact => offset of the contact
      nextContact => offset of the next contact
      firstEvent => offset of the first event
      lastEvent => offset of the last event
    ),
    settings => array( // contact settings
      module1 => array(
        key1 => value1
        key2 => value2
        ...
      ),
      module2 => array(
        key1 => value1
        key2 => value2
        ...
      ),
      ...
    )
  ),
  ...
)

array getEventsAfterOffset ( )

Returns the events of a contact after the specified offset.

array(
  array(
    ofsEvent => offset of the event
    ofsModule => offset of the module which owns this event
    timestamp => timestamp of the event
    flags => the flag of the event (sent or read)
    type => module-defined event type
    text => the text of the event (module-defined formatting,
            only read the string before the first character NUL)
  ),
  ...
)

HISTORY

v0.01.0 (04/01/2006)

AUTHOR

2006, Wudi <wudicgi-at-yahoo.de>, MSN Space