【php开源代码栏目提醒】:以下是网学会员为您推荐的php开源代码-folders.php,希望本篇文章对您学习有所帮助。
<?
// load session management
include("session_management.php");
//检查创建的文件夹是否合法
if($newfolder != "" &&
ereg("[A-Za-z0-9\.-]",$newfolder) &&
!file_exists($userfolder.$newfolder))
mkdir($userfolder.$newfolder,0777);
//检查删除的文件夹,
系统文件夹不能被删除
if($delfolder != "" &&
$delfolder != "inbox" &&
$delfolder != "sent" &&
$delfolder != "trash" &&
$delfolder != "_attachments" &&
$delfolder != "_infos" &&
ereg("[A-Za-z0-9\.-]",$delfolder) &&
(strpos($delfolder,"..") === false))
@RmDirR($userfolder.$delfolder);
$jssource = "
<script language=\"
JavaScript\">
function newmsg() { location = 'newmsg.php?pag=$pag&folder=".urlencode($folder)."&sid=$sid&lid=$lid'; }
function refreshlist() { location = 'folders.php?folder=".urlencode($folder)."&sid=$sid&lid=$lid'}
function goend() { location = 'logout.php?sid=$sid&lid=$lid'; }
function search() { location = 'search.php?sid=$sid&lid=$lid'; }
function goinbox() { location = 'msglist.php?folder=inbox&sid=$sid&lid=$lid'; }
function emptytrash() { location = 'folders.php?empty=trash&folder=".urlencode($folder)."&goback=true&sid=$sid&lid=$lid';}
function addresses() { location = 'addressbook.php?sid=$sid&lid=$lid'; }
function prefs() { location = 'preferences.php?sid=$sid&lid=$lid'; }
function create() {
strPat = /[^A-Za-z0-9\.-]/;
frm = document.forms[0];
strName = frm.newfolder.value
mathArray = strName.match(strPat)
if(mathArray != null) {
alert('$error_invalid_name')
return false;
}else
frm.submit();
}
</script>
";
if(isset($empty)) {
if($empty=="inbox" && count($sess["headers"]) > 0) {
$headers = $sess["headers"];
if(!$p3->pop_connect()) die("<script language=\"javascript\">location = 'error.php?msg=".urlencode($error_connect)."&sid=$sid&lid=$lid';</script>");
if(!$p3->pop_auth()) die("<script language=\"javascript\">location = 'badlogin.php?sid=$sid&lid=$lid'</script>");
for($i=0;$i<count($headers);$i++) {
$mail_info = $headers[$i];
$mnum = $mail_info["id"];
$mid = md5($mail_info["message-id"]);
$msize = $mail_info["size"];
$read = file_exists($mail_info["localname"]);
$trash = 0;
if($send_to_trash) {
$trash = 1;
if($st_only_read && !$read) $trash = 0;
}
if(!$p3->pop_dele_msg($mnum,$mid,$msize,$trash)) die("<script language=\"javascript\">location = 'error.php?sid=$sid&lid=$lid&msg=".urlencode($error_deleting)."';</script>");
}
$headers = $p3->pop_list_msgs();
$p3->pop_disconnect();
$sess["headers"] = $headers;
save_session($sess);
} else {
$headers = build_local_list($userfolder.$empty);
for($i=0;$i<count($headers);$i++) {
$mail_info = $headers[$i];
$localname = $mail_info["localname"];
$mid = md5($mail_info["message-id"]);
$msize = $mail_info["size"];
$read = $mail_info["read"];
$trash = 0;
if($send_to_trash) {
$trash = 1;
if($st_only_read && !$read) $trash = 0;
}
if($trash && $empty != "trash")
copy($localname,$userfolder."trash/".basename($localname));
@unlink($localname);
}
if(isset($goback)) Header("Location: msglist.php?folder=".urlencode($folder)."&sid=$sid&lid=$lid");
}
}
echo($nocache);
$tcontent = read_file($folder_list_template);
$tcontent = eregi_replace("<!--%UM_LID%-->",$lid,$tcontent);
$tcontent = eregi_replace("<!--%UM_SID%-->",$sid,$tcontent);
$tcontent = eregi_replace("<!--%UM_USER_EMAIL%-->",$sess["email"],$tcontent);
$tcontent = eregi_replace("<!--%UM_JS%-->",$jssource,$tcontent);
$startpos = strpos($tcontent,"<!--%UM_BEGIN_FOLDERS_LOOP%-->");
$endpos = strpos($tcontent,"<!--%UM_END_FOLDERS_LOOP%-->")+28;
$loopline = substr($tcontent,$startpos+30,$endpos-$startpos-58);
$d = dir($userfolder);
$scounter = 0;
$pcounter = 0;
$totalused = 0;
while($entry=$d->read()) {
if( is_dir($userfolder.$entry) &&
$entry != ".." &&
substr($entry,0,1) != "_" &&
$entry != ".") {
$unread = 0;
if ($entry == "inbox") $thisbox = $sess["headers"];
else $thisbox = build_local_list($userfolder.$entry);
$boxsize = 0;
for($i=0;$i<count($thi