/// <summary> /// 登陆主站 /// </summary> /// <param name="user"></param> /// <returns></returns> public object[] LoginMainSite(UserEntity user) { var result = new object[] { false, "登录失败!" }; try { const string fmdo = "login"; const string dopost = "login"; const string gourl = ""; var userid = user.UserName; var pwd = user.PassWord; const string keeptime = "2592000"; const string vdcode = "ProxyHeroLog"; string postData = string.Format( "fmdo={0}&dopost={1}&gourl={2}&userid={3}&pwd={4}&keeptime={5}&vdcode={6}", fmdo, dopost, gourl, userid, pwd, keeptime, vdcode); var html = GetHtml("http://www.loamen.com/member/index_do.php", postData, Encoding.GetEncoding(Encode)); if (html.Contains("成功登录")) { _currentUser = user; _currentUser.IsLogged = true; result[0] = true; result[1] = "成功登录!"; CookiesHelper.SetIECookie(this, "http://www.loamen.com"); } else { result[0] = false; } } catch (Exception ex) { result[0] = false; result[1] = ex.Message; } return(result); }
/// <summary> /// 登录论坛 /// </summary> /// <param name="user"></param> /// <returns></returns> public object[] LoginBbs(UserEntity user) { var result = new object[] { false, "登录失败!" }; try { const string forward = ""; var jumpurl = "http://" + Config.ProxyHeroCloudSetting.BbsDomain + ""; const string step = "2"; const string lgt = "0"; var pwuser = user.UserName; var pwpwd = user.PassWord; const string hideid = "0"; const string cktime = "2592000"; string postData = string.Format( "forward={0}&jumpurl={1}&step={2}&lgt={3}&pwuser={4}&pwpwd={5}&hideid={6}&cktime={7}", forward, jumpurl, step, lgt, pwuser, pwpwd, hideid, cktime); var html = GetHtml("http://" + Config.ProxyHeroCloudSetting.BbsDomain + "/login.php?", postData, Encoding.GetEncoding(Encode)); result[1] = StringHelper.GetMidString(html, @"<span class=""f14"">", @"</span>"); if (html.Contains("顺利登录") || html.Contains("请不要重复登录")) { _currentBbsUser = user; _currentBbsUser.IsLogged = true; result[0] = true; CookiesHelper.SetIECookie(this, "http://" + Config.ProxyHeroCloudSetting.BbsDomain + ""); html = GetHtml("http://" + Config.ProxyHeroCloudSetting.BbsDomain + "/mode.php?m=o&q=user"); if (html.Contains("个人空间")) { //匹配头像url if (!File.Exists(AvatarPath)) { var regex = new Regex( "<div\\sclass=\"user_face\"><img\\s+src=\"(?<url>[^\"]+)\"\\s+width=\"120\"\\s+height=\"120\"\\s+border=\"0"); MatchCollection matchs = regex.Matches(html); var imagesHelper = new ImagesHelper(); if (matchs.Count > 0) { string imgesUrl = matchs[0].Groups["url"].Value; imagesHelper.SaveImage(imgesUrl, AvatarPath, new Size(24, 24)); } else { imagesHelper.SaveImage("http://bbs.uueasy.com/images/face/none.gif", AvatarPath, new Size(24, 24)); } } } } else { result[0] = false; } } catch (Exception ex) { result[0] = false; result[1] = ex.Message; } return(result); }