📄 msg.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Web.SessionState;
using System.Data;
using System.Data.OleDb;
namespace xajh.chat
{
/// <summary>
/// msg 的摘要说明。
/// </summary>
public class msg
{
private System.Web.HttpContext xajh = System.Web.HttpContext.Current;
public void Start(string myname, string isinchat, DateTime oldtime)
{
if (this.xajh.Request.Cookies["byts"] == null || myname != this.xajh.Request.Cookies["byts"]["chat"])
{
this.xajh.Session.Abandon();
this.xajh.Response.Write ("<script language=javascript type=text/javascript>top.location.href='../error.aspx?v=%c7%eb%b2%bb%d2%aa%cd%ac%ca%b1%ca%b9%d3%c3%c1%bd%b8%f6%c3%fb%d7%d6%b5%c7%c2%bd%bb%f2%d6%d0%cd%be%c9%be%b3%fdcookie!'</script>");
this.xajh.Response.End();
}
if (isinchat == "false")
{
this.xajh.Response.Write ("<script language=javascript type=text/javascript>top.location.href='../error.aspx?v=outchat'</script>");
this.xajh.Response.End();
}
if (oldtime.AddSeconds(3) > DateTime.Now)
{
this.xajh.Response.Write ("<script language=javascript type=text/javascript>alert('慢慢来,别噎着哦!')</script>");
this.xajh.Response.End();
}
}
public void Add(string[] aword, x.UserInfo info)
{
this.xajh.Application.Lock();
ArrayList words = (ArrayList) this.xajh.Application["byts_xajh_chat_words_" + info.RoomID];
words.Add(aword);
words.RemoveAt(0);
this.xajh.Application["byts_xajh_chat_line_" + info.RoomID] = (int) this.xajh.Application["byts_xajh_chat_line_" + info.RoomID] + 1;
int all_line = (int) this.xajh.Application["byts_xajh_chat_line_" + info.RoomID];
this.xajh.Application.UnLock();
int check_line = 30 - (all_line - info.MsgLine);
if (check_line < 0)
{
check_line = 0;
}
string[] mywords;
this.xajh.Response.Write ("<script language=javascript type=text/javascript>\r");
for (int myline = check_line; myline < 30; myline ++)
{
mywords = (string[]) words[myline];
if (!(mywords[0] == "only" && mywords[1] != info.UserName && mywords[2] != info.UserName))
{
this.xajh.Response.Write ("parent.h0.byts_getmsg(\"" + mywords[0] + "\",\"" + mywords[1] + "\",\"" + mywords[2] + "\",\"" + mywords[3] + "\",\"" + mywords[4] + "\",\"" + mywords[5] + "\",\"" + mywords[6] + "\",\"" + mywords[7] + "\",\"" + mywords[8] + "\");\r");
}
}
this.xajh.Response.Write ("</script>");
info.MsgLine = all_line;
info.LastSaid = DateTime.Now;
this.xajh.Session["info"] = info;
System.Random MyRan = new System.Random();
if (MyRan.Next(0, 100) < (int) this.xajh.Application["byts_xajh_chat_ranthing_" + info.RoomID])
{
ArrayList online = (ArrayList) this.xajh.Application["byts_xajh_chat_online_" + info.RoomID];
string[] ran_info = (string[]) var.public_randomhappen[MyRan.Next(0, var.public_randomhappen.Count)];
string[] do_who = var.public_onlineinfo[online[MyRan.Next(0, online.Count)]].ToString().Split('|');
string[] v_max = var.public_goldmax[int.Parse(do_who[6])].Split('|');
int do_num = MyRan.Next(int.Parse(ran_info[2]), int.Parse(ran_info[3]) + 1);
int maxnum;
string sql;
switch (ran_info[4])
{
case "0":
sql = "点券";
maxnum = int.Parse(v_max[0]);
break;
case "1":
sql = "武功";
maxnum = int.Parse(v_max[1]);
break;
case "2":
sql = "内力";
maxnum = int.Parse(v_max[2]);
break;
case "3":
sql = "体力";
maxnum = int.Parse(v_max[3]);
break;
case "4":
sql = "攻击";
maxnum = int.Parse(v_max[4]);
break;
case "5":
sql = "防御";
maxnum = int.Parse(v_max[5]);
break;
case "6":
sql = "智力";
maxnum = int.Parse(v_max[6]);
break;
case "7":
sql = "生命";
maxnum = int.Parse(v_max[7]);
break;
case "8":
sql = "魅力";
maxnum = int.Parse(v_max[8]);
break;
case "9":
sql = "精确";
maxnum = int.Parse(v_max[9]);
break;
default:
sql = "银两";
maxnum = 0;
break;
}
switch (var.public_maxfor)
{
case "等级":
maxnum = maxnum * int.Parse(do_who[4]);
break;
case "战斗等级":
maxnum = maxnum * int.Parse(do_who[5]);
break;
default:
break;
}
OleDbConnection MyConn = new OleDbConnection(var.public_conn);
MyConn.Open();
OleDbCommand MyComm = new OleDbCommand(@"select [" + sql + "] from [注册用户] where [id]=" + do_who[1], MyConn);
OleDbDataReader dr = MyComm.ExecuteReader();
if (dr.Read())
{
int oldv = (int) dr[sql];
int newv;
dr.Close();
switch(ran_info[5])
{
case "-":
newv = oldv - do_num;
break;
case "*":
newv = oldv * do_num;
break;
case "/":
newv = oldv / do_num;
break;
default:
newv = oldv + do_num;
break;
}
if (newv < 0)
{
newv = 0;
}
else if (newv > maxnum && maxnum != 0)
{
newv = maxnum;
}
if (newv != oldv)
{
if (sql == "生命" && newv <= 0)
{
MyComm.CommandText = @"update [注册用户] set [状态]='死' where [id]=" + do_who[1];
}
else
{
MyComm.CommandText = @"update [注册用户] set [" + sql + "]=" + newv + " where [id]=" + do_who[1];
}
MyComm.ExecuteNonQuery();
MyConn.Close();
MyConn.Dispose();
}
}
else
{
dr.Close();
MyConn.Close();
MyConn.Dispose();
return;
}
aword = new string[9];
aword[0] = "ran";
aword[1] = "";
aword[2] = do_who[0];
aword[3] = ran_info[1];
aword[4] = "";
aword[5] = "";
aword[6] = ran_info[6].Replace("$$", "<font style=\\\"color:#FF0000\\\">" + do_num + "</font>");
aword[7] = ran_info[0];
aword[8] = DateTime.Now.ToLongTimeString();
this.xajh.Application.Lock();
words = (ArrayList) xajh.Application["byts_xajh_chat_words_" + info.RoomID];
words.Add(aword);
words.RemoveAt(0);
this.xajh.Application["byts_xajh_chat_line_" + info.RoomID] = (int) xajh.Application["byts_xajh_chat_line_" + info.RoomID] + 1;
this.xajh.Application.UnLock();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -