| | |
| | | using System.Collections.Generic; |
| | | using System.Security.Cryptography;
|
| | | using System.Text;
|
| | | using System.Text.RegularExpressions;
|
| | | using UnityEngine; |
| | | |
| | | public class LanguageVerify : Singleton<LanguageVerify>
|
| | |
| | | var account = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
|
| | | var playerId = PlayerDatas.Instance.baseData.PlayerID;
|
| | | var playerName = PlayerDatas.Instance.baseData.PlayerName;
|
| | | var ts = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
|
| | |
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["game_code"] = "snxxz";
|
| | |
| | | tables["server_name"] = StringUtility.Contact("s", ServerListCenter.Instance.currentServer.region_flag);
|
| | | tables["chat_type"] = 1.ToString();
|
| | | tables["chat_channel"] = channel.ToString();
|
| | | tables["chat_content"] = WWW.EscapeURL(UIHelper.TrimContentToServer(content));
|
| | | tables["chat_content"] = TransferContent(ts.Ticks, content);
|
| | | tables["sender_uid"] = account;
|
| | | tables["sender_rid"] = playerId.ToString();
|
| | | tables["sender_name"] = UIHelper.ServerStringTrim(playerName);
|
| | |
| | | tables["receiver_level"] = channel == 3 ? (toPlayerLevel == 0 ? string.Empty : toPlayerLevel.ToString()) : string.Empty;
|
| | | tables["receiver_vip_level"] = string.Empty;
|
| | |
|
| | | var ts = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
|
| | | tables["timestamp"] = ((long)System.Convert.ToInt64(ts.TotalSeconds)).ToString();
|
| | | tables["key"] = FileExtersion.GetStringMD5Hash(StringUtility.Contact(Sercret, tables["timestamp"]));
|
| | |
|
| | |
| | | {
|
| | | if (callback != null)
|
| | | {
|
| | | callback(true, response.content);
|
| | | callback(true, DisTransfer(ts.Ticks, response.content));
|
| | | callback = null;
|
| | | return;
|
| | | }
|
| | |
| | | });
|
| | | } |
| | | |
| | | Dictionary<long, List<string>> transferContents = new Dictionary<long, List<string>>();
|
| | |
|
| | | List<MatchString> matchs = new List<MatchString>(); |
| | | |
| | | const string TransferIdentify = " 0 "; |
| | | Regex transferRegex = new Regex(TransferIdentify, RegexOptions.Singleline); |
| | | |
| | | struct MatchString
|
| | | {
|
| | | public int index;
|
| | | public string value;
|
| | | } |
| | | |
| | | void AddMathcs(MatchCollection _matchs)
|
| | | {
|
| | | if (_matchs.Count == 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | foreach (Match match in _matchs)
|
| | | {
|
| | | matchs.Add(new MatchString()
|
| | | {
|
| | | index = match.Index,
|
| | | value = match.Value,
|
| | | });
|
| | | }
|
| | | } |
| | | |
| | | string TransferContent(long tick, string content)
|
| | | {
|
| | | List<string> list;
|
| | | if (!transferContents.TryGetValue(tick, out list))
|
| | | {
|
| | | list = new List<string>();
|
| | | transferContents.Add(tick, list);
|
| | | }
|
| | | list.Clear();
|
| | | matchs.Clear();
|
| | | AddMathcs(WordAnalysis.Color_Start_Regex.Matches(content));
|
| | | AddMathcs(WordAnalysis.Color_End_Regex.Matches(content));
|
| | | AddMathcs(ImgAnalysis.FaceRegex.Matches(content));
|
| | | AddMathcs(ChatCtrl.InviteRegex.Matches(content));
|
| | | AddMathcs(WordAnalysis.Size_Start_Regex.Matches(content));
|
| | | AddMathcs(WordAnalysis.Size_End_Regex.Matches(content));
|
| | | AddMathcs(WordAnalysis.Space_Regex.Matches(content));
|
| | | AddMathcs(ChatCtrl.KillRegex.Matches(content));
|
| | | matchs.Sort((x, y) =>
|
| | | {
|
| | | return x.index.CompareTo(y.index);
|
| | | });
|
| | | for (int i = 0; i < matchs.Count; i++)
|
| | | {
|
| | | list.Add(matchs[i].value);
|
| | | }
|
| | | content = WordAnalysis.Color_Start_Regex.Replace(content, TransferIdentify);
|
| | | content = WordAnalysis.Color_End_Regex.Replace(content, TransferIdentify);
|
| | | content = ImgAnalysis.FaceRegex.Replace(content, TransferIdentify);
|
| | | content = ChatCtrl.InviteRegex.Replace(content, TransferIdentify);
|
| | | content = WordAnalysis.Size_Start_Regex.Replace(content, TransferIdentify);
|
| | | content = WordAnalysis.Size_End_Regex.Replace(content, TransferIdentify);
|
| | | content = WordAnalysis.Space_Regex.Replace(content, TransferIdentify);
|
| | | content = ChatCtrl.KillRegex.Replace(content, TransferIdentify);
|
| | | return content;
|
| | | } |
| | | |
| | | string DisTransfer(long tick, string content)
|
| | | {
|
| | | List<string> list;
|
| | | if (!transferContents.TryGetValue(tick, out list))
|
| | | {
|
| | | return content;
|
| | | }
|
| | | var stringIndex = 0;
|
| | | var index = 0;
|
| | | s_StringBuilder.Length = 0;
|
| | | foreach (Match match in transferRegex.Matches(content))
|
| | | {
|
| | | s_StringBuilder.Append(content.Substring(index, match.Index - index));
|
| | | if (stringIndex < list.Count)
|
| | | {
|
| | | s_StringBuilder.Append(list[stringIndex]);
|
| | | stringIndex++;
|
| | | }
|
| | | index = match.Index + match.Length;
|
| | | }
|
| | | transferContents.Remove(tick);
|
| | | s_StringBuilder.Append(content.Substring(index, content.Length - index));
|
| | | return s_StringBuilder.ToString();
|
| | | } |
| | | |
| | | bool GetChannel(ChatInfoType type, out int channel)
|
| | | {
|
| | | channel = 0;
|