You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
4.7 KiB
Plaintext
119 lines
4.7 KiB
Plaintext
11 months ago
|
<%@ WebHandler Language="C#" Class="Validate" %>
|
||
|
|
||
|
using System;
|
||
|
using System.Web;
|
||
|
using System.Web.SessionState;
|
||
|
using System.Data;
|
||
|
using System.Text;
|
||
|
using System.Text.RegularExpressions;
|
||
|
using DSWebComponent;
|
||
|
using DSWebMobileService.Common;
|
||
|
|
||
|
public class Validate : IHttpHandler, System.Web.SessionState.IRequiresSessionState
|
||
|
{
|
||
|
static string userName = "";
|
||
|
public void ProcessRequest (HttpContext context) {
|
||
|
string action = context.Request.QueryString["action"].ToString();
|
||
|
|
||
|
switch (action)
|
||
|
{
|
||
|
case "0":
|
||
|
SetSign(context);
|
||
|
break;
|
||
|
case "1":
|
||
|
CheckSign(context);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void SetSign(HttpContext context)
|
||
|
{
|
||
|
string relUserName = "";
|
||
|
string relPassword = "";
|
||
|
string relYear = "";
|
||
|
string relMonth = "";
|
||
|
string relDay = "";
|
||
|
string relHours = "";
|
||
|
string pattern = "\0";
|
||
|
string replacement = "";
|
||
|
|
||
|
string u = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["u"].ToString());
|
||
|
string w = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["w"].ToString());
|
||
|
string y = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["y"].ToString());
|
||
|
string m = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["m"].ToString());
|
||
|
string d = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["d"].ToString());
|
||
|
string h = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["h"].ToString());
|
||
|
|
||
|
Regex rgx = new Regex(pattern);
|
||
|
relUserName = rgx.Replace(u, replacement);
|
||
|
relPassword = rgx.Replace(w, replacement);
|
||
|
relYear = rgx.Replace(y, replacement);
|
||
|
relMonth = rgx.Replace(m, replacement);
|
||
|
relDay = rgx.Replace(d, replacement);
|
||
|
relHours = rgx.Replace(h, replacement);
|
||
|
pattern = "\t";
|
||
|
Regex rgx2 = new Regex(pattern);
|
||
|
relUserName = rgx2.Replace(relUserName, replacement);
|
||
|
relPassword = rgx2.Replace(relPassword, replacement);
|
||
|
relYear = rgx2.Replace(relYear, replacement);
|
||
|
relMonth = rgx2.Replace(relMonth, replacement);
|
||
|
relDay = rgx2.Replace(relDay, replacement);
|
||
|
relHours = rgx2.Replace(relHours, replacement);
|
||
|
|
||
|
SessionUtil.Session["SHOWNAME"] = relUserName;
|
||
|
SessionUtil.Session["Password"] = relPassword;
|
||
|
SessionUtil.Session["Year"] = relYear;
|
||
|
SessionUtil.Session["Month"] = relMonth;
|
||
|
SessionUtil.Session["Day"] = relDay;
|
||
|
SessionUtil.Session["Hours"] = relHours;
|
||
|
|
||
|
//userName = relUserName;
|
||
|
}
|
||
|
|
||
|
private void CheckSign(HttpContext context)
|
||
|
{
|
||
|
string relUserName = "";
|
||
|
string relPassword = "";
|
||
|
string pattern = "\0";
|
||
|
string replacement = "";
|
||
|
string u = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["u"].ToString());
|
||
|
string w = Encrypt.DesDecrypt("#7c&e@63", context.Request.QueryString["w"].ToString());
|
||
|
//string u= context.Request.QueryString["u"].ToString();
|
||
|
//string w= context.Request.QueryString["w"].ToString();
|
||
|
string UserName = SessionUtil.Session["SHOWNAME"].ToString();
|
||
|
string Password = SessionUtil.Session["Password"].ToString();
|
||
|
string Year = SessionUtil.Session["Year"].ToString();
|
||
|
string Month = SessionUtil.Session["Month"].ToString();
|
||
|
string Day = SessionUtil.Session["Day"].ToString();
|
||
|
string Hours = SessionUtil.Session["Hours"].ToString();
|
||
|
|
||
|
Regex rgx = new Regex(pattern);
|
||
|
relUserName = rgx.Replace(u, replacement);
|
||
|
relPassword = rgx.Replace(w, replacement);
|
||
|
pattern = "\t";
|
||
|
Regex rgx2 = new Regex(pattern);
|
||
|
relUserName = rgx2.Replace(relUserName, replacement);
|
||
|
relPassword = rgx2.Replace(relPassword, replacement);
|
||
|
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
if (UserName != "" && Password != "" && Year != "" && Month != "" && Day != "" && Hours != "" && UserName != null && Password != null && Year != null && Month != null && Day != null && Hours != null && relUserName == UserName && relPassword == Password && Year == DateTime.Now.Year.ToString() && Month == DateTime.Now.Month.ToString() && Day == DateTime.Now.Day.ToString() && Hours == DateTime.Now.Hour.ToString())
|
||
|
{
|
||
|
SessionUtil.Session["Hours"] = DateTime.Now.Hour.ToString();
|
||
|
sb.Append("[{\"result\":\"success\"}]");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
sb.Append("[{\"result\":\"fail\"}]");
|
||
|
}
|
||
|
context.Response.ContentType = "text/plain";
|
||
|
context.Response.Write(sb.ToString());
|
||
|
context.Response.End();
|
||
|
}
|
||
|
|
||
|
public bool IsReusable {
|
||
|
get {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|