📄 addmsg.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;
using System.Text.RegularExpressions;
namespace xajh.chat
{
/// <summary>
/// 普通发言。
/// </summary>
public class addmsg : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
if (this.Session["info"] == null)
{
this.Response.Write ("<script language=javascript type=text/javascript>top.location.href='../error.aspx?v=relogin'</script>");
return;
}
x.UserInfo info = (x.UserInfo) this.Session["info"];
xajh.chat.msg chat = new xajh.chat.msg();
chat.Start(info.UserName, info.RoomID, info.LastSaid);
string v1 = this.Request.Form["v1"].Trim(); //他名
string v2 = this.Request.Form["v2"].Trim(); //话
int v3 = int.Parse(this.Request.Form["v3"]);//颜色1
int v4 = int.Parse(this.Request.Form["v4"]);//颜色2
string v5 = this.Request.Form["v5"]; //私聊
string v6 = this.Request.Form["v6"]; //标题
int v7 = int.Parse(this.Request.Form["v7"]);//表情
if (v1 == "" || v1 == info.UserName)
{
return;
}
if (((ArrayList) this.Application["byts_xajh_chat_online_" + info.RoomID]).IndexOf(v1) == -1 && v1 != "大家")
{
this.Response.Write ("<script language=javascript type=text/javascript>alert('该聊友不在本聊天室内,无法对其发言!')</script>");
return;
}
string mytype = "all";
if (v2.Length > 60)
{
v2 = v2.Substring(0, 60) + "......";
}
if (info.Grade < var.public_html)//html权限
{
v2 = this.Server.HtmlEncode(v2);
}
if (info.Grade >= var.public_pbc)//pbc权限
{
v2 = Regex.Replace(v2, @"(\[IMG\])(.[^\[\\]*)(\[\/IMG\])", "<a href=\"$2\" target=_blank><img src=\"$2\" border=\"0\" alt=\"按此在新窗口浏览图片\" onload=\"javascript:if(this.width>" + var.public_pbc_imgwidth + "||this.height>" + var.public_pbc_imgheight + "){this.width=" + var.public_pbc_imgwidth + ";this.height=" + var.public_pbc_imgheight + ";}\" /></a>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v2 = Regex.Replace(v2, @"\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/GLOW]", "<table align=\"center\" width=\"$1\" style=\"filter:glow(color=$2, strength=$3)\">$4</table>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v2 = Regex.Replace(v2, @"\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/SHADOW]", "<table align=\"center\" width=\"$1\" style=\"filter:shadow(color=$2, strength=$3)\">$4</table>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v2 = Regex.Replace(v2, @"(\[I\])(.[^\[]*)(\[\/I\])", "<i>$2</i>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v2 = Regex.Replace(v2, @"(\[U\])(.[^\[]*)(\[\/U\])", "<u>$2</u>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v2 = Regex.Replace(v2, @"(\[B\])(.[^\[]*)(\[\/B\])", "<b>$2</b>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v2 = Regex.Replace(v2, @"(\[URL\])(.[^\[]*)(\[\/URL\])", "<img src=\"../xajhimg/url.gif\" style=\"width:16px;height:16px\" /><a href=\"$2\" target=\"_blank\">$2</a>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v2 = Regex.Replace(v2, @"(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])", "<img src=\"../xajhimg/url.gif\" style=\"width:16px;height:16px\" /><a href=\"$2\" target=\"_blank\">$3</a>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
}
v2 = v2.Replace("\r", "").Replace("\n", "").Replace("\\", "\\\\").Replace("/", "\\/").Replace("\"", "\\\"");
if (v2 == "")
{
return;
}
if (v3 > 16 || v3 < 0)
{
v3 = 0;
}
if (v4 > 16 || v4 < 0)
{
v4 = 0;
}
if (v7 > 38 || v7 < 0)
{
v7 = 0;
}
if (v6 == "yes" && info.Grade >= var.public_title)
{
mytype = "title";
}
else if (v5 == "yes" && v1 != "大家")
{
mytype = "only";
}
string[] aword = new string[9];
aword[0] = mytype;
aword[1] = info.UserName;
aword[2] = v1;
aword[3] = v7.ToString();
aword[4] = v3.ToString();
aword[5] = v4.ToString();
aword[6] = v2;
aword[7] = "";
aword[8] = DateTime.Now.ToLongTimeString();
chat.Add(aword, info);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -