温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:多层结构会员管理系统源码
当前文件路径:mvcMemberShip/LIB/StringUtil.cs

1using System; 2
using System.Drawing; 3
using System.Data; 4
using System.Web; 5
using System.Web.UI; 6
using System.Web.UI.WebControls; 7
using System.Text.RegularExpressions; 8
using System.IO; 9
using System.Drawing.Imaging; 10
using System.Text; 11
using System.Web.Security; 12
13
namespace STAR.LIB 14
{ 15
/// <summary> 16
/// 对一些字符串进行操作的类 17
/// 创建时间:2007-04-27 18
/// 创建者:汤明伟 19
/// </summary> 20
public class StringUtil 21
{ 22
private static string passWord; //加密字符串 23
24
/// <summary> 25
/// 判断输入是否数字 26
/// </summary> 27
/// <param name="num">要判断的字符串</param> 28
/// <returns></returns> 29
static public bool VldInt(string num) 30
{ 31
... 39
} 40
41
42
/// <summary> 43
/// 修改特殊字符 44
/// </summary> 45
/// <param name="str">要替换的字符串</param> 46
/// <returns></returns> 47
static public string CheckStr(string str) 48
{ 49
... 55
} 56
57
/// <summary> 58
/// 恢复特殊字符 59
/// </summary> 60
/// <param name="str">要替换的字符串</param> 61
/// <returns></returns> 62
static public string UnCheckStr(string str) 63
{ 64
... 69
} 70
71
/// <summary> 72
/// 编辑器代码转换 73
/// </summary> 74
/// <returns></returns> 75
//static public string UBBCode(string strContent, string DisSM, string DisUBB, string DisIMG, string AutoURL, string AutoKEY, DataView log_Smilies, DataView log_KeywordsContent) 76
//{ 77
// #region 78
// string re, tmpStr, tmpStr1, tmpStr2, tmpStr3, tmpStr4, rndID; 79
// // Regex r;// 声明一个 Regex类的变量 80
// MatchCollection strMatchs;//表示非重叠匹配的序列 81
// //string strContent,string DisSM,string DisUBB,string DisIMG,string AutoURL,string AutoKEY 82
83
// if (AutoURL == "1") 84
// { 85
// re = @"([^=\]][\'']*?|^)(http|https|rstp|ftp|mms|ed2k)://([A-Za-z0-9\.\/=\?%\-_~`&@':+!]*)"; 86
// // r = new Regex(re); 87
// //strMatchs = r.Matches(strContent); 88
// strMatchs = Regex.Matches(strContent, re); 89
// foreach (Match NextMatch in strMatchs) 90
// { 91
// tmpStr = NextMatch.Groups[0].Value; 92
// tmpStr1 = NextMatch.Groups[1].Value; 93
// tmpStr2 = NextMatch.Groups[2].Value; 94
// tmpStr3 = NextMatch.Groups[3].Value; 95
// strContent = strContent.Replace(tmpStr, @"<a href=""" + tmpStr2 + @"://" + tmpStr3 + @""" target=""_blank"">" + tmpStr2 + @"://" + tmpStr3 + @"</a>"); 96
// } 97
// } 98
// if (DisUBB != "1") 99
// { 100
// if (DisIMG == "1") 101
// { 102
// re = @"(\[img\])(.[^\]]*)\[\/img\]"; 103
// strMatchs = Regex.Matches(strContent, re); 104
// foreach (Match NextMatch in strMatchs) 105
// { 106
// tmpStr = NextMatch.Groups[0].Value; 107
// tmpStr2 = NextMatch.Groups[2].Value; 108
// if (DisIMG == "1") 109
// strContent = strContent.Replace(tmpStr, @"<img src=""" + tmpStr2 + @""" border=""0"" alt=""""/>"); 110
// else 111
// strContent = strContent.Replace(tmpStr, @"<a href=""" + tmpStr2 + @""" target=""_blank"" title=""" + tmpStr2 + @"""><img src=""images/image.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>查看图片</a>"); 112
// } 113
114
// re = @"\[img=(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])"; 115
// strMatchs = Regex.Matches(strContent, re); 116
// foreach (Match NextMatch in strMatchs) 117
// { 118
// tmpStr = NextMatch.Groups[0].Value; 119
// tmpStr1 = NextMatch.Groups[1].Value; 120
// tmpStr2 = NextMatch.Groups[2].Value; 121
// if (DisIMG == "1") 122
// strContent = strContent.Replace(tmpStr, @"<img align=""" + tmpStr1 + @""" src=""" + tmpStr2 + @""" border=""0"" alt=""""/>"); 123
// else 124
// strContent = strContent.Replace(tmpStr, @"<a href=""" + tmpStr2 + @""" target=""_blank"" title=""" + tmpStr2 + @"""><img src=""images/image.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>查看图片</a>"); 125
// } 126
127
// re = @"\[img=(\d*|),(\d*|)\](.[^\]]*)\[\/img\]"; 128
// strMatchs = Regex.Matches(strContent, re); 129
// foreach (Match NextMatch in strMatchs) 130
// { 131
// tmpStr = NextMatch.Groups[0].Value; 132
// tmpStr1 = NextMatch.Groups[1].Value; 133
// tmpStr2 = NextMatch.Groups[2].Value; 134
// tmpStr3 = NextMatch.Groups[3].Value; 135
// if (DisIMG == "1") 136
// strContent = strContent.Replace(tmpStr, @"<img width=""" + tmpStr1 + @""" height=""" + tmpStr2 + @""" src=""" + tmpStr3 + @""" border=""0"" alt=""""/>"); 137
// else 138
// strContent = strContent.Replace(tmpStr, @"<a href=""" + tmpStr3 + @""" target=""_blank"" title=""" + tmpStr3 + @"""><img src=""images/image.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>查看图片</a>"); 139
// } 140
141
// re = @"\[img=(\d*|),(\d*|),(left|right|center|absmiddle|)\](.[^\]]*)(\[\/img\])"; 142
// strMatchs = Regex.Matches(strContent, re); 143
// foreach (Match NextMatch in strMatchs) 144
// { 145
// tmpStr = NextMatch.Groups[0].Value; 146
// tmpStr1 = NextMatch.Groups[1].Value; 147
// tmpStr2 = NextMatch.Groups[2].Value; 148
// tmpStr3 = NextMatch.Groups[3].Value; 149
// tmpStr4 = NextMatch.Groups[4].Value; 150
// if (DisIMG == "1") 151
// strContent = strContent.Replace(tmpStr, @"<img width=""" + tmpStr1 + @""" height=""" + tmpStr2 + @""" align=""" + tmpStr3 + @""" src=""" + tmpStr4 + @""" border=""0"" alt=""""/>"); 152
// else 153
// strContent = strContent.Replace(tmpStr, @"<a href=""" + tmpStr4 + @""" target=""_blank"" title=""" + tmpStr4 + @"""><img src=""images/image.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>查看图片</a>"); 154
// } 155
// //-----------多媒体标签---------------- 156
// re = @"\[(swf|wma|wmv|rm|ra|qt)(=\d*?|)(,\d*?|)\]([^<>]*?)\[\/(swf|wma|wmv|rm|ra|qt)\]"; 157
// strMatchs = Regex.Matches(strContent, re); 158
// string strType, strWidth, strHeight, strSRC; 159
// string TitleText = ""; 160
// foreach (Match NextMatch in strMatchs) 161
// { 162
// tmpStr = NextMatch.Groups[0].Value; 163
// strType = NextMatch.Groups[1].Value; 164
// if (strType == "swf") 165
// TitleText = @"<img src=""images/flash.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>Flash动画"; 166
// else if (strType == "wma") 167
// TitleText = @"<img src=""images/music.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放音频文件"; 168
// else if (strType == "wmv") 169
// TitleText = @"<img src=""images/mediaplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放视频文件"; 170
// else if (strType == "rm") 171
// TitleText = @"<img src=""images/realplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放real视频流文件"; 172
// else if (strType == "ra") 173
// TitleText = @"<img src=""images/realplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放real音频流文件"; 174
// else if (strType == "qt") 175
// TitleText = @"<img src=""images/mediaplayer.gif"" alt="""" style=""margin:0px 2px -3px 0px"" border=""0""/>播放mov视频文件"; 176
177
// strWidth = NextMatch.Groups[2].Value; 178
// strHeight = NextMatch.Groups[3].Value; 179
// if (strWidth.Length == 0) 180
// strWidth = "400"; 181
// else 182
// strWidth = strWidth.Substring(strWidth.Length - 1); 183
184
// if (strHeight.Length == 0) 185
// strHeight = "300"; 186
// else 187
// strHeight = strHeight.Substring(strHeight.Length - 1); 188
189
// strSRC = NextMatch.Groups[4].Value; 190
// rndID = GenerateCheckCode(); 191
// strContent = strContent.Replace(tmpStr, @"<div class=""UBBPanel""><div class=""UBBTitle"">" + TitleText + @"</div><div class=""UBBContent""><a id=""" + rndID + @"_href"" href=""javascript:MediaShow('" + strType + "','" + rndID + "','" + strSRC + "','" + strWidth + "','" + strHeight + @"')""><img name=""" + rndID + @"_img"" src=""images/mm_snd.gif"" style=""margin:0px 3px -2px 0px"" border=""0"" alt=""""/><span id=""" + rndID + @"_text"">在线播放</span></a><div id=""" + rndID + @"""></div></div></div>"); 192
// } 193
194
// re = @"(\[mid\])(.[^\]]*)\[\/mid\]"; 195
// strContent = Regex.Replace(strContent, re, @"<embed src=""$2"" height=""45"" width=""314"" autostart=""0""></embed>"); 196
// //-----------常规标签---------------- 197
// re = @"\[url=(.[^\]]*)\](.[^\[]*)\[\/url]"; 198
// strMatchs = Regex.Matches(strContent, re); 199
// foreach (Match NextMatch in strMatchs) 200
// { 201
// tmpStr = NextMatch.Groups[0].Value; 202
// tmpStr1 = NextMatch.Groups[1].Value; 203
// tmpStr2 = NextMatch.Groups[2].Value; 204
// strContent = strContent.Replace(tmpStr, @"<a target=""_blank"" href=""" + tmpStr1 + @""">" + tmpStr2 + @"</a>"); 205
// } 206
207
// re = @"\[url](.[^\[]*)\[\/url]"; 208
// strMatchs = Regex.Matches(strContent, re); 209
// foreach (Match NextMatch in strMatchs) 210
// { 211
// tmpStr = NextMatch.Groups[0].Value; 212
// tmpStr1 = NextMatch.Groups[1].Value; 213
// strContent = strContent.Replace(tmpStr, @"<a target=""_blank"" href=""" + tmpStr1 + @""">" + tmpStr1 + @"</a>"); 214
// } 215
216
// re = @"\[ed2k=([^\r]*?)\]([^\r]*?)\[\/ed2k]"; 217
// strMatchs = Regex.Matches(strContent, re); 218
// foreach (Match NextMatch in strMatchs) 219
// { 220
// tmpStr = NextMatch.Groups[0].Value; 221
// tmpStr1 = NextMatch.Groups[1].Value; 222
// tmpStr2 = NextMatch.Groups[2].Value; 223
// strContent = strContent.Replace(tmpStr, @"<img border="""" src=""images/ed2k.gif"" alt=""""/><a target=""_blank"" href=""" + tmpStr1 + @""">" + tmpStr2 + @"</a>"); 224
// } 225
226
// re = @"\[ed2k]([^\r]*?)\[\/ed2k]"; 227
// strMatchs = Regex.Matches(strContent, re); 228
// foreach (Match NextMatch in strMatchs) 229
// { 230
// tmpStr = NextMatch.Groups[0].Value; 231
// tmpStr1 = NextMatch.Groups[1].Value; 232
// strContent = strContent.Replace(tmpStr, @"<img border="""" src=""images/ed2k.gif"" alt=""""/><a target=""_blank"" href=""" + tmpStr1 + @""">" + tmpStr1 + @"</a>"); 233
// } 234
235
// re = @"\[email=(.[^\]]*)\](.[^\[]*)\[\/email]"; 236
// strMatchs = Regex.Matches(strContent, re); 237
// foreach (Match NextMatch in strMatchs) 238
// { 239
// tmpStr = NextMatch.Groups[0].Value; 240
// tmpStr1 = NextMatch.Groups[1].Value; 241
// tmpStr2 = NextMatch.Groups[2].Value; 242
// strContent = strContent.Replace(tmpStr, @"<a href=""mailto:" + tmpStr1 + @""">" + tmpStr2 + @"</a>"); 243
// } 244
245
246
// re = @"\[email](.[^\[]*)\[\/email]"; 247
// strMatchs = Regex.Matches(strContent, re); 248
// foreach (Match NextMatch in strMatchs) 249
// { 250
// tmpStr = NextMatch.Groups[0].Value; 251
// tmpStr1 = NextMatch.Groups[1].Value; 252
// strContent = strContent.Replace(tmpStr, @"<a href=""mailto:" + tmpStr1 + @""">" + tmpStr1 + @"</a>"); 253
// } 254
// //-----------字体格式---------------- 255
// re = @"\[pagesplitxx\]"; 256
// strContent = Regex.Replace(strContent, re, @"<span style=""PAGE-BREAK-AFTER: always"">[pagesplitxx]</span>"); 257
// re = @"\[space\]"; 258
// strContent = Regex.Replace(strContent, re, @"  "); 259
// re = @"\[align=(\w{4,6})\]([^\r]*?)\[\/align\]"; 260
// strContent = Regex.Replace(strContent, re, @"<div align=""$1"">$2</div>"); 261
// re = @"\[color=(#\w{3,10}|\w{3,10})\]([^\r]*?)\[\/color\]"; 262
// strContent = Regex.Replace(strContent, re, @"<span style=""color:$1"">$2</span>"); 263
// re = @"\[size=(\d{1,2})\]([^\r]*?)\[\/size\]"; 264
// strContent = Regex.Replace(strContent, re, @"<span style=""font-size:$1pt"">$2</span>"); 265
// re = @"\[font=([^\r]*?)\]([^\r]*?)\[\/font\]"; 266
// strContent = Regex.Replace(strContent, re, @"<span style=""font-family:$1"">$2</span>"); 267
// re = @"\[b\]([^\r]*?)\[\/b\]"; 268
// strContent = Regex.Replace(strContent, re, @"<strong>$1</strong>"); 269
// re = @"\[i\]([^\r]*?)\[\/i\]"; 270
// strContent = Regex.Replace(strContent, re, @"<i>$1</i>"); 271
// re = @"\[u\]([^\r]*?)\[\/u\]"; 272
// strContent = Regex.Replace(strContent, re, @"<u>$1</u>"); 273
// re = @"\[s\]([^\r]*?)\[\/s\]"; 274
// strContent = Regex.Replace(strContent, re, @"<s>$1</s>"); 275
// re = @"\[sup\]([^\r]*?)\[\/sup\]"; 276
// strContent = Regex.Replace(strContent, re, @"<sup>$1</sup>"); 277
// re = @"\[sub\]([^\r]*?)\[\/sub\]"; 278
// strContent = Regex.Replace(strContent, re, @"<sub>$1</sub>"); 279
// re = @"\[fly\]([^\r]*?)\[\/fly\]"; 280
// strContent = Regex.Replace(strContent, re, @"<marquee width=""90%"" behavior=""alternate"" scrollamount=""3"">$1</marquee>"); 281
// //-----------特殊标签--------------- 282
// re = @"\[down=(.[^\]]*)\](.[^\[]*)\[\/down]"; 283
// strMatchs = Regex.Matches(strContent, re); 284
// foreach (Match NextMatch in strMatchs) 285
// { 286
// tmpStr = NextMatch.Groups[0].Value; 287
// tmpStr1 = NextMatch.Groups[1].Value; 288
// tmpStr2 = NextMatch.Groups[2].Value; 289
// strContent = strContent.Replace(tmpStr, @"<img src=""images/download.gif"" alt=""下载文件"" style=""margin:0px 2px -4px 0px""/> <a href=""" + tmpStr1 + @""" target=""_blank"">" + tmpStr2 + @"</a>"); 290
// } 291
292
// re = @"\[down\](.[^\[]*)\[\/down]"; 293
// strMatchs = Regex.Matches(strContent, re); 294
// foreach (Match NextMatch in strMatchs) 295
// { 296
// tmpStr = NextMatch.Groups[0].Value; 297
// tmpStr1 = NextMatch.Groups[1].Value; 298
// strContent = strContent.Replace(tmpStr, @"<img src=""images/download.gif"" alt=""下载文件"" style=""margin:0px 2px -4px 0px""/> <a href=""" + tmpStr1 + @""" target=""_blank"">下载此文件</a>"); 299
// } 300
301
// re = @"\[mDown=(.[^\]]*)\](.[^\[]*)\[\/mDown]"; 302
// strMatchs = Regex.Matches(strContent, re); 303
// foreach (Match NextMatch in strMatchs) 304
// { 305
// tmpStr = NextMatch.Groups[0].Value; 306
// tmpStr1 = NextMatch.Groups[1].Value; 307
// tmpStr2 = NextMatch.Groups[2].Value; 308
// if (UsersInfo.GetUserName != null) 309
// strContent = strContent.Replace(tmpStr, @"<img src=""images/download.gif"" alt=""下载文件"" style=""margin:0px 2px -4px 0px""/> <a href=""" + tmpStr1 + @""" target=""_blank"">" + tmpStr2 + @"</a>"); 310
// else 311
// strContent = strContent.Replace(tmpStr, @"<img src=""images/download.gif"" alt=""只允许会员下载"" style=""margin:0px 2px -4px 0px""/> 该文件只允许会员下载! <a href=""login.aspx"">登录</a> | <a href=""register.aspx"">注册</a>"); 312
// } 313
314
// re = @"\[mDown\](.[^\[]*)\[\/mDown]"; 315
// strMatchs = Regex.Matches(strContent, re); 316
// foreach (Match NextMatch in strMatchs) 317
// { 318
// tmpStr = NextMatch.Groups[0].Value; 319
// tmpStr1 = NextMatch.Groups[1].Value; 320
// if (UsersInfo.GetUserName != null) 321
// strContent = strContent.Replace(tmpStr, @"<img src=""images/download.gif"" alt=""下载文件"" style=""margin:0px 2px -4px 0px""/> <a href=""" + tmpStr1 + @""" target=""_blank"">下载此文件</a>"); 322
// else 323
// strContent = strContent.Replace(tmpStr, @"<img src=""images/download.gif"" alt=""只允许会员下载"" style=""margin:0px 2px -4px 0px""/> 该文件只允许会员下载! <a href=""login.aspx"">登录</a> | <a href=""register.aspx"">注册</a>"); 324
// } 325
326
// re = @"\[code\](.*?)\[\/code\]"; 327
// strContent = Regex.Replace(strContent, re, @"<div class=""UBBPanel""><div class=""UBBTitle""><img src=""images/code.gif"" style=""margin:0px 2px -3px 0px"" alt=""程序代码""/> 程序代码</div><div class=""UBBContent"">$1</div></div>"); 328
// re = @"\[quote\](.*?)\[\/quote\]"; 329
// strContent = Regex.Replace(strContent, re, @"<div class=""UBBPanel""><div class=""UBBTitle""><img src=""images/quote.gif"" style=""margin:0px 2px -3px 0px"" alt=""引用内容""/> 引用内容</div><div class=""UBBContent"">$1</div></div>"); 330
// re = @"\[quote=(.[^\]]*)\](.*?)\[\/quote\]"; 331<




