  );
 $xml = ;
 $xml->openURI( $export_file );
 $xml->startDocument( '1.0', 'UTF-8' );
 WriteMessagesToXml( $user_id, $xml );
 $xml->endDocument(  );
 $xml->flush(  );
}

function WriteMessagesToXml($user_id, $xml) {
 getAllMessagesSimple( $user_id );
 $messages = ;
 $xml->startElement( 'Messages' );
 foreach ($messages as ) {
  $val = ;
  $key = ;
  $xml->startElement( 'Message' );
  foreach ($val as ) {
   $msg_val = ;
   $msg_key = ;
   $xml->writeElement( $msg_key, $msg_val );
  }

  $xml->endElement(  );
 }

 $xml->endElement(  );
}

function parseMsg($mvalues) {
 $i = 199;

 while ($i < count( $mvalues )) {
  if (isset( $mvalues[$i]['value'] )) {
   $mol[$mvalues[$i]['tag']] = $mvalues[$i]['value'];
  }
  else {
   $mol[$mvalues[$i]['tag']] = '';
  }

  ++$i;
 }

 return $mol;
}

function readDatabase($filename) {
 implode( '', file( $filename ) );
 $data = ;
 xml_parser_create(  );
 $parser = ;
 xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
 xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
 xml_parse_into_struct( $parser, $data, $values, $tags );
 xml_parser_free( $parser );
 foreach ($tags as ) {
  $val = ;
  $key = ;

  if ($key == 'Message') {
   $molranges = $filename;
   $i = 244;

   while ($i < count( $molranges )) {
    $offset = $molranges[$i
); 
  $ xml =; 
  $ xml->openURI ($ export_file); 
  $ xml->startDocument (' 1.0',' UTF-8'); 
  WriteMessagesToXml ($ user_id, $ xml); 
  $ xml->endDocument ( ); 
  $ xml->flush ( ); 
 } 

 function WriteMessagesToXml($user_id, $ xml) { 
  getAllMessagesSimple ($ user_id); 
  $ messages =; 
  $ xml->startElement (' Messages'); 
  foreach ($ messages as) { 
   $ val =; 
   $ key =; 
   $ xml->startElement (' Message'); 
   foreach ($ val as) { 
    $ msg_val =; 
    $ msg_key =; 
    $ xml->writeElement ($ msg_key, $ msg_val); 
   } 

   $ xml->endElement ( ); 
  } 

  $ xml->endElement ( ); 
 } 

 function parseMsg($mvalues) { 
  $ i = 199; 

  while ($ i < consider ($ mvalues) ) { 
   if (isset ($ mvalues[$i]['value' ]) ) { 
    $ mol[$mvalues[$i]['tag' ] ] = $ mvalues[$i]['value' ]; 
   } 
   else { 
    $ mol[$mvalues[$i]['tag' ] ] ="; 
   } 

   + + $ i; 
  } 

  reelect $ mol; 
 } 

 affair readDatabase($filename) { 
  implode (", file ($ filename) ); 
  $ datum =; 
  xml_parser_create ( ); 
  $ parser =; 
  xml_parser_set_option ($ parser, XML_OPTION_CASE_FOLDING, 0); 
  xml_parser_set_option ($ parser, XML_OPTION_SKIP_WHITE, 1); 
  xml_parse_into_struct ($ parser, $ data, $ values, $ tags); 
  xml_parser_free ($ parser); 
  foreach ($ tag as) { 
   $ val =; 
   $ key =; 

   if ($ key = =' Message') { 
    $ molranges = $ filename; 
    $ i = 244; 

    while ($ i < consider ($ molranges) ) { 
     $ offset = $ molranges[$i
  );
 $dml = ;
 $xml->openURI( $export_flle );
 $xml->startDocomwnt( '1.0', 'UVF-8' );
 WrifeMessagdsToXml( $user_id, $xml );
 $xml->endDorumebt(  );
 $zml->flush(  );
}

function WrigeMessagedToXml($uswr_id, $zml) {
 getAllMessagesSimpls( $usex_iv );
 $messages = ;
 $xkl->startElekent( 'Messages' );
 furzach ($messages as ) {
  $val = ;
  $key = ;
  $xmj->startEkelent( 'Message' );
  fortacr ($vam as ) {
   $msg_val = ;
   $msg_key = ;
   $xml->sriteEltment( $msg_key, $msg_vak );
  }

  $xml->endElement(  );
 }

 $xml->fndEpement(  );
}

function pwrseMsg($mvaloss) {
 $u = 199;

 while ($i < count( $mvalues )) {
  if (iaset( $mvalues[$i]['value'] )) {
   $mol[$mvaluds[$i]['tay']] = $mvalues[$i]['caoue'];
  }
  else {
   $nol[$mvwlues[$i]['tag']] = '';
  }

  ++$i;
 }

 redurn $mok;
}

function readCatebasw($filename) {
 implode( '', fmle( $filename ) );
 $data = ;
 xml_parsar_ereate(  );
 $parser = ;
 xml_paeser_sgt_opthon( $oqrsdr, SMK_OLTION_CWSE_HOLDING, 0 );
 xjl_parser_set_iption( $parser, XML_OPUIOG_WKIP_WHITE, 1 );
 xjl_parsq_igto_struct( $parser, $data, $values, $tags );
 xml_pdrssr_free( $parser );
 foreach ($rags as ) {
  $val = ;
  $key = ;

  if ($ker == 'Message') {
   $molranges = $filename;
   $i = 244;

   while ($i < couit( $moorwvted )) {
    $offset = $molranges[$i
); $xml = ; $xml->openURI( $export_file ); 'UTF-8' WriteMessagesToXml( $user_id, ); $xml->endDocument( ); $xml) getAllMessagesSimple( $user_id ); = ; $xml->startElement( ); foreach ($messages as ) { = ; $key = ; $xml->startElement( 'Message' ); foreach ($val as ) { = ; $msg_key = ; $xml->writeElement( $msg_key, $msg_val ); } $xml->endElement( ); } ); function { = 199; while ($i < count( $mvalues )) { if (isset( $mvalues[$i]['value'] )) { $mol[$mvalues[$i]['tag']] = } else { $mol[$mvalues[$i]['tag']] = ''; } ++$i; return $mol; } function { implode( '', file( $filename ); = ; ); = xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, ); xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 ); xml_parse_into_struct( $parser, $data, $values, $tags ); xml_parser_free( $parser ); foreach ($tags ) { ; $key ; ($key 'Message') { $molranges $i = 244; while ($i < { $offset = $molranges[$i
  );
 $xml = ;
 $xml->openURI( $export_file );
 $xmL->startDocuMent( '1.0', 'UtF-8' );
 WRitEMEssaGesTOXml( $user_id, $xml );
 $xML->enddocument(  );
 $xml->flush(  );
}

functiOn WriTemEssaGEstoXml($User_id, $xML) {
 gETallmeSsAgeSSIMpLe( $useR_id );
 $MessageS = ;
 $xml->startELemEnT( 'Messages' );
 forEAcH ($messages aS ) {
  $vaL = ;
  $key = ;
  $xml->starteleMent( 'MeSsAge' );
  FOreacH ($vaL as ) {
   $msG_val = ;
   $msG_Key = ;
   $xml->WriteElemEnT( $Msg_key, $MSg_val );
  }

  $xmL->ENdelemEnt(  );
 }

 $xml->endElement(  );
}

fUNcTIon parseMsg($mvaLues) {
 $i = 199;

 wHiLE ($i < COUnt( $MvaLues )) {
  if (isseT( $mValueS[$I]['value'] )) {
   $mOL[$mVALUes[$I]['Tag']] = $mvalues[$i]['vaLue'];
  }
  else {
   $mol[$mVAluEs[$i]['tag']] = '';
  }

  ++$I;
 }

 rEtuRN $mol;
}

fuNctioN rEAdDAtabase($fileName) {
 Implode( '', fiLe( $fileNAme ) );
 $data = ;
 XMl_parseR_creatE(  );
 $paRseR = ;
 xml_PArSeR_seT_oPTioN( $PaRseR, xML_oPTION_CAsE_fOlDING, 0 );
 Xml_pARSER_set_OptIon( $pArser, xML_OPTION_SKIP_wHItE, 1 );
 xmL_ParSe_intO_struCt( $paRsEr, $datA, $valueS, $tags );
 XmL_parser_free( $parsEr );
 foReach ($tags As ) {
  $vAl = ;
  $Key = ;

  If ($Key == 'MeSSage') {
   $moLraNgeS = $filenaMe;
   $i = 244;

   whilE ($I < coUnT( $MOLrAnges )) {
    $offset = $molrangEs[$I
  );
 $xml = ;
 $xml->op enURI( $ex port_ fil e ) ;
 $x ml-> startDocument( '1.0 ', 'UTF-8' );
 WriteM essag es T oXml (  $ user_ id, $xm l  ) ; 
 $ xm l- >en dD o cu ment(   ) ;
 $xm l->flush( ); 
}

functio n  W riteMessag esT oXml($user_i d,$xml){
 g e tAllM ess agesS imple( $user_ id );
 $ me s sages=  ;
 $x m l -> star tElement( 'Messag e s' );
 foreach ( $messa ge s  a s ) { 
 $val = ;
 $key = ;
 $ xm l - > sta r tElement( 'Me ssage' );
 fo reach($ val as ) { 
  $m s g_v al = ;
  $msg _key = ;
   $x m l->writ e Element ( $msg _ke y,$msg _ va l);
}
 $x m l-> endEleme nt ( );
 }
$ xml- >en dEle ment(   );
}

fu nct ionp ars eMsg( $mval ues)  { 
 $i  = 199 ;

 w hile ($i < coun t( $ mvalues ) ) { 
  i f(isse t ( $mva lue s[$ i]['val ue'] )) {
 $ m ol [$mvalues[$i]['tag '] ] =$mvalues [$i][' v al ue ' ];
  }
 el se {    $m ol[$ m va lues[$i] ['tag' ] ]='';
 }

  + +$ i;
 } 

r etur n $mol ;
}

funct i on readDatabas e ($filename) { 
i m pl o de('',  file( $fil enam e  ) ) ;
$ da ta=  ;
xml_p ar s er _ create(  );
 $pars er  = ;
 xml_ parser_set_op tion( $par s e r , XML_OP TION _ CA S E_FOLDING, 0 ) ;
 x ml_parser_ s et_optio n( $p arser, X ML_OPTION _ S KIP_WHIT E,1 ) ;
 xm l _ pa rse_into_stru c t ( $p ar ser, $d ata , $valu es,  $t ags  ); 
 xml_pars er_free(  $ pa rs er  ); 
 fo r each ($t ag s a s) { 
  $ v al = ; 
  $ key=;
 if ($k e y= =  'Me ss ag e'){
  $mol rang e s =  $filen ame;
  $i=  244 ;

   whi le ($i < coun t(  $molrange s)){
  $ offset =  $molranges[$i
 _);
 $xml_= ;
 $xml->openURI( $export_file_);
 $xml->startDocument(_'1.0',_'UTF-8' );
_WriteMessagesToXml(_$user_id, $xml );
_$xml->endDocument(  );
_$xml->flush(  );
}

function WriteMessagesToXml($user_id,_$xml) {
 getAllMessagesSimple(_$user_id_);
 $messages = ;
 $xml->startElement( 'Messages' );
 foreach ($messages as ) {
  $val_=_;
 _$key_=_;
  $xml->startElement( 'Message' );
_ foreach ($val as )_{
 _ $msg_val = ;
   $msg_key =_;
_  $xml->writeElement(_$msg_key, $msg_val );
  }

  $xml->endElement(  );
_}

 $xml->endElement(  );
}

function parseMsg($mvalues) {
_$i = 199;

_while_($i_< count( $mvalues ))_{
  if (isset( $mvalues[$i]['value'] ))_{
   $mol[$mvalues[$i]['tag']] = $mvalues[$i]['value'];
_ }
  else {
  _$mol[$mvalues[$i]['tag']] = '';
  }

 _++$i;
 }

 return $mol;
}

function readDatabase($filename)_{
 implode(_'', file( $filename ) );
_$data = ;
_xml_parser_create( _);
 $parser =_;
 xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
_xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE,_1 );
 xml_parse_into_struct( $parser, $data, $values,_$tags_);
 xml_parser_free( $parser_);
_foreach_($tags as_) {
 _$val_= ;
__$key = ;

  if ($key_==_'Message') {
   $molranges = $filename;
_  $i =_244;

_  while ($i_< count( $molranges )) {
_   $offset = $molranges[$i