📄 addmsg_1.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
namespace xajh.chat
{
/// <summary>
/// 千里传音。
/// </summary>
public class addmsg_1 : 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);
x.CheckUse useinfo = var.public_fly;
if (useinfo.MinGrade != -1 && info.Grade < useinfo.MinGrade)
{
this.Response.Write ("<script language=javascript type=text/javascript>alert('等级小于 " + useinfo.MinGrade + " 不能使用千里传音!')</script>");
return;
}
if (useinfo.MaxGrade != -1 && info.Grade > useinfo.MaxGrade)
{
this.Response.Write ("<script language=javascript type=text/javascript>alert('等级大于 " + useinfo.MaxGrade + " 不能使用千里传音!')</script>");
return;
}
if (useinfo.MinFGrade != -1 && info.FGrade < useinfo.MinFGrade)
{
this.Response.Write ("<script language=javascript type=text/javascript>alert('战斗等级小于 " + useinfo.MinFGrade + " 不能使用千里传音!')</script>");
return;
}
if (useinfo.MaxFGrade != -1 && info.FGrade > useinfo.MaxFGrade)
{
this.Response.Write ("<script language=javascript type=text/javascript>alert('战斗等级大于 " + useinfo.MaxFGrade + " 不能使用千里传音!')</script>");
return;
}
if (useinfo.MinGGrade != -1 && info.Gold < useinfo.MinGGrade)
{
this.Response.Write ("<script language=javascript type=text/javascript>alert('会员等级小于 " + useinfo.MinGGrade + " 不能使用千里传音!')</script>");
return;
}
if (useinfo.MaxGGrade != -1 && info.Gold > useinfo.MaxGGrade)
{
this.Response.Write ("<script language=javascript type=text/javascript>alert('会员等级大于 " + useinfo.MaxGGrade + " 不能使用千里传音!')</script>");
return;
}
if (useinfo.CheckSex == "boy" && info.Sex != "boy")
{
this.Response.Write ("<script language=javascript type=text/javascript>alert('性别必须为 男 才能使用千里传音!')</script>");
return;
}
if (useinfo.CheckSex == "girl" && info.Sex != "girl")
{
this.Response.Write ("<script language=javascript type=text/javascript>alert('性别必须为 女 才能使用千里传音!')</script>");
return;
}
if (useinfo.CheckIn != "(无)" || useinfo.sql != "")
{
string sql = @"select [点券],[银两],[存款],[武功],[智力],[内力],[体力],[攻击],[防御],[生命],[魅力],[精确] from [注册用户] where [id]=" + info.DataID;
if (useinfo.CheckIn != "(无)")
{
sql += " and " + useinfo.CheckIn;
}
OleDbConnection MyConn = new OleDbConnection(var.public_conn);
MyConn.Open();
OleDbCommand MyComm = new OleDbCommand(sql, MyConn);
OleDbDataReader dr = MyComm.ExecuteReader();
if (dr.Read())
{
for (int i = 0; i < 3; i ++)
{
if (useinfo.Run_Name[i] != "(无)")
{
if ((int)dr[useinfo.Run_Name[i]] < useinfo.Run_Value[i])
{
dr.Close();
MyConn.Close();
MyConn.Dispose();
this.Response.Write ("<script language=javascript type=text/javascript>alert('使用千里传音要耗费" + useinfo.Run_Name[i] + " " + useinfo.Run_Value[i] + ",而你的" + useinfo.Run_Name[i] + "不够!')</script>");
return;
}
}
}
if (useinfo.sql != "")
{
dr.Close();
MyComm.CommandText = @"update [注册用户] set " + useinfo.sql.Substring(0, useinfo.sql.Length - 1) + " where [id]=" + info.DataID;
MyComm.ExecuteNonQuery();
MyConn.Close();
MyConn.Dispose();
}
else
{
dr.Close();
MyConn.Close();
MyConn.Dispose();
}
}
else
{
dr.Close();
MyConn.Close();
MyConn.Dispose();
this.Response.Write ("<script language=javascript type=text/javascript>alert(\"必须符合 " + useinfo.CheckIn + " 才能使用千里传音!\")</script>");
return;
}
}
string v1 = this.Request.Form["v1"].Trim();
int v2 = int.Parse(this.Request.Form["v2"]);
int v3 = int.Parse(this.Request.Form["v3"]);
if (v1.Length > 60)
{
v1 = v1.Substring(0, 60) + "......";
}
if (info.Grade < var.public_html)//html权限
{
v1 = this.Server.HtmlEncode(v1);
}
if (info.Grade >= var.public_pbc)//pbc权限
{
v1 = Regex.Replace(v1, @"(\[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);
v1 = Regex.Replace(v1, @"\[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);
v1 = Regex.Replace(v1, @"\[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);
v1 = Regex.Replace(v1, @"(\[I\])(.[^\[]*)(\[\/I\])", "<i>$2</i>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v1 = Regex.Replace(v1, @"(\[U\])(.[^\[]*)(\[\/U\])", "<u>$2</u>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v1 = Regex.Replace(v1, @"(\[B\])(.[^\[]*)(\[\/B\])", "<b>$2</b>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v1 = Regex.Replace(v1, @"(\[URL\])(.[^\[]*)(\[\/URL\])", "<img src=\"../xajhimg/url.gif\" style=\"width:16px;height:16px\" /><a href=\"$2\" target=\"_blank\">$2</a>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
v1 = Regex.Replace(v1, @"(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])", "<img src=\"../xajhimg/url.gif\" style=\"width:16px;height:16px\" /><a href=\"$2\" target=\"_blank\">$3</a>", RegexOptions.Compiled|RegexOptions.IgnoreCase);
}
v1 = v1.Replace("\r", "").Replace("\n", "").Replace("\\", "\\\\").Replace("/", "\\/").Replace("\"", "\\\"");
if (v1 == "")
{
return;
}
if (v2 > 16 || v2 < 0)
{
v2 = 0;
}
if (v3 > 16 || v3 < 0)
{
v3 = 0;
}
string[] aword = new string[9];
aword[0] = "fly";
aword[1] = info.UserName;
aword[2] = "";
aword[3] = "";
aword[4] = v2.ToString();
aword[5] = v3.ToString();
aword[6] = v1;
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 + -