PHP操作IMAP服务器的类
服务器
我认为是相当经典的,帮过我大忙,可以实现很多PHP的IMAP函数不能实现的功能。以前在广州站贴过,那时北京站还没PHP版,现在再贴一个吧。:)
/*************************************************************
File: cyradm.inc.php
Author: 忘了,嘻嘻
Date: 2000-11-01
This is a completely new implementation of the IMAP Access for
PHP. It is based on a socket connection to the server an is
independent from the imap-Functions of PHP
***************************************************************/
class cyradm {
var $host;
var $port;
var $mbox;
var $list;
var $admin;
var $pass;
var $fp;
var $line;
var $error_msg;
/*
#
#Konstruktor
#
*/
function cyradm($IMAP_HOST="localhost", $IMAP_ADMIN="", $IMAP_PW="", $IMAP_PORT="143"){
$this->host = $IMAP_HOST;
$this->port = $IMAP_PORT;
$this->mbox = "";
$this->list = array();
$this->admin = $IMAP_ADMIN;
$this->pass = $IMAP_PW;
$this->fp = 0;
$this->line = "";
$this->error_msg = "";
}
/*
#
# SOCKETLOGIN on Server via Telnet-Connection!
#
*/
function imap_login() {
$this->fp = fsockopen($this->host, $this->port, &$errno, &$errstr);
$this->error_msg=$errstr;
if(!$this->fp) {
echo "
ERRORNO: ($errno)
ERRSTR: ($errstr)
\n";
} else {
$this->command(". login \"$this->admin\" \"$this->pass\"");
}
return $errno;
}
/*
#
# SOCKETLOGOUT from Server via Telnet-Connection!
#
*/
function imap_logout() {
$this->command(". logout");
fclose($this->fp);
}
/*
#
# SENDING COMMAND to Server via Telnet-Connection!
#
*/
function command($line) {
/* print ("$line
"); */
$result = array();
$i=0; $f=0;
$returntext="";
$r = fputs($this->fp,"$line\n");
while (!((strstr($returntext,". OK")||(strstr($returntext,". NO"))||(strstr($returntext,". BAD")))))
{
$returntext=$this->getline();
/* print ("$returntext
"); */
if ($returntext)
{
if (!((strstr($returntext,". OK")||(strstr($returntext,". NO"))||(strstr($returntext,". BAD")))))
{
$result[$i]=$returntext;
}
$i++;
}
}
if (strstr($returntext,". BAD")||(strstr($returntext,". NO")))
{
$result[0]="$returntext";
$this->error_msg = $returntext;
if (( strstr($returntext,". NO Quota") ))
{
}
else
{
print "
UNEXPECTED IMAP-SERVER-ERROR
SENT COMMAND: | $line |
SERVER RETURNED: | |
$result[$i] |
";
}
}
return $result;
}
/*
#
# READING from Server via Telnet-Connection!
#
*/
function getline() {
$this->line = fgets($this->fp, 256);
return $this->line;
}
/*
#
# QUOTA Functions
#
*/
// GETTING QUOTA
function getquota($mb_name) {
$output=$this->command(". getquota \"$mb_name\"");
if (strstr($output[0],". NO"))
{
$ret["used"] = "NOT-SET";
$ret["qmax"] = "NOT-SET";
}
else
{
$realoutput = str_replace(")", "", $output[0]);
$tok_list = split(" ",$realoutput);
$si_used=sizeof($tok_list)-2;
$si_max=sizeof($tok_list)-1;
$ret["used"] = str_replace(")","",$tok_list[$si_used]);
$ret["qmax"] = $tok_list[$si_max];
}
return $ret;
}
// SETTING QUOTA
function setmbquota($mb_name, $quota) {
$this->command(". setquota \"$mb_name\" (STORAGE $quota)");
}
/*
#
# MAILBOX Functions
#
*/
function createmb($mb_name, $mb_partition="") {
$this->command(". create \"$mb_name\" $mb_partition");
}
function deletemb($mb_name) {
$this->command(". setacl \"$mb_name\" $this->admin d");
$this->command(". delete \"$mb_name\"");
}
function renamemb($mb_name, $newmbname) {
$all="lrswipcda";
$this->setacl($mb_name, $this->admin,$all);
$this->command(". rename \"$mb_name\" \"$newmbname\"");
$this->deleteacl($newmbname, $this->admin);
}
function renameuser($from_mb_name, $to_mb_name) {
$all="lrswipcda"; $find_out=array(); $split_res=array(); $owner=""; $oldowner="";
/* Anlegen und Kopieren der INBOX */
$this->createmb($to_mb_name);
$this->setacl($to_mb_name, $this->admin,$all);
$this->copymailsfromfolder($from_mb_name, $to_mb_name);
/* Quotas uebernehmen */
$quota=$this->getquota($from_mb_name);
$oldquota=trim($quota["qmax"]);
if (strcmp($oldquota,"NOT-SET")!=0) {
$this->setmbquota($to_mb_name, $oldquota);
}
/* Den Rest Umbenennen */
$username=str_replace(".","/",$from_mb_name);
$split_res=explode(".", $to_mb_name);
if (strcmp($split_res[0],"user")==0) {
$owner=$split_res[1];
}
$split_res=explode(".", $from_mb_name);
if (strcmp($split_res[0],"user")==0) {
$oldowner=$split_res[1];
}
$find_out=$this->GetFolders($username);
for ($i=0; $i
if (strcmp($find_out[$i],$username)!=0) {
$split_res=split("$username",$find_out[$i]);
$split_res[1]=str_replace("/",".",$split_res[1]);
$this->renamemb((str_replace("/",".",$find_out[$i])), ("$to_mb_name"."$split_res[1]"));
if ($owner) {
$this->setacl(("$to_mb_name"."$split_res[1]"),$owner,$all);
}
if ($oldowner) {
$this->deleteacl(("$to_mb_name"."$split_res[1]"),$oldowner);
}
};
}
$this->deleteacl($to_mb_name, $this->admin);
$this->imap_logout();
$this->imap_login();
$this->deletemb($from_mb_name);
}
function copymailsfromfolder($from_mb_name, $to_mb_name) {
$com_ret=array();
$find_out=array();
$all="lrswipcda";
$mails=0;
$this->setacl($from_mb_name, $this->admin,$all);
$com_ret=$this->command(". select $from_mb_name");
for ($i=0; $i if (strstr( $com_ret[$i], "EXISTS"))
{
$findout=explode(" ", $com_ret[$i]);
$mails=$findout[1];
}
}
if ( $mails != 0 ) {
$com_ret=$this->command(". copy 1:$mails $to_mb_name");
for ($i=0; $i print "$com_ret[$i]
";
}
}
$this->deleteacl($from_mb_name, $this->admin);
}
/*
#
# ACL Functions
#
*/
function setacl($mb_name, $user, $acl) {
$this->command(". setacl \"$mb_name\" \"$user\" $acl");
}
function deleteacl($mb_name, $user) {
$result=$this->command(". deleteacl \"$mb_name\" \"$user\"");
}
function getacl($mb_name) {
$aclflag=1; $tmp_pos=0;
$output = $this->command(". getacl \"$mb_name\"");
$output = explode(" ", $output[0]);
$i=count($output)-1;
while ($i>3) {
if (strstr($output[$i],'"')) {
$i++;
}
if (strstr($output[$i-1],'"')) {
$aclflag=1;
$lauf=$i-1;
$spacestring=$output[$lauf];
$tmp_pos=$i;
$i=$i-2;
while ($aclflag!=0)
{
$spacestring=$output[$i]." ".$spacestring;
if (strstr($output[$i],'"')) { $aclflag=0; }
$i--;
}
$spacestring=str_replace("\"","",$spacestring);
if ($i>2) {
$ret[$spacestring] = $output[$tmp_pos];
}
}
else
{
$ret[$output[$i-1]] = $output[$i];
$i = $i - 2;
}
}
return $ret;
}
/*
#
# Folder Functions
#
*/
function GetFolders($username){
$username=str_replace("/",".",$username);
$output = $this->command(". list \"$username\" *");
for ($i=0; $i $splitfolder=split("\"",$output[$i]);
$output[$i]=str_replace(".","/",$splitfolder[3]);
}
return $output;
}
function EGetFolders($username){
$lastfolder=split("/",$username);
$position=count($lastfolder)-1;
$last=$lastfolder[$position];
$username=str_replace("/",".",$username);
$output = $this->command(". list \"$username\" *");
for ($i=0; $i $splitfolder=split("\"",$output[$i]);
$currentfolder=split("\.",$splitfolder[3]);
$current=$currentfolder[$position];
// echo "
FOLDER:($) CURRENTFOLDER:($splitfolder[3]) CURRENT:($current) LAST:($last) POSITION:($position)
";
if (strcmp($current,$last)==0){
$newoutput[$i]=str_replace(".","/",$splitfolder[3]);
}
}
return $newoutput;
}
/*
#
# Folder-Output Functions
#
*/
function GenerateFolderList($folder_array, $username)
{
print "
urlencode($username), "&folder=", urlencode($folder_array[$l]), "\">/$folder_array[$l] |
}
function GetUsers($char) {
$users = array();
$this->imap_login();
$output=$this->GetFolders("user.$char");
$this->imap_logout();
$j = 0;
$prev = 0;
for ($i=0; $i $username = split("/", $output[$i],-1);
$this->debug("($username[1]),
$users[$prev])");
if ((isset($username)) && (isset($users))) {
if (strcmp($username[1], $users[$prev])) {
$users[$j] = $username[1];
$j++;
}
}
if ($j != 0) { $prev = $j - 1; }
}
return $users;
}
function debug($message) {
// echo "
$message
";
}
} //KLASSEN ENDE
?>

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

许多用户在选择智能手表的时候都会选择的华为的品牌,其中华为GT3pro和GT4都是非常热门的选择,不少用户都很好奇华为GT3pro和GT4有什么区别,下面就就给大家介绍一下二者。华为GT3pro和GT4有什么区别一、外观GT4:46mm和41mm,材质是玻璃表镜+不锈钢机身+高分纤维后壳。GT3pro:46.6mm和42.9mm,材质是蓝宝石玻璃表镜+钛金属机身/陶瓷机身+陶瓷后壳二、健康GT4:采用最新的华为Truseen5.5+算法,结果会更加的精准。GT3pro:多了ECG心电图和血管及安

为什么截图工具在Windows11上不起作用了解问题的根本原因有助于找到正确的解决方案。以下是截图工具可能无法正常工作的主要原因:对焦助手已打开:这可以防止截图工具打开。应用程序损坏:如果截图工具在启动时崩溃,则可能已损坏。过时的图形驱动程序:不兼容的驱动程序可能会干扰截图工具。来自其他应用程序的干扰:其他正在运行的应用程序可能与截图工具冲突。证书已过期:升级过程中的错误可能会导致此issu简单的解决方案这些适合大多数用户,不需要任何特殊的技术知识。1.更新窗口和Microsoft应用商店应用程

第1部分:初始故障排除步骤检查苹果的系统状态:在深入研究复杂的解决方案之前,让我们从基础知识开始。问题可能不在于您的设备;苹果的服务器可能会关闭。访问Apple的系统状态页面,查看AppStore是否正常工作。如果有问题,您所能做的就是等待Apple修复它。检查您的互联网连接:确保您拥有稳定的互联网连接,因为“无法连接到AppStore”问题有时可归因于连接不良。尝试在Wi-Fi和移动数据之间切换或重置网络设置(“常规”>“重置”>“重置网络设置”>设置)。更新您的iOS版本:

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

前端output配置,需要具体代码示例前端开发中,output配置是一项非常重要的配置。它用于定义项目打包后生成的文件路径、文件名以及相关的资源路径等。本文将介绍前端output配置的作用、常用配置选项,并给出具体的代码示例。output配置的作用:output配置项用于指定项目打包后生成的文件路径和文件名。它决定了项目的最终输出结果。在webpack等打包

同事因为this指向的问题卡住的bug,vue2的this指向问题,使用了箭头函数,导致拿不到对应的props。当我给他介绍的时候他竟然不知道,随后也刻意的看了一下前端交流群,至今最起码还有70%以上的前端程序员搞不明白,今天给大家分享一下this指向,如果啥都没学会,请给我一个大嘴巴子。

watch4pro和gt各自具有不用的特点和适用场景,如果注重功能的全面性、高性能和时尚外观,同时愿意承担较高的价格,那么Watch 4 Pro可能更适合。如果对功能要求不高,更注重电池续航和价格的合理性,那么GT系列可能更适合。最终的选择应根据个人需求、预算和喜好来决定,建议在购买前仔细考虑自己的需求,并参考各种产品的评测和比较,以做出更明智的选择。

本篇文章带大家解读vue源码,来介绍一下Vue2中为什么可以使用 this 访问各种选项中的属性,希望对大家有所帮助!
