Changeset 504


Ignore:
Timestamp:
10/07/08 14:50:11 (15 years ago)
Author:
niltonneto
Message:

Vide no Trac #344 - Melhorar tratamento de erros (parte 1)

Location:
trunk/expressoMail1_2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/controller.php

    r2 r504  
    2020        // NO ACTION 
    2121        else 
    22                 return $_SESSION['response'] = 'false'; 
     22                return $_SESSION['response'] = 'Post-Content-Length'; 
    2323         
    2424        // Load dinamically class file. 
  • trunk/expressoMail1_2/inc/class.imap_functions.inc.php

    r485 r504  
    4242        { 
    4343                $folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1"); 
    44                 $this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => imap_last_error()))); 
     44                $this->mbox = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error())))); 
    4545                return $this->mbox; 
    4646         } 
    4747 
     48        function parse_error($error){ 
     49                // This error is returned from Imap. 
     50                if(strstr($error,'Connection refused')) { 
     51                        return str_replace("%1", $this->functions->getLang("Mail"), $this->functions->getLang("Connection failed with %1 Server. Try later.")); 
     52                } 
     53                // This error is returned from Postfix. 
     54                elseif(strstr($error,'message file too big')) { 
     55                        return str_replace("%1", ini_get('upload_max_filesize'),$this->functions->getLang('The size of this message has exceeded  the limit (%1B).'));                   
     56                } 
     57                // This condition verifies if SESSION is expired. 
     58                elseif(!count($_SESSION))                        
     59                        return "nosession"; 
     60 
     61                return $error; 
     62        } 
     63         
    4864        function get_range_msgs2($params) 
    4965        { 
     
    833849                } 
    834850 
    835                 //$mbox_stream = $this->open_mbox($folder); 
    836                 $mbox_stream = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => imap_last_error()))); 
     851                //$mbox_stream = $this->open_mbox($folder);              
     852                $mbox_stream = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error())))); 
    837853                 
    838854                foreach ($msgs_number as $msg_number) 
     
    12591275                        } 
    12601276                        if( $total_uploaded_size > $upload_max_filesize) 
    1261                                 return 'false';                  
     1277                                return $this->parse_error("message file too big");                       
    12621278                }                        
    12631279//////////////////////////////////////////////////////////////////////////////////////////////////// 
     
    12921308                        $mail->ConfirmReadingTo = $_SESSION['phpgw_info']['expressomail']['user']['email']; 
    12931309//////////////////////////////////////////////////////////////////////////////////////////////////// 
     1310 
    12941311                $sent = $mail->Send(); 
     1312                 
    12951313                if(!$sent) 
    12961314                { 
    1297                         return $mail->ErrorInfo; 
     1315                        return $this->parse_error($mail->ErrorInfo); 
    12981316                } 
    12991317                else 
     
    15361554                                $userID         = $_SESSION['phpgw_info']['expressomail']['user']['userid'];                                                             
    15371555                                $server         = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer']; 
    1538                                 $mbox           = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}INBOX", $accountID, $pass) or die(serialize(array('imap_error' => imap_last_error()))); 
     1556                                $mbox           = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}INBOX", $accountID, $pass) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error())))); 
    15391557                                if(!$mbox) 
    15401558                                        return imap_last_error(); 
  • trunk/expressoMail1_2/inc/class.phpmailer.php

    r426 r504  
    345345     */ 
    346346    function Send() { 
     347         
     348     
    347349        $header = ""; 
    348350        $body = ""; 
     
    351353        if(((count($this->to) + count($this->cc) + count($this->bcc)) < 1) && (!$this->SaveMessageAsDraft)) 
    352354        { 
    353             $this->SetError($this->Lang("provide_address")); 
     355            $this->SetError($this->Lang("provide_address"));             
    354356            return false; 
    355357        } 
    356  
     358                 
    357359        // Set whether the message is multipart/alternative 
    358360        if(!empty($this->AltBody)) 
     
    379381                break; 
    380382            default: 
    381             $this->SetError($this->Mailer . $this->Lang("mailer_not_supported")); 
     383                    $this->SetError($this->Mailer . $this->Lang("mailer_not_supported")); 
    382384                $result = false; 
    383385                break; 
     
    11681170          case "base64": 
    11691171              // chunk_split is found in PHP >= 3.0.6 
    1170               $encoded = chunk_split(base64_encode($str), 76, $this->LE); 
     1172              $encoded = @chunk_split(base64_encode($str), 76, $this->LE); 
    11711173              break; 
    11721174          case "7bit": 
  • trunk/expressoMail1_2/js/main.js

    r485 r504  
    7777 
    7878 
    79 function show_msg(msg_info){ 
     79function show_msg(msg_info){     
    8080        if(!verify_session(msg_info)) 
    8181                return; 
     
    872872        } 
    873873        else{                    
    874                 if(data == 'false') 
     874                if(data == 'Post-Content-Length') 
    875875                        write_msg(get_lang('The size of this message has exceeded  the limit (%1B).',Element('upload_max_filesize').value)); 
    876                 else if(data == null) 
    877                         write_msg(get_lang("your session could not be verified.")); 
     876                else if(data) 
     877                        write_msg(data); 
    878878                else 
    879                         write_msg(data); 
     879                        write_msg(get_lang("Connection failed with %1 Server. Try later.", "Web")); 
    880880        } 
    881881} 
     
    13661366 
    13671367function verify_session(data){ 
     1368 
    13681369        if(data && data.imap_error) { 
    1369                 write_msg(get_lang("your session could not be verified.")); 
    1370                 // Hold session for edit message. 
    1371                 if(!hold_session) 
    1372                         location.href="../login.php?cd=10&phpgw_forward=%2FexpressoMail1_2%2Findex.php"; 
     1370                if(data.imap_error == "nosession") 
     1371                        write_msg(get_lang("your session could not be verified.")); 
     1372                else 
     1373                        write_msg(data.imap_error); 
     1374                // Hold sesion for edit message. 
     1375                //if(!hold_session) 
     1376                //      location.href="../login.php?cd=10&phpgw_forward=%2FexpressoMail1_2%2Findex.php";                 
    13731377                return false; 
    13741378        } 
Note: See TracChangeset for help on using the changeset viewer.