此腳本檢查Postfix郵箱文件夾的修改日期。需要使用方法或案例語句更新PHP腳本的幫助
問題是,我有多個位置需要檢查。
夾的/ mnt/MAIL1/包含郵件顯示目錄的a,b,d,克
夾的/ mnt/mail2/包含其餘C,E,F,H,.... ....,X,Z
腳本通過網址https://URL/[email protected]
只需運行我需要的腳本,在正確的檢查依賴於電子郵件地址被檢查掛載點。在上面的情況下,它應該檢查/mnt/mail2/d/e/delta.com/.....
請幫忙。我對PHP一無所知。
<?php
if (isset($_REQUEST["email"])) {
$emailaddress= trim($_REQUEST["email"]);
$emailparts = explode("@",$emailaddress);
if (sizeof($emailparts) != 2) {
print "invalid-email,,,,";
exit();
}
$username = $emailparts[0];
$domain = $emailparts[1];
$basedir = "/mnt/mail1/";
$livePrefix = $basedir;
$archivePrefix = $basedir."archive/";
$livePath = $livePrefix . substr($domain,0,1) . "/" . substr($domain,1,1) . "/" . $domain . "/" . substr($username,0,1) . "/" . $username;
$archivePath = $archivePrefix . $domain ;
$liveStat = stat($livePath . "/" . "cur");
$archStat = false;
if (file_exists($archivePath) && is_dir($archivePrefix)) {
$arhiveDirs = scandir($archivePath);
foreach($arhiveDirs as $i => $fname) {
if (stripos($fname , $username . "-" ) !== false) {
$archivePath = $archivePath . "/" . $fname ;
$archStat = stat($archivePath . "/cur");
break;
}
}
}
$status="lost" ;
if ($liveStat != false) {
$status = "live" . "," . date("Y-m-d H:i:s", $liveStat['mtime']) . "," . sizeof(scandir($livePath . "/new")) . "," ;
} else if ($archStat != false) {
$status = "archived,,,";
} else {
$status = "lost,,,";
}
if ($archStat != false) {
$status = $status . date("Y-m-d H:i:s", $archStat['mtime']) . "," . sizeof(scandir($archivePath . "/new")) ;
} else {
$status = $status . "," ;
}
print $status ;
exit();
} else {
print "error,,,,";
exit();
}
?>
而且您認爲我們願意花時間實現您想要的功能嗎?拿一本書,學習PHP,如果你有一個特殊的問題,我們在這裏幫助你。 – 2015-03-06 09:52:54
代碼格式化。 – SSA 2015-03-06 11:13:04