cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<%@ WebHandler Language="C#"Class="Handler" %>
 
using System;
using System.Web;
public class Handler :IHttpHandler {
    public void ProcessRequest (HttpContext context) {
        Object obj = context.Request.Params["action"];
        string as_action = "query";
        if(obj!=null){
            as_action = obj.ToString();
        }
        obj = context.Request.Params["us"];
        if(obj==null){
            context.Response.Write("Óû§Ãû²»ÄÜΪ¿Õ");
            return;
        }
        string as_name = obj.ToString();
        context.Response.ContentType= "text/html";
        if(as_action=="query")
        {
            context.Response.Write((DbHelperOleDb.GetSingle(string.Format("select count(*) from tb_user where username='{0}'", as_name))).ToString());
        }
        else
        {
            context.Response.Write(AddUser(as_name));
        }
        
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
 
 
    private string CheckUser(string as_name)
    {
        return (DbHelperOleDb.GetSingle(string.Format("select count(*) from tb_user where username='{0}'", as_name))).ToString();
    }
 
    private string AddUser(string as_name)
    {
        if (Convert.ToInt32(DbHelperOleDb.GetSingle("select count(*) from tb_user")) > 1000)
        {
            throw new ApplicationException("²åÈëµÄÓû§¼Ç¼ÊýÒѾ­³¬³ö趬ÉèÖõÄ×î´ó±ÊÊý(1000)£¬Çëµ½QQȺÀï֪ͨ趬Çå³ý¼Ç¼");
        }
        if (CheckUser(as_name) == "0")
        {
            return Insert(as_name);
        }
        else
        {
            return "0";
        }
 
    }
 
    private string Insert(string as_name)
    {
        try
        {
            return DbHelperOleDb.ExecuteSql(string.Format("insert into tb_user(username) values('{0}')", as_name)).ToString();
        }
        catch (Exception ex)
        {
            return "0";
        }
    }
}