📄 keepforlzs2.java
字号:
import java.io.*;
import java.text.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class KeepForLzs2 extends HttpServlet
{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException
{
doGet(request,response);
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException
{
try{
HtmlOut htmlOut = new HtmlOut (response);
// 得到名字和口令
String name = CommonMethods.getParameterValue (request,"Name");
String pass = CommonMethods.getParameterValue (request,"Password");
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 p=new Person();
p.setName (name);
System.out.println(p.getName());
System.out.println(pass);
if( p.getName ()==null || (!p.checkPassword(pass))
||(!p.IsSuperMan () &&!p.IsManager ()) )
{
htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
"请先登录!","/manage/");
htmlOut.outHtml();
return;
}
String sAct= CommonMethods.getParameterValue(request,"action");
DBOperater DB = new DBOperater("");
ResultSet rs;
String sVer,sInfo1,sInfo2,sPhone,sWeb;
sVer=sInfo1=sInfo2=sPhone=sWeb=null;
if(sAct!=null && sAct.compareTo ( "add" )==0 ){
sVer=CommonMethods.getParameterValue(request,"version");
sInfo1=CommonMethods.getParameterValue(request,"info1");
sInfo2=CommonMethods.getParameterValue(request,"info2");
sPhone=CommonMethods.getParameterValue(request,"phone");
sWeb=CommonMethods.getParameterValue(request,"web");
if( sVer==null || sInfo1==null || sInfo2==null ||
sPhone==null ||sWeb==null || sInfo1.length()<1
||sInfo2.length()<1 || sVer.length ()<1
||sPhone.length()<1
||sWeb.length()<1 ){
htmlOut.setErrorID(htmlOut.SHOW_SIMPLE_MESSAGE,"","信息不全!"
,"forup/add_cp.html");
}
else{
DB.executeUpdate("insert into cp_info values("
+sVer
+",'"+sInfo1
+"','"+sInfo2
+"','"+sPhone
+"','"+sWeb
+"','')"
);
rs=DB.executeQuery("select * from user_cp");
while( rs.next () ){
System.out.println( rs.getString(2) );
CommonMethods.sendSMS(rs.getString(2),
"声讯通提供中华风采第"
+sVer+"期中华风采福利彩票开奖信息:"
+"传统奖中奖号码:"+sInfo1+".特等奖中奖信息:"+sInfo2
+".声讯电话:"+sPhone
+"福彩站点:"+sWeb);
}
htmlOut.setErrorID(htmlOut.SHOW_SIMPLE_MESSAGE,"","信息发布成功!"
,"WebManage");
}
}else if( sAct!=null && sAct.compareTo ( "check" )==0 ){
String sQr = "select * from user_cp where username='"+name+"'";
rs=DB.executeQuery(sQr);
if( rs.next () ){
DB.executeUpdate("delete from user_cp where username='"+name+"'");
htmlOut.setErrorID(htmlOut.SHOW_SIMPLE_MESSAGE,"","您删除了个人的彩票通知!"
,"");
}
else{
String sMobile=null;
rs=DB.executeQuery("select * from person where username='"+name+"'");
if(rs.next() )
sMobile= rs.getString("mobile");
if( sMobile!=null){
DB.executeUpdate("insert into user_cp values('"+name+"','"+sMobile+"')");
htmlOut.setErrorID(htmlOut.SHOW_SIMPLE_MESSAGE,"","您定制了个人的彩票通知!"
,"Login");
}
else{
htmlOut.setErrorID(htmlOut.SHOW_SIMPLE_MESSAGE,"","您的手机号码不正确!"
,"Login");
}
}
}
else{
System.out.println("send redirect...");
response.sendRedirect ("/forup/add_cp.html");
}
DB.close ();
htmlOut.outHtml ();
}catch(Exception e){
System.out.println(""+e.toString() );
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -