Ejemplo n.º 1
0
        /// <summary>
        /// Serialize <see cref="RequestDelete"/>.
        /// </summary>
        /// <param name="request">Request to serialize</param>
        private void SerializeRequestCheck(RequestCheck request)
        {
            this.binaryWriter.Write(request.Version);
            this.binaryWriter.Write((byte)request.UniqueIncarnationIdKind);
            if (request.UniqueIncarnationIdKind != RequestCheck.UniqueIncarnationIdType.None)
            {
                this.binaryWriter.Write((Guid)request.UniqueIncarnationId);
            }

            if (this.versionToUse >= SerializationFormatVersions.Version16)
            {
                this.binaryWriter.Write(request.CVersion);
                this.binaryWriter.Write(request.AVersion);
            }
        }
        public override void OnActionExecuting(HttpActionContext filterContext)
        {
            RequestCheck requestCheck = new RequestCheck();

            filterContext.Request.Headers.TryGetValues("Token", out IEnumerable <string> token);

            var loginState = requestCheck.RequestLoginStateCheck(token == null ? "" : token.First(), filterContext.Request.RequestUri.LocalPath);

            if (ErrorType.Success == loginState)
            {
            }
            else
            {
                var response = filterContext.Response = filterContext.Response ?? new HttpResponseMessage();
                response.Content = new StringContent(JsonConvert.SerializeObject(MessageEntityTool.GetMessage(loginState)), Encoding.UTF8, "application/json");
                return;
            }
        }
Ejemplo n.º 3
0
        private static void BeginRequest(object sender, EventArgs e)
        {
            var isFirstRequest = RequestCheck.IsFirstRequest();

            if (isFirstRequest)
            {
                Trace.TraceInformation("[FranksteinHttpModule]: First request arrived. ");

                //start job scheduler

                if (BootstrapperSection.Instance.Tasks.Enabled)
                {
                    var interval = BootstrapperSection.Instance.Tasks.Interval;
                    var job      = new KeepWebSiteAlive(interval);
                    job.Register();
                }
            }
        }
Ejemplo n.º 4
0
    // Determines the correct index for an item in the inventory, checking the preferred slot first
    int DetermineDesiredIndex(int itemID, int preferredIndex = -1, RequestCheck check = RequestCheck.None)
    {
        // Prioritise the preferred index over the itemID
        if (IsDesiredIndex(preferredIndex, itemID, check))
        {
            return(preferredIndex);
        }

        // Brute force search
        else
        {
            for (int i = 0; i < m_inventory.Count; ++i)
            {
                if (IsDesiredIndex(i, itemID, check))
                {
                    return(i);
                }
            }
        }

        // -1 represents failure
        return(-1);
    }
Ejemplo n.º 5
0
    // Checks whether the item at the passed index is the desired item
    bool IsDesiredIndex(int index, int itemID, RequestCheck check = RequestCheck.None)
    {
        if (IsValidIndex(index))
        {
            // Check the itemID is correct then check whether it matters if it has been requested or not
            if (m_inventory[index] && m_inventory[index].m_equipmentID == itemID)
            {
                switch (check)
                {
                case RequestCheck.None:
                    return(true);

                case RequestCheck.Requested:
                    return(m_isItemRequested[index]);

                case RequestCheck.Unrequested:
                    return(!m_isItemRequested[index]);
                }
            }
        }

        return(false);
    }
Ejemplo n.º 6
0
        private static void AddWorkTask(RequestData requestData)
        {
            if (requestData.SafeRequestUrl.Length > 3 && !RequestCheck.IsNotSafeRequest(requestData.SafeRequestUrl))
            {
                HttpWorker.EndRequest(requestData.Socket, 400, "Path:" + requestData.SafeRequestUrl);
                requestData.SaveToPoll();
                return;
            }
            string fileExt = CommonUtil.GetFileExtention(requestData.SafeRequestUrl);

            if (!string.IsNullOrEmpty(fileExt))
            {
                fileExt = fileExt.ToLower();
            }

            #region 静态文件请求处理

            if (!string.IsNullOrEmpty(fileExt) && !_dynamicReqDic.ContainsKey(fileExt) && requestData.HttpMethod == "GET")
            {
                HttpWorker httpWorker = new HttpWorker();
                if (httpWorker.Process(requestData))
                {
                    return;
                }
            }
            #endregion

            #region 动态请求处理
            if (ApplicationInfo.OwinAdapter != null)
            {
                if ((requestData.HttpMethod == "POST" || requestData.HttpMethod == "PUT") &&
                    requestData.HeadDomainDic != null && requestData.HeadDomainDic.Keys.Contains("Expect"))
                {
                    //http 100-continue用于客户端在发送POST数据给服务器前,征询服务器情况,看服务器是否处理POST的数据,如果不处理,客户端则不上传POST数据,如果处理,则POST上传数据。在现实应用中,通过在POST大数据时,才会使用100-continue协议。 Client发送Expect:100-continue消息
                    //在使用curl做POST的时候, 当要POST的数据大于1024字节的时候, curl并不会直接就发起POST请求, 而是会分为俩步,
                    //1. 发送一个请求, 包含一个Expect:100-continue, 询问Server使用愿意接受数据
                    //2. 接收到Server返回的100-continue应答以后, 才把数据POST给Server
                    //大致功能好像是当post数据超过1024时,不用询问服务器是否接受其他数据
                    string text2 = requestData.HeadDomainDic["Expect"].FirstOrDefault <string>();
                    if (string.Equals(text2, "100-continue", StringComparison.OrdinalIgnoreCase))
                    {
                        requestData.Socket.Write(Continue100, WriteCallBack, null);
                        requestData.HeadDomainDic.Remove("Expect");
                    }
                }
                OwinAdapterManage owinAdapterManage = new OwinAdapterManage();
                if (owinAdapterManage.Process(requestData))
                {
                    return;
                }
            }

            #endregion
            #region 请求Info信息

            if (requestData.SafeRequestUrl == "/info")
            {
                SendWelcomePage((OwinSocket)requestData.Socket, requestData);
                return;
            }
            #endregion

            HttpWorker.EndRequest(requestData.Socket, 404, requestData.RequestUrl);
            requestData.SaveToPoll();
        }
Ejemplo n.º 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CheckAdminLogin())
        {
            return;//已经登录过了
        }
        string validate = StringHelp.FilterSymbolStr(q("validate"));

        if (string.IsNullOrEmpty(validate))
        {
            return;                                                           //参数丢失;
        }
        if (string.Compare(validate, Session["LVNum"].ToString(), true) == 0) //不区分大小写比较验证码
        {
            string count = q("paramName");
            string pwd   = q("paramPwd");

            if (string.IsNullOrEmpty(count) || string.IsNullOrEmpty(pwd))
            {
                Response.Write("1|" + Test_BUL.sysParam.ErrorPageTip("1"));
            }
            if (RequestCheck.CheckKeyWord(count) || RequestCheck.CheckKeyWord(pwd))
            {
                Response.Write("3|" + Test_BUL.sysParam.ErrorPageTip("3"));
            }
            else
            {
                string  strsql = common.GetCustomDSsql("tb_sys_admin", "id,count,password,loginIP,loginTime,telephone,email,sex,birthday,createTime,roleid,adminTag,AccountState,PowerLeave ", " count='" + count + "' ");
                DataSet ds     = common.GetList(strsql);
                if (Tools.Validator.CheckDataSet(ds, 0))
                {
                    if (ds.Tables[0].Rows[0]["password"].ToString() == EncryptAdmin(pwd))
                    {
                        string state = ds.Tables[0].Rows[0]["AccountState"].ToString();
                        //账号状态:10正常,20冻结,30禁用
                        if (state == "20")
                        {
                            Response.Write("20|" + Test_BUL.sysParam.ErrorPageTip("11"));
                        }
                        else if (state == "30")
                        {
                            Response.Write("30|" + Test_BUL.sysParam.ErrorPageTip("12"));
                        }
                        else
                        {
                            string tempRoleId   = ds.Tables[0].Rows[0]["roleid"].ToString();
                            string tempAdminTag = ds.Tables[0].Rows[0]["adminTag"].ToString();

                            if (string.IsNullOrEmpty(tempRoleId) || state != "10" || string.IsNullOrEmpty(tempAdminTag))
                            {
                                Response.Write("14|" + Test_BUL.sysParam.ErrorPageTip("14"));
                            }
                            else
                            {
                                SetUserCookie(ds.Tables[0]);                            //用户信息写入Cookies
                                Test_BUL.sys_admin blladmin = new Test_BUL.sys_admin(); //更新登录IP和登录时间
                                blladmin.UpdateLogin(count, Tools.IPHelp.ClientIP, DateTime.Now);
                                Response.Write("10|" + Test_BUL.sysParam.ErrorPageTip("10"));
                            }
                        }
                    }
                    else
                    {
                        Response.Write("9|" + Test_BUL.sysParam.ErrorPageTip("9"));
                    }
                }
                else
                {
                    Response.Write("8|" + Test_BUL.sysParam.ErrorPageTip("8"));
                }
            }
        }
        else
        {
            Response.Write("15|" + Test_BUL.sysParam.ErrorPageTip("15"));
        }
    }