Exemplo n.º 1
0
        private void Refresh_Account()
        {
            string result = "";

            try
            {
                string uid = Request["uid"] == null ? "" : Request["uid"].ToString();
                txtChannel.Text = Request["serverid"] == null ? "" : Request["serverid"].ToString();

                if (!string.IsNullOrEmpty(uid) && !string.IsNullOrEmpty(UserAccountUrl))
                {
                    //key: md5(code + uid +约定值)
                    string sign  = BaseInterface.md5(Code + uid + Key);
                    string param = string.Format("uid={0}&code={1}&key={2}", HttpUtility.UrlEncode(uid), Code, sign);

                    result = BaseInterface.RequestContent(UserAccountUrl + "?" + param);
                    tdAccount.InnerText = result;
                }
                else
                {
                    tdAccount.InnerText = "0";
                }
            }
            catch
            {
                tdAccount.InnerText = "0";
            }
        }
Exemplo n.º 2
0
        public BaseInterface RemoveInterface(BaseInterface Interface)
        {
            lock (Interfaces)
                Interfaces.Remove(Interface);

            return(Interface);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string result = "";

            try
            {
                string uid = Request["uid"] == null ? "" : Request["uid"].ToString();

                if (!string.IsNullOrEmpty(uid))
                {
                    if (!string.IsNullOrEmpty(UserInfoUrl))
                    {
                        //key:MD5(code+uid+约定值)
                        string sign  = BaseInterface.md5(Code + uid + Key);
                        string param = string.Format("uid={0}&code={1}&key={2}", HttpUtility.UrlEncode(uid), Code, sign);

                        result = BaseInterface.RequestContent(UserInfoUrl + "?" + param);
                        Response.Write(result);
                        return;
                    }
                }
                Response.Write("");
            }
            catch
            {
                Response.Write("");
            }
        }
Exemplo n.º 4
0
        private Program()
        {
            OneTimeConfig();

            _lcd = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
            Touch.Initialize(this);

            this.MainWindow = new Window();
            this.MainWindow.TouchDown += MainWindow_TouchDown;
            this.MainWindow.TouchUp += MainWindow_TouchUp;
            this.MainWindow.TouchMove += MainWindow_TouchMove;

            var eth = new EthernetBuiltIn();
            eth.Open();
            if (!eth.CableConnected)
            {
                eth.Close();
                var wifi = new WiFiRS9110(SPI.SPI_module.SPI1, G400.PD13, G400.PD12, G400.PD15);
                _netif = wifi;
                _netif.Open();
                wifi.Join("XXX", "XXX");
            }
            else
            {
                _netif = eth;
            }
            if (!_netif.IsDhcpEnabled)
                _netif.EnableDhcp();
            if (!_netif.IsDynamicDnsEnabled)
                _netif.EnableDynamicDns();

            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
        }
Exemplo n.º 5
0
        public void ObjectIsTypeCanBeValidated()
        {
            int testInt = 0;

            Requires.Argument(testInt, nameof(testInt)).IsType(typeof(int));
            Assert.Throws <ArgumentException>(() => Requires.Argument(testInt, nameof(testInt)).IsType(typeof(sbyte)));
            Assert.Throws <ArgumentException>(() => Requires.Argument(testInt, nameof(testInt)).IsType(typeof(short)));
            Assert.Throws <ArgumentException>(() => Requires.Argument(testInt, nameof(testInt)).IsType(typeof(long)));

            DerivedClass derivedClass = new DerivedClass();

            Requires.Argument(derivedClass, nameof(derivedClass)).IsType(typeof(BaseInterface));
            Requires.Argument(derivedClass, nameof(derivedClass)).IsType(typeof(BaseClass));
            Requires.Argument(derivedClass, nameof(derivedClass)).IsType(typeof(DerivedClass));

            BaseClass baseClassFromCast = derivedClass;

            Requires.Argument(baseClassFromCast, nameof(baseClassFromCast)).IsType(typeof(BaseInterface));
            Requires.Argument(baseClassFromCast, nameof(baseClassFromCast)).IsType(typeof(BaseClass));
            Requires.Argument(baseClassFromCast, nameof(baseClassFromCast)).IsType(typeof(DerivedClass));

            BaseInterface baseInterfaceFromCast = derivedClass;

            Requires.Argument(baseInterfaceFromCast, nameof(baseInterfaceFromCast)).IsType(typeof(BaseInterface));
            Requires.Argument(baseInterfaceFromCast, nameof(baseInterfaceFromCast)).IsType(typeof(BaseClass));
            Requires.Argument(baseInterfaceFromCast, nameof(baseInterfaceFromCast)).IsType(typeof(DerivedClass));

            BaseClass baseClass = new BaseClass();

            Requires.Argument(baseClass, nameof(baseClass)).IsType(typeof(BaseInterface));
            Requires.Argument(baseClass, nameof(baseClass)).IsType(typeof(BaseClass));
            Assert.Throws <ArgumentException>(() => Requires.Argument(baseClass, nameof(baseClass)).IsType(typeof(DerivedClass)));
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int result = 1;

            try
            {
                string username = HttpUtility.UrlDecode(Request["username"]);
                string site     = Request["site"] == null ? "" : HttpUtility.UrlDecode(Request["site"]);

                if (!string.IsNullOrEmpty(username))
                {
                    username = BaseInterface.GetNameBySite(username, site);
                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        PlayerInfo info = db.GetUserSingleByUserName(username);
                        if (info != null)
                        {
                            result = 0;
                        }
                        else
                        {
                            result = 2;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("UserNameCheck:", ex);
            }
            Response.Write(result);
        }
Exemplo n.º 7
0
        private void Charge_Submit()
        {
            string result = "";

            try
            {
                string uid = Request["uid"] == null ? "" : Request["uid"].ToString();

                if (!string.IsNullOrEmpty(uid))
                {
                    int money     = int.Parse(select.Value);
                    int needMoney = money / 100;
                    if (needMoney <= 0)
                    {
                        return;
                    }

                    string billId = Guid.NewGuid().ToString();
                    string payWay = "default";

                    if (!string.IsNullOrEmpty(PayUrl))
                    {
                        string sign  = BaseInterface.md5(Code + uid + TraceStr + needMoney + billId + PayKey);
                        string param = string.Format("uid={0}&code={1}&name={2}&trace={3}&money={4}&billId={5}&key={6}", HttpUtility.UrlEncode(uid), Code, HttpUtility.UrlEncode(GameName), TraceStr, needMoney, billId, sign);

                        result = BaseInterface.RequestContent(PayUrl + "?" + param);
                    }
                    else
                    {
                        result = "0";
                    }

                    if (result == "0")
                    {
                        string v   = BaseInterface.md5(billId + uid + money + payWay + needMoney + BaseInterface.GetChargeKey);
                        string Url = ChargeUrl + "?content=" + billId + "|" + uid + "|" + money + "|" + payWay + "|" + needMoney + "|" + v;
                        result = BaseInterface.RequestContent(Url);
                        if (result == "0")
                        {
                            this.Response.Write("<script language='javascript'>alert('充值成功!');window.close();</script>");
                        }
                        else
                        {
                            StatMgr.SaveError(billId, uid, needMoney, eChargeError.RequestError.ToString());
                            this.Response.Write("<script language='javascript'>alert('充值异常,请联系GM!');</script>");
                        }
                        return;
                    }
                    else
                    {
                        StatMgr.SaveError(billId, uid, needMoney, eChargeError.RenRenError.ToString());
                    }
                }
            }
            catch
            {
                StatMgr.SaveError("billId", "uid", 0, eChargeError.DefaultError.ToString());
            }
            this.Response.Write("<script language='javascript'>alert('充值失败!');</script>");
        }
        public WiredNetwork(BaseInterface networkInterface)
        {
            this.NetworkInterface = networkInterface;

            // TODO: hook up events
            //NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
        }
Exemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            LanguageMgr.Setup(ConfigurationManager.AppSettings["ReqPath"]);
            bool   value   = false;
            string message = LanguageMgr.GetTranslation("Tank.Request.RenameConsortiaName.Fail1");// "Login Fail!";

            XElement result = new XElement("Result");

            try
            {
                BaseInterface inter = BaseInterface.CreateInterface();
                string        p     = context.Request["p"];
                string        site  = context.Request["site"] == null ? "" : HttpUtility.UrlDecode(context.Request["site"]);
                //string nickname = context.Request["nickname"] == null ? "" : HttpUtility.UrlDecode(context.Request["nickname"]);
                //string newNickname = context.Request["consortiaName"] == null ? "" : HttpUtility.UrlDecode(context.Request["consortiaName"]);
                string IP = context.Request.UserHostAddress;
                if (!string.IsNullOrEmpty(p))
                {
                    //解密
                    byte[]   src     = CryptoHelper.RsaDecryt2(StaticFunction.RsaCryptor, p);
                    string[] strList = Encoding.UTF8.GetString(src, 7, src.Length - 7).Split(',');
                    if (strList.Length == 5)
                    {
                        string name          = strList[0];
                        string pwd           = strList[1];
                        string newPwd        = strList[2];
                        string nickname      = strList[3];
                        string consortiaName = strList[4];

                        if (PlayerManager.Login(name, pwd))
                        {
                            using (PlayerBussiness db = new PlayerBussiness())
                            {
                                if (db.RenameConsortiaName(name, nickname, consortiaName, ref message))
                                {
                                    PlayerManager.Update(name, newPwd);
                                    value   = true;
                                    message = LanguageMgr.GetTranslation("Tank.Request.RenameConsortiaName.Success");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("RenameConsortiaName", ex);
                value   = false;
                message = LanguageMgr.GetTranslation("Tank.Request.RenameConsortiaName.Fail2");
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));

            context.Response.ContentType = "text/plain";
            context.Response.Write(result.ToString(false));
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string result = "";

            try
            {
                //HttpCookie aCookie = Request.Cookies["societyguester"];
                HttpCookie aCookie = Request.Cookies["t"];
                if (aCookie != null)
                {
                    string value = aCookie.Value;
                    string uid   = string.Empty;
                    if (!string.IsNullOrEmpty(ValidateUrl))
                    {
                        //key:  MD5(code + trace + s + 约定值)
                        string sign  = BaseInterface.md5(Code + TraceStr + value + Key);
                        string param = string.Format("s={0}&trace={1}&code={2}&key={3}", HttpUtility.UrlEncode(value), TraceStr, Code, sign);

                        result = BaseInterface.RequestContent(ValidateUrl + "?" + param);

                        if (!string.IsNullOrEmpty(result) && result.IndexOf("ok") != -1)
                        {
                            string[] para = result.Split(':');
                            uid    = para[1];
                            result = "0";
                        }
                    }
                    else
                    {
                        result = "0";
                    }

                    if (result == "0")
                    {
                        string password = Guid.NewGuid().ToString();
                        int    time     = BaseInterface.ConvertDateTimeInt(DateTime.Now);
                        string v        = BaseInterface.md5(uid + password + time.ToString() + BaseInterface.GetLoginKey);
                        string Url      = BaseInterface.LoginUrl + "?content=" + HttpUtility.UrlEncode(uid + "|" + password + "|" + time.ToString() + "|" + v);
                        result = BaseInterface.RequestContent(Url);
                        if (result == "0")
                        {
                            string flashUrl = FlashUrl + "?user="******"&key=" + HttpUtility.UrlEncode(password);
                            Response.Redirect(flashUrl, false);
                            return;
                        }
                        result = "";
                    }
                }

                Response.Redirect(LoginOnUrl, false);
            }
            catch
            {
                Response.Redirect(LoginOnUrl, false);
            }
        }
Exemplo n.º 11
0
        public BaseInterface AddInterface(BaseInterface Interface)
        {
            lock (Interfaces)
            {
                Interfaces.Add(Interface);
            }

            Interface.SetOwner(this);
            return(Interface);
        }
Exemplo n.º 12
0
        public static void Covariance_and_Contravariance()
        {
            DeriveClass dc = new DeriveClass();

            // 协变
            Covariance(dc);

            // 抗变
            BaseInterface bc = Contravariance();
        }
Exemplo n.º 13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            try
            {
                //param格式://int templateID, int count, int validDate, int StrengthenLevel, int AttackCompose, int DefendCompose, int AgilityCompose, int LuckCompose, bool isBinds
                //result:0:成功 1:失败 2:没有该账号 3:ip无效  4:param不合法 5:key错误 6:content内参数列不正确 7:超时
                int result = 1;

                //判断IP是否合法
                if (ValidSentRewardIP(context.Request.UserHostAddress))
                {
                    string content = HttpUtility.UrlDecode(context.Request["content"]);


                    string key = GetSentRewardKey;

                    BaseInterface inter     = BaseInterface.CreateInterface();
                    string[]      str_param = inter.UnEncryptSentReward(content, ref result, key);

                    if (str_param.Length == 8 && result != 5 && result != 6 && result != 7)
                    {
                        string mailTitle   = str_param[0];
                        string mailContent = str_param[1];
                        string username    = str_param[2];
                        int    gold        = Int32.Parse(str_param[3]);
                        int    money       = Int32.Parse(str_param[4]);
                        string param       = str_param[5];

                        //判断para是否合法,并将不合法的数值设为默认合法值
                        if (checkParam(ref param))
                        {
                            PlayerBussiness pb = new PlayerBussiness();
                            result = pb.SendMailAndItemByUserName(mailTitle, mailContent, username, gold, money, param);
                        }
                        else
                        {
                            result = 4;
                        }
                    }
                }
                else
                {
                    result = 3;
                }

                context.Response.Write(result);
            }
            catch (Exception ex)
            {
                log.Error("SentReward", ex);
            }
        }
Exemplo n.º 14
0
        public T AddInterface <T>() where T : BaseInterface
        {
            BaseInterface Interface = Activator.CreateInstance <T>();

            lock (Interfaces)
            {
                Interfaces.Add(Interface);
            }

            Interface.SetOwner(this);
            return((T)Interface);
        }
        private int HandleServerMapUpdate()
        {
            string Url = "http://" + HttpContext.Current.Request.Url.Authority.ToString() + "/MapServerList.ashx";

            string strRlt = BaseInterface.RequestContent(Url);

            if (strRlt.Contains("Success"))
            {
                return(0);
            }
            else
            {
                return(3);
            }
        }
Exemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string name     = "onelife";  // Request["name"];
            string pass     = "******";   // Request["pass"];
            int    time     = 1255165271; // BaseInterface.ConvertDateTimeInt(DateTime.Now);
            string loginKey = "yk-MotL-qhpAo88-7road-mtl55dantang-login-logddt777";
            string key      = BaseInterface.md5(name + pass + time.ToString() + loginKey);
            string content  = "content=" + HttpUtility.UrlEncode(name + "|" + pass + "|" + time.ToString() + "|" + key);

            string str = "http://localhost:728/CreateLogin.aspx?content=" + HttpUtility.UrlEncode(name + "|" + pass + "|" + time.ToString() + "|" + key);
            // string str = "http://localhost:728/CreateLogin.aspx?content=" + name + "|" + pass + "|" + time.ToString() + "|" + key;
            string url = BaseInterface.RequestContent(str);

            //string url = BaseInterface.RequestContent(str, content);
            Response.Write(url);
        }
Exemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((Session["username"] == null) && string.IsNullOrEmpty(Session["username"].ToString()))
            {
                Response.Redirect("~/Login.htm");
            }
            string result = "";

            try
            {
                string name     = Session["username"].ToString();
                string password = Guid.NewGuid().ToString();
                string time     = BaseInterface.ConvertDateTimeInt(DateTime.Now).ToString();
                string key      = string.Empty;

                if (string.IsNullOrEmpty(key))
                {
                    key = BaseInterface.GetLoginKey;
                }
                string v   = BaseInterface.md5(name + password + time.ToString() + key);
                string Url = (BaseInterface.LoginUrl + "?content=" + HttpUtility.UrlEncode(name + "|" + password + "|" + time.ToString() + "|" + v));
                result = BaseInterface.RequestContent(Url);
                if (result == "0")
                {
                    string flashUrl = FlashUrl + "?user="******"&key=" + HttpUtility.UrlEncode(password) + "&editby=Trminhpc";
                    if ("1" == ConfigurationManager.AppSettings["content2"])
                    {
                        password = (Session["password"] == null) ? password : Session["password"].ToString();
                        string iv        = "5C90D3C2C576A773";
                        string keyEncode = "5628eb9a3485fbf61f51927b8a8eee03c5962c6b64847aeb";
                        string origin    = name + "|" + password;
                        flashUrl = FlashUrl + "?content2=" + CryptoHelper.TripleDesEncrypt(keyEncode, origin, ref iv);
                    }
                    Response.Redirect(flashUrl, false);
                }
                else
                {
                    Response.Write(result);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
Exemplo n.º 18
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string chargeID = context.Request["chargeID"];
                string userName = context.Request["userName"];
                int money = int.Parse(context.Request["money"]);
                string payWay = context.Request["payWay"];
                decimal needMoney = decimal.Parse(context.Request["needMoney"]);
                string nickname = context.Request["nickname"] == null ? "" : HttpUtility.UrlDecode(context.Request["nickname"]);
                string site = "";

                QYInterface qy = new QYInterface();

                string key = string.Empty;
                if (!string.IsNullOrEmpty(site))
                {
                    key = ConfigurationManager.AppSettings[string.Format("ChargeKey_{0}", site)];
                }
                else
                {
                    key = BaseInterface.GetChargeKey;
                }

                string v = BaseInterface.md5(chargeID + userName + money + payWay + needMoney + key);
                string Url = "http://192.168.0.4:828/ChargeMoney.aspx?content=" + chargeID + "|" + userName + "|" + money + "|" + payWay + "|" + needMoney + "|" + v;
                Url += "&site=" + site;
                Url += "&nickname=" + HttpUtility.UrlEncode(nickname);
                context.Response.Write(BaseInterface.RequestContent(Url));

                //int userid = 0;
                //int isResult = 0;
                //using (PlayerBussiness db = new PlayerBussiness())
                //{
                //    db.AddChargeMoney(chargeID, "dandan", 1000, "sdf", 200, out userid, ref isResult);
                //}
                //context.Response.Write(isResult);

            }
            catch 
            {
                context.Response.Write("false");
            }
        }
Exemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string result = "";

            try
            {
                string site     = Request.Form["txtSite"]; //"A";
                string name     = Request.Form["txtUserName"];
                string password = Request.Form["txtPassword"];
                string time     = "1236319807954";// BaseInterface.ConvertDateTimeInt(DateTime.Now);

                string key = string.Empty;
                if (!string.IsNullOrEmpty(site))
                {
                    key = ConfigurationSettings.AppSettings[string.Format("LoginKey_{0}", site)];
                }

                if (string.IsNullOrEmpty(key))
                {
                    key = BaseInterface.GetLoginKey;
                }

                string v   = BaseInterface.md5(name + password + time.ToString() + key);
                string Url = BaseInterface.LoginUrl + "?content=" + HttpUtility.UrlEncode(name + "|" + password + "|" + time.ToString() + "|" + v);
                Url   += "&site=" + site;
                result = BaseInterface.RequestContent(Url);

                if (result == "0")
                {
                    string flashUrl = FlashUrl + "?user="******"&key=" + HttpUtility.UrlEncode(password)
                                      + "&site=" + site + "&sitename=" + site;
                    Response.Redirect(flashUrl, false);
                }
                else
                {
                    Response.Write(result);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
Exemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string result = "";

            try
            {
                string site     = "";
                string id       = Request["id"] == null ? "" : Request["id"]; //"A";
                string name     = Request["username"];
                string password = Request["password"] == null ? "" : Request["password"];
                password = Guid.NewGuid().ToString();
                string time = "1236319807954";// BaseInterface.ConvertDateTimeInt(DateTime.Now);

                string key = string.Empty;
                if (string.IsNullOrEmpty(key))
                {
                    key = BaseInterface.GetLoginKey;
                }

                string v   = BaseInterface.md5(name + password + time.ToString() + key);
                string Url = BaseInterface.LoginUrl + "?content=" + HttpUtility.UrlEncode(name + "|" + password + "|" + time.ToString() + "|" + v);
                Url   += "&site=" + site;
                result = BaseInterface.RequestContent(Url);

                if (result == "0")
                {
                    string flashUrl = FlashUrl + "?user="******"&key=" + HttpUtility.UrlEncode(password)
                                      + "&site=" + site + "&sitename=" + site;
                    Response.Write(flashUrl);
                }
                else
                {
                    Response.Write(result);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
Exemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string mailTitle   = "大幅度是";
            string mailContent = "大幅度是";
            string username    = "******";
            string gold        = "6666";
            string money       = "99999";
            //param格式://int templateID, int count, int validDate, int StrengthenLevel, int AttackCompose, int DefendCompose, int AgilityCompose, int LuckCompose, bool isBinds
            string param = "11020,4,0,0,0,0,0,0,1|7014,2,9,400,400,400,400,400,0";


            string content = mailTitle + "#" + mailContent + "#" + username + "#" + gold + "#" + money + "#" + param + "#";

            DateTime time = DateTime.Now;

            string key = "asdfgh";
            string v   = BaseInterface.md5(username + gold + money + param + BaseInterface.ConvertDateTimeInt(time) + key);

            content = content + BaseInterface.ConvertDateTimeInt(time) + "#" + v;

            Response.Redirect("http://192.168.0.4:828/SentReward.ashx?content=" + Server.UrlEncode(content));
        }
Exemplo n.º 22
0
        private Program()
        {
            var eth = new EthernetBuiltIn();
            eth.Open();
            if (!eth.CableConnected)
            {
                eth.Close();
                var wifi = new WiFiRS9110(SPI.SPI_module.SPI2, G120E.Gpio.P3_30, G120E.Gpio.P2_30, G120E.Gpio.P4_31);
                _netif = wifi;
                _netif.Open();
                wifi.Join("XXX", "XXX");
            }
            else
            {
                _netif = eth;
            }
            if (!_netif.IsDhcpEnabled)
                _netif.EnableDhcp();
            if (!_netif.IsDynamicDnsEnabled)
                _netif.EnableDynamicDns();

            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
        }
Exemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int result = 1;

            try
            {
                if (ValidLoginIP(Context.Request.UserHostAddress))
                {
                    string        content = HttpUtility.UrlDecode(Request["content"]);
                    string        site    = Request["site"] == null ? "" : HttpUtility.UrlDecode(Request["site"]).ToLower();
                    BaseInterface inter   = BaseInterface.CreateInterface();
                    string[]      str     = inter.UnEncryptLogin(content, ref result, site);
                    if (str.Length > 3)
                    {
                        string name     = str[0].Trim();
                        string password = str[1].Trim();
                        if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(password))
                        {
                            name = BaseInterface.GetNameBySite(name, site);
                            PlayerManager.Add(name, password);

                            result = 0;
                        }
                    }
                }
                else
                {
                    result = 3;
                }
            }
            catch (Exception ex)
            {
                log.Error("CreateLogin:", ex);
            }
            Response.Write(result);
        }
Exemplo n.º 24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int result = 1;

            try
            {
                string IP = Context.Request.UserHostAddress;
                if (ValidLoginIP(IP))
                {
                    string content  = HttpUtility.UrlDecode(Request["content"]);
                    string site     = Request["site"] == null ? "" : HttpUtility.UrlDecode(Request["site"]).ToLower();
                    string nickname = Request["nickname"] == null ? "" : HttpUtility.UrlDecode(Request["nickname"]);

                    BaseInterface inter = BaseInterface.CreateInterface();
                    string[]      str   = inter.UnEncryptCharge(content, ref result, site);
                    if (str.Length > 5)
                    {
                        string  chargeID  = str[0];
                        string  userName  = str[1].Trim();
                        int     money     = int.Parse(str[2]);
                        string  payWay    = str[3];
                        decimal needMoney = decimal.Parse(str[4]);

                        if (!string.IsNullOrEmpty(userName))
                        {
                            userName = BaseInterface.GetNameBySite(userName, site);
                            if (money > 0)
                            {
                                using (PlayerBussiness db = new PlayerBussiness())
                                {
                                    int      userID;
                                    DateTime date = DateTime.Now;
                                    if (db.AddChargeMoney(chargeID, userName, money, payWay, needMoney, out userID, ref result, date, IP, nickname))
                                    {
                                        result = 0;
                                        using (CenterServiceClient temp = new CenterServiceClient())
                                        {
                                            temp.ChargeMoney(userID, chargeID);
                                            using (PlayerBussiness pb = new PlayerBussiness())
                                            {
                                                PlayerInfo player = pb.GetUserSingleByUserID(userID);
                                                if (player != null)
                                                {
                                                    StaticsMgr.Log(date, userName, player.Sex, money, payWay, needMoney);
                                                }
                                                else
                                                {
                                                    StaticsMgr.Log(date, userName, true, money, payWay, needMoney);
                                                    log.Error("ChargeMoney_StaticsMgr:Player is null!");
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                result = 3;
                            }
                        }
                        else
                        {
                            result = 2;
                        }
                    }
                }
                else
                {
                    result = 5;
                }
            }
            catch (Exception ex)
            {
                log.Error("ChargeMoney:", ex);
            }
            Response.Write(result);
        }
Exemplo n.º 25
0
        public void ProcessRequest(HttpContext context)
        {
            LanguageMgr.Setup(ConfigurationManager.AppSettings["ReqPath"]);
            bool   value   = false;
            string message = LanguageMgr.GetTranslation("Tank.Request.Login.Fail1");// "Login Fail!";
            string style   = "";
            bool   isError = false;

            XElement result = new XElement("Result");

            try
            {
                BaseInterface inter = BaseInterface.CreateInterface();
                string        p     = context.Request["p"];//?
                string        site  = context.Request["site"] == null ? "" : HttpUtility.UrlDecode(context.Request["site"]);
                //string nickname = context.Request["nickname"] == null ? "" : HttpUtility.UrlDecode(context.Request["nickname"]);
                string IP = context.Request.UserHostAddress;
                if (!string.IsNullOrEmpty(p))
                {
                    //解密
                    byte[]   src     = CryptoHelper.RsaDecryt2(StaticFunction.RsaCryptor, p);
                    string[] strList = Encoding.UTF8.GetString(src, 7, src.Length - 7).Split(',');
                    if (strList.Length == 4)
                    {
                        string name     = strList[0];
                        string pwd      = strList[1];
                        string newPwd   = strList[2];
                        string nickname = strList[3];

                        if (true)    //(PlayerManager.Login(name, pwd))
                        {
                            int  isFirst       = 0;
                            bool isActive      = false;
                            bool firstValidate = PlayerManager.GetByUserIsFirst(name);
                            //using (PlayerBussiness db = new PlayerBussiness())
                            //{
                            //    PlayerInfo[] infos = db.GetUserLoginList(name);

                            //    if (infos.Length <= 0)
                            //    {
                            //        throw new Exception();
                            //    }
                            //}
                            PlayerInfo player = inter.CreateLogin(name, newPwd, ref message, ref isFirst, IP, ref isError, firstValidate, ref isActive, site, nickname);

                            if (player != null && !isError)
                            {
                                if (isFirst == 0)
                                {
                                    PlayerManager.Update(name, newPwd);
                                }
                                else
                                {
                                    PlayerManager.Remove(name);
                                }
                                style         = string.IsNullOrEmpty(player.Style) ? ",,,,,,,," : player.Style;
                                player.Colors = string.IsNullOrEmpty(player.Colors) ? ",,,,,,,," : player.Colors;

                                XElement node = new XElement("Item",
                                                             new XAttribute("ID", player.ID),
                                                             new XAttribute("IsFirst", isFirst),
                                                             new XAttribute("NickName", player.NickName),
                                                             new XAttribute("Date", ""),
                                                             new XAttribute("IsConsortia", 0),
                                                             new XAttribute("ConsortiaID", player.ConsortiaID),
                                                             new XAttribute("Sex", player.Sex),
                                                             new XAttribute("WinCount", player.Win),
                                                             new XAttribute("TotalCount", player.Total),
                                                             new XAttribute("EscapeCount", player.Escape),
                                                             new XAttribute("DutyName", player.DutyName == null ? "" : player.DutyName),
                                                             new XAttribute("GP", player.GP),
                                                             new XAttribute("Honor", ""),
                                                             new XAttribute("Style", player.Style == null ? style : player.Style),
                                                             new XAttribute("Gold", player.Gold),
                                                             new XAttribute("Colors", player.Colors == null ? "" : player.Colors),
                                                             new XAttribute("Attack", player.Attack),
                                                             new XAttribute("Defence", player.Defence),
                                                             new XAttribute("Agility", player.Agility),
                                                             new XAttribute("Luck", player.Luck),
                                                             new XAttribute("Grade", player.Grade),
                                                             new XAttribute("Hide", player.Hide),
                                                             new XAttribute("Repute", player.Repute),
                                                             new XAttribute("ConsortiaName", player.ConsortiaName == null ? "" : player.ConsortiaName),
                                                             new XAttribute("Offer", player.Offer),
                                                             new XAttribute("Skin", player.Skin == null ? "" : player.Skin),
                                                             new XAttribute("ReputeOffer", player.ReputeOffer),
                                                             new XAttribute("ConsortiaHonor", player.ConsortiaHonor),
                                                             new XAttribute("ConsortiaLevel", player.ConsortiaLevel),
                                                             new XAttribute("ConsortiaRepute", player.ConsortiaRepute),
                                                             new XAttribute("Money", player.Money),
                                                             new XAttribute("AntiAddiction", player.AntiAddiction),
                                                             new XAttribute("IsMarried", player.IsMarried),
                                                             new XAttribute("SpouseID", player.SpouseID),
                                                             new XAttribute("SpouseName", player.SpouseName == null ? "" : player.SpouseName),
                                                             new XAttribute("MarryInfoID", player.MarryInfoID),
                                                             new XAttribute("IsCreatedMarryRoom", player.IsCreatedMarryRoom),
                                                             new XAttribute("IsGotRing", player.IsGotRing),
                                                             new XAttribute("LoginName", player.UserName == null ? "" : player.UserName),
                                                             new XAttribute("Nimbus", player.Nimbus),
                                                             new XAttribute("FightPower", player.FightPower),
                                                             new XAttribute("AnswerSite", player.AnswerSite),
                                                             new XAttribute("WeaklessGuildProgressStr", player.WeaklessGuildProgressStr == null ? "" : player.WeaklessGuildProgressStr),
                                                             new XAttribute("IsOldPlayer", player.IsOldPlayer));

                                result.Add(node);
                                value   = true;
                                message = LanguageMgr.GetTranslation("Tank.Request.Login.Success");;
                            }
                            else
                            {
                                PlayerManager.Remove(name);
                            }
                        }
                        else
                        {
                            message = LanguageMgr.GetTranslation("BaseInterface.LoginAndUpdate.Try");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("User Login error", ex);
                value   = false;
                message = LanguageMgr.GetTranslation("Tank.Request.Login.Fail2");
            }
            finally
            {
                result.Add(new XAttribute("value", value));
                result.Add(new XAttribute("message", message));
                context.Response.ContentType = "text/plain";
                context.Response.Write(result.ToString(false));
            }
        }
Exemplo n.º 26
0
 public ObavezaController(BaseInterface <Obaveza, ObavezaVM> baseInterface)
 {
     _baseInterface = baseInterface;
 }
Exemplo n.º 27
0
 public ChatPorukaController(BaseInterface <ChatPoruka, ChatPorukaVM> baseInterface)
 {
     _baseInterface = baseInterface;
 }
Exemplo n.º 28
0
 public NalazController(BaseInterface <Nalaz, NalazVM> nalazInterface)
 {
     _nalazInterface = nalazInterface;
 }
Exemplo n.º 29
0
 public KonsultacijePorukaController(BaseInterface <KonsultacijePoruka, KonsultacijePorukaVM> baseInterface)
 {
     _baseInterface = baseInterface;
 }
Exemplo n.º 30
0
 public int HandlePacket(GameClient client, GSPacketIn packet)
 {
     try
     {
         if (client.Player == null)
         {
             int version = packet.ReadInt();
             packet.ReadInt();
             byte[] array  = new byte[8];
             byte[] array2 = packet.ReadBytes();
             try
             {
                 array2 = WorldMgr.RsaCryptor.Decrypt(array2, false);
             }
             catch (ExecutionEngineException exception)
             {
                 client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError", new object[0]));
                 client.Disconnect();
                 GameServer.log.Error("ExecutionEngineException", exception);
                 int result = 0;
                 return(result);
             }
             catch (Exception exception2)
             {
                 client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError", new object[0]));
                 client.Disconnect();
                 GameServer.log.Error("RsaCryptor", exception2);
                 int result = 0;
                 return(result);
             }
             string arg_B1_0 = GameServer.Edition;
             for (int i = 0; i < 8; i++)
             {
                 array[i] = array2[i + 7];
             }
             client.setKey(array);
             string[] array3 = Encoding.UTF8.GetString(array2, 15, array2.Length - 15).Split(new char[]
             {
                 ','
             });
             if (array3.Length == 2)
             {
                 string text = array3[0];
                 string pass = array3[1];
                 if (!LoginMgr.ContainsUser(text))
                 {
                     bool          flag          = false;
                     BaseInterface baseInterface = BaseInterface.CreateInterface();
                     PlayerInfo    playerInfo    = baseInterface.LoginGame(text, pass, ref flag);
                     if (playerInfo != null && playerInfo.ID != 0)
                     {
                         if (playerInfo.ID == -2)
                         {
                             client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid", new object[0]));
                             client.Disconnect();
                             int result = 0;
                             return(result);
                         }
                         if (!flag)
                         {
                             client.Player = new GamePlayer(playerInfo.ID, text, client, playerInfo);
                             LoginMgr.Add(playerInfo.ID, client);
                             client.Server.LoginServer.SendAllowUserLogin(playerInfo.ID);
                             client.Version = version;
                         }
                         else
                         {
                             client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register", new object[0]));
                             client.Disconnect();
                         }
                     }
                     else
                     {
                         client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime", new object[0]));
                         client.Disconnect();
                     }
                 }
                 else
                 {
                     client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LoginError", new object[0]));
                     client.Disconnect();
                 }
             }
             else
             {
                 client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LengthError", new object[0]));
                 client.Disconnect();
             }
         }
     }
     catch (Exception exception3)
     {
         client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.ServerError", new object[0]));
         client.Disconnect();
         GameServer.log.Error(LanguageMgr.GetTranslation("UserLoginHandler.ServerError", new object[0]), exception3);
     }
     return(1);
 }
Exemplo n.º 31
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            try
            {
                GSPacketIn pkg = new GSPacketIn((byte)ePackageType.LOGIN);
                pkg.ClientID = packet.ClientID;
                if (client.Player == null)
                {
                    int    version    = packet.ReadInt();
                    int    clientType = packet.ReadInt();
                    byte[] src        = packet.ReadBytes();
                    //解密
                    try
                    {
                        src = WorldMgr.RsaCryptor.Decrypt(src, false);
                    }
                    catch (ExecutionEngineException e)
                    {
                        client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError"));
                        client.Disconnect();
                        GameServer.log.Error("ExecutionEngineException", e);
                        return(0);
                    }
                    catch (Exception ex)
                    {
                        //防止攻击,如果解密出错,直接断开连接
                        client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError"));
                        client.Disconnect();
                        GameServer.log.Error("RsaCryptor", ex);
                        return(0);
                    }
                    //DateTime date = new DateTime(src[0] * 256 + src[1], src[2], src[3], src[4], src[5], src[6]);
                    int fms_key = (src[7] << 8) + src[8];
                    client.SetFsm(fms_key, version);

                    //string edition = GameServer.Instance.Configuration.Edition;
                    string edition = GameServer.Edition;
                    //if (version.ToString() != edition && edition != "0")
                    //{
                    //    client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.EditionError"));
                    //    //client.Out.SendEditionError(LanguageMgr.GetTranslation("UserLoginHandler.EditionError"));
                    //    client.Disconnect();
                    //    return 0;
                    //}

                    string[] temp = Encoding.UTF8.GetString(src, 9, src.Length - 9).Split(',');
                    if (temp.Length == 2)
                    {
                        string user = temp[0];
                        string pass = temp[1];

                        //TimeSpan span = date - DateTime.UtcNow;
                        //if (Math.Abs(span.TotalMinutes) < 5)
                        //{
                        if (!LoginMgr.ContainsUser(user))
                        {
                            bool          isFirst = false;
                            BaseInterface inter   = BaseInterface.CreateInterface();
                            PlayerInfo    cha     = inter.LoginGame(user, pass, ref isFirst);

                            if (cha != null && cha.ID != 0)
                            {
                                if (cha.ID == -2)
                                {
                                    //帐号被禁用
                                    client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid"));
                                    client.Disconnect();
                                    return(0);
                                }

                                if (!isFirst)
                                {
                                    client.Player = new GamePlayer(cha.ID, user, client, cha);
                                    LoginMgr.Add(cha.ID, client);
                                    client.Server.LoginServer.SendAllowUserLogin(cha.ID);
                                    client.Out.SendLoginSuccess2();
                                    client.Version = version;
                                }
                                else
                                {
                                    client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register"));
                                    client.Disconnect();
                                }
                            }
                            else
                            {
                                //client.Out.SendLoginFailed("用户名密码错误");
                                client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime"));
                                client.Disconnect();
                            }
                        }
                        else
                        {
                            //避免攻击,有另外的客户端在登陆,则断掉次客户端。
                            client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LoginError"));
                            client.Disconnect();
                        }
                    }
                    else
                    {
                        client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LengthError"));
                        //验证格式错误,端口连接
                        client.Disconnect();
                    }
                }
            }
            catch (Exception ex)
            {
                client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.ServerError"));
                client.Disconnect();
                GameServer.log.Error(LanguageMgr.GetTranslation("UserLoginHandler.ServerError"), ex);
            }

            return(1);
        }
Exemplo n.º 32
0
 public ChatObavezaController(BaseInterface <ChatObaveza, ChatObavezaVM> baseInterface)
 {
     _baseInterface = baseInterface;
 }