2 /* INDEV / DO NOT TOUCH | dump_mail_xml button functionality in mailbox | maniax */
4 if (!defined('M_ENDL')) define('M_ENDL', chr(10));
6 function dmx_gen_entry($m_rec) {
7 printf(' <mail id="%d">'.M_ENDL, $m_rec['mail_id']);
8 printf(' <datetime>%s</datetime>'.M_ENDL, $m_rec['mail_timestamp']);
9 printf(' <from id="%d"><![CDATA[%s]]></from>'.M_ENDL, $m_rec['mail_from'], htmlspecialchars($m_rec['mail_from_login']));
10 printf(' <to id="%d"><![CDATA[%s]]></to>'.M_ENDL, $m_rec['mail_to'], htmlspecialchars($m_rec['mail_to_login']));
11 echo ' <text><![CDATA['.M_ENDL;
12 printf(' %s'.M_ENDL, $m_rec['mail_text']);
13 echo ' ]]></text>'.M_ENDL;
14 printf(' </mail>'.M_ENDL);
17 function dump_mail_xml($node_id) {
18 global $node, $db, $error;
20 $user_id = $_SESSION['user_id'];
22 $gm_qs = sprintf('select mail.*, users_from.login as mail_from_login, users_to.login as mail_to_login from mail
23 join users as users_from on users_from.user_id = mail.mail_from
24 join users as users_to on users_to.user_id = mail.mail_to
25 where mail_user = %d order by mail_id asc', $user_id);
27 $m_set = $db->query($gm_qs);
29 if (!empty($_POST['FORCE_OB']) && $_POST['FORCE_OB'] == 'true') ob_clean();
31 Header('Content-type:application/octet-stream');
32 Header(sprintf('Content-disposition:attachment;filename=maildump-%d.xml', $user_id));
34 echo '<?xml version="1.0"?>'.M_ENDL;
35 printf('<!-- XML mail dump for user id %s, generated @ %s -->'.M_ENDL, $user_id, date('d-m-Y, H:i:s'));
36 printf('<maillist owner="%d">'.M_ENDL, $user_id);
37 while ($m_set->next())
38 dmx_gen_entry($m_set->getRecord());
39 printf('</maillist>'.M_ENDL);