using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Resources;
using System.Globalization;
using System.Threading;
using vbenc;
namespace infoExpediters
{
///
/// Summary description for BBCode.
///
public class BBCode
{
string orgMessage, str1, specialchars = "$#@*(%~";
string[] SmilieCodeFind;
string[] SmilieCodeReplace;
string[] BBCodes ={"[code]",
"[quote]",
"[quote=",
"[highlight]",
"[b]","[u]","[i]","[color=","[size=","[font=","[left]","[center]","[right]","[indent]",
"[list=",
"[list]",
"[email]",
"[email=",
"[url]",
"[url=",
"[sup]",
"[sub]","[justification]"};
string[] FindCode ={ @"\[code\](.*)\[/code\]",
@"\[quote\](.*)\[/quote\]",
@"\[quote=("|""|'|)(.*)\1\](.*)\[/quote\]",
@"\[highlight\](.*)\[/highlight\]",
@"\[b\](.*)\[/b\]",
@"\[u\](.*)\[/u\]",
@"\[i\](.*)\[/i\]",
@"\[color=("|""|'|)(\#?\w+)\1\](.*)\[/color\]",
@"\[size=("|""|'|)([0-9\+\-]+)\1\](.*)\[/size\]",
@"\[font=("|""|'|)([^"":]*)\1\](.*)\[/font\]",
@"\[left\](.*)\[/left\](
|
)??",
@"\[center\](.*)\[/center\](
|
)??",
@"\[right\](.*)\[/right\](
|
)??",
@"\[indent\](.*)\[/indent\]",
@"\s*(\[list=("|""|'|)([^\]]*)\2\](.*)\[/list(=\2\3\2)?\])\s*",
@"\s*(\[list\](.*)\[/list\])\s*",
@"\[email\](.*)\[/email\]",
@"\[email=("|""|'|)(.*)\1\](.*)\[/email\]",
@"\[url\](.*)\[/url\]",
@"\[url=("|""|'|)(.*)\1\](.*)\[/url\]",
@"\[sup\](.*)\[/sup\]",
@"\[sub\](.*)\[/sub\]",
@"\[justification\](.*)\[/justification\](
|
)??",
};
public String imgReg;
public BBCode()
{
//
// TODO: Add constructor logic here
//
}
public void PopulateSmileyArray()
{
WebCode objWebCode = new WebCode();
DataSet ds = new DataSet();
ds = objWebCode.getAllSmilies();
int recordcount = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString());
int i = 0;
int temp;
temp = recordcount + 14;
SmilieCodeFind = new string[temp];
SmilieCodeReplace = new string[temp];
//For SmileCode Find values --begin
SmilieCodeFind[0] = @">)";
SmilieCodeFind[1] = "<)";
SmilieCodeFind[2] = "")";
SmilieCodeFind[3] = @":)";
SmilieCodeFind[4] = ":o";
SmilieCodeFind[5] = ":D";
SmilieCodeFind[6] = @";)";
SmilieCodeFind[7] = ":p";
SmilieCodeFind[8] = ":mad:";
SmilieCodeFind[9] = ":confused:";
SmilieCodeFind[10] = @":(";
SmilieCodeFind[11] = ":rolleyes:";
SmilieCodeFind[12] = ":cool:";
SmilieCodeFind[13] = ":eek:";
//For SmileCode Find values --End
//For SmilieCode Replace values --begin
SmilieCodeReplace[0] = ">|||)";
SmilieCodeReplace[1] = "<|||)";
SmilieCodeReplace[2] = ""|||)";
SmilieCodeReplace[3] = "
";
SmilieCodeReplace[4] = "
";
SmilieCodeReplace[5] = "
";
SmilieCodeReplace[6] = "
";
SmilieCodeReplace[7] = "
";
SmilieCodeReplace[8] = "
";
SmilieCodeReplace[9] = "
";
SmilieCodeReplace[10] = "
";
SmilieCodeReplace[11] = "
";
SmilieCodeReplace[12] = "
";
SmilieCodeReplace[13] = "
";
while (i < recordcount)
{
SmilieCodeFind[14 + i] = ds.Tables[0].Rows[i][1].ToString();
string replace = "
";
SmilieCodeReplace[14 + i] = replace;
i++;
}
}
public String convertBBCode(String message, int EnableBB, int EnableSMiley)
{
StringConvert objSC = new StringConvert();
message = objSC.TrimWebCode(HttpUtility.HtmlEncode(message));
//For Inserting Image.
imgReg = @"\[img\]\s*(https?://([^<>*""?]+|[a-z0-9/\\._\- !]+))\[/img\]";
int i;
///For Handling html tags---Begin
if (EnableBB == 1)
{
message = Regex.Replace(message, "/&(?!#[0-9]+;)/", "&");
message.Replace("<", "<");
message.Replace("<", "<");
message.Replace(">", ">");
message.Replace("\"", """);
}
//For Handling html tags----End
////For Removing White spaces in the input string --Begin
if (EnableBB == 1)
{
message = Regex.Replace(message, @"(\r\n|\n|\r)?( )*(\[\*\]|\[/list|\[list|\[indent)", @"$3");
message = Regex.Replace(message, @"(/list\]|/indent\])( )*(\r\n|\n|\r)", @"$1");
message = message.Replace("\n", "
");
}
////For Removing White spaces in the input string --End
//For Preventing XSS Scripting --Begin
if (EnableBB == 1 || EnableSMiley == 1)
{
message = Regex.Replace(message, @"javascript:", @"java_script_:", RegexOptions.IgnoreCase);
message = Regex.Replace(message, @"livescript:", @"live_script_:", RegexOptions.IgnoreCase);
message = Regex.Replace(message, @"about:", @"about_:", RegexOptions.IgnoreCase);
message = Regex.Replace(message, @"vbscript:", @"vb_script_:", RegexOptions.IgnoreCase);
message = Regex.Replace(message, @"&(?![a-z0-9#]+;)", @"&", RegexOptions.IgnoreCase);
}
//For Preventing XSS Scripting --End
orgMessage = message;
if (EnableSMiley == 1)///For Process Smiley Codes
{ //For Smiley Codes
for (i = 0; i < SmilieCodeFind.Length; i++)
{
str1 = SmilieCodeFind.GetValue(i).ToString();
if (message.IndexOf(SmilieCodeFind.GetValue(i).ToString(), 0) >= 0)
{
orgMessage = message;
message = message.Replace(SmilieCodeFind.GetValue(i).ToString(), SmilieCodeReplace.GetValue(i).ToString());
}
}
}
orgMessage = message;
if (EnableBB == 1)///For Process Smiley Codes
{
while (message.ToLower().IndexOf("[img]", 0) >= 0)
{
orgMessage = message;
message = Regex.Replace(message, imgReg, handle_image(Regex.Match(message, imgReg, RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
if (orgMessage.Equals(message))
{
break;
}
}
for (i = 0; i < BBCodes.Length; i++)
{
str1 = BBCodes.GetValue(i).ToString();
while (message.ToLower().IndexOf(BBCodes.GetValue(i).ToString(), 0) >= 0)
{
orgMessage = message;
if (i == 0)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_code(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 1)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_quote(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 2)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_quoteequal(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 3)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_highlight(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 4)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_bold(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 5)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_Underline(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 6)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_Italic(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 7)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_color(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 8)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_size(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 9)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_font(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 10)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_left(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 11)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_center(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 12)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_right(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 13)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_indent(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 14 || i == 15)
{
orgMessage = Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value;
if (orgMessage.Length > 0)
{
orgMessage = handle_list(orgMessage);
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), orgMessage);
}
else
{
break;
}
}
else if (i == 16)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_mail(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 17)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_mailequal(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 18)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_link(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 19)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_linkequal(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 20)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_supcode(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 21)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_subscript(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else if (i == 22)
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_justification(Regex.Match(message, FindCode.GetValue(i).ToString(), RegexOptions.IgnoreCase).Value), RegexOptions.IgnoreCase);
}
else
{
message = Regex.Replace(message, FindCode.GetValue(i).ToString(), handle_bbcode(BBCodes.GetValue(i).ToString(), "$1", "$2", "$3"), RegexOptions.IgnoreCase);
}
message = message.Replace("$#&", "$&");
if (orgMessage.Equals(message))
{
break;
}
}///End Of While...
}///End Of For...
}///End Of If...
return message;
}
public string handle_bbcode(string tag, string text1, string text2, string text3)
{
string strReturn = "";
switch (tag.ToLower())
{
case "[code]":
strReturn = handle_code(text1);
break;
case "[quote]":
strReturn = handle_quote(text1);
break;
case "[quote=":
break;
case "[b]":
strReturn = "" + text1 + "";
break;
case "[highlight]":
strReturn = "" + text1 + "";
break;
case "[u]":
strReturn = "" + text1 + "";
break;
case "[i]":
strReturn = "" + text1 + "";
break;
case "[color=":
strReturn = "" + text3 + "";
break;
case "[size=":
strReturn = "" + text3 + "";
break;
case "[font=":
strReturn = "" + text3 + "";
break;
case "[left]":
strReturn = "
" + text1 + "
";
break;
case "[center]":
strReturn = "" + text1 + "
";
break;
case "[right]":
strReturn = "" + text1 + "
";
break;
case "[indent]":
strReturn = "" + text1 + "
";
break;
case "[email]":
strReturn = handle_url(text1, "", "email");
break;
case "[email=":
strReturn = handle_url(text3, text2, "email");
break;
case "[list=":
strReturn = handle_list(text1);
break;
case "[list]":
strReturn = handle_list(text1);
break;
case "[url]":
strReturn = handle_url(text1, "", "url");
break;
case "[url=":
strReturn = handle_url(text3, text2, "url");
break;
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_plaintext(string text1, string text2, string text3)
{
string strReturn;
strReturn = "" + text1;
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_bold(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_bold1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(4).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_bold1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(4).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_bold1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("[B]", "[b]");
list = list.Replace("[/B]", "[/b]");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/b")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[b")) - "[b".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/b]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_Italic(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_Italic1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(6).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_Italic1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(6).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_Italic1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("[I]", "[i]");
list = list.Replace("[/I]", "[/i]");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/i")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[i")) - "[i".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/i]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_Underline(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_Underline1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(5).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_Underline1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(5).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_Underline1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("[U]", "[u]");
list = list.Replace("[/U]", "[/u]");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/u]")) + 1;
string tmp = list.Substring(0, slashlist);
int temppos = stripos(strrev(tmp), strrev("[u"));
int openlist = tmp.Length - temppos - "[u".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/u]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_left(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_left1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(10).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_left1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(10).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_left1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("LEFT", "left");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/left")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[left")) - "[left".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/left]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "
";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_center(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_center1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(11).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_center1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(11).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_center1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("CENTER", "center");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/center")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[center")) - "[center".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/center]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "
";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_right(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_right1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(12).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_right1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(12).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_right1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("RIGHT", "right");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/right")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[right")) - "[right".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/right]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "
";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_indent(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_indent1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(13).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_indent1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(13).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_indent1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("INDENT", "indent");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/indent")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[indent")) - "[indent".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/indent]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "
";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_highlight(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_highlight1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(3).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_highlight1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(3).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_highlight1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("HIGHLIGHT", "highlight");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/highlight")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[highlight")) - "[highlight".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/highlight]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_code(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_code1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(0).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_code1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(0).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_code1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
string getlist = "";
try
{
list = list.Replace("CODE", "code");
////
//Call unremove smiles
list = unparseSmileyCode(list);
list.Replace("
", "");
list.Replace("
", "");
list = Regex.Replace(list, "/&(?!#[0-9]+;)/", "&");
list.Replace("<", "<");
list.Replace("<", "<");
list.Replace(">", ">");
list.Replace("\"", """);
///
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/code")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[code")) - "[code".Length;
getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/code]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string strCode;
strCode = @"";
strCode += @"
Code:
";
strCode += @"
";
strCode += midstr;
strCode += @"";
strCode += @"
";
message = list;
message = message.Replace(getlist, strCode);
}
catch
{
message = getlist;
}
}
return message;
}
public string handle_quote(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_quote1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(1).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_quote1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(1).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_quote1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
string getlist = "";
try
{
list = list.Replace("QUOTE", "quote");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/quote")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[quote")) - "[quote".Length;
getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/quote]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string strQuote;
strQuote = @"";
strQuote += @"
Quote:
";
strQuote += @"
";
strQuote += @"";
strQuote += @"| ";
strQuote += midstr;
strQuote += @" | ";
strQuote += @"
";
strQuote += @"
";
strQuote += @"
";
message = list;
message = message.Replace(getlist, strQuote);
}
catch
{
message = getlist;
}
}
return message;
}
public string handle_quoteequal(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_quoteequal1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(2).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_quoteequal1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(2).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_quoteequal1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
string getlist = "";
try
{
list = list.Replace("QUOTE", "quote");
string midstr = "";
int length, sindex1, sindex2;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/quote")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[quote")) - "[quote".Length;
getlist = list.Substring(openlist, (slashlist - openlist));
sindex1 = getlist.IndexOf("[quote=") + 7;
sindex2 = getlist.IndexOf("]");
string fontface = getlist.Substring(7, sindex2 - 7);
midstr = getlist;
length = getlist.ToString().IndexOf("[/quote]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "";
string strQuote;
strQuote = @"";
strQuote += @"
Quote:
";
strQuote += @"
";//width='100%'
strQuote += @"";
strQuote += @"| ";
strQuote += @" Originally Posted by " + fontface + " ";
strQuote += @"" + midstr + " ";///Passed String
strQuote += @" | ";
strQuote += @"
";
strQuote += @"
";
strQuote += @"
";
message = list;
message = message.Replace(getlist, strQuote);
}
catch
{
message = getlist;
}
}
return message;
}
public string handle_url(string text, string link, string val)//string text1,string text2,string val
{
string tmp = "";
string rightlink = "";
if (text.Trim().Equals(""))
{
return "";
}
rightlink = link.Trim();
if (rightlink.Equals(""))
{
rightlink = text.Trim();
}
rightlink = Regex.Replace(rightlink, "\"", """);
if (val.Equals("url") && !(Regex.IsMatch(rightlink, "^[a-z0-9]+://")))
{
//rightlink = "http://" + rightlink;
//$rightlink = "http://$rightlink";
}
if (!(link.Trim().Equals("")) || text.Equals(rightlink))
{ tmp = rightlink;
tmp.Replace("<", "<");
tmp.Replace(">", ">");
tmp.Replace(""", "\"");
tmp.Replace("&", "&");
if (tmp.Length > 55)//AND !$wysiwygparse)
{
text = tmp.Substring(0, 35) + "..." + tmp.Substring(-15);///have to confirm
}
}
rightlink = Regex.Replace(rightlink, " ", "");
text = Regex.Replace(text, "\"", "\"");//have to confirm
if (val.Equals("url"))
{
// standard URL hyperlink
return "" + text + "";
}
else
{
string returnMail = "" + text + "";
returnMail = returnMail.Replace("$&", "$#&");
return returnMail;
}
}
public string handle_mail(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_mail1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(16).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_mail1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(16).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_mail1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("EMAIL", "email");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/email")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[email")) - "[email".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/email]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string returnMail = "";
// standard EMAIL hyperlink
if (Regex.IsMatch(midstr, @"[\w\.\-]+\@[\w\.\-]+\.(com|net|org|info|biz|tv|us|cc|ws|bz|vg|gs|tc|ms|name|edu|gov|mil|co){1}(\.(\w{2}))?$", RegexOptions.IgnoreCase))
{
///For Checking Valid EMAIl --End
// standard EMAIL hyperlink
returnMail = "" + midstr + "";
}
else
{
returnMail = midstr;
}
message = list;
message = message.Replace(getlist, returnMail);
}
return message;
}
public string handle_mailequal(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_mailequal1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(17).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_mailequal1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(17).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_mailequal1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("EMAIL", "email");
string midstr = "";
int length, sindex1, sindex2;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/email")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[email")) - "[email".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
sindex1 = getlist.IndexOf("[email=") + 7;
sindex2 = getlist.IndexOf("]");
string rightlink = getlist.Substring(7, sindex2 - 7);
midstr = getlist;
length = getlist.ToString().IndexOf("[/email]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
///For Checking Valid EMAIL --Begin
string returnMail = "";
if (Regex.IsMatch(rightlink, @"[\w\.\-]+\@[\w\.\-]+\.(com|net|org|info|biz|tv|us|cc|ws|bz|vg|gs|tc|ms|name|edu|gov|mil|co){1}(\.(\w{2}))?$", RegexOptions.IgnoreCase))
{
// standard EMAIL hyperlink
returnMail = "" + midstr + "";
}
else
{
returnMail = rightlink;
}
///For Checking Valid EMAIL --End
message = list;
message = message.Replace(getlist, returnMail);
}
return message;
}
public string handle_link(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_link1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(18).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_link1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(18).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_link1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("URL", "url");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/url")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[url")) - "[url".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/url]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
// standard URL hyperlink
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_linkequal(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_linkequal1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(19).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_linkequal1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(19).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_linkequal1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("URL", "url");
string midstr = "";
int length, sindex1, sindex2;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/url")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[url")) - "[url".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
sindex1 = getlist.IndexOf("[url=") + 5;
sindex2 = getlist.IndexOf("]");
string rightlink = getlist.Substring(5, sindex2 - 5);
midstr = getlist;
length = getlist.ToString().IndexOf("[/url]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
// standard URL hyperlink
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_list1(string text2, string text1, string val)
{
string tmp = "";
if (text1.Trim().Equals(""))
{
return "";
}
text2 = text2.Trim();
if (text2.Equals(null))
{
text2 = text1.Trim();
}
//text2 = strip_smilies(str_replace('\\"', '"', $rightlink));// for smiley replaces.not done.
text2 = Regex.Replace(text2, "\"", """);
if (val.Equals("url") && !(Regex.IsMatch(text2, "^[a-z0-9]+://")))
{
text2 = "http://" + text2;
}
if (!(text2.Trim().Equals(null)) || text1.Equals(text2))
{
text2.Replace("*", "POOL");
text2.Replace(@"$1", "xx");
text2.Replace(""", "\"");
text2.Replace("&", "&");
tmp = text2;
if (text2.Length > 55)//AND !$wysiwygparse)
{
text2 = text2.Substring(0, 35) + "..." + tmp.Substring(-15);///have to confirm
}
}
text2 = Regex.Replace(text2, " ", "");
text2 = Regex.Replace(text2, "\"", "\"");//have to confirm
if (val.Equals("url"))
{
// standard URL hyperlink
return "" + text1 + "";
}
else
{
string returnMail = "" + text1 + "";
return returnMail;
}
}
public int stripos(string handle, string needle)
{
int i;
if (handle.IndexOf(needle) < 0)
i = 0;
else
i = handle.IndexOf(needle);
string foundstring = handle.Substring(i);//,handle.Length-1);
if (foundstring.Equals(handle))
return 0;
else
return handle.Length - foundstring.Length;
}
public string strrev(string str)
{
string strRet = "";
for (int i = (str.Length - 1); i >= 0; i--)
{ strRet += str.Substring(i, 1); }
return strRet;
}
public string handle_color(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_color1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(7).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_color1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(7).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_color1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
string midstr = "";
list = list.Replace("COLOR", "color");
int length, sindex1, sindex2;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/color")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[color")) - "[color".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
sindex1 = getlist.IndexOf("[color=") + 7;
sindex2 = getlist.IndexOf("]");
string fontface = getlist.Substring(7, sindex2 - 7);
midstr = getlist;
length = getlist.ToString().IndexOf("[/color]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_list(string list)
{
string listtype = "", firstbit = "", midstr = "", listmode = "1";
int i, length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/list")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[list")) - "[list".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/list]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string[] str = Regex.Split(midstr, @"\s*\[\*\]", RegexOptions.IgnorePatternWhitespace);
if (str == null)
{
return Regex.Replace(list, @"\s*" + midstr + @"\s*", "
");
}
listmode = getlist.Substring(6, 1);
if (listmode != "")
{
// switch (regs[4])
switch (listmode)
{
case "A":
// listtype = "upper-alpha";
listtype = "A";
break;
case "a":
//listtype = "lower-alpha";
listtype = "a";
break;
case "I":
//listtype = "upper-roman";
listtype = "I";
break;
case "i":
//listtype = "lower-roman";
listtype = "i";
break;
case "1":
//listtype = "decimal";
listtype = "1";
break;
default:
//listtype = "decimal";
listtype = "1";
break;
}
}
else
{
listtype = "";
}
string processList = "";
if (listtype != null)
//processList="";
processList = "";
else
processList = "";
for (i = 0; i < (str.Length); i++)
{
if (!str.GetValue(i).ToString().Equals(""))
{
if (str.GetValue(i).ToString().Length > 2)
firstbit = str.GetValue(i).ToString().Substring(0, 3).ToLower();
else
firstbit = str.GetValue(i).ToString();
if (firstbit.Equals("" + str.GetValue(i).ToString() + "";
}
}//End of If !str.GetValue(i).ToString().Equals("")
}////End of For
if (listtype != "")
processList += "
";
else
processList += "";
string ss = list.Replace(getlist, processList);
ss = ss.Replace("$&", "$#&");
return ss;
}
public string handle_font(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_font1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(9).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_font1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(9).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_font1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("FONT", "font");
string midstr = "";
int length, sindex1, sindex2;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/font")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[font")) - "[font".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
sindex1 = getlist.IndexOf("[font=") + 6;
sindex2 = getlist.IndexOf("]");
string fontface = getlist.Substring(6, sindex2 - 6);
midstr = getlist;
length = getlist.ToString().IndexOf("[/font]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_size(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_size1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(8).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_size1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(8).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_size1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("SIZE", "size");
string midstr = "";
int length, sindex1, sindex2;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/size")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[size")) - "[size".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
sindex1 = getlist.IndexOf("[size=") + 6;
sindex2 = getlist.IndexOf("]");
string fontface = getlist.Substring(6, sindex2 - 6);
midstr = getlist;
length = getlist.ToString().IndexOf("[/size]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public string handle_image(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_image1(list);
string orgMessage = Regex.Match(message, imgReg, RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_image1(strReturn);
orgMessage = Regex.Match(strReturn, imgReg, RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_image1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
string getlist = "";
try
{
list = list.Replace("IMG", "img");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/img")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[img")) - "[img".Length;
getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/img]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
//message=Regex.Replace(orgMessage,imgReg,"
",RegexOptions.IgnoreCase);
string strImage;
strImage = @"
";
message = list;
message = message.Replace(getlist, strImage);
}
catch (Exception)
{
message = getlist;
}
}
return message;
}
public string handle_imagecount(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_imagecount1(list);
string orgMessage = Regex.Match(message, imgReg, RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_imagecount1(strReturn);
orgMessage = Regex.Match(strReturn, imgReg, RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_imagecount1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("IMG", "img");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/img")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[img")) - "[img".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/img]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string strImage;
strImage = @"
";
message = list;
message = message.Replace(getlist, specialchars);
}
return message;
}
public string unparseSmileyCode(string message)
{
//For Smiley Codes
int i;
for (i = 0; i < SmilieCodeReplace.Length; i++)
{
str1 = SmilieCodeReplace.GetValue(i).ToString();
if (message.IndexOf(SmilieCodeReplace.GetValue(i).ToString(), 0) >= 0)
{
message = message.Replace(SmilieCodeReplace.GetValue(i).ToString(), SmilieCodeFind.GetValue(i).ToString());
}
}
return message;
}
//START TAG CODE
public string handle_supcode(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_supcode1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(20).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_supcode1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(20).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_supcode1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("[SUP]", "[sup]");
list = list.Replace("[/SUP]", "[/sup]");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", supp(list, "[/sup")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - supp(supp1(tmp), supp1("[sup")) - "[sup".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/sup]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public int supp(string handle, string needle)
{
int i;
if (handle.IndexOf(needle) < 0)
i = 0;
else
i = handle.IndexOf(needle);
string foundstring = handle.Substring(i);//,handle.Length-1);
if (foundstring.Equals(handle))
return 0;
else
return handle.Length - foundstring.Length;
}
public string supp1(string str)
{
string strRet = "";
for (int i = (str.Length - 1); i >= 0; i--)
{ strRet += str.Substring(i, 1); }
return strRet;
}
//END TAG CODE
//START TAG CODE
public string handle_subscript(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_supscript1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(21).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_supscript1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(21).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_supscript1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("[SUB]", "[sub]");
list = list.Replace("[/SUB]", "[/sub]");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", subsrc(list, "[/sub")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - subsrc(subsrc1(tmp), subsrc1("[sub")) - "[sub".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/sub]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
public int subsrc(string handle, string needle)
{
int i;
if (handle.IndexOf(needle) < 0)
i = 0;
else
i = handle.IndexOf(needle);
string foundstring = handle.Substring(i);
if (foundstring.Equals(handle))
return 0;
else
return handle.Length - foundstring.Length;
}
public string subsrc1(string str)
{
string strRet = "";
for (int i = (str.Length - 1); i >= 0; i--)
{ strRet += str.Substring(i, 1); }
return strRet;
}
//END TAG CODE
//start Justification
public string handle_justification(string list)
{
string strReturn = "";
if (list.Equals("") || list.Equals(null))
{
strReturn = "";
}
else
{
string message = handle_justification1(list);
string orgMessage = Regex.Match(message, FindCode.GetValue(22).ToString(), RegexOptions.IgnoreCase).Value;
strReturn = message;
while (orgMessage.Length > 0)
{
strReturn = handle_justification1(strReturn);
orgMessage = Regex.Match(strReturn, FindCode.GetValue(22).ToString(), RegexOptions.IgnoreCase).Value;
}
}
strReturn = strReturn.Replace("$&", "$#&");
return strReturn;
}
public string handle_justification1(string list)
{
string message = "";
if (list.Equals("") || list.Equals(null))
{
message = "";
}
else
{
list = list.Replace("JUSTIFICATION", "justification");
string midstr = "";
int length;
list = list.Trim();
int slashlist = list.IndexOf("]", stripos(list, "[/justification")) + 1;
string tmp = list.Substring(0, slashlist);
int openlist = tmp.Length - stripos(strrev(tmp), strrev("[justification")) - "[justification".Length;
string getlist = list.Substring(openlist, (slashlist - openlist));
midstr = getlist;
length = getlist.ToString().IndexOf("[/justification]", 0) - getlist.IndexOf("]", 0);
midstr = getlist.Substring(getlist.IndexOf("]", 0) + 1, length - 1);
string ss = "" + midstr + "
";
message = list;
message = message.Replace(getlist, ss);
}
return message;
}
//end justification
}
}