using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    my_basic my_b = new my_basic();
    my_conn my_c = new my_conn();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string type = "";
            try
            {
                type = Request.QueryString["type"].ToString();
            }
            catch
            { }
            if (type == "qq")
            {
                string nickname = Server.HtmlDecode(Request.QueryString["nickname"].ToString());
                string figureurl = Server.HtmlDecode(Request.QueryString["figureurl"].ToString());
                string xingbie = Server.HtmlDecode(Request.QueryString["xingbie"].ToString());
                string suozaidi = Server.HtmlDecode(Request.QueryString["suozaidi"].ToString());

                string yonghuming = "";
                if (figureurl != "")
                {
                    try
                    {
                        yonghuming = figureurl.Substring(0, figureurl.LastIndexOf("/"));
                        yonghuming = yonghuming.Substring(yonghuming.LastIndexOf("/") + 1);
                    }
                    catch { }
                }


                DataTable dt = new DataTable();
                if (my_b.get_count("sl_user", "where yonghuming='" + yonghuming + "'") > 0)
                {
                    dt = my_c.GetTable("select * from sl_user where yonghuming='" + yonghuming + "'");
                    my_b.c_cookie(dt.Rows[0]["zuocheng"].ToString(), "user_name");
                    my_b.c_cookie(dt.Rows[0]["mima"].ToString(), "user_pwd");
                }
                else
                {
                    string sql = "insert into sl_user(yonghuming,mima,zuocheng,touxiang,suozaidi,xingbie,leixing) values('" + yonghuming + "','','" + nickname + "','" + figureurl + "','" + suozaidi + "','" + xingbie + "','学生')";


                    my_c.genxin(sql);

                    my_c.genxin("insert into sl_system (u1,u2,u3,u4) values('" + yonghuming + "','此会员（" + yonghuming + "）注册成功!操作页面" + Request.Url.ToString() + "','" + Request.UserHostAddress.ToString() + "','QQ会员')");

                    my_b.c_cookie(nickname, "user_name");
                    my_b.c_cookie(yonghuming, "user_pwd");
                }


                Response.Redirect("/default.aspx");
            }
        }
    }

}
