public string GetAddressByIP(string ip) { string ipfilePath = ConfigurationManager.AppSettings["IPDataUrl"]; IPSearch ipSearch = new IPSearch(ipfilePath); IPSearch.IPLocation loc = ipSearch.GetIPLocation(ip); return loc.country; }
public string GetAddressByIP(string ip) { string ipfilePath = ConfigurationManager.AppSettings["IPDataUrl"]; IPSearch ipSearch = new IPSearch(ipfilePath); IPSearch.IPLocation loc = ipSearch.GetIPLocation(ip); return(loc.country); }
//测试 static void Main(string[] args) { IPSearch ipSearch = new IPSearch(); string ip = "72.51.27.51"; IPSearch.IPLocation loc = IPSearch.GetIPLocation(ip); Console.WriteLine("你查的ip是:{0} 地理位置:{1} {2}", ip, loc.country, loc.area); Console.ReadKey(); }
protected void Page_Load(object sender, EventArgs e) { // 进行安全检查 if (Session["yonghuming"] == null) { Response.Redirect("../default.aspx"); } if (Session["xiangmuhao"] == null) { Response.Redirect("../login.aspx"); } security sc = new security(); int xx = sc.flag(Session["yonghuming"].ToString(), Request.UserHostAddress.ToString()); if (xx == 1) { Response.Redirect("../alert.aspx"); } // 建立连接 string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); //try { // 获取登录用户的IP地址并写入数据库 SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "SELECT * FROM pro" + Session["xiangmuhao"].ToString() + " WHERE username = '******'"; SqlDataReader dr = cmd.ExecuteReader(); if (!dr.Read()) { dr.Close(); Response.Redirect("temp.aspx"); // 如果查询不到结果,说明该成员尚未加入项目,跳转至提示页面 } string ipdizhi; ipdizhi = Request.UserHostAddress.ToString(); dr.Close(); IPSearch.IPLocation wulidizhi; if (ipdizhi != "::1") { IPSearch ips = new IPSearch(); wulidizhi = ips.GetIPLocation(ipdizhi); } else { ipdizhi = "127.0.0.1"; wulidizhi.country = "维护地址"; wulidizhi.area = "主机"; } cmd.CommandText = "INSERT INTO records VALUES('" + Session["yonghuming"].ToString() + "','" + Session["xingming"].ToString() + "','" + DateTime.Now.ToString("MM-dd") + "','" + DateTime.Now.ToLongTimeString().ToString() + "','" + ipdizhi + "','" + Session["xiangmuhao"].ToString() + "','" + wulidizhi.country + wulidizhi.area + "')"; cmd.ExecuteNonQuery(); dr.Close(); // 关闭读取器,以便之后的代码可以调用该读取器 // 绘制项目成果汇总图 string[] name = new string[5] { "期刊论文", "会议论文", "申请专利", "授权专利", "其它" }; string[] number = new string[5]; /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and type='期刊论文' and checked='是'"; dr = cmd.ExecuteReader(); if (dr.Read()) { number[0] = dr[0].ToString().Trim(); } else { number[0] = "0"; } dr.Close(); /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and type='会议论文' and checked='是'"; dr = cmd.ExecuteReader(); if (dr.Read()) { number[1] = dr[0].ToString().Trim(); } else { number[1] = "0"; } dr.Close(); /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and type='申请专利' and checked='是'"; dr = cmd.ExecuteReader(); if (dr.Read()) { number[2] = dr[0].ToString().Trim(); } else { number[2] = "0"; } dr.Close(); /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and type='授权专利' and checked='是'"; dr = cmd.ExecuteReader(); if (dr.Read()) { number[3] = dr[0].ToString().Trim(); } else { number[3] = "0"; } dr.Close(); /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' and type='其它' and checked='是'"; dr = cmd.ExecuteReader(); if (dr.Read()) { number[4] = dr[0].ToString().Trim(); } else { number[4] = "0"; } dr.Close(); DataTable dt = new DataTable(); dt.Columns.Add("hengzuobiao", System.Type.GetType("System.String")); dt.Columns.Add("zongzuobiao", System.Type.GetType("System.String")); for (int i = 0; i <= 4; i++) { DataRow row = dt.NewRow(); row["hengzuobiao"] = name[i]; row["zongzuobiao"] = number[i]; dt.Rows.Add(row); } this.Chart1.DataSource = dt; this.Chart1.Series[0].XValueMember = "hengzuobiao"; this.Chart1.Series[0].YValueMembers = "zongzuobiao"; this.Chart1.ChartAreas["ChartArea1"].AxisX.Title = "类别"; this.Chart1.ChartAreas["ChartArea1"].AxisY.Title = "数量"; Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; this.Chart1.Series[0].IsValueShownAsLabel = true; // 绘制访问量变化统计图 /* * cmd.CommandText = "SELECT COUNT(*),date FROM records WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' GROUP BY date ORDER BY date DESC"; * dr = cmd.ExecuteReader(); * string[] label = new string[7]; * string[] quantity = new string[7]; * * int a; * * for (a = 6; a >= 0; a--) * { * if (dr.Read()) * { * label[a] = dr[1].ToString().Trim(); * quantity[a] = dr[0].ToString().Trim(); * } * else * { * break; * } * } * * dr.Close(); * * DataTable dt1 = new DataTable(); * dt1.Columns.Add("riqi", System.Type.GetType("System.String")); * dt1.Columns.Add("shuliang", System.Type.GetType("System.String")); * int b; * * for (b = 0; b < 7; b++) * { * DataRow row = dt1.NewRow(); * row["riqi"] = label[b]; * row["shuliang"] = quantity[b]; * dt1.Rows.Add(row); * } * * this.Chart2.DataSource = dt1; * this.Chart2.Series[0].XValueMember = "riqi"; * this.Chart2.Series[0].YValueMembers = "shuliang"; * * this.Chart2.ChartAreas[0].AxisX.Title = "日期"; * this.Chart2.ChartAreas[0].AxisY.Title = "访问量"; * Chart2.ChartAreas["ChartArea2"].AxisX.Interval = 1; * this.Chart2.Series[0].IsValueShownAsLabel = true; * dr.Close(); */ // 绘制经费使用情况图 string[] type = new string[7] { "设备费", "材料费", "资料费", "差旅费", "通信费", "劳务费", "其它" }; double[] money = new double[7] { 0, 0, 0, 0, 0, 0, 0 }; /* * 以下过程可以循环使用 */ cmd.CommandText = "SELECT flag,money FROM moneyrecord WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); while (dr.Read()) { //string[] tmpstr = dr[0].ToString().Trim().Split(new char[] { '#', '#' }); string[] tmpstr = new string[2]; tmpstr[0] = dr[0].ToString().Trim(); tmpstr[1] = dr[1].ToString().Trim(); if (tmpstr[0].IndexOf("设备费") >= 0) { money[0] = money[0] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("材料费") >= 0) { money[1] = money[1] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("资料费") >= 0) { money[2] = money[2] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("差旅费") >= 0) { money[3] = money[3] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("通信费") >= 0) { money[4] = money[4] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("劳务费") >= 0) { money[5] = money[5] + Convert.ToDouble(tmpstr[1]) / 10000; } else if (tmpstr[0].IndexOf("其它") >= 0) { money[6] = money[6] + Convert.ToDouble(tmpstr[1]) / 10000; } } dr.Close(); DataTable dt1 = new DataTable(); dt1.Columns.Add("hengzuobiao1", System.Type.GetType("System.String")); dt1.Columns.Add("zongzuobiao1", System.Type.GetType("System.String")); for (int i = 0; i <= 6; i++) { DataRow row = dt1.NewRow(); row["hengzuobiao1"] = type[i]; row["zongzuobiao1"] = money[i].ToString(); dt1.Rows.Add(row); } this.Chart2.DataSource = dt1; this.Chart2.Series[0].XValueMember = "hengzuobiao1"; this.Chart2.Series[0].YValueMembers = "zongzuobiao1"; this.Chart2.ChartAreas["ChartArea2"].AxisX.Title = "类别"; this.Chart2.ChartAreas["ChartArea2"].AxisY.Title = "数量"; Chart2.ChartAreas["ChartArea2"].AxisX.Interval = 1; this.Chart2.Series[0].IsValueShownAsLabel = true; // 填充公告栏内容 cmd.CommandText = "SELECT message,dateandtime FROM publics WHERE projectno = '" + Session["xiangmuhao"].ToString() + "' ORDER BY dateandtime DESC"; dr = cmd.ExecuteReader(); dr.Read(); gonggao = dr[0].ToString().Trim(); shijian = dr[1].ToString().Trim(); dr.Close(); // 填充成员信息 cmd.CommandText = "SELECT username,name,money,spent,company,email FROM pro" + Session["xiangmuhao"].ToString(); codemaker maker = new codemaker(); dr = cmd.ExecuteReader(); SqlCommand tmpcmd = new SqlCommand(); SqlConnection conn1 = new SqlConnection(connStr); conn1.Open(); tmpcmd.Connection = conn1; while (dr.Read()) { string spent; string totalmoney; string username = dr[0].ToString().Trim(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM moneyrecord WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader = tmpcmd.ExecuteReader(); moneyReader.Read(); if (moneyReader[0].ToString().Trim() != "") { spent = moneyReader[0].ToString().Trim(); } else { spent = "0"; } moneyReader.Close(); tmpcmd.CommandText = "SELECT SUM(ALL money) as tomoney FROM bonus WHERE name='" + dr[1].ToString().Trim() + "' and projectno='" + Session["xiangmuhao"].ToString() + "'"; SqlDataReader moneyReader1 = tmpcmd.ExecuteReader(); moneyReader1.Read(); if (moneyReader1[0].ToString().Trim() != "") { totalmoney = moneyReader1[0].ToString().Trim(); } else { totalmoney = "0"; } moneyReader1.Close(); if (Session["yonghuming"].ToString() == dr[0].ToString() || Session["yonghuming"].ToString() == Session["guanliyuan"].ToString()) { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), true); } else { member = member + maker.member(dr[0].ToString().Trim(), dr[1].ToString().Trim(), totalmoney, spent, dr[4].ToString().Trim(), dr[5].ToString().Trim(), false); } } dr.Close(); conn1.Close(); conn1.Dispose(); // 填充平台人数总占比及总人数 cmd.CommandText = "SELECT COUNT(*) FROM pro" + Session["xiangmuhao"].ToString(); dr = cmd.ExecuteReader(); dr.Read(); double int1 = Convert.ToDouble(dr[0].ToString()); renshu = int1.ToString(); dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM main"; dr = cmd.ExecuteReader(); dr.Read(); double int2 = Convert.ToDouble(dr[0].ToString()); dr.Close(); double result = int1 / int2 * 100; rszb = ((int)result).ToString(); // 填充平台经费总占比 cmd.CommandText = "SELECT money FROM project WHERE username='******'"; dr = cmd.ExecuteReader(); dr.Read(); int1 = Convert.ToDouble(dr[0].ToString()); dr.Close(); cmd.CommandText = "SELECT SUM(ALL money) AS tomoney FROM project"; dr = cmd.ExecuteReader(); dr.Read(); int2 = Convert.ToDouble(dr[0].ToString()); dr.Close(); result = int1 / int2 * 100; jfzb = ((int)result).ToString(); // 填充平台成果总占比 cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno='" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); dr.Read(); int1 = Convert.ToDouble(dr[0].ToString()); dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM files"; dr = cmd.ExecuteReader(); dr.Read(); int2 = Convert.ToDouble(dr[0].ToString()); dr.Close(); result = int1 / int2 * 100; cgzb = ((int)result).ToString(); // 填充访问总流量 cmd.CommandText = "SELECT COUNT(*) FROM records WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); dr.Read(); liuliang = dr[0].ToString().Trim(); dr.Close(); // 填充任务下拉菜单及任务数量 cmd.CommandText = "SELECT name,number FROM task WHERE projectno = '" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); int num = 0; while (dr.Read()) { renwu = renwu + maker.progress(dr[1].ToString().Trim(), dr[0].ToString().Trim()); num = num + 1; } tempnum = num.ToString(); if (num == 0) { tempnum1 = ""; } else { tempnum1 = tempnum; } dr.Close(); // 填充私信下拉菜单 string guanliyuan; cmd.CommandText = "SELECT name FROM main WHERE username = '******'"; dr = cmd.ExecuteReader(); dr.Read(); guanliyuan = dr[0].ToString().Trim(); dr.Close(); cmd.CommandText = "SELECT dateandtime,senduser,message FROM webchat WHERE receiveuser ='******' and flag='否' ORDER BY dateandtime DESC"; dr = cmd.ExecuteReader(); num = 0; while (dr.Read()) { webchat = webchat + maker.webchat(dr[1].ToString().Trim(), guanliyuan, dr[0].ToString().Trim(), dr[2].ToString().Trim()); num++; } chatnum = num.ToString(); if (num == 0) { chatnum1 = ""; } else { chatnum1 = chatnum; } dr.Close(); // 填充最近活动 cmd.CommandText = "SELECT dateandtime,message,type FROM messages WHERE projectno ='" + Session["xiangmuhao"].ToString() + "' ORDER BY dateandtime DESC"; dr = cmd.ExecuteReader(); int tmpint = 0; while (dr.Read() && tmpint <= 25) { activity = activity + maker.activity(dr[1].ToString().Trim(), dr[0].ToString().Trim(), dr[2].ToString().Trim()); tmpint++; } dr.Close(); // 填充聊天窗口 cmd.CommandText = "SELECT name,dateandtime,message,username FROM bbs WHERE projectno='" + Session["xiangmuhao"].ToString() + "' ORDER BY dateandtime DESC"; dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr[3].ToString() == Session["yonghuming"].ToString()) { chatwindow = chatwindow + maker.chatwindow2(dr[0].ToString().Trim(), dr[2].ToString().Trim(), dr[1].ToString().Trim(), dr[3].ToString().Trim()); } else { chatwindow = chatwindow + maker.chatwindow(dr[0].ToString().Trim(), dr[2].ToString().Trim(), dr[1].ToString().Trim(), dr[3].ToString().Trim()); } } dr.Close(); // 填充控制中心数量提醒 cmd.CommandText = "SELECT COUNT(*) FROM files WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked='否'"; dr = cmd.ExecuteReader(); int total = 0; if (dr.Read()) { total = Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM weekreport WHERE projectno='" + Session["xiangmuhao"].ToString() + "' and checked = '否'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); cmd.CommandText = "SELECT COUNT(*) FROM applies WHERE prono='" + Session["xiangmuhao"].ToString() + "'"; dr = cmd.ExecuteReader(); if (dr.Read()) { total = total + Convert.ToInt16(dr[0].ToString().Trim()); } dr.Close(); if (total != 0) { tixing = "<span class=\"badge pull-right\">" + total.ToString() + "</span>"; } /* * } * catch(Exception ex) * { * conn.Close(); * conn.Dispose(); * Response.Write("<script>alert(\"" + ex.Message + "\")</script>"); * } * finally * { * conn.Close(); * conn.Dispose(); * } * */ }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); this.ValidateRequest = false; WorkContext.IP = WebHelper.GetIP(); if (WebHelper.GetQueryString("ip") == WorkContext.IP) { WorkContext.RegionInfo = Regions.GetRegionById(WebHelper.GetQueryInt("regionid")); } else { WorkContext.RegionInfo = IPSearch.SearchRegion(WorkContext.IP); } if (WorkContext.RegionInfo == null) { WorkContext.RegionInfo = new RegionInfo() { RegionId = -1, Name = "未知区域" }; } WorkContext.RegionId = WorkContext.RegionInfo.RegionId; WorkContext.Url = WebHelper.GetUrl(); WorkContext.AppType = WebHelper.GetQueryInt("appType"); WorkContext.AppVersion = WebHelper.GetQueryString("appVersion"); WorkContext.AppOS = WebHelper.GetQueryString("appOS"); //获得用户唯一标示符sid WorkContext.Sid = WebHelper.GetQueryString("sid"); if (WorkContext.Sid.Length == 0) { //生成sid WorkContext.Sid = Sessions.GenerateSid(); } PartUserInfo partUserInfo; //获得用户id int uid = WebHelper.GetQueryInt("uid"); if (uid < 1)//当用户为游客时 { //创建游客 partUserInfo = Users.CreatePartGuest(); } else//当用户为会员时 { string encryptPwd = WebHelper.GetQueryString("encryptPwd"); //防止用户密码被篡改为危险字符 if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd)) { //创建游客 partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; } else { partUserInfo = Users.GetPartUserByUidAndPwd(uid, MallUtils.DecryptCookiePassword(encryptPwd)); if (partUserInfo != null) { //发放登陆积分 Credits.SendLoginCredits(ref partUserInfo, DateTime.Now, TypeHelper.StringToDateTime(WebHelper.GetQueryString("slctime")), out WorkContext.SLCTime); } else//当会员的账号或密码不正确时,将用户置为游客 { partUserInfo = Users.CreatePartGuest(); encryptPwd = string.Empty; } } WorkContext.EncryptPwd = encryptPwd; } //设置用户等级 if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now) { UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits); Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid); partUserInfo.UserRid = userRankInfo.UserRid; } WorkContext.PartUserInfo = partUserInfo; WorkContext.Uid = partUserInfo.Uid; WorkContext.UserName = partUserInfo.UserName; WorkContext.UserEmail = partUserInfo.Email; WorkContext.UserMobile = partUserInfo.Mobile; WorkContext.Password = partUserInfo.Password; WorkContext.NickName = partUserInfo.NickName; WorkContext.Avatar = partUserInfo.Avatar; WorkContext.PayCreditName = Credits.PayCreditName; WorkContext.PayCreditCount = partUserInfo.PayCredits; WorkContext.RankCreditName = Credits.RankCreditName; WorkContext.RankCreditCount = partUserInfo.RankCredits; WorkContext.UserRid = partUserInfo.UserRid; WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid); WorkContext.UserRTitle = WorkContext.UserRankInfo.Title; //设置用户商城管理员组 WorkContext.MallAGid = partUserInfo.MallAGid; WorkContext.MallAdminGroupInfo = MallAdminGroups.GetMallAdminGroupById(partUserInfo.MallAGid); WorkContext.MallAGTitle = WorkContext.MallAdminGroupInfo.Title; //设置当前控制器类名 WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower(); //设置当前动作方法名 WorkContext.Action = RouteData.Values["action"].ToString().ToLower(); WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action); WorkContext.ImageCDN = WorkContext.MallConfig.ImageCDN; WorkContext.CSSCDN = WorkContext.MallConfig.CSSCDN; WorkContext.ScriptCDN = WorkContext.MallConfig.ScriptCDN; //在线总人数 WorkContext.OnlineUserCount = OnlineUsers.GetOnlineUserCount(); //在线游客数 WorkContext.OnlineGuestCount = OnlineUsers.GetOnlineGuestCount(); //在线会员数 WorkContext.OnlineMemberCount = WorkContext.OnlineUserCount - WorkContext.OnlineGuestCount; //购物车中商品数量 WorkContext.CartProductCount = WebHelper.GetQueryInt("cartProductCount"); }
/// <summary> /// IP统计 /// </summary> private void IpPage() { //计算总量 int total = new BCW.BLL.Statinfo().GetCount(""); builder.Append(Out.Tab("<div>", "<br />")); builder.Append("累计流量" + total + ""); builder.Append(Out.Tab("</div>", "")); builder.Append(Out.Tab("<div>", "<br />")); builder.Append("IP|访问量|比例"); builder.Append(Out.Tab("</div>", "<br />")); int pageIndex; int recordCount; int pageSize = Convert.ToInt32(ub.Get("SiteListNo")); string[] pageValUrl = { "ptype" }; pageIndex = Utils.ParseInt(Request.QueryString["page"]); if (pageIndex == 0) { pageIndex = 1; } // 开始读取列表 IList <BCW.Model.Statinfo> listStatinfo = new BCW.BLL.Statinfo().GetIPs(pageIndex, pageSize, out recordCount); if (listStatinfo.Count > 0) { int k = 1; foreach (BCW.Model.Statinfo n in listStatinfo) { if (k % 2 == 0) { builder.Append(Out.Tab("<div>", "<br />")); } else { if (k == 1) { builder.Append(Out.Tab("<div>", "")); } else { builder.Append(Out.Tab("<div>", "<br />")); } } string ipCity = new IPSearch().GetAddressWithIP(n.IP); if (!string.IsNullOrEmpty(ipCity)) { ipCity = ipCity.Replace("IANA保留地址 CZ88.NET", "本机地址").Replace("CZ88.NET", "") + ":"; } if (!Utils.Isie()) { builder.Append(ipCity + "" + n.IP + "—" + n.IpCount + "—" + (Convert.ToInt32(Percent(n.IpCount, total) * 100)) + "%"); } else { builder.Append(ipCity + "" + n.IP + "—" + n.IpCount + "—<img src=\"/Files/sys/bar.gif\" height=\"10\" width=\"" + Percent(n.IpCount, total) * 100 + "\" />" + Convert.ToInt32(Percent(n.IpCount, total) * 100) + "%"); } k++; builder.Append(Out.Tab("</div>", "")); } // 分页 builder.Append(BasePage.MultiPage(pageIndex, pageSize, recordCount, Utils.getPageUrl(), pageValUrl, "page", 0)); } else { builder.Append(Out.Div("div", "没有相关记录..")); } }
private void IpListPage() { Master.Title = "查看IP"; int id = int.Parse(Utils.GetRequest("id", "get", 1, @"^[0-9]\d*$", "0")); int ptype = int.Parse(Utils.GetRequest("ptype", "get", 1, @"^[0-2]\d*$", "0")); builder.Append(Out.Tab("<div class=\"title\">", "")); if (id > 0) { builder.Append(new BCW.BLL.Link().GetLinkName(id)); } builder.Append("IP记录"); builder.Append(Out.Tab("</div>", "<br />")); builder.Append(Out.Tab("<div class=\"text\">", "")); if (ptype == 0) { builder.Append("全部|"); } else { builder.Append("<a href=\"" + Utils.getUrl("link.aspx?act=iplist&ptype=0&id=" + id + "&backurl=" + Utils.getPage(0) + "") + "\">全部</a>|"); } if (ptype == 1) { builder.Append("链入IP|"); } else { builder.Append("<a href=\"" + Utils.getUrl("link.aspx?act=iplist&ptype=1&id=" + id + "&backurl=" + Utils.getPage(0) + "") + "\">链入IP</a>|"); } if (ptype == 2) { builder.Append("链出IP"); } else { builder.Append("<a href=\"" + Utils.getUrl("link.aspx?act=iplist&ptype=2&id=" + id + "&backurl=" + Utils.getPage(0) + "") + "\">链出IP</a>"); } builder.Append(Out.Tab("</div>", "<br />")); int pageIndex; int recordCount; int pageSize = Convert.ToInt32(ub.Get("SiteListNo")); string strWhere = ""; string[] pageValUrl = { "act", "ptype", "id", "backurl" }; pageIndex = Utils.ParseInt(Request.QueryString["page"]); if (pageIndex == 0) { pageIndex = 1; } //查询条件 if (id > 0) { strWhere += "LinkId=" + id + ""; } if (ptype > 0) { if (strWhere != "") { strWhere += " and Types=" + (ptype - 1) + ""; } else { strWhere += "Types=" + (ptype - 1) + ""; } } // 开始读取列表 IList <BCW.Model.LinkIp> listLinkIp = new BCW.BLL.LinkIp().GetLinkIps(pageIndex, pageSize, strWhere, out recordCount); if (listLinkIp.Count > 0) { int k = 1; foreach (BCW.Model.LinkIp n in listLinkIp) { if (k % 2 == 0) { builder.Append(Out.Tab("<div class=\"text\">", "<br />")); } else { if (k == 1) { builder.Append(Out.Tab("<div>", "")); } else { builder.Append(Out.Tab("<div>", "<br />")); } } string ipCity = new IPSearch().GetAddressWithIP(n.AddUsIP); if (!string.IsNullOrEmpty(ipCity)) { ipCity = ipCity.Replace("IANA保留地址 CZ88.NET", "本机地址").Replace("CZ88.NET", "") + ":"; } builder.Append("[" + ((pageIndex - 1) * pageSize + k) + "]"); builder.Append(ipCity + "" + n.AddUsIP + ""); builder.Append("浏览器:" + n.AddUsUA + ""); if (!string.IsNullOrEmpty(n.AddUsPage)) { if (n.Types == 0) { builder.Append("来访页:" + Out.UBB(n.AddUsPage) + ""); } else { builder.Append("去访页:" + Out.UBB(n.AddUsPage) + ""); } } builder.Append("[" + DT.FormatDate(n.AddTime, 12) + "]"); k++; builder.Append(Out.Tab("</div>", "")); } // 分页 builder.Append(BasePage.MultiPage(pageIndex, pageSize, recordCount, Utils.getPageUrl(), pageValUrl, "page", 0)); } else { builder.Append(Out.Div("div", "没有相关记录..")); } builder.Append(Out.Tab("<div>", "<br />")); builder.Append("温馨提示:IP记录只保留当天的记录."); builder.Append(Out.Tab("</div>", "")); builder.Append(Out.Tab("<div class=\"hr\"></div>", Out.Hr())); builder.Append(Out.Tab("<div>", "")); if (id > 0) { builder.Append("<a href=\"" + Utils.getUrl("link.aspx?act=view&id=" + id + "&backurl=" + Utils.getPage(0) + "") + "\">查看友链</a><br />"); } builder.Append("<a href=\"" + Utils.getPage("link.aspx") + "\">返回上一级</a><br />"); builder.Append(Out.Tab("</div><div class=\"title\"><a href=\"" + Utils.getUrl("default.aspx") + "\">返回管理中心</a>", "<a href=\"" + Utils.getUrl("default.aspx") + "\">返回管理中心</a>")); builder.Append(Out.Tab("</div>", "<br />")); }
protected void Page_Load(object sender, EventArgs e) { //DataSet ds = new BCW.BLL.Text().GetList("id", "select from tb_tbapay where group by id having count(*)>1"); //DataSet ds = new TPR2.BLL.guess.BaPay().GetBaPayList("id", "dt>=0 group by id having count(*)>1"); DataSet ds = BCW.Data.SqlHelper.Query("select Mobile,EndIP from tb_User where IsVerify=1"); if (ds != null && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string EndIP = ds.Tables[0].Rows[i]["EndIP"].ToString(); string Mobile = ds.Tables[0].Rows[i]["Mobile"].ToString(); string ipCity = string.Empty; if (!string.IsNullOrEmpty(EndIP)) { ipCity = new IPSearch().GetAddressWithIP(EndIP); if (!string.IsNullOrEmpty(ipCity)) { ipCity = ipCity.Replace("IANA保留地址 CZ88.NET", "本机地址").Replace("CZ88.NET", "") + ":"; } if (!ipCity.Contains("肇庆")) { builder.Append("" + Mobile + "<br />"); } } } } //DataSet ds = new BCW.BLL.Goldlog().GetList("usid,Sum(AcGold) as cent", "Types=0 and addtime>'2014-3-1 12:00:00' and addtime<'2014-3-20 15:00:00' and PUrl LIKE '/bbs/guess%' group by usid"); //int iTar = 50; //if (ds != null && ds.Tables[0].Rows.Count > 0) //{ // for (int i = 0; i < ds.Tables[0].Rows.Count; i++) // { // int usid = int.Parse(ds.Tables[0].Rows[i]["usid"].ToString()); // long Cents = Convert.ToInt64(ds.Tables[0].Rows[i]["cent"].ToString()); // if (Cents < 0) // { // long cent = Convert.ToInt64((-Cents) * (iTar * 0.001)); // new BCW.BLL.User().UpdateiGold(usid, cent, "竞猜返负(含半场单节)"); // //发内线 // string strLog = "根据你上期竞猜(含半场单节)排行榜上的亏损情况,系统自动返还了" + cent + "" + ub.Get("SiteBz") + "[url=/bbs/guess2/default.aspx]进入球彩竞猜[/url]"; // new BCW.BLL.Guest().Add(0, usid, new BCW.BLL.User().GetUsName(usid), strLog); // builder.Append(usid + "|" + Cents + "|" +cent + "<br />"); // } // } //} ////注册一万个ID //int k = 0; //for (int i = 0; i < 2000; i++) //{ // Random ra = new Random(unchecked((int)DateTime.Now.Ticks)); // string mobile = "15107582999"; // //取得会员ID // int maxId = BCW.User.Reg.GetRandId(); // if (maxId == 0 || maxId.ToString().Length != 5)// // { // continue; // } // //加密用户密码 // string strPwd = Utils.MD5Str(new Rand().RandNum(10) + ra.Next(10000, 1000000)); // //取随机识别串 // string UsKey = new Rand().RandNum(10); // //写入注册表 // BCW.Model.User model = new BCW.Model.User(); // model.ID = maxId; // model.Mobile = mobile; // model.UsName = "" + ub.Get("SiteText") + "网" + maxId + ""; // model.UsPwd = strPwd; // model.UsKey = UsKey; // model.Photo = "/Files/Avatar/image0.gif"; // model.Sex = ra.Next(1, 3); // model.RegTime = DateTime.Parse("2013-" + ra.Next(1, 9) + "-" + ra.Next(1, 29) + ""); // model.RegIP = Utils.GetUsIP(); // model.EndTime = DateTime.Now; // model.Birth = DateTime.Parse("" + ra.Next(1980, 1999) + "-" + ra.Next(1, 9) + "-" + ra.Next(1, 29) + ""); // model.Sign = "未设置签名"; // model.InviteNum = 0; // model.IsVerify = 1; // model.Email = ""; // new BCW.BLL.User().Add(model); // //积分操作 // new BCW.User.Cent().UpdateCent(BCW.User.Cent.enumRole.Cent_RegUser, maxId); // //城市就随机分配 // string sCity = Utils.DelLastChar(BCW.User.City.GetCity(), "#"); // string[] sNum = sCity.Split("#".ToCharArray()); // Random rd = new Random(); // string City = sNum[rd.Next(sNum.Length)]; // long iScore = ra.Next(800, 2000); // int Click = ra.Next(10, 300); // int Leven = ra.Next(1, 9); // int OnTime = ra.Next(500, 20000); // BCW.Data.SqlHelper.ExecuteSql("update tb_user set City='" + City + "',iScore=" + iScore + ",Click=" + Click + ",Leven=" + Leven + ",OnTime=" + OnTime + " where id=" + maxId + ""); // k++; //} //builder.Append("成功注册" + k + "个"); }
private void OkPage() { string Name = Utils.GetRequest("Name", "post", 2, @"^\d{1,10}$|^(?:13|14|15|18)\d{9}$", "请正确输入ID或者手机号"); string Pwd = Utils.GetRequest("Pwd", "post", 2, @"^[A-Za-z0-9]{6,20}$", "请正确输入您的密码"); bool IsMy = bool.Parse(Utils.GetRequest("IsMy", "post", 1, @"^True|False$", "False")); int State = int.Parse(Utils.GetRequest("State", "post", 1, @"^[0-1]$", "0")); int rowsAffected = 0; BCW.Model.User modellogin = new BCW.Model.User(); modellogin.UsPwd = Utils.MD5Str(Pwd); if (Name.Length == 11) { modellogin.Mobile = Name; rowsAffected = new BCW.BLL.User().GetRowByMobile(modellogin); } else { modellogin.ID = Convert.ToInt32(Name); rowsAffected = new BCW.BLL.User().GetRowByID(modellogin); } if (rowsAffected > 0) { BCW.Model.User model = new BCW.Model.User(); //if (Name.Length == 11) //{ // model = new BCW.BLL.User().GetKey(Name); //} //else //{ //model = new BCW.BLL.User().GetKey(Convert.ToInt32(Name)); //} model = new BCW.BLL.User().GetKey(rowsAffected); int UsId = model.ID; string UsKey = model.UsKey; string UsPwd = model.UsPwd; int IsVerify = model.IsVerify; if (IsVerify == 2) { Utils.Error("您的ID还没有通过邮箱验证,如您没到验证邮件,<a href=\"" + Utils.getUrl("reg.aspx?act=reemail") + "\">请重试</a>", ""); } string ac = Utils.GetRequest("ac", "all", 1, "", ""); if (Utils.ToSChinese(ac) == "安全登录") { //取随机识别串 UsKey = new Rand().RandNum(10); new BCW.BLL.User().UpdateUsKey(UsId, UsKey); } //加密用户密码 string strPwd = Utils.MD5Str(UsPwd.Trim()); //设置keys string keys = ""; keys = BCW.User.Users.SetUserKeys(UsId, UsPwd, UsKey); string bUrl = string.Empty; if (Utils.getPage(1) != "") { bUrl = Utils.getUrl(Utils.removeUVe(Utils.getPage(1))); } else { bUrl = Utils.getUrl("/default.aspx"); } //更新识别串 string SID = ConfigHelper.GetConfigString("SID"); bUrl = UrlOper.UpdateParam(bUrl, SID, keys); //写入Cookie if (IsMy == true) { HttpCookie cookie = new HttpCookie("LoginComment"); cookie.Expires = DateTime.Now.AddDays(30);//30天 cookie.Values.Add("userkeys", DESEncrypt.Encrypt(Utils.Mid(keys, 0, keys.Length - 4))); Response.Cookies.Add(cookie); } else { //清Cookie HttpCookie Cookie = new HttpCookie("LoginComment"); Cookie.Expires = DateTime.Now.AddDays(-1); HttpContext.Current.Response.Cookies.Add(Cookie); } if (Request["IsMy"] == "pwd") { string ForumSet = new BCW.BLL.User().GetForumSet(UsId); string[] fs = ForumSet.Split(",".ToCharArray()); string sforumsets = string.Empty; for (int i = 0; i < fs.Length; i++) { string[] sfs = fs[i].ToString().Split("|".ToCharArray()); if (i == 25) { sforumsets += "," + sfs[0] + "|" + DateTime.Now; } else { sforumsets += "," + sfs[0] + "|" + sfs[1]; } } sforumsets = Utils.Mid(sforumsets, 1, sforumsets.Length); new BCW.BLL.User().UpdateForumSet(UsId, sforumsets); } //----------------------写入登录日志文件作永久保存 try { string MyIP = Utils.GetUsIP(); string ipCity = string.Empty; if (!string.IsNullOrEmpty(MyIP)) { ipCity = new IPSearch().GetAddressWithIP(MyIP); if (!string.IsNullOrEmpty(ipCity)) { ipCity = ipCity.Replace("IANA保留地址 CZ88.NET", "本机地址").Replace("CZ88.NET", "") + ":"; } string FilePath = System.Web.HttpContext.Current.Server.MapPath("/log/loginip/" + UsId + "_" + DESEncrypt.Encrypt(UsId.ToString(), "kubaoLogenpt") + ".log"); LogHelper.Write(FilePath, "" + ipCity + "" + MyIP + "(登录)"); } } catch { } //----------------------写入日志文件作永久保存 new BCW.BLL.User().UpdateTime(UsId); //VIP隐身 int VipLeven = BCW.User.Users.VipLeven(UsId); if (new BCW.BLL.Role().IsAllMode(UsId) == false && VipLeven > 0) { new BCW.BLL.User().UpdateState(UsId, 1); } Utils.Success("登录成功", "登录成功!返回登录前的页面..<br />如果没有自动跳转,请点击以下链接..", Out.SysUBB(bUrl), "2"); } else { Utils.Error("登录失败,会员ID/手机号码或密码错误", ""); } }