Changeset bdab2c5 in github


Ignore:
Timestamp:
Sep 20, 2009 6:25:14 AM (4 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
104a14d
Parents:
67bb96f
Message:
  • small code improvements
Location:
program
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcmail.php

    rb48d9bf rbdab2c5  
    379379    // using NAMESPACE and LIST  
    380380    $options = array( 
    381       'imap' => $this->config->get('imap_auth_type', 'check'), 
     381      'auth_method' => $this->config->get('imap_auth_type', 'check'), 
    382382      'delimiter' => isset($_SESSION['imap_delimiter']) ? $_SESSION['imap_delimiter'] : $this->config->get('imap_delimiter'), 
    383383      'rootdir' => isset($_SESSION['imap_root']) ? $_SESSION['imap_root'] : $this->config->get('imap_root'), 
  • program/include/rcube_imap.php

    r59395e7 rbdab2c5  
    7070  var $debug_level = 1; 
    7171  var $error_code = 0; 
    72   var $options = array('imap' => 'check'); 
     72  var $options = array('auth_method' => 'check'); 
    7373   
    7474  private $host, $user, $pass, $port, $ssl; 
  • program/lib/imap.inc

    r587444f rbdab2c5  
    304304        $a = explode(' ', trim($string)); 
    305305        if (count($a) >= 2) { 
    306                 if (strcasecmp($a[1], 'OK') == 0) { 
     306                $res = strtoupper($a[1]); 
     307                if ($res == 'OK') { 
    307308                        return 0; 
    308                 } else if (strcasecmp($a[1], 'NO') == 0) { 
     309                } else if ($res == 'NO') { 
    309310                        return -1; 
    310                 } else if (strcasecmp($a[1], 'BAD') == 0) { 
     311                } else if ($res == 'BAD') { 
    311312                        return -2; 
    312                 } else if (strcasecmp($a[1], 'BYE') == 0) { 
     313                } else if ($res == 'BYE') { 
    313314                        return -3; 
    314315                } 
     
    556557                foreach($options as $optkey => $optval) { 
    557558                        if ($optkey == 'imap') { 
    558                                 $auth_method = $optval; 
     559                                $auth_method = strtoupper($optval); 
    559560                        } else if ($optkey == 'rootdir') { 
    560561                                $my_prefs['rootdir'] = $optval; 
     
    568569 
    569570        if (empty($auth_method)) 
    570                 $auth_method = 'check'; 
     571                $auth_method = 'CHECK'; 
    571572                 
    572573        $message = "INITIAL: $auth_method\n"; 
     
    666667        } 
    667668 
    668         if (strcasecmp($auth_method, "check") == 0) { 
     669        if ($auth_method == 'CHECK') { 
    669670                //check for supported auth methods 
    670671                if (iil_C_GetCapability($conn, 'AUTH=CRAM-MD5') || iil_C_GetCapability($conn, 'AUTH=CRAM_MD5')) { 
    671                         $auth_method = 'auth'; 
     672                        $auth_method = 'AUTH'; 
    672673                } 
    673674                else { 
    674675                        //default to plain text auth 
    675                         $auth_method = 'plain'; 
    676                 } 
    677         } 
    678  
    679         if (strcasecmp($auth_method, 'auth') == 0) { 
    680                 $conn->message .= "Trying CRAM-MD5\n"; 
    681  
     676                        $auth_method = 'PLAIN'; 
     677                } 
     678        } 
     679 
     680        if ($auth_method == 'AUTH') { 
    682681                //do CRAM-MD5 authentication 
    683682                iil_PutLine($conn->fp, "a000 AUTHENTICATE CRAM-MD5"); 
    684683                $line = trim(iil_ReadLine($conn->fp, 1024)); 
    685684 
    686                 $conn->message .= "$line\n"; 
    687  
    688685                if ($line[0] == '+') { 
    689                         $conn->message .= 'Got challenge: ' . htmlspecialchars($line) . "\n"; 
    690  
    691686                        //got a challenge string, try CRAM-5 
    692687                        $result = iil_C_Authenticate($conn, $user, $password, substr($line,2)); 
     
    698693                                return false; 
    699694                        } 
    700                         $conn->message .= "Tried CRAM-MD5: $result \n"; 
     695                        $conn->message .= "AUTH CRAM-MD5: $result\n"; 
    701696                } else { 
    702                         $conn->message .='No challenge ('.htmlspecialchars($line)."), try plain\n"; 
    703                         $auth = 'plain'; 
     697                        $conn->message .= "AUTH CRAM-MD5: failed\n"; 
     698                        $auth_method = 'PLAIN'; 
    704699                } 
    705700        } 
    706701                 
    707         if (!$result || strcasecmp($auth, "plain") == 0) { 
     702        if (!$result || $auth_method == 'PLAIN') { 
    708703                //do plain text auth 
    709704                $result = iil_C_Login($conn, $user, $password); 
    710                 $conn->message .= "Tried PLAIN: $result \n"; 
     705                $conn->message .= "AUTH PLAIN: $result\n"; 
    711706        } 
    712707                 
    713         $conn->message .= $auth; 
    714                          
    715708        if (!is_int($result)) { 
    716709                iil_C_Namespace($conn); 
     
    780773                return false; 
    781774        } 
    782         if (strcmp($conn->selected, $mailbox) == 0) { 
     775        if ($conn->selected == $mailbox) { 
    783776                return true; 
    784777        } 
     
    789782                        $a = explode(' ', $line); 
    790783                        if (count($a) == 3) { 
    791                                 if (strcasecmp($a[2], 'EXISTS') == 0) { 
     784                                $token = strtoupper($a[2]); 
     785                                if ($token == 'EXISTS') { 
    792786                                        $conn->exists = (int) $a[1]; 
    793787                                } 
    794                                 else if (strcasecmp($a[2], 'RECENT') == 0) { 
     788                                else if ($token == 'RECENT') { 
    795789                                        $conn->recent = (int) $a[1]; 
    796790                                } 
     
    800794                        } 
    801795                } while (!iil_StartsWith($line, 'sel1', true)); 
    802  
    803                 $a = explode(' ', $line); 
    804796 
    805797                if (strcasecmp($a[1], 'OK') == 0) { 
     
    14781470                                if ($parts_count>=6) { 
    14791471                                        for ($i=0; $i<$parts_count; $i=$i+2) { 
    1480                                                 if (strcasecmp($a[$i],'UID') == 0) 
     1472                                                if ($a[$i] == 'UID') 
    14811473                                                        $result[$id]->uid = $a[$i+1]; 
    1482                                                 else if (strcasecmp($a[$i],'RFC822.SIZE') == 0) 
     1474                                                else if ($a[$i] == 'RFC822.SIZE') 
    14831475                                                        $result[$id]->size = $a[$i+1]; 
    1484                                                 else if (strcasecmp($a[$i],'INTERNALDATE') == 0) 
     1476                                                else if ($a[$i] == 'INTERNALDATE') 
    14851477                                                        $time_str = $a[$i+1]; 
    1486                                                 else if (strcasecmp($a[$i],'FLAGS') == 0) 
     1478                                                else if ($a[$i] == 'FLAGS') 
    14871479                                                        $flags_str = $a[$i+1]; 
    14881480                                        } 
     
    16451637                                         
    16461638                                if (is_array($flags_a)) { 
    1647                                         reset($flags_a); 
    1648                                         while (list(,$val)=each($flags_a)) { 
    1649                                                 if (strcasecmp($val,'Seen') == 0) { 
     1639                                //      reset($flags_a); 
     1640                                        foreach($flags_a as $flag) { 
     1641                                                $flag = strtoupper($flag); 
     1642                                                if ($flag == 'SEEN') { 
    16501643                                                    $result[$id]->seen = true; 
    1651                                                 } else if (strcasecmp($val, 'Deleted') == 0) { 
    1652                                                     $result[$id]->deleted=true; 
    1653                                                 } else if (strcasecmp($val, 'Recent') == 0) { 
     1644                                                } else if ($flag == 'DELETED') { 
     1645                                                    $result[$id]->deleted = true; 
     1646                                                } else if ($flag == 'RECENT') { 
    16541647                                                    $result[$id]->recent = true; 
    1655                                                 } else if (strcasecmp($val, 'Answered') == 0) { 
     1648                                                } else if ($flag == 'ANSWERED') { 
    16561649                                                        $result[$id]->answered = true; 
    1657                                                 } else if (strcasecmp($val, '$Forwarded') == 0) { 
     1650                                                } else if ($flag == '$FORWARDED') { 
    16581651                                                        $result[$id]->forwarded = true; 
    1659                                                 } else if (strcasecmp($val, 'Draft') == 0) { 
     1652                                                } else if ($flag == 'DRAFT') { 
    16601653                                                        $result[$id]->is_draft = true; 
    1661                                                 } else if (strcasecmp($val, '$MDNSent') == 0) { 
     1654                                                } else if ($flag == '$MDNSENT') { 
    16621655                                                        $result[$id]->mdn_sent = true; 
    1663                                                 } else if (strcasecmp($val, 'Flagged') == 0) { 
     1656                                                } else if ($flag == 'FLAGGED') { 
    16641657                                                         $result[$id]->flagged = true; 
    16651658                                                } 
Note: See TracChangeset for help on using the changeset viewer.