imap.php.tmp
来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· TMP 代码 · 共 1,840 行 · 第 1/4 页
TMP
1,840 行
} if( strtoupper( $ret["RESPONSE"]["CODE"]) != "OK" ){ // if the error is that the user does not have quota set return an array // and not pear error if( substr(strtoupper($ret["RESPONSE"]["STR_CODE"]),0,5) == "QUOTA" ){ return array('USED'=>'NOT SET', 'QMAX'=>'NOT SET'); } return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]); } if( isset( $ret['PARSED']['EXT']['QUOTA']['STORAGE'] ) ){ return $ret['PARSED']['EXT']['QUOTA']['STORAGE']; } return array('USED'=>'NOT SET', 'QMAX'=>'NOT SET'); } /** * Returns MESSAGES quota details * @param string $mailbox_name Mailbox to get quota info. * @return assoc array contaning the quota info on success or PEAR_Error * * @access public * @since 1.0 */ function getMessagesQuota($mailbox_name = null ) { if($mailbox_name == null){ $mailbox_name = $this->getCurrentMailbox(); } if ( PEAR::isError( $ret = $this->cmdGetQuota($mailbox_name) ) ) { return new PEAR_Error($ret->getMessage()); } if( strtoupper( $ret["RESPONSE"]["CODE"]) != "OK" ){ // if the error is that the user does not have quota set return an array // and not pear error if( substr(strtoupper($ret["RESPONSE"]["STR_CODE"]),0,5) == "QUOTA" ){ return array('USED'=>'NOT SET', 'QMAX'=>'NOT SET'); } return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]); } if( isset( $ret['PARSED']['EXT']['QUOTA']['MESSAGES'] ) ){ return $ret['PARSED']['EXT']['QUOTA']['MESSAGES']; } return array('USED'=>'NOT SET', 'QMAX'=>'NOT SET'); } /** * sets STORAGE quota details * @param string $mailbox_name Mailbox to get quota info. * @return true on success or PEAR_Error * * @access public * @since 1.0 */ function setStorageQuota($mailbox_name, $quota) { if ( PEAR::isError( $ret = $this->cmdSetQuota($mailbox_name,$quota) ) ) { return new PEAR_Error($ret->getMessage()); } if( strtoupper( $ret["RESPONSE"]["CODE"]) != "OK" ){ return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]); } return true; } /** * sets MESSAGES quota details * @param string $mailbox_name Mailbox to get quota info. * @return true on success or PEAR_Error * * @access public * @since 1.0 */ function setMessagesQuota($mailbox_name, $quota) { if ( PEAR::isError( $ret = $this->cmdSetQuota($mailbox_name,'',$quota) ) ) { return new PEAR_Error($ret->getMessage()); } if( strtoupper( $ret["RESPONSE"]["CODE"]) != "OK" ){ return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]); } return true; } /****************************************************************** ** ** ** ACL METHODS ** ** ** ******************************************************************/ /** * get the Access Control List details * @param string $mailbox_name Mailbox to get ACL info. * @return string on success or PEAR_Error * * @access public * @since 1.0 */ function getACL($mailbox_name = null ) { if($mailbox_name == null){ $mailbox_name = $this->getCurrentMailbox(); } if ( PEAR::isError( $ret = $this->cmdGetACL($mailbox_name) ) ) { return new PEAR_Error($ret->getMessage()); } if( strtoupper( $ret["RESPONSE"]["CODE"]) != "OK" ){ return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]); } if( isset($ret['PARSED']['USERS']) ){ return $ret['PARSED']['USERS']; }else{ return false; } } /** * Set ACL on a mailbox * * @param string $mailbox_name the mailbox * @param string $user user to set the ACL * @param string $acl ACL list * @return mixed True on success, or PEAR_Error on false * * @access public * @since 1.0 */ function setACL($mailbox_name, $user, $acl) { if ( PEAR::isError( $ret = $this->cmdSetACL($mailbox_name, $user, $acl) ) ) { return new PEAR_Error($ret->getMessage()); } if( strtoupper( $ret["RESPONSE"]["CODE"]) != "OK" ){ return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]); } return true; } /** * deletes the ACL on a mailbox * * @param string $mailbox_name the mailbox * @param string $user user to set the ACL * @return mixed True on success, or PEAR_Error on false * * @access public * @since 1.0 */ function deleteACL($mailbox_name, $user) { if ( PEAR::isError( $ret = $this->cmdDeleteACL($mailbox_name, $user) ) ) { return new PEAR_Error($ret->getMessage()); } if( strtoupper( $ret["RESPONSE"]["CODE"]) != "OK" ){ return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]); } return true; } /** * returns the rights that the user logged on has on the mailbox * this method can be used by any user, not only the administrator * * @param string $mailbox_name the mailbox to query rights * @return mixed string contailing the list of rights on success, or PEAR_Error on failure * * @access public * @since 1.0 */ function getMyRights($mailbox_name = null) { if($mailbox_name == null){ $mailbox_name = $this->getCurrentMailbox(); } if ( PEAR::isError( $ret = $this->cmdMyRights($mailbox_name) ) ) { return new PEAR_Error($ret->getMessage()); } if( strtoupper( $ret["RESPONSE"]["CODE"]) != "OK" ){ return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]); } if(isset($ret['PARSED']['GRANTED'])){ return $ret['PARSED']['GRANTED']; } return new PEAR_Error('Bogus response from server!' ); } /** * returns an array containing the rights that a user logged on has on the mailbox * this method can be used by any user, not only the administrator * * @param string $mailbox_name the mailbox to query rights * @return mixed string contailing the list of rights on success, or PEAR_Error on failure * * @access public * @since 1.0 */ function getACLRights($user,$mailbox_name = null) { if($mailbox_name == null){ $mailbox_name = $this->getCurrentMailbox(); } if ( PEAR::isError( $ret = $this->cmdListRights($mailbox_name, $user) ) ) { return new PEAR_Error($ret->getMessage()); } if( strtoupper( $ret["RESPONSE"]["CODE"]) != "OK" ){ return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]); } if(isset($ret['PARSED']['GRANTED'])){ return $ret['PARSED']['GRANTED']; } return new PEAR_Error('Bogus response from server!' ); } /****************************************************************** ** ** ** ANNOTATEMORE METHODS ** ** ** ******************************************************************/ function setAnnotation($entry, $values, $mailbox_name = null ) { if($mailbox_name == null){ $mailbox_name = $this->getCurrentMailbox(); } if (PEAR::isError($ret = $this->cmdSetAnnotation($mailbox_name, $entry, $values))) { return new PEAR_Error($ret->getMessage()); } if (strtoupper($ret['RESPONSE']['CODE']) != 'OK') { return new PEAR_Error($ret['RESPONSE']['CODE'] . ', ' . $ret['RESPONSE']['STR_CODE']); } return true; } function deleteAnnotation($entry, $values, $mailbox_name = null ) { if($mailbox_name == null){ $mailbox_name = $this->getCurrentMailbox(); } if (PEAR::isError($ret = $this->cmdDeleteAnnotation($mailbox_name, $entry, $values))) { return new PEAR_Error($ret->getMessage()); } if (strtoupper($ret['RESPONSE']['CODE']) != 'OK') { return new PEAR_Error($ret['RESPONSE']['CODE'] . ', ' . $ret['RESPONSE']['STR_CODE']); } return true; } function getAnnotation($entries, $values, $mailbox_name = null) { if($mailbox_name == null){ $mailbox_name = $this->getCurrentMailbox(); } if (!is_array($entries)) { $entries = array($entries); } if (!is_array($values)) { $values = array($values); } if (PEAR::isError($ret = $this->cmdGetAnnotation($mailbox_name, $entries, $values))) { return new PEAR_Error($ret->getMessage()); } if (strtoupper($ret['RESPONSE']['CODE']) != 'OK') { return new PEAR_Error($ret['RESPONSE']['CODE'] . ', ' . $ret['RESPONSE']['STR_CODE']); } $ret_aux = array(); if (isset($ret['PARSED'])) { foreach ($ret['PARSED'] as $mbox) { $rawvalues = $mbox['EXT']['ATTRIBUTES']; $values = array(); for ($i = 0; $i < count($rawvalues); $i += 2) { $values[$rawvalues[$i]] = $rawvalues[$i + 1]; } $mbox['EXT']['ATTRIBUTES'] = $values; $ret_aux[] = $mbox['EXT']; } } if (count($ret_aux) == 1 && $ret_aux[0]['MAILBOX'] == $mailbox_name) { if (count($entries) == 1 && $ret_aux[0]['ENTRY'] == $entries[0]) { if (count($ret_aux[0]['ATTRIBUTES']) == 1 && count($values) == 1) { $attrs = array_keys($ret_aux[0]['ATTRIBUTES']); $vals = array_keys($values); if ($attrs[0] == $vals[0]) { return $ret_aux[0]['ATTRIBUTES'][$attrs[0]]; } } } } return $ret_aux; } /* * Transform an array to a list to be used in the cmdFetch method * */ function _getSearchListFromArray($arr){ $txt=implode(',' , $arr); return $txt; } /***************************************************** Net_POP3 Compatibility functions: Warning!!! Those functions could dissapear in the future *********************************************************/ function getSize(){ return $this->getMailboxSize(); } function numMsg($mailbox = null){ return $this->getNumberOfMessages($mailbox); } /* * Returns the entire message with given message number. * * @param $msg_id Message number * @return mixed Either entire message or false on error */ function getMsg($msg_id) { $ret=$this->getMessages($msg_id,false); // false means that getMessages() must not use the msg number as array key if(isset($ret[0])){ return $ret[0]; }else{ return $ret; } } function getListing($msg_id = null) { return $this->getMessagesList($msg_id); } function deleteMsg($msg_id){ return $this->deleteMessages($msg_id); }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?