static public string MakeHtml(yaf.pages.ForumPage basePage, string bbcode, bool DoFormatting) { System.Collections.ArrayList codes = new System.Collections.ArrayList(); const string codeFormat = ".code@{0}."; Match m = r_code2.Match(bbcode); int nCodes = 0; while (m.Success) { string before_replace = m.Groups[0].Value; string after_replace = m.Groups["inner"].Value; try { HighLighter hl = new HighLighter(); hl.ReplaceEnter = true; after_replace = hl.colorText(after_replace, System.Web.HttpContext.Current.Server.MapPath(Data.ForumRoot + "defs/"), m.Groups["language"].Value); } catch (Exception x) { if (basePage.IsAdmin) { basePage.AddLoadMessage(x.Message); } after_replace = FixCode(after_replace); } bbcode = bbcode.Replace(before_replace, string.Format(codeFormat, nCodes++)); codes.Add(string.Format("<div class='code'><b>Code:</b><div class='innercode'>{0}</div></div>", after_replace)); m = r_code2.Match(bbcode); } m = r_code1.Match(bbcode); while (m.Success) { string before_replace = m.Groups[0].Value; string after_replace = FixCode(m.Groups["inner"].Value); bbcode = bbcode.Replace(before_replace, string.Format(codeFormat, nCodes++)); codes.Add(string.Format("<div class='code'><b>Code:</b><div class='innercode'>{0}</div></div>", after_replace)); m = r_code1.Match(bbcode); } m = r_size.Match(bbcode); while (m.Success) { ///Console.WriteLine("{0}",m.Groups["size"]); int i = GetNumber(m.Groups["size"].Value); string tmp; if (i < 1) { tmp = m.Groups["inner"].Value; } else if (i > 9) { tmp = string.Format("<span style=\"font-size:{1}\">{0}</span>", m.Groups["inner"].Value, GetFontSize(9)); } else { tmp = string.Format("<span style=\"font-size:{1}\">{0}</span>", m.Groups["inner"].Value, GetFontSize(i)); } bbcode = bbcode.Substring(0, m.Groups[0].Index) + tmp + bbcode.Substring(m.Groups[0].Index + m.Groups[0].Length); m = r_size.Match(bbcode); } bbcode = FormatMsg.iAddSmiles(basePage, bbcode); if (DoFormatting) { NestedReplace(ref bbcode, r_bold, "<b>${inner}</b>"); NestedReplace(ref bbcode, r_strike, "<s>${inner}</s>"); NestedReplace(ref bbcode, r_italic, "<i>${inner}</i>"); NestedReplace(ref bbcode, r_underline, "<u>${inner}</u>"); // e-mails NestedReplace(ref bbcode, r_email2, "<a href=\"mailto:${email}\">${inner}</a>", new string[] { "email" }); NestedReplace(ref bbcode, r_email1, "<a href=\"mailto:${inner}\">${inner}</a>"); // urls if (basePage.BoardSettings.BlankLinks) { NestedReplace(ref bbcode, r_url2, "<a target=\"_blank\" href=\"${http}${url}\">${inner}</a>", new string[] { "url", "http" }, new string[] { "", "http://" }); NestedReplace(ref bbcode, r_url1, "<a target=\"_blank\" href=\"${http}${inner}\">${http}${inner}</a>", new string[] { "http" }, new string[] { "http://" }); } else { NestedReplace(ref bbcode, r_url2, "<a href=\"${http}${url}\">${inner}</a>", new string[] { "url", "http" }, new string[] { "", "http://" }); NestedReplace(ref bbcode, r_url1, "<a href=\"${http}${inner}\">${http}${inner}</a>", new string[] { "http" }, new string[] { "http://" }); } // font NestedReplace(ref bbcode, r_font, "<span style=\"font-family:${font}\">${inner}</span>", new string[] { "font" }); NestedReplace(ref bbcode, r_color, "<span style=\"color:${color}\">${inner}</span>", new string[] { "color" }); // bullets bbcode = r_bullet.Replace(bbcode, "<li>"); NestedReplace(ref bbcode, r_list4, "<ol type=\"i\">${inner}</ol>"); NestedReplace(ref bbcode, r_list3, "<ol type=\"a\">${inner}</ol>"); NestedReplace(ref bbcode, r_list2, "<ol>${inner}</ol>"); NestedReplace(ref bbcode, r_list2, "<ul>${inner}</ul>"); // alignment NestedReplace(ref bbcode, r_center, "<div align=\"center\">${inner}</div>"); NestedReplace(ref bbcode, r_left, "<div align=\"left\">${inner}</div>"); NestedReplace(ref bbcode, r_right, "<div align=\"right\">${inner}</div>"); // image NestedReplace(ref bbcode, r_img, "<img src=\"${inner}\"/>"); bbcode = r_hr.Replace(bbcode, "<hr noshade/>"); bbcode = r_br.Replace(bbcode, "<br/>"); } while (r_quote2.IsMatch(bbcode)) { bbcode = r_quote2.Replace(bbcode, "<div class='quote'><b>${quote} wrote:</b><div class='innerquote'>${inner}</div></div>"); } while (r_quote1.IsMatch(bbcode)) { bbcode = r_quote1.Replace(bbcode, "<div class='quote'><b>Quote:</b><div class='innerquote'>${inner}</div></div>"); } m = r_post.Match(bbcode); while (m.Success) { string link = Forum.GetLink(Pages.posts, "m={0}#{0}", m.Groups["post"]); if (basePage.BoardSettings.BlankLinks) { bbcode = bbcode.Replace(m.Groups[0].ToString(), string.Format("<a target=\"_blank\" href=\"{0}\">{1}</a>", link, m.Groups["inner"])); } else { bbcode = bbcode.Replace(m.Groups[0].ToString(), string.Format("<a href=\"{0}\">{1}</a>", link, m.Groups["inner"])); } m = r_post.Match(bbcode); } m = r_topic.Match(bbcode); while (m.Success) { string link = Forum.GetLink(Pages.posts, "t={0}", m.Groups["topic"]); if (basePage.BoardSettings.BlankLinks) { bbcode = bbcode.Replace(m.Groups[0].ToString(), string.Format("<a target=\"_blank\" href=\"{0}\">{1}</a>", link, m.Groups["inner"])); } else { bbcode = bbcode.Replace(m.Groups[0].ToString(), string.Format("<a href=\"{0}\">{1}</a>", link, m.Groups["inner"])); } m = r_topic.Match(bbcode); } while (nCodes > 0) { bbcode = bbcode.Replace(string.Format(codeFormat, --nCodes), codes[nCodes].ToString()); } return(bbcode); }
static public void CreateWatchEmail(pages.ForumPage basePage, object messageID) { using (DataTable dt = DB.message_list(messageID)) { foreach (DataRow row in dt.Rows) { // Send track mails string subject = String.Format("Topic Subscription New Post Notification (From {0})", basePage.BoardSettings.Name); string body = Utils.ReadTemplate("topicpost.txt"); body = body.Replace("{forumname}", basePage.BoardSettings.Name); body = body.Replace("{topic}", row["Topic"].ToString()); body = body.Replace("{link}", String.Format("{0}{1}", basePage.ServerURL, Forum.GetLink(Pages.posts, "m={0}#{0}", messageID))); DB.mail_createwatch(row["TopicID"], basePage.BoardSettings.ForumEmail, subject, body, row["UserID"]); } } }