You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
526 lines
18 KiB
526 lines
18 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Threading;
|
|
|
|
|
|
using Sog;
|
|
|
|
using LitJson;
|
|
using SimpleHttpServer;
|
|
using MySql.Data.MySqlClient;
|
|
|
|
using ProtoCSStruct;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
namespace Operation
|
|
{
|
|
public class BanReqObj
|
|
{
|
|
public int server_id;
|
|
public string role_id;
|
|
public int lock_time;
|
|
public int type;
|
|
public string reason;
|
|
}
|
|
|
|
//封号
|
|
public class BanUser
|
|
{
|
|
private static Dictionary<string, int> m_reasonMap = new Dictionary<string, int> {
|
|
{"游戏内违规行为",1},
|
|
{"发布不良信息", 2},
|
|
{"违规使用脚本外挂",3},
|
|
{"诽谤/辱骂他人",4}
|
|
};
|
|
|
|
//封号请求
|
|
public static void DoBanUserReq(JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, BanReqObj param = null)
|
|
{
|
|
TraceLog.Trace("BanUser.DoBanUserReq Url{0} , param count {1}", request.Url, query.Count);
|
|
|
|
string struid = query.GetValue("uid");
|
|
string strbantime = query.GetValue("bantime");
|
|
int reasonType = query.GetValue("reasonType").Toint32(0);
|
|
int lock_time = 0;
|
|
|
|
if (param != null)
|
|
{
|
|
lock_time = param.lock_time;
|
|
struid = param.role_id;
|
|
m_reasonMap.TryGetValue(param.reason, out reasonType);
|
|
}
|
|
|
|
string otherStr = query.GetValue("otherStr");
|
|
string token = query.GetValue("token");
|
|
var account = "";
|
|
if (!string.IsNullOrEmpty(token))
|
|
{
|
|
account = OperationServerUtils.GetAccount(token);
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(otherStr) && !string.IsNullOrEmpty(account))
|
|
{
|
|
otherStr = "op:" + account;
|
|
}
|
|
|
|
long uid = 0;
|
|
int bantime = 0;
|
|
|
|
try
|
|
{
|
|
long.TryParse(struid, out uid);
|
|
int.TryParse(strbantime, out bantime);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
TraceLog.Error("BanUser.DoBanUserReq param error : {0} !", e.Message);
|
|
jsondata["ret"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
return;
|
|
}
|
|
|
|
if (uid <= 0)
|
|
{
|
|
jsondata["ret"] = -1;
|
|
jsondata["code"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
|
|
TraceLog.Trace("BanUser.DoBanUserReq param error uid {0} bantime {1}", uid, bantime);
|
|
return;
|
|
}
|
|
|
|
if (reasonType == 0)
|
|
{
|
|
jsondata["ret"] = -1;
|
|
jsondata["msg"] = "封禁原因错误!";
|
|
|
|
TraceLog.Trace("BanUser.DoBanUserReq param error uid {0} bantime {1}", uid, bantime);
|
|
return;
|
|
}
|
|
|
|
bantime = bantime * 86400;
|
|
|
|
if(lock_time != 0 && lock_time > OperationServerUtils.GetTimeSecond())
|
|
{
|
|
bantime = lock_time - (int)OperationServerUtils.GetTimeSecond();
|
|
}
|
|
|
|
long freezeEndTime = OperationServerUtils.GetTimeSecond() + bantime;
|
|
|
|
SSGMSetFreezeTime req = new SSGMSetFreezeTime();
|
|
req.FreezeTime = freezeEndTime;
|
|
req.Uid = uid;
|
|
req.FromServerID = OperationServerUtils.GetAppID();
|
|
req.FreezeReason = (FreezeReasonType)reasonType;
|
|
req.OpSource.SetString("oss");
|
|
if (!string.IsNullOrEmpty(otherStr))
|
|
{
|
|
req.FreezeReasonStr.SetString(otherStr);
|
|
}
|
|
|
|
TraceLog.Trace("BanUser.DoBanUserReq req.FromServerID {0}", req.FromServerID);
|
|
OperationServerUtils.SendToWorld((int)SSGameMsgID.GmSetFreezeTime, ref req, req.Uid, 0, "");
|
|
|
|
jsondata["ret"] = 0;
|
|
jsondata["msg"] = "发送封号请求成功!";
|
|
|
|
TraceLog.Trace("BanUser.DoBanUserReq Success, uid {0} bantime {1}", uid, bantime);
|
|
return;
|
|
}
|
|
|
|
//聊天禁言
|
|
public static void DoBanChatReq(JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, BanReqObj param = null)
|
|
{
|
|
TraceLog.Trace("BanUser.DoBanChatReq Url{0},param count {1}", request.Url, query.Count);
|
|
|
|
string struid = query.GetValue("uid");
|
|
string strbantime = query.GetValue("bantime");
|
|
|
|
int lock_time = 0;
|
|
|
|
if(param != null)
|
|
{
|
|
lock_time = param.lock_time;
|
|
struid = param.role_id;
|
|
}
|
|
|
|
long uid = 0;
|
|
int bantime = 0;
|
|
long.TryParse(struid, out uid);
|
|
int.TryParse(strbantime, out bantime);
|
|
|
|
if (uid <= 0 || bantime < 0)
|
|
{
|
|
jsondata["ret"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
|
|
TraceLog.Trace("BanUser.DoBanChatReq param error uid {0} bantime {1}", uid, bantime);
|
|
return;
|
|
}
|
|
|
|
// 这里bantime 是小时
|
|
bantime = bantime * 3600;
|
|
|
|
if (lock_time != 0 && lock_time > OperationServerUtils.GetTimeSecond())
|
|
{
|
|
bantime = lock_time - (int)OperationServerUtils.GetTimeSecond();
|
|
}
|
|
|
|
long freezeEndTime = OperationServerUtils.GetTimeSecond() + bantime;
|
|
SSEnableSendMsgReq req = new SSEnableSendMsgReq();
|
|
req.EnableTime = (int)freezeEndTime;
|
|
req.Uid = uid;
|
|
req.OpSource.SetString("oss");
|
|
|
|
jsondata["ret"] = 0;
|
|
jsondata["msg"] = "发送禁言请求成功!";
|
|
|
|
OperationServerUtils.SendToWorld((int)SSGameMsgID.EnableSendMsgReq, ref req, req.Uid, 0, "");
|
|
|
|
TraceLog.Trace("BanUser.DoBanChatReq Success, uid {0} bantime {1} freezeEndTime {2}", uid, bantime, freezeEndTime);
|
|
return;
|
|
}
|
|
|
|
//封号禁言
|
|
[RequestMapping("禁言",PermissionCode.BAN_USER_CHAT, toLog: true, ignored: true)]
|
|
public static int OnBanUserChatReq(string httpApiCmd, JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, uint httpContextId)
|
|
{
|
|
int type = query.GetValue("type").Toint32(0);
|
|
if (type == 0)
|
|
{
|
|
var content = System.Web.HttpUtility.UrlDecode(request.Content);
|
|
TraceLog.Debug("BanUser.BanUserChat content : {0}", content);
|
|
var req = content.ToJson<BanReqObj>();
|
|
type = req.type;
|
|
if(type == 0)
|
|
{
|
|
jsondata["ret"] = -1;
|
|
jsondata["msg"] = "请求参数错误";
|
|
}
|
|
|
|
if (type == 1)
|
|
{
|
|
DoBanUserReq(jsondata, rsp, request, query, req);
|
|
}
|
|
else if (type == 2)
|
|
{
|
|
DoBanChatReq(jsondata, rsp, request, query, req);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(type == 1)
|
|
{
|
|
DoBanUserReq(jsondata, rsp, request, query);
|
|
}
|
|
else if(type == 2)
|
|
{
|
|
DoBanChatReq(jsondata, rsp, request, query);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
//封号回包
|
|
public static void OnBanUserRes(uint remoteAppId, StructPacket packet, DBOperator dbOperator)
|
|
{
|
|
ref SSGMSetFreezeTimeRes res = ref packet.GetMessage<SSGMSetFreezeTimeRes>();
|
|
|
|
if (res.Ret != 0)
|
|
{
|
|
TraceLog.Error("BanUser.OnBanUserRes error ret {0}", res.Ret);
|
|
return;
|
|
}
|
|
|
|
dbOperator.DBInsertBanUser(ref res);
|
|
}
|
|
|
|
//禁言回包
|
|
public static void OnBanChatRes(uint remoteAppId, StructPacket packet, DBOperator dbOperator)
|
|
{
|
|
ref SSEnableSendMsgRes res = ref packet.GetMessage<SSEnableSendMsgRes>();
|
|
|
|
if (res.Ret != 0)
|
|
{
|
|
TraceLog.Error("BanUser.OnBanChatRes error ret {0}", res.Ret);
|
|
return;
|
|
}
|
|
|
|
dbOperator.DBInsertBanChat(ref res);
|
|
}
|
|
|
|
//解封请求
|
|
[RequestMapping("解封请求",PermissionCode.UNBAN_SELECT, toLog: true,ignored:true)]
|
|
public static int OnUnBanUserChatReq(string httpApiCmd, JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, uint httpContextId)
|
|
{
|
|
TraceLog.Trace("BanUser.OnUnBanUserChatReq Url{0},param count {1}", request.Url, query.Count);
|
|
|
|
var req = request.Content.ToJson<BanReqObj>();
|
|
|
|
int type = req.type;
|
|
string struid = req.role_id;
|
|
|
|
long uid = 0;
|
|
long.TryParse(struid, out uid);
|
|
|
|
if (uid <= 0)
|
|
{
|
|
jsondata["ret"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
|
|
TraceLog.Trace("BanUser.OnUnBanUserChatReq param uid error ");
|
|
return -1;
|
|
}
|
|
|
|
long freezeEndTime = OperationServerUtils.GetTimeSecond();
|
|
|
|
TraceLog.Trace("BanUser.OnUnBanUserChatReq type{0}, uid:{1}", type, uid);
|
|
|
|
if (type == 1)
|
|
{
|
|
SSGMSetFreezeTime freeReq = new SSGMSetFreezeTime();
|
|
freeReq.FreezeTime = freezeEndTime;
|
|
freeReq.Uid = uid;
|
|
freeReq.FromServerID = OperationServerUtils.GetAppID();
|
|
freeReq.OpSource.SetString("oss");
|
|
OperationServerUtils.SendToWorld((int)SSGameMsgID.GmSetFreezeTime, ref freeReq, freeReq.Uid, 0, "");
|
|
}
|
|
else if (type == 2)
|
|
{
|
|
SSEnableSendMsgReq enableMsgReq = new SSEnableSendMsgReq();
|
|
enableMsgReq.EnableTime = (int)freezeEndTime;
|
|
enableMsgReq.Uid = uid;
|
|
enableMsgReq.OpSource.SetString("oss");
|
|
OperationServerUtils.SendToWorld((int)SSGameMsgID.EnableSendMsgReq, ref enableMsgReq, enableMsgReq.Uid, 0, "");
|
|
}
|
|
else
|
|
{
|
|
jsondata["ret"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
|
|
TraceLog.Trace("BanUser.OnUnBanUserChatReq param type error uid {0}", struid);
|
|
return -1;
|
|
}
|
|
|
|
jsondata["ret"] = 0;
|
|
jsondata["msg"] = "发送解封请求成功!";
|
|
|
|
TraceLog.Trace("BanUser.OnUnBanUserChatReq Success, type {0}, uid {1}", type, uid);
|
|
|
|
return 0;
|
|
}
|
|
|
|
//hero舆情系统封号请求
|
|
public static void DoBanPlayerReq(JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, BanReqObj param = null)
|
|
{
|
|
TraceLog.Trace("BanUser.DoBanPlayerReq Url{0} , param count {1}", request.Url, query.Count);
|
|
|
|
int serverId = query.GetValue("server_id").Toint32(0);
|
|
string struid = query.GetValue("role_id");
|
|
string strLockTime = query.GetValue("lock_time");
|
|
string reason = query.GetValue("reason");
|
|
|
|
long uid = 0;
|
|
long freezeEndTime = 0;
|
|
|
|
try
|
|
{
|
|
long.TryParse(struid, out uid);
|
|
long.TryParse(strLockTime, out freezeEndTime);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
TraceLog.Error("BanUser.DoBanPlayerReq param error : {0} !", e.Message);
|
|
jsondata["code"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
jsondata["data"] = null;
|
|
|
|
return;
|
|
}
|
|
|
|
if (uid <= 0)
|
|
{
|
|
jsondata["code"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
jsondata["data"] = null;
|
|
|
|
TraceLog.Trace("BanUser.DoBanPlayerReq param error uid {0} freezeEndTime {1}", uid, freezeEndTime);
|
|
return;
|
|
}
|
|
|
|
SSGMSetFreezeTime req = new SSGMSetFreezeTime();
|
|
req.FreezeTime = freezeEndTime;
|
|
req.Uid = uid;
|
|
req.FromServerID = OperationServerUtils.GetAppID();
|
|
req.FreezeReason = FreezeReasonType.None;
|
|
req.OpSource.SetString("hero");
|
|
|
|
if (!string.IsNullOrEmpty(reason))
|
|
{
|
|
req.FreezeReasonStr.SetString(reason);
|
|
}
|
|
|
|
TraceLog.Trace("BanUser.DoBanPlayerReq req.FromServerID {0}", req.FromServerID);
|
|
|
|
OperationServerUtils.SendToWorld((int)SSGameMsgID.GmSetFreezeTime, ref req, req.Uid, 0, "");
|
|
|
|
jsondata["code"] = 0;
|
|
jsondata["msg"] = "发送封号请求成功!";
|
|
jsondata["data"] = null;
|
|
|
|
TraceLog.Trace("BanUser.DoBanPlayerReq Success, uid {0} freezeEndTime {1} serverId {2}", uid, freezeEndTime, serverId);
|
|
|
|
return;
|
|
}
|
|
|
|
//hero舆情系统聊天禁言
|
|
public static void DoBanPlayerChatReq(JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, BanReqObj param = null)
|
|
{
|
|
TraceLog.Trace("BanUser.DoBanPlayerChatReq Url{0},param count {1}", request.Url, query.Count);
|
|
|
|
int serverId = query.GetValue("server_id").Toint32(0);
|
|
string struid = query.GetValue("role_id");
|
|
string strLockTime = query.GetValue("lock_time");
|
|
string reason = query.GetValue("reason");
|
|
|
|
long uid = 0;
|
|
long freezeEndTime = 0;
|
|
|
|
try
|
|
{
|
|
long.TryParse(struid, out uid);
|
|
long.TryParse(strLockTime, out freezeEndTime);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
TraceLog.Error("BanUser.DoBanPlayerChatReq param error : {0} !", e.Message);
|
|
jsondata["code"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
jsondata["data"] = null;
|
|
|
|
return;
|
|
}
|
|
|
|
if (uid <= 0)
|
|
{
|
|
jsondata["code"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
jsondata["data"] = null;
|
|
|
|
TraceLog.Trace("BanUser.DoBanPlayerChatReq param error uid {0} freezeEndTime {1}", uid, freezeEndTime);
|
|
return;
|
|
}
|
|
|
|
SSEnableSendMsgReq req = new SSEnableSendMsgReq();
|
|
req.EnableTime = (int)freezeEndTime;
|
|
req.Uid = uid;
|
|
req.OpSource.SetString("hero");
|
|
|
|
if (!string.IsNullOrEmpty(reason))
|
|
{
|
|
req.FreezeReasonStr.SetString(reason);
|
|
}
|
|
|
|
jsondata["code"] = 0;
|
|
jsondata["msg"] = "发送禁言请求成功!";
|
|
jsondata["data"] = null;
|
|
|
|
OperationServerUtils.SendToWorld((int)SSGameMsgID.EnableSendMsgReq, ref req, req.Uid, 0, "");
|
|
|
|
TraceLog.Trace("BanUser.DoBanPlayerChatReq Success, uid {0} freezeEndTime {1} serverId {2}", uid, freezeEndTime, serverId);
|
|
|
|
return;
|
|
}
|
|
|
|
//hero舆情系统封号禁言
|
|
[RequestMapping("玩家封号",PermissionCode.BAN_USERT, toLog: true,ignored:true)]
|
|
public static int OnBanPlayerReq(string httpApiCmd, JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, uint httpContextId)
|
|
{
|
|
int type = query.GetValue("type").Toint32(0);
|
|
TraceLog.Debug("BanUser.OnBanPlayerReq type : {0}", type);
|
|
|
|
if (type == 1)
|
|
{
|
|
DoBanPlayerReq(jsondata, rsp, request, query);
|
|
}
|
|
else if (type == 2)
|
|
{
|
|
DoBanPlayerChatReq(jsondata, rsp, request, query);
|
|
}
|
|
else
|
|
{
|
|
jsondata["code"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
jsondata["data"] = null;
|
|
|
|
TraceLog.Trace("BanUser.OnBanPlayerReq param type error {0}", type);
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
//hero舆情系统解封请求
|
|
[RequestMapping("解封账号",PermissionCode.UNBAN_USER, toLog: true,ignored:true)]
|
|
public static int OnUnBanPlayerReq(string httpApiCmd, JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query, uint httpContextId)
|
|
{
|
|
TraceLog.Trace("BanUser.OnUnBanPlayerReq Url{0},param count {1}", request.Url, query.Count);
|
|
|
|
int serverId = query.GetValue("server_id").Toint32(0);
|
|
long uid = query.GetValue("role_id").Tolong(0);
|
|
int type = query.GetValue("type").Toint32(0);
|
|
|
|
if (uid <= 0)
|
|
{
|
|
jsondata["code"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
jsondata["data"] = null;
|
|
|
|
TraceLog.Trace("BanUser.OnUnBanPlayerReq param error uid {0} type {1}", uid, type);
|
|
return -1;
|
|
}
|
|
|
|
long freezeEndTime = OperationServerUtils.GetTimeSecond();
|
|
|
|
TraceLog.Trace("BanUser.OnUnBanPlayerReq type{0}, uid:{1}", type, uid);
|
|
|
|
if (type == 1) //解封号
|
|
{
|
|
SSGMSetFreezeTime freeReq = new SSGMSetFreezeTime();
|
|
freeReq.FreezeTime = freezeEndTime;
|
|
freeReq.Uid = uid;
|
|
freeReq.FromServerID = OperationServerUtils.GetAppID();
|
|
freeReq.OpSource.SetString("hero");
|
|
OperationServerUtils.SendToWorld((int)SSGameMsgID.GmSetFreezeTime, ref freeReq, freeReq.Uid, 0, "");
|
|
}
|
|
else if (type == 2) //解禁言
|
|
{
|
|
SSEnableSendMsgReq enableMsgReq = new SSEnableSendMsgReq();
|
|
enableMsgReq.EnableTime = (int)freezeEndTime;
|
|
enableMsgReq.Uid = uid;
|
|
enableMsgReq.OpSource.SetString("hero");
|
|
OperationServerUtils.SendToWorld((int)SSGameMsgID.EnableSendMsgReq, ref enableMsgReq, enableMsgReq.Uid, 0, "");
|
|
}
|
|
else
|
|
{
|
|
jsondata["code"] = -1;
|
|
jsondata["msg"] = "参数错误";
|
|
jsondata["data"] = null;
|
|
|
|
TraceLog.Trace("BanUser.OnUnBanPlayerReq param type error uid {0} type {1}", uid, type);
|
|
return -1;
|
|
}
|
|
|
|
jsondata["code"] = 0;
|
|
jsondata["msg"] = "发送解封请求成功!";
|
|
jsondata["data"] = null;
|
|
|
|
TraceLog.Trace("BanUser.OnUnBanPlayerReq Success, type {0}, uid {1}", type, uid);
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|