📄 webmanage.java
字号:
/*
*
*/
import java.io.*;
import java.text.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*
*
* @author Chen Xin Wu
*/
public class WebManage extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request,response);
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
try{
HtmlOut htmlOut = new HtmlOut (response);
// 得到名字和口令
//one way , user are login by name and pass;
// 得到名字和口令
String name="",pass;
name=request.getParameter ("username");
pass=request.getParameter ("password");
//set page cookie;
Person person = new Person();
if(name!=null&&pass!=null){
htmlOut.addCookie ("username",name);
htmlOut.addCookie ("password",pass);
}
else{//other we get it by cookie;
name = CommonMethods.GetUserName(request);
pass = CommonMethods.GetUserPass(request);
}
person.setName (name);
person.setPassword ( pass );
if( person.getName ()==null || (!person.checkPassword(pass)))
{
htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
"请先登录!","/manage/");
htmlOut.outHtml();
return;
}
if (!person.IsManager ())
{
htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
"您没有权限进行此项操作!","/manage/");
htmlOut.outHtml();
return;
}
TemplateList tempList = CommonMethods.getWebManageTemplate ();
SingleTemplate st,stManage,stSuper;
st = tempList.searchTemplate ("ROOT");
stManage=tempList.searchTemplate ("管理用户");
stSuper=tempList.searchTemplate ("超级用户");
if(st==null)
{
htmlOut.setErrorID (htmlOut.SINGLE_TEMPLATE_NOTFIND ,"",
"无法找到ROOT模板","WebManage");
htmlOut.outHtml();
return ;
}
if(stManage==null)
{
htmlOut.setErrorID (htmlOut.SINGLE_TEMPLATE_NOTFIND ,"",
"无法找到管理用户模板","WebManage");
htmlOut.outHtml();
return ;
}
if(stManage==null)
{
htmlOut.setErrorID (htmlOut.SINGLE_TEMPLATE_NOTFIND ,"",
"无法找到超级用户模板","WebManage");
htmlOut.outHtml();
return ;
}
//根据用户级别替换模板文件
int nKey = st.getKeyNum ();
String sKey= new String ();
//int nYear,nMonth,nDay;
for(int i=0;i<nKey;i++){
System.out.println("search key:"+st.getKeyAt (i));
htmlOut.addString(st.getStringAt (i));
sKey = st.getKeyAt (i);
if( sKey.compareTo("cgi-path")==0 )
htmlOut.addString (CommonMethods.sHostNameCGI);
if (sKey.compareTo ("管理内容")==0)
{
//查找并替换子模板
if (person.IsManager ())
htmlOut.addString (stManage.getEndString ());
if (person.IsSuperMan ())
htmlOut.addString (stSuper.getEndString ());
}
}
htmlOut.addString (st.getEndString ());
htmlOut.outHtml();
//
}catch(Exception e){
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -