📄 viewfolders.java
字号:
import java.io.*;
import java.text.*;
import java.util.*;
import java.sql.*;
import java.util .Vector ;
import javax.servlet.http.*;
public class ViewFolders extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException
{
doGet(request,response);
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException
{
HtmlOut htmlOut = new HtmlOut (response);
// 得到名字和口令
String name="",pass;
Person person = new Person();
person.setName (CommonMethods.GetUserName(request));
pass = CommonMethods.GetUserPass (request);
if( person.getName ()==null || (!person.checkPassword(pass)) )
{
htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
"请先登录!","Login?action=reLog");
htmlOut.outHtml();
return;
}
GetEmailInfo GM = new GetEmailInfo ();
String sNewF= request.getParameter ("FOLDERNEW");
if(sNewF!=null){
String sF= request.getParameter("FOLDERNEWNAME");
//sF = CommonMethods.DealWithGBCodeOfRequest (sF);
if(sF!=null){
GM.CreateFolder (person.getName (),pass,sF);
}
}
Vector fs= GM.ListMailFolder(person.getName (),pass);
if(fs==null){
htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
"请先登录",
"");
htmlOut.outHtml();
return;
}
String sEmpty = request.getParameter ("FOLDEREMPTY");
if( sEmpty!=null ){
sEmpty = CommonMethods.DealWithGBCodeOfRequest (sEmpty);
String sID = getFolderID( fs,sEmpty );
emptyFolder(fs,sEmpty);
GM.EmptyFolder (person.getName (),pass,sEmpty);
}
String sDel = request.getParameter ("FOLDERDEL");
if( sDel!=null ){
sDel = CommonMethods.DealWithGBCodeOfRequest (sDel);
String sID = getFolderID( fs,sDel );
deleteFolder(fs , sDel);
GM.DelFolder (person.getName (),pass,sID);
}
//fs= GM.ListMailFolder(person.getName (),pass);
TemplateList tempList = CommonMethods.getViewFoldersTemplate ();
if(tempList!=null){
SingleTemplate st = tempList.searchTemplate ("ROOT");
for(int i=0;i<st.getKeyNum ();i++){
String sKey = st.getKeyAt (i);
htmlOut.addString (st.getStringAt (i));
if( sKey .compareTo("cgi-path")==0 )
htmlOut.addString (CommonMethods.sHostNameCGI);
if( sKey.compareTo ("folders")==0 ){
SingleTemplate st1 = tempList.searchTemplate ("folder");
for( int k=0;k<fs.size ();k++){
MailFolder mf= (MailFolder )fs.elementAt (k);
for( int j=0;j<st1.getKeyNum ();j++){
sKey = st1.getKeyAt (j);
htmlOut.addString (st1.getStringAt (j));
if( sKey .compareTo("cgi-path")==0 )
htmlOut.addString (CommonMethods.sHostNameCGI);
if( sKey.compareTo ("ID")==0){
htmlOut.addString (mf.sName );
}
if( sKey.compareTo ("name")==0){
htmlOut.addString (mf.sName );
}
if( sKey.compareTo ("all")==0){
htmlOut.addString (mf.nMail );
}
if( sKey.compareTo ("new")==0){
htmlOut.addString (mf.nNew );
}
if( sKey.compareTo ("notread")==0){
htmlOut.addString (mf.nNotRead );
}
if( sKey.compareTo ("Delete")==0 ){
if( mf.isNormal == false ){
htmlOut.addString ( "<TD><INPUT class=font9 id=button1 name=button1"
+" onclick=\"location='ViewFolders?FOLDERDEL="
+ mf.sID +"'\" type=button value=删除></TD>" );
}
}
}
htmlOut.addString (st1.getEndString ());
}
}
}
htmlOut.addString (st.getEndString ());
}
htmlOut.outHtml ();
}
String getFolderID( Vector allF , String sFolderName )
{
for( int i=0;i<allF.size ();i++)
if( ((MailFolder)(allF.elementAt(i))).sName .compareTo (sFolderName)==0 )
return ((MailFolder)(allF.elementAt(i))).sID ;
return null;
}
void deleteFolder(Vector allF , String sFolderName)
{
for( int i=0;i<allF.size ();i++)
if( ((MailFolder)(allF.elementAt(i))).sName .compareTo (sFolderName)==0 )
allF.removeElementAt (i);
}
void emptyFolder(Vector allF , String sFolderName)
{
for( int i=0;i<allF.size ();i++)
if( ((MailFolder)(allF.elementAt(i))).sName .compareTo (sFolderName)==0 ){
((MailFolder)(allF.elementAt(i))).nMail ="0";
((MailFolder)(allF.elementAt(i))).nNew ="0";
((MailFolder)(allF.elementAt(i))).nNotRead ="0";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -