private void AddSession(string sOpenId, string sFakeId, string sSession) { string sSql = string.Format("INSERT INTO `mpserver_session` (`session`, `time`, `user`, `other`) VALUES ('{0}', '{1}', '{2}', '{3}')", sSession, DateTime.Now, sOpenId, sFakeId); CDBAccess.MySqlDt(sSql); }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace((string)Session["User"])) { Response.Redirect("Login.aspx"); return; } sUserID = Request["ID"]; if (string.IsNullOrWhiteSpace(sUserID)) { Response.Redirect("Login.aspx"); } else { string sSql = string.Format("SELECT * FROM `mpserver_mpweixin_login` WHERE `Id` = {0}", sUserID); DataTable dt = CDBAccess.MySqlDt(sSql); if (dt.Rows.Count <= 0) { Response.Redirect("Admin.aspx"); } else { TBMPUser.Text = dt.Rows[0]["MPUser"].ToString(); TBPass.Text = dt.Rows[0]["MPPass"].ToString(); TBYsid.Text = dt.Rows[0]["OriginalId"].ToString(); TBKfid.Text = dt.Rows[0]["ServerId"].ToString(); } } }
protected void ButEdit_Click(object sender, EventArgs e) { string sSql = string.Format("UPDATE `mpserver_mpweixin_login` SET `MPUser`='{0}', `MPPass`='{1}', `OriginalId`='{2}', `MPKey`='{3}', `User`='{4}', `ServerId`='{5}' WHERE (`Id`='{6}')", TBMPUser.Text, TBPass.Text, TBYsid.Text, TBKfid.Text, sUserID); CDBAccess.MySqlDt(sSql); Response.Redirect("Admin.aspx"); }
protected void ButEdit_Click(object sender, EventArgs e) { string sMPKey = Guid.NewGuid().ToString().Substring(1, 5); string sAddUser = (string)Session["User"]; string sSql = string.Format("INSERT INTO `mpserver_mpweixin_login` (`MPUser`, `MPPass`, `OriginalId`, `MPKey`, `User`, `ServerId`) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", TBMPUser.Text, TBPass.Text, TBYuanShiId.Text, sMPKey, sAddUser, TBKfid.Text); CDBAccess.MySqlDt(sSql); Response.Redirect("Admin.aspx"); }
internal static void AddEdit(HttpContext context) { string sSql = string.Format("DELETE FROM `Push_Messages` WHERE `OriginalId` = '{0}'", context.Request["OriginalId"]); CDBAccess.MySqlDt(sSql); string[] sData = new string[] { context.Request["j1"], context.Request["MsgText1"], context.Request["OriginalId"] }; sSql = string.Format("INSERT INTO `Push_Messages` (`type`, `text`, `OriginalId`) VALUES ('{0}', '{1}', '{2}')", sData); CDBAccess.MySqlDt(sSql); sData = new string[] { context.Request["j2"], context.Request["MsgText2"], context.Request["OriginalId"] }; sSql = string.Format("INSERT INTO `Push_Messages` (`type`, `text`, `OriginalId`) VALUES ('{0}', '{1}', '{2}')", sData); CDBAccess.MySqlDt(sSql); }
/// <summary> /// 写入Cookies /// </summary> private static void WriteCookies() { //删除同OriginalId的记录 string sSql = string.Format("DELETE FROM `mpserver_cookies` WHERE OriginalId = '{0}'", WeiXinMsgInfo.OriginalId); CDBAccess.MySqlDt(sSql); //插入新OriginalId记录 string sCookies = GetAllCookies(LoginInfo.LoginCookie); sSql = string.Format("INSERT INTO `mpserver_cookies` (`Cookies`, `Token`, `OriginalId`, `Time`) VALUES ('{0}', '{1}', '{2}', '{3}')", sCookies, LoginInfo.Token, WeiXinMsgInfo.OriginalId, LoginInfo.CreateDate); CDBAccess.MySqlDt(sSql); }
public static DataTable ShowEdit(HttpContext context) { string sSql = string.Format("Select * From `Push_Messages` WHERE `OriginalId` = '{0}' LIMIT 0, 2", context.Request["OriginalId"]); DataTable dt = CDBAccess.MySqlDt(sSql); if (dt.Rows.Count <= 0) { return(null); } else { return(dt); } }
public bool ChecksOriginalId(string sOriginalId) { string sSql = string.Format("SELECT COUNT(1) FROM `mpserver_mpweixin_login` WHERE `OriginalId` = '{0}'", sOriginalId); DataTable dt = CDBAccess.MySqlDt(sSql); if (dt.Rows.Count < 0) { return(false); } else { return(Convert.ToInt16(dt.Rows[0][0]) > 0); } }
public static DataTable ShowSendUser(string sOriginalId) { string sSql = string.Format("SELECT `Id`,`OpenId`,`DateTime` FROM `push_logs` WHERE `DateTime` >= NOW() - INTERVAL 2 DAY AND `OriginalId` = '{0}' GROUP BY `OpenId`", sOriginalId); DataTable dt = CDBAccess.MySqlDt(sSql); if (dt.Rows.Count <= 0) { return(null); } else { return(dt); } }
/*ERROR CODE: * -10011 MP帐号密码未设置 * -10001 系统错误 * 1绑定成功 * 0记录成功 */ public static string IsBindFakeId() { bool bGetFans = WeiXinTool.OpenIdToFans(WeiXinMsgInfo.OpenId); string[] aMPInfo = WeiXinTool.GetMPUserInfo(WeiXinMsgInfo.OriginalId); WeiXinBindInfo.MPUser = aMPInfo[0]; WeiXinBindInfo.MPPass = aMPInfo[1]; Weixin_Server.Bind.Helper.WeiXinLogin.ExecLogin(WeiXinBindInfo.MPUser, WeiXinBindInfo.MPPass); if (aMPInfo == null) { return("-10011"); } WeiXinBindInfo.BreakMsg = Guid.NewGuid().ToString().Substring(0, 5); //WeiXinBindInfo.BreakMsg = "cbe5c"; if (!bGetFans) { string sOutText = string.Format("您是首次使用本平台,将会为您自动注册,如果在5秒内收到绑定成功信息则代表注册成功!<a href=\"http:////Rmbz.Net\\{0}\"> </a>", WeiXinBindInfo.BreakMsg); //MPServer mp = new MPServer(); WritePage(sOutText, false); Thread.Sleep(2500); string[] aFakeId = Bind.MPBind.BindFakeId(WeiXinBindInfo.BreakMsg, WeiXinBindInfo.MPUser, WeiXinBindInfo.MPPass); if (aFakeId.Length == 2) { WeiXinFans.sFakeId = aFakeId[0]; string sSql = string.Format("INSERT INTO `mpserver_bridge` (`openid`, `fakeid`, `name`, `time`) VALUES ('{0}', '{1}', '{2}', '{3}')", WeiXinMsgInfo.OpenId, aFakeId[0], WeiXinTool.Base64Code(aFakeId[1]), DateTime.Now); CDBAccess.MySqlDt(sSql); Weixin_Server.Bind.Helper.SendMsg.SendMessageText(aFakeId[1] + " 绑定成功,现在您可以体验完整功能啦。", WeiXinFans.sFakeId); return("1"); } else { string sSql = string.Format("INSERT INTO `mpserver_bridge` (`openid`, `fakeid`, `name`, `time`) VALUES ('{0}', '{1}', '{2}', '{3}')", WeiXinMsgInfo.OpenId, 0, 0, DateTime.Now); CDBAccess.MySqlDt(sSql); return("-10001"); } } else { string sSql = string.Format("INSERT INTO `Push_logs` (`openid`, `text`, `do`, `datetime`, `OriginalId`) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}')", WeiXinMsgInfo.OpenId, WeiXinMsgInfo.Text, WeiXinMsgInfo.Do, DateTime.Now, WeiXinMsgInfo.OriginalId); CDBAccess.MySqlDt(sSql); return("0"); } }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace((string)Session["User"])) { Response.Redirect("Login.aspx"); return; } string sUserId = Request["id"]; if (string.IsNullOrWhiteSpace(sUserId)) { Response.Redirect("Login.aspx"); } else { string sSql = string.Format("DELETE FROM `mpserver_mpweixin_login` WHERE (`Id`='{0}')", sUserId); CDBAccess.MySqlDt(sSql); Response.Redirect("Admin.aspx"); } }
private bool CheckSession(string sOpenId, string sSession) { string sSql = string.Format("SELECT * FROM `mpserver_session` WHERE `User` = '{0}' AND `session` = '{1}'", sOpenId, sSession); DataTable dt = CDBAccess.MySqlDt(sSql); if (dt.Rows.Count <= 0) { return(false); } else { DateTime dtTime = (DateTime)dt.Rows[0]["time"]; if ((DateTime.Now - dtTime).TotalSeconds <= 300) { return(true); } else { DelSession(sOpenId); return(true); } } }
protected void ButLogin_Click(object sender, EventArgs e) { string sUser = TBUser.Text; string sPass = TBPass.Text; if (string.IsNullOrWhiteSpace(sUser)) { Tips.Text = "用户名不能为空"; return; } if (string.IsNullOrWhiteSpace(sPass)) { Tips.Text = "用户名不能为空"; return; } string sSql = string.Format("SELECT * FROM `mpserver_server_user` WHERE `user`='{0}'", sUser); DataTable dt = CDBAccess.MySqlDt(sSql); if (dt.Rows.Count <= 0) { Tips.Text = "帐号或密码错误!"; return; } else { if (dt.Rows[0]["pass"].ToString() != sPass) { Tips.Text = "帐号或密码错误!"; return; } else { Session.Add("User", sUser); Response.Redirect("admin.aspx"); } } }
public static DataTable FakeList(string sOriginalId) { string sSql = string.Format(@"SELECT `push_logs`.`OpenId`, `mpserver_bridge`.`fakeid` FROM `push_logs` LEFT JOIN `mpserver_bridge` ON `push_logs`.`OpenId` = `mpserver_bridge`.`openid` WHERE `DateTime` >= NOW() - INTERVAL 2 DAY AND `OriginalId` = '{0}' GROUP BY `push_logs`.`OpenId`" , sOriginalId); DataTable dt = CDBAccess.MySqlDt(sSql); if (dt.Rows.Count <= 0) { return(null); } else { return(dt); } }
private DataTable GetUserList(string sUser) { string sSql = string.Format("SELECT * FROM `mpserver_mpweixin_login` WHERE `User` = '{0}'", sUser); return(CDBAccess.MySqlDt(sSql)); }
private DataTable GetUserList(string sUser) { string sSql = "SELECT * FROM `mpserver_server_user`"; return(CDBAccess.MySqlDt(sSql)); }
private void DelSession(string sOpenId) { string sSql = string.Format("DELETE FROM `mpserver_session` WHERE (`User`='{0}')", sOpenId); CDBAccess.MySqlDt(sSql); }