Changeset 4219 for contrib/z-push/backend/imap.php
- Timestamp:
- 05/05/11 09:37:13 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/z-push/backend/imap.php
r3754 r4219 313 313 if ($search !== false) 314 314 $sequence = implode(",", $search); 315 } 315 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::GetMessageList-> A função @imap_search leu as seguintes SEQUÊNCIAS do servidor IMAP com base no filtro de data: '.$sequence); 316 } 317 316 318 $overviews = @imap_fetch_overview($this->_mbox, $sequence); 317 319 … … 322 324 $date = ""; 323 325 $vars = get_object_vars($overview); 326 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::GetMessageList-> A função @imap_fetch_overview leu mais detalhes da mensagem: '. print_r($overview,1)); 324 327 if (array_key_exists( "date", $vars)) { 325 328 // message is out of range for cutoffdate, ignore it 326 if(strtotime(preg_replace("/\(.*\)/", "", $overview->date)) < $cutoffdate) continue; // emerson-faria.nobre@serpro.gov.br - 07/feb/2011 329 if(strtotime(preg_replace("/\(.*\)/", "", $overview->date)) < $cutoffdate) { // emerson-faria.nobre@serpro.gov.br - 07/feb/2011 330 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::GetMessageList-> O overview->date: '.$overview->date.' (overview->date_timestamp: '.strtotime(preg_replace("/\(.*\)/", "", $overview->date)).') é menor que o $cutoffdate: '.date("d/m/Y G:i:s",$cutoffdate).' ($cutoffdate_timestamp: '.$cutoffdate.') ou a função "strtotime" gerou um ERRO porque não conseguiu retornar um valor para o overview->date_timestamp. A mensagem será descartada da sincronização.'); 331 continue; 332 } 327 333 //if(strtotime($overview->date) < $cutoffdate) continue; 328 334 $date = $overview->date; 335 } else if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::GetMessageList-> ERRO: O campo date não existe no overview da mensagem.'); 336 337 // cut of deleted messages 338 if (array_key_exists( "deleted", $vars) && $overview->deleted) { 339 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::GetMessageList-> A mensagem está com o flag deleted ativo e será descartada da sincronização'); 340 continue; 329 341 } 330 331 // cut of deleted messages332 if (array_key_exists( "deleted", $vars) && $overview->deleted)333 continue;334 342 335 343 if (array_key_exists( "uid", $vars)) { … … 342 350 if(array_key_exists( "seen", $vars) && $overview->seen) 343 351 $message["flags"] = 1; 344 345 352 array_push($messages, $message); 346 } 353 } else if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::GetMessageList-> ERRO: O campo uid não existe no overview da mensagem.'); 347 354 } 348 355 } … … 361 368 $list = array_reverse($list); 362 369 foreach ($list as $val) { 370 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::GetFolderList-> Pasta lida usando a função @imap_getmailboxes: '.print_r($val,1)); 363 371 $box = array(); 364 372 … … 379 387 $box["parent"] = "0"; 380 388 } 381 389 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::GetFolderList-> Parâmetros da pasta após decodificação: '.print_r($box,1)); 382 390 $folders[]=$box; 383 391 } … … 461 469 //advanced debugging 462 470 //debugLog("IMAP-GetFolder(id: '$id') -> " . print_r($folder, 1)); 471 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::GetFolder(id: '.$id.'): '.print_r($folder,1)); 463 472 464 473 return $folder; … … 481 490 $stat["parent"] = $folder->parentid; 482 491 $stat["mod"] = $folder->displayname; 483 492 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::StatFolder(id: '.$id.'): '.print_r($stat,1)); 484 493 return $stat; 485 494 } … … 535 544 if (isset($message->parts[$part]->body)) 536 545 print $message->parts[$part]->body; 537 546 538 547 // unset mimedecoder & mail 539 548 unset($mobj); … … 565 574 $vars = get_object_vars($overview[0]); 566 575 576 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL') and (! array_key_exists( "uid", $vars))) debugLog('IMAP::StatMessage-> ERRO: A mensagem será desconsiderada porque não tem o campo "uid"'); 567 577 // without uid it's not a valid message 568 578 if (! array_key_exists( "uid", $vars)) return false; … … 578 588 $entry["flags"] = 1; 579 589 590 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::StatMessage: '.print_r($entry,1)); 591 580 592 //advanced debugging 581 593 //debugLog("IMAP-StatMessage-parsed: ". print_r($entry,1)); … … 601 613 $mail = @imap_fetchheader($this->_mbox, $id, FT_PREFETCHTEXT | FT_UID) . @imap_body($this->_mbox, $id, FT_PEEK | FT_UID); 602 614 615 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog("IMAP-GetMessage: Mensagem lida do servidor IMAP através da função @imap_fetchheader: ". print_r($mail,1)); 616 603 617 $mobj = new Mail_mimeDecode($mail); 604 618 $message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $mail, 'crlf' => "\n", 'charset' => 'utf-8')); 619 620 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog("IMAP-GetMessage: Mensagem mime decodificada: ". print_r($message,1)); 605 621 606 622 $output = new SyncMail(); … … 661 677 unset($mobj); 662 678 unset($mail); 679 if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog("IMAP-GetMessage: Mensagem formatada para envio ao celular: ". print_r($output,1)); 663 680 return $output; 664 681 } … … 808 825 $this->getBodyRecursive($message, "plain", $body); 809 826 810 if(!isset($body) || $body === "") {827 if(!isset($body) or $body === '') { 811 828 $this->getBodyRecursive($message, "html", $body); 812 829 // remove css-style tags … … 817 834 // Remove the HTML tags using the 'html2text' - emerson-faria.nobre@serpro.gov.br 818 835 // The 'html2text' (http://www.mbayer.de/html2text) must be installed in Z-Push server. 819 836 820 837 // Advanced debug 821 838 // debugLog("IMAP-getBody: subject: " . $message->headers["subject"]); 822 $body = utf8_encode($body); 839 $body = utf8_encode($body); 823 840 libxml_use_internal_errors(true); 824 841 try {
Note: See TracChangeset
for help on using the changeset viewer.