imapprotocol.php.svn-base

来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· SVN-BASE 代码 · 共 2,517 行 · 第 1/5 页

SVN-BASE
2,517
字号
            if( $messagesQuota != null ){                //if we have both types of quota on the same call we must append an space between                // those parameters                $param=sprintf("%s ",$param);            }        }        if($messagesQuota != null ){            $param=sprintf("%sMESSAGES %s",$param,$messagesQuota);        }        $param=sprintf("%s)",$param);        return $this->_genericCommand('SETQUOTAROOT', $param );    }/***********************************************************************             RFC2087 IMAP4 QUOTA extension ENDS HERE********************************************************************//***********************************************************************             RFC2086 IMAP4 ACL extension BEGINS HERE********************************************************************/    function cmdSetACL($mailbox_name, $user, $acl)    {        //Check if the IMAP server has ACL support        if( ! $this->hasAclSupport() ){            return new PEAR_Error("This IMAP server does not support ACL's! ");        }        $mailbox_name=sprintf("\"%s\"",$this->utf_7_encode($mailbox_name) );        $user_name=sprintf("\"%s\"",$this->utf_7_encode($user) );        if(is_array($acl)){            $acl=implode('',$acl);        }        return $this->_genericCommand('SETACL', sprintf("%s %s \"%s\"",$mailbox_name,$user_name,$acl) );    }    function cmdDeleteACL($mailbox_name, $user)    {        //Check if the IMAP server has ACL support        if( ! $this->hasAclSupport() ){            return new PEAR_Error("This IMAP server does not support ACL's! ");        }        $mailbox_name=sprintf("\"%s\"",$this->utf_7_encode($mailbox_name) );                return $this->_genericCommand('DELETEACL', sprintf("%s \"%s\"",$mailbox_name,$user) );    }    function cmdGetACL($mailbox_name)    {        //Check if the IMAP server has ACL support        if( ! $this->hasAclSupport() ){            return new PEAR_Error("This IMAP server does not support ACL's! ");        }        $mailbox_name=sprintf("\"%s\"",$this->utf_7_encode($mailbox_name) );        $ret = $this->_genericCommand('GETACL', sprintf("%s",$mailbox_name) );        if(isset( $ret["PARSED"] ) ){            $ret['PARSED']=$ret["PARSED"][0]["EXT"];        }        return $ret;   }    function cmdListRights($mailbox_name, $user)    {        //Check if the IMAP server has ACL support        if( ! $this->hasAclSupport() ){            return new PEAR_Error("This IMAP server does not support ACL's! ");        }        $mailbox_name=sprintf("\"%s\"",$this->utf_7_encode($mailbox_name) );        $ret = $this->_genericCommand('LISTRIGHTS', sprintf("%s \"%s\"",$mailbox_name,$user) );        if(isset( $ret["PARSED"] ) ){            $ret["PARSED"]=$ret["PARSED"][0]["EXT"];        }        return $ret;    }    function cmdMyRights($mailbox_name)    {        //Check if the IMAP server has ACL support        if( ! $this->hasAclSupport() ){            return new PEAR_Error("This IMAP server does not support ACL's! ");        }        $mailbox_name=sprintf("\"%s\"",$this->utf_7_encode($mailbox_name) );        $ret = $this->_genericCommand('MYRIGHTS', sprintf("%s",$mailbox_name) );        if(isset( $ret["PARSED"] ) ){            $ret["PARSED"]=$ret["PARSED"][0]["EXT"];        }        return $ret;    }/***********************************************************************             RFC2086 IMAP4 ACL extension ENDs HERE********************************************************************//**********************************************************************************  draft-daboo-imap-annotatemore-05 IMAP4 ANNOTATEMORE extension BEGINS HERE********************************************************************************/    function cmdSetAnnotation($mailbox_name, $entry, $values)    {        // Check if the IMAP server has ANNOTATEMORE support        if(!$this->hasAnnotateMoreSupport()) {            return new PEAR_Error('This IMAP server does not support the ANNOTATEMORE extension!');        }        if (!is_array($values)) {            return new PEAR_Error('Invalid $values argument passed to cmdSetAnnotation');        }        $vallist = '';        foreach ($values as $name => $value) {            $vallist .= "\"$name\" \"$value\" ";        }        $vallist = rtrim($vallist);        return $this->_genericCommand('SETANNOTATION', sprintf('"%s" "%s" (%s)', $mailbox_name, $entry, $vallist));    }    function cmdDeleteAnnotation($mailbox_name, $entry, $values)    {        // Check if the IMAP server has ANNOTATEMORE support        if(!$this->hasAnnotateMoreSupport()) {            return new PEAR_Error('This IMAP server does not support the ANNOTATEMORE extension!');        }        if (!is_array($values)) {            return new PEAR_Error('Invalid $values argument passed to cmdDeleteAnnotation');        }        $vallist = '';        foreach ($values as $name) {            $vallist .= "\"$name\" NIL ";        }        $vallist = rtrim($vallist);        return $this->_genericCommand('SETANNOTATION', sprintf('"%s" "%s" (%s)', $mailbox_name, $entry, $vallist));    }    function cmdGetAnnotation($mailbox_name, $entries, $values)    {        // Check if the IMAP server has ANNOTATEMORE support        if(!$this->hasAnnotateMoreSupport()) {            return new PEAR_Error('This IMAP server does not support the ANNOTATEMORE extension!');        }        $entlist = '';       if (!is_array($entries)) {            $entries = array($entries);       }        foreach ($entries as $name) {            $entlist .= "\"$name\" ";        }        $entlist = rtrim($entlist);        if (count($entries) > 1) {            $entlist = "($entlist)";        }        $vallist = '';        if (!is_array($values)) {            $values = array($values);        }        foreach ($values as $name) {            $vallist .= "\"$name\" ";        }        $vallist = rtrim($vallist);        if (count($values) > 1) {            $vallist = "($vallist)";        }        return $this->_genericCommand('GETANNOTATION', sprintf('"%s" %s %s', $mailbox_name, $entlist, $vallist));   }/********************************************************************************  draft-daboo-imap-annotatemore-05 IMAP4 ANNOTATEMORE extension ENDs HERE******************************************************************************//**************************************************************************             HERE ENDS THE EXTENSIONS FUNCTIONS***             AND BEGIN THE AUXILIARY FUNCTIONS***********************************************************************/    /**    * tell if the server has capability $capability    *    * @return true or false    *    * @access public    * @since  1.0    */    function getServerAuthMethods()    {        if( $this->_serverAuthMethods == null ){            $this->cmdCapability();            return $this->_serverAuthMethods;        }        return false;    }    /**    * tell if the server has capability $capability    *    * @return true or false    *    * @access public    * @since  1.0    */    function hasCapability($capability)    {        if( $this->_serverSupportedCapabilities == null ){            $this->cmdCapability();        }        if($this->_serverSupportedCapabilities != null ){            if( in_array( $capability , $this->_serverSupportedCapabilities ) ){                return true;            }        }        return false;    }    /**    * tell if the server has Quota support    *    * @return true or false    *    * @access public    * @since  1.0    */    function hasQuotaSupport()    {        return $this->hasCapability('QUOTA');    }    /**    * tell if the server has Quota support    *    * @return true or false    *    * @access public    * @since  1.0    */    function hasAclSupport()    {        return $this->hasCapability('ACL');    }    /**    * tell if the server has support for the ANNOTATEMORE extension    *    * @return true or false    *    * @access public    * @since  1.0    */    function hasAnnotateMoreSupport()    {        return $this->hasCapability('ANNOTATEMORE');    }    /**    * Parses the responses like RFC822.SIZE and INTERNALDATE    *    * @param string the IMAP's server response    *    * @return string containing  the parsed response    * @access private    * @since  1.0    */    function _parseOneStringResponse(&$str, $line,$file)    {        $this->_parseSpace($str , $line , $file );        $size = $this->_getNextToken($str,$uid);        return $uid;    }    /**    * Parses the FLAG response    *    * @param string the IMAP's server response    *    * @return Array containing  the parsed  response    * @access private    * @since  1.0    */    function _parseFLAGSresponse(&$str)    {        $this->_parseSpace($str , __LINE__ , __FILE__ );        $params_arr[] = $this->_arrayfy_content($str);        $flags_arr=array();        for( $i = 0 ; $i < count($params_arr[0]) ; $i++ ){            $flags_arr[] = $params_arr[0][$i];        }        return $flags_arr;    }    /**    * Parses the BODY response    *    * @param string the IMAP's server response    *    * @return Array containing  the parsed  response    * @access private    * @since  1.0    */    function _parseBodyResponse(&$str, $command){            $this->_parseSpace($str , __LINE__ , __FILE__ );            while($str[0] != ')' && $str!=''){                $params_arr[] = $this->_arrayfy_content($str);            }            return $params_arr;    }    /**    * Makes the content an Array    *    * @param string the IMAP's server response    *    * @return Array containing  the parsed  response    * @access private    * @since  1.0    */    function _arrayfy_content(&$str)    {        $params_arr=array();        $this->_getNextToken($str,$params);        if($params != '(' ){            return $params;        }        $this->_getNextToken($str,$params,false,false);        while ( $str != '' && $params != ')'){                if($params != '' ){                    if($params[0] == '(' ){                        $params=$this->_arrayfy_content( $params );                    }                    if($params != ' ' ){                        //I don't remove the colons (") to handle the case of retriving " "                        // If I remove the colons the parser will interpret this field as an imap separator (space)                        // instead of a valid field so I remove the colons here                        if($params=='""'){                            $params='';                        }else{                            if($params[0]=='"'){                                $params=substr($params,1,strlen($params)-2);                            }                        }                        $params_arr[]=$params;                    }                }else{                    //if params if empty (for example i'm parsing 2 quotes ("")                    // I'll append an array entry to mantain compatibility                    $params_arr[]=$params;                }                $this->_getNextToken($str,$params,false,false);        }        return $params_arr;    }    /**    * Parses the BODY[],BODY[TEXT],.... responses    *    * @param string the IMAP's server response    *    * @return Array containing  the parsed  response    * @access private    * @since  1.0    */    function _parseContentresponse(&$str, $command)    {        $content = '';        $this->_parseSpace($str , __LINE__ , __FILE__ );        $size  =$this->_getNextToken($str,$content);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?