Ignore:
Timestamp:
05/05/11 09:37:13 (13 years ago)
Author:
emersonfaria
Message:

Ticket #1829 - Criado trace detalhado filtrado por usuario e backend

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/z-push/backend/imap.php

    r3754 r4219  
    313313                        if ($search !== false) 
    314314                        $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 
    316318                $overviews = @imap_fetch_overview($this->_mbox, $sequence); 
    317319 
     
    322324                                $date = ""; 
    323325                                $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)); 
    324327                                if (array_key_exists( "date", $vars)) { 
    325328                                        // 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                                        } 
    327333                                        //if(strtotime($overview->date) < $cutoffdate) continue; 
    328334                                        $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; 
    329341                                } 
    330  
    331                                 // cut of deleted messages 
    332                                 if (array_key_exists( "deleted", $vars) && $overview->deleted) 
    333                                 continue; 
    334342 
    335343                                if (array_key_exists( "uid", $vars)) { 
     
    342350                                        if(array_key_exists( "seen", $vars) && $overview->seen) 
    343351                                        $message["flags"] = 1; 
    344  
    345352                                        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.'); 
    347354                        } 
    348355                } 
     
    361368                        $list = array_reverse($list); 
    362369                        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)); 
    363371                                $box = array(); 
    364372 
     
    379387                                        $box["parent"] = "0"; 
    380388                                } 
    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)); 
    382390                                $folders[]=$box; 
    383391                        } 
     
    461469                //advanced debugging 
    462470                //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)); 
    463472 
    464473                return $folder; 
     
    481490                $stat["parent"] = $folder->parentid; 
    482491                $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)); 
    484493                return $stat; 
    485494        } 
     
    535544                if (isset($message->parts[$part]->body)) 
    536545                print $message->parts[$part]->body; 
    537  
     546                 
    538547                // unset mimedecoder & mail 
    539548                unset($mobj); 
     
    565574                        $vars = get_object_vars($overview[0]); 
    566575 
     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"'); 
    567577                        // without uid it's not a valid message 
    568578                        if (! array_key_exists( "uid", $vars)) return false; 
     
    578588                        $entry["flags"] = 1; 
    579589 
     590                        if (TRACE_UID !== false and (TRACE_TYPE == 'IMAP' or TRACE_TYPE == 'ALL')) traceLog('IMAP::StatMessage: '.print_r($entry,1)); 
     591 
    580592                        //advanced debugging 
    581593                        //debugLog("IMAP-StatMessage-parsed: ". print_r($entry,1)); 
     
    601613                        $mail = @imap_fetchheader($this->_mbox, $id, FT_PREFETCHTEXT | FT_UID) . @imap_body($this->_mbox, $id, FT_PEEK | FT_UID); 
    602614 
     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 
    603617                        $mobj = new Mail_mimeDecode($mail); 
    604618                        $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)); 
    605621 
    606622                        $output = new SyncMail(); 
     
    661677                        unset($mobj); 
    662678                        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)); 
    663680                        return $output; 
    664681                } 
     
    808825                $this->getBodyRecursive($message, "plain", $body); 
    809826 
    810                 if(!isset($body) || $body === "") { 
     827                if(!isset($body) or $body === '') { 
    811828                        $this->getBodyRecursive($message, "html", $body); 
    812829                        // remove css-style tags 
     
    817834                        // Remove the HTML tags using the 'html2text' - emerson-faria.nobre@serpro.gov.br 
    818835                        // The 'html2text' (http://www.mbayer.de/html2text) must be installed in Z-Push server. 
    819                                  
     836 
    820837                        // Advanced debug 
    821838                        // debugLog("IMAP-getBody: subject: " . $message->headers["subject"]); 
    822                         $body = utf8_encode($body);      
     839                        $body = utf8_encode($body); 
    823840                        libxml_use_internal_errors(true); 
    824841                        try { 
Note: See TracChangeset for help on using the changeset viewer.