hMailServer的PHP管理
时间:2011-01-04 来源:kuhanzhu
<?php
/*以下为核心代码,不包含程序逻辑处理,剥离自hMailServer自带的管理程序PHPWebAdmin
>>22:33 2011-1-4 kuhanzhu
*/
//$_SESSION['session_loggedin']=1;
$obBaseApp = new COM("hMailServer.Application");//调用 login('[email protected]','password');//Email邮局管理员帐户登陆,不登陆执行不了一些功能,应该属于server级帐户。详情参考PHPWebAdmin界面(建立不同级别帐户登陆上去就看出来功能的区别了)
//$obBaseApp->Stop();//停止服务,此功能与hMailAdmin.exe里操作的一样,并不终止进程,区别与开始目录的stop
//$obBaseApp->Start();//启动
$obStatus=$obBaseApp->Status();
$statusstarttime = $obStatus->StartTime();//开始运行时间 $serverstate= $obBaseApp->ServerState();//软件运行状态。详情见下面的switch //$obSettings = $obBaseApp->Settings();
//$obLogging = $obSettings->Logging(); $servername = $obDatabase->ServerName;//服务器地址
$obDatabase = $obBaseApp->Database;
$databasename = $obDatabase->DatabaseName;//数据库名
$statusprocessedmessages = $obStatus->ProcessedMessages();//处理邮件数,比如正发送中的……
$statusmessageswithvirus = $obStatus->RemovedViruses();//病毒数
$statusmessageswithspam = $obStatus->RemovedSpamMessages();//被过滤邮件数 //$sessions_smtp = $obStatus->SessionCount(STSMTP);
//$sessions_pop3 = $obStatus->SessionCount(STPOP3);
//$sessions_imap = $obStatus->SessionCount(STIMAP); //以下为输出示例
echo $obBaseApp->Version.'<br/>';
echo $statusstarttime;
echo $serverstate;
echo $servername;
echo $databasename; echo $statusprocessedmessages;
echo $statusmessageswithvirus;
echo $statusmessageswithspam; switch($serverstate)
{
case 1:
echo "Stopped";
break;
case 2:
echo "Starting";
break;
case 3:
echo "Running";
break;
case 4:
echo "Stopping";
break;
default:
echo "Unknown";;
break;
} //以下为函数
function Login($username, $password)
{
global $obBaseApp;
$obAccount = $obBaseApp->Authenticate($username, $password);
// if (!isset($obAccount))LoginError();
// $_SESSION['session_loggedin'] = 1;
// $_SESSION['session_adminlevel'] = $obAccount->AdminLevel();
// $_SESSION['session_username'] = $obAccount->Address;
// $_SESSION['session_password'] = $password;
// $_SESSION['session_domainid'] = $obAccount->DomainID();
// $_SESSION['session_accountid'] = $obAccount->ID();
return true;
}
/*function hmail_isloggedin()
{
if (isset($_SESSION['session_loggedin']) &&
$_SESSION['session_loggedin'] == "1")
return true;
else
return false;
}*/
?>
>>22:33 2011-1-4 kuhanzhu
*/
//$_SESSION['session_loggedin']=1;
$obBaseApp = new COM("hMailServer.Application");//调用 login('[email protected]','password');//Email邮局管理员帐户登陆,不登陆执行不了一些功能,应该属于server级帐户。详情参考PHPWebAdmin界面(建立不同级别帐户登陆上去就看出来功能的区别了)
//$obBaseApp->Stop();//停止服务,此功能与hMailAdmin.exe里操作的一样,并不终止进程,区别与开始目录的stop
//$obBaseApp->Start();//启动
$obStatus=$obBaseApp->Status();
$statusstarttime = $obStatus->StartTime();//开始运行时间 $serverstate= $obBaseApp->ServerState();//软件运行状态。详情见下面的switch //$obSettings = $obBaseApp->Settings();
//$obLogging = $obSettings->Logging(); $servername = $obDatabase->ServerName;//服务器地址
$obDatabase = $obBaseApp->Database;
$databasename = $obDatabase->DatabaseName;//数据库名
$statusprocessedmessages = $obStatus->ProcessedMessages();//处理邮件数,比如正发送中的……
$statusmessageswithvirus = $obStatus->RemovedViruses();//病毒数
$statusmessageswithspam = $obStatus->RemovedSpamMessages();//被过滤邮件数 //$sessions_smtp = $obStatus->SessionCount(STSMTP);
//$sessions_pop3 = $obStatus->SessionCount(STPOP3);
//$sessions_imap = $obStatus->SessionCount(STIMAP); //以下为输出示例
echo $obBaseApp->Version.'<br/>';
echo $statusstarttime;
echo $serverstate;
echo $servername;
echo $databasename; echo $statusprocessedmessages;
echo $statusmessageswithvirus;
echo $statusmessageswithspam; switch($serverstate)
{
case 1:
echo "Stopped";
break;
case 2:
echo "Starting";
break;
case 3:
echo "Running";
break;
case 4:
echo "Stopping";
break;
default:
echo "Unknown";;
break;
} //以下为函数
function Login($username, $password)
{
global $obBaseApp;
$obAccount = $obBaseApp->Authenticate($username, $password);
// if (!isset($obAccount))LoginError();
// $_SESSION['session_loggedin'] = 1;
// $_SESSION['session_adminlevel'] = $obAccount->AdminLevel();
// $_SESSION['session_username'] = $obAccount->Address;
// $_SESSION['session_password'] = $password;
// $_SESSION['session_domainid'] = $obAccount->DomainID();
// $_SESSION['session_accountid'] = $obAccount->ID();
return true;
}
/*function hmail_isloggedin()
{
if (isset($_SESSION['session_loggedin']) &&
$_SESSION['session_loggedin'] == "1")
return true;
else
return false;
}*/
?>
相关阅读 更多 +