private static async Task <string> ReadBoardData(string url, bool isUpdate) { if (url.IndexOf("jbbs.livedoor.jp") != -1 || url.Contains("jbbs.shitaraba.net")) { System.Text.RegularExpressions.Match m = new System.Text.RegularExpressions.Regex(@"http://jbbs.(livedoor.jp|shitaraba.net)/(?<category>.+)/(?<number>\d+)/", System.Text.RegularExpressions.RegexOptions.Compiled).Match(url); try { if (isUpdate) { throw new System.IO.FileNotFoundException(); } string data = await Utility.TextUtility.ReadAsync(gs.BoardInfoFilePath + "\\" + m.Groups["category"].Value + "-" + m.Groups["number"].Value + ".txt"); if (data == null) { throw new System.IO.FileNotFoundException(); } return(data); } catch (System.IO.FileNotFoundException) { BBS.Common.HttpClient hc = new BBS.Common.HttpClient(String.Format("http://jbbs.shitaraba.net/bbs/api/setting.cgi/{0}/{1}/", m.Groups["category"].Value, m.Groups["number"].Value)); hc.Encoding = "EUC-JP"; string data = hc.GetStringSync(); Utility.TextUtility.Write(gs.BoardInfoFilePath + "\\" + m.Groups["category"].Value + "-" + m.Groups["number"].Value + ".txt", data, false); return(data); } } else if (url.Contains("machi.to")) { return(String.Empty); } else { System.Text.RegularExpressions.Match m = new System.Text.RegularExpressions.Regex("http://(?<host>.+)/(?<folder>.+/)").Match(url); try { if (isUpdate) { throw new System.IO.FileNotFoundException(); } string data = await Utility.TextUtility.ReadAsync(gs.BoardInfoFilePath + "\\" + m.Groups["host"].Value + "-" + m.Groups["folder"].Value.Replace("/", "") + ".txt"); if (data == null) { throw new System.IO.FileNotFoundException(); } return(data); } catch (System.IO.FileNotFoundException) { BBS.Common.HttpClient hc = new BBS.Common.HttpClient(url + "SETTING.TXT"); hc.Encoding = "Shift-JIS"; string data = hc.GetStringSync(); Utility.TextUtility.Write(gs.BoardInfoFilePath + "\\" + m.Groups["host"].Value + "-" + m.Groups["folder"].Value.Replace("/", "") + ".txt", data, false); return(data); } } }
/// <summary> /// 指定した文字列を送信します /// </summary> /// <param name="data">送信するデータ</param> public static async void DataPush(string data) { Setting.GeneralSetting gs = new GeneralSetting(); string path = gs.CurrentDirectory + "\\exlog.txt"; BBS.Common.HttpClient hc = new BBS.Common.HttpClient("http://uravip.tonkotsu.jp/test/bbs.cgi"); var coo = new System.Net.CookieCollection(); coo.Add(new System.Net.Cookie("NAME", "", "/", "uravip.tonkotsu.jp")); coo.Add(new System.Net.Cookie("MAIL", "", "/", "uravip.tonkotsu.jp")); hc.Cookies = coo; await hc.PostStringAsync(String.Format("bbs=labo&key=1385391757&time={0}&FROM=&mail=&MESSAGE={1}&submit=書き込む", Chron.Calture.GetTime(DateTime.Now), data)); }
/// <summary> /// 指定されたURL先の板のローカルルールを取得します /// </summary> /// <param name="boardUrl">取得先の板のURL</param> /// <returns>取得したデータ 失敗した場合はnullが入っています</returns> public static async Task <string> GetLocalRule(string boardUrl) { var type = Common.TypeJudgment.BBSTypeJudg(boardUrl); if (type == BBSType._2ch || type == BBSType.jbbs) { boardUrl += "head.txt"; } else { return(null); } BBS.Common.HttpClient hc = new BBS.Common.HttpClient(boardUrl); return(await hc.GetStringAsync()); }
/// <summary> /// 規制されているか確認します /// </summary> /// <returns>規制状況</returns> /// <param name="specific">板別規制の際の板名</param> public static DenyType Check(ref string[] specific) { BBS.Common.HttpClient hc = new BBS.Common.HttpClient("http://uravip.tonkotsu.jp/host.pl"); var host = hc.GetStringSync(); BBS.Common.HttpClient hcc = new BBS.Common.HttpClient("http://qb7.2ch.net/_403/madakana.cgi"); string dat = hcc.GetStringSync(); var data = dat.Split(new string[] { "<hr>" }, StringSplitOptions.RemoveEmptyEntries); var baseString = data[1]; string[] lines = baseString.Split(new string[] { "<br>", "<br/>" }, StringSplitOptions.RemoveEmptyEntries); var l = new List <string>(); foreach (var item in lines) { string li = item.Replace("\n", ""); if (li.IndexOf("#") != 0 && !String.IsNullOrWhiteSpace(li)) { li = VIPBrowserLibrary.Utility.StringUtility.RemoveTag(li, "b"); li = Regex.Replace(li, "<small.+?>.+?</small>", "", RegexOptions.Compiled).Replace(" ", ""); l.Add(li); } } List <string> speList = new List <string>(); bool isC = false; DenyType dt = 0; foreach (var item in l) { string hosts = Regex.Replace(item, @"_[\w_]+_", "", RegexOptions.Compiled); if (Regex.IsMatch(host, hosts, RegexOptions.Compiled)) { if (Regex.IsMatch(item, @"_\d{10}_", RegexOptions.Compiled)) { continue; } isC = true; if (item.Contains("_HANA_")) { dt = DenyType.Hana | dt; } else if (item.Contains("_BBS_")) { dt = DenyType.SpecificBoard | dt; string boardName = Regex.Match(item, "_BBS_(?<name>.+?)_", RegexOptions.Compiled).Groups["name"].Value; speList.Add(boardName); } else if (item.Contains("_2CH_")) { dt = DenyType.Twoch | dt; } else if (item.Contains("_PINK_")) { dt = DenyType.Pink | dt; } else { dt = DenyType.AllBoard | dt; } } } specific = speList.ToArray(); if (isC) { return(dt); } else { return(DenyType.None); } }