예제 #1
0
        /// <summary>
        /// 获取标签值
        /// </summary>
        /// <param name="flags"></param>
        /// <returns></returns>
        public static BuiltInArchiveFlags GetBuiltInFlags(string flags)
        {
            JsonAnalyzer        json = new JsonAnalyzer(flags);
            BuiltInArchiveFlags flag = BuiltInArchiveFlags.None;


            if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.AsPage]) == "1")
            {
                flag |= BuiltInArchiveFlags.AsPage;
            }
            if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.IsSpecial]) == "1")
            {
                flag |= BuiltInArchiveFlags.IsSpecial;
            }

            if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.IsSystem]) == "1")
            {
                flag |= BuiltInArchiveFlags.IsSystem;
            }
            if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.Visible]) == "1")
            {
                flag |= BuiltInArchiveFlags.Visible;
            }

            return(flag);
        }
예제 #2
0
        //[AcceptVerbs("POST")]
        public string Verify(string domain,string key,string token)
        {
            //activatorFile.Append("YmIyNDAwMGI3YmEyZGMwZTgxZWI2OGQxYzk3MWU4NWI=", "{domain:'temp.ops.cc',start:'*',end='*'}");
            try
            {

                if (activatorFile.Contains(key))
                {

                    JsonAnalyzer ja=new JsonAnalyzer(activatorFile[key]);

                    string endDate = ja.GetValue("end");
                    //如果结束时间为不限
                    if (endDate == "*") return GethandleJson("ok");
                    //判断结束时间是否已过,未过则返回"ok";
                    DateTime _endDate;
                    DateTime.TryParse(endDate, out _endDate);
                    if (_endDate > DateTime.Now) return GethandleJson("ok");
                }
            }
            catch
            {
                //如果控制端出现任何异常,则默认全部通过
                return GethandleJson("ok");
            }

            //
            // 不存在Key或者已过有效期
            // 返回值
            // go:返回数据但不调用Response.End()
            // end:返回数据调用Response.End()
            // 其他数据则默认通过且存入缓存
            return GethandleJson("end");
        }
예제 #3
0
        private static int GetIntValue(string field)
        {
            int i = 0;

            string json = GetData(DateTime.Now);
            if (String.Compare(json, defaultJson, true) != 0)
            {
                JsonAnalyzer js = new JsonAnalyzer(json);
                int.TryParse(js.GetValue(field), out i);
            }
            return i;
        }
예제 #4
0
        private static int GetIntValue(string field)
        {
            int i = 0;

            string json = GetData(DateTime.Now);

            if (String.Compare(json, defaultJson, true) != 0)
            {
                JsonAnalyzer js = new JsonAnalyzer(json);
                int.TryParse(js.GetValue(field), out i);
            }
            return(i);
        }
예제 #5
0
        //[AcceptVerbs("POST")]
        public string Verify(string domain, string key, string token)
        {
            //activatorFile.Append("YmIyNDAwMGI3YmEyZGMwZTgxZWI2OGQxYzk3MWU4NWI=", "{domain:'temp.j6.cc',start:'*',end='*'}");
            try
            {
                if (activatorFile.Contains(key))
                {
                    JsonAnalyzer ja = new JsonAnalyzer(activatorFile[key]);

                    string endDate = ja.GetValue("end");
                    //如果结束时间为不限
                    if (endDate == "*")
                    {
                        return(GethandleJson("ok"));
                    }
                    //判断结束时间是否已过,未过则返回"ok";
                    DateTime _endDate;
                    DateTime.TryParse(endDate, out _endDate);
                    if (_endDate > DateTime.Now)
                    {
                        return(GethandleJson("ok"));
                    }
                }
            }
            catch
            {
                //如果控制端出现任何异常,则默认全部通过
                return(GethandleJson("ok"));
            }


            //
            // 不存在Key或者已过有效期
            // 返回值
            // go:返回数据但不调用Response.End()
            // end:返回数据调用Response.End()
            // 其他数据则默认通过且存入缓存
            return(GethandleJson("end"));
        }
예제 #6
0
        /// <summary>
        /// 获取标签值
        /// </summary>
        /// <param name="flags"></param>
        /// <param name="flagKey"></param>
        /// <returns></returns>
        public static bool GetFlag(string flags, string flagKey)
        {
            JsonAnalyzer json = new JsonAnalyzer(flags);

            return(json.GetValue(flagKey) == "1");
        }
예제 #7
0
        /// <summary>
        /// 记录IP信息
        /// </summary>
        /// <param name="ip"></param>
        public static void Record(string ip)
        {
            new Thread(() =>
            {
                try
                {
                    string key = String.Format("{0:yyyyMMdd}", DateTime.Now);
                    string data;                                   //流量数据
                    int todayIP = 0, todayPV = 0,
                    totalIP     = 0, totalPV = 0;

                    string ips = String.Empty;                     //IP库

                    //获取累计的IP和PV,如果不存在,则创建字段
                    if (trafficFile.Contains("totalIP"))
                    {
                        int.TryParse(trafficFile["totalIP"], out totalIP);
                    }
                    else
                    {
                        trafficFile.Add("totalIP", "0");
                    }

                    if (trafficFile.Contains("totalPV"))
                    {
                        int.TryParse(trafficFile["totalPV"], out totalPV);
                    }
                    else
                    {
                        trafficFile.Add("totalPV", "0");
                    }

                    data            = GetData(DateTime.Now);
                    JsonAnalyzer js = new JsonAnalyzer(data);

                    int.TryParse(js.GetValue("ip"), out todayIP);
                    int.TryParse(js.GetValue("pv"), out todayPV);

                    //检测是否是独立访客,如果是则增加IP并记录
                    if (trafficFile.Contains("ips"))
                    {
                        ips = trafficFile["ips"];
                    }
                    else
                    {
                        trafficFile.Add("ips", "");
                    }

                    if (ips.IndexOf(ip) == -1)
                    {
                        ips = String.Format("{0}{1}|", ips, ip);
                        trafficFile["ips"] = ips;
                        ++todayIP;
                        ++totalIP;

                        //更新今日IP数据并返回新的JSON
                        js = new JsonAnalyzer(js.SetValue("ip", todayIP.ToString()));

                        //保存总的IP数据
                        if (trafficFile.Contains("totalIP"))
                        {
                            trafficFile["totalIP"] = totalIP.ToString();
                        }
                        else
                        {
                            trafficFile.Add("totalIP", totalIP.ToString());
                        }
                    }
                    ++todayPV;
                    ++totalPV;

                    //保存今日PV
                    trafficFile[key] = js.SetValue("pv", todayPV.ToString());

                    //保存总的PV数据
                    trafficFile["totalPV"] = totalPV.ToString();
                }
                catch (Exception ex)
                {
                    //
                    //Catch error
                    //

                    trafficFile.Flush();
                }
            }).Start();
        }
예제 #8
0
        /// <summary>
        /// 校验激活状态
        /// </summary>
        internal static void VerifyActivation()
        {
            if (DateTime.Now < new DateTime(2014, 02, 16))
            {
                return;
            }
            //
            // 如果异步方式调用
            // 或在本地调试则不校验
            //
            if (Cms.Cache.Get(checkKey) != null || CheckIsHostOnLocalhost())
            {
                return;
            }



            //
            // 异步从服务器读取激活状态
            //

            /*
             * new Thread(() =>
             * {
             *  lock (activeInfo)
             *  {
             *      CheckActiveState();
             *  }
             *
             * }).Start();*/


            CheckActiveState();

            //=====分析获得的数据并返回到客户端=====//
            if (!String.IsNullOrEmpty(activeInfo))
            {
                lock (activeInfo)
                {
                    try
                    {
                        JsonAnalyzer js     = new JsonAnalyzer(activeInfo);
                        string       result = js.GetValue("state");

                        if (result != "ok")
                        {
                            activiveIsNormal = false;                           //设置状态

                            string content = js.GetValue("content");
                            HttpContext.Current.Response.ClearContent();
                            HttpContext.Current.Response.Write(content);

                            //返回字符串
                            if (result == "end")
                            {
                                HttpRuntime.UnloadAppDomain();
                                HttpContext.Current.Response.End();
                                return;
                            }
                            else if (result == "go")
                            {
                                return;
                            }
                        }
                        else
                        {
                            activiveIsNormal = true;                           //设置状态
                            //如果通过校验,则缓存1日激活状态

                            Cms.Cache.Insert(checkKey, "1", DateTime.Now.AddDays(7));
                        }
                    }
                    catch
                    {
                        //如果发生异常
                        //则创建缓存3天候过期来避免频繁向服务器发送校验请求
                        Cms.Cache.Insert(checkKey, "1", DateTime.Now.AddDays(3));
                    }
                }
            }
        }
예제 #9
0
        /// <summary>
        /// 获取标签值
        /// </summary>
        /// <param name="flags"></param>
        /// <returns></returns>
        public static BuiltInArchiveFlags GetBuiltInFlags(string flags)
        {
            JsonAnalyzer json = new JsonAnalyzer(flags);
            BuiltInArchiveFlags flag = BuiltInArchiveFlags.None;


            if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.AsPage]) == "1")
            {
                flag |= BuiltInArchiveFlags.AsPage;
            }
            if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.IsSpecial]) == "1")
            {
                flag |= BuiltInArchiveFlags.IsSpecial;
            }

            if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.IsSystem]) == "1")
            {
                flag |= BuiltInArchiveFlags.IsSystem;
            }
            if (json.GetValue(internalFlagTexts[(int)BuiltInArchiveFlags.Visible]) == "1")
            {
                flag |= BuiltInArchiveFlags.Visible;
            }

            return flag;

        }
예제 #10
0
 /// <summary>
 /// 获取标签值
 /// </summary>
 /// <param name="flags"></param>
 /// <param name="flagKey"></param>
 /// <returns></returns>
 public static bool GetFlag(string flags, string flagKey)
 {
     JsonAnalyzer json = new JsonAnalyzer(flags);
     return json.GetValue(flagKey) == "1";
 }
예제 #11
0
        /// <summary>
        /// 校验激活状态
        /// </summary>
        internal static void VerifyActivation()
        {

        	if(DateTime.Now<new DateTime(2014,02,16)){
        		return;
        	}
            //
            // 如果异步方式调用
            // 或在本地调试则不校验
            //
            if (Cms.Cache.Get(checkKey) != null || CheckIsHostOnLocalhost())
            {
                return;
            }
            


            //
            // 异步从服务器读取激活状态
            //
            /*
            new Thread(() =>
            {
                lock (activeInfo)
                {
                    CheckActiveState();
                }

            }).Start();*/


            CheckActiveState();

            //=====分析获得的数据并返回到客户端=====//
            if (!String.IsNullOrEmpty(activeInfo))
            {
                lock (activeInfo)
                {
                    try
                    {
                        JsonAnalyzer js = new JsonAnalyzer(activeInfo);
                        string result = js.GetValue("state");

                        if (result != "ok")
                        {
                            activiveIsNormal = false;                           //设置状态

                            string content = js.GetValue("content");
                            HttpContext.Current.Response.ClearContent();
                            HttpContext.Current.Response.Write(content);

                            //返回字符串
                            if (result == "end")
                            {
                                HttpRuntime.UnloadAppDomain();
                                HttpContext.Current.Response.End();
                                return;
                            }
                            else if (result == "go")
                            {
                                return;
                            }
                        }
                        else
                        {
                            activiveIsNormal = true;                           //设置状态
                            //如果通过校验,则缓存1日激活状态

                            Cms.Cache.Insert(checkKey, "1", DateTime.Now.AddDays(7));

                        }
                    }
                    catch
                    {
                        //如果发生异常
                        //则创建缓存3天候过期来避免频繁向服务器发送校验请求
                         Cms.Cache.Insert(checkKey, "1", DateTime.Now.AddDays(3));
                    }
                }
            }
        }
예제 #12
0
        /// <summary>
        /// 记录IP信息
        /// </summary>
        /// <param name="ip"></param>
        public static void Record(string ip)
        {
            new Thread(() =>
            {

                try
                {
                    string key = String.Format("{0:yyyyMMdd}", DateTime.Now);
                    string data;                                   //流量数据
                    int todayIP = 0, todayPV = 0,
                        totalIP = 0, totalPV = 0;

                    string ips = String.Empty;                     //IP库

                    //获取累计的IP和PV,如果不存在,则创建字段
                    if (trafficFile.Contains("totalIP"))
                    {
                        int.TryParse(trafficFile["totalIP"], out totalIP);
                    }
                    else
                    {
                        trafficFile.Append("totalIP", "0");
                    }

                    if (trafficFile.Contains("totalPV"))
                    {
                        int.TryParse(trafficFile["totalPV"], out totalPV);
                    }
                    else
                    {
                        trafficFile.Append("totalPV", "0");
                    }

                    data = GetData(DateTime.Now);
                    JsonAnalyzer js = new JsonAnalyzer(data);

                    int.TryParse(js.GetValue("ip"), out todayIP);
                    int.TryParse(js.GetValue("pv"), out todayPV);

                    //检测是否是独立访客,如果是则增加IP并记录
                    if (trafficFile.Contains("ips"))
                    {
                        ips = trafficFile["ips"];
                    }
                    else
                    {
                        trafficFile.Append("ips", "");
                    }

                    if (ips.IndexOf(ip) == -1)
                    {
                        ips = String.Format("{0}{1}|", ips, ip);
                        trafficFile["ips"] = ips;
                        ++todayIP;
                        ++totalIP;

                        //更新今日IP数据并返回新的JSON
                        js = new JsonAnalyzer(js.SetValue("ip", todayIP.ToString()));

                        //保存总的IP数据
                        if (trafficFile.Contains("totalIP"))
                        {
                            trafficFile["totalIP"] = totalIP.ToString();
                        }
                        else
                        {
                            trafficFile.Append("totalIP", totalIP.ToString());
                        }
                    }
                    ++todayPV;
                    ++totalPV;

                    //保存今日PV
                    trafficFile[key] = js.SetValue("pv", todayPV.ToString());

                    //保存总的PV数据
                    trafficFile["totalPV"] = totalPV.ToString();
                }
                catch (Exception ex)
                {
                    //
                    //Catch error
                    //

                    trafficFile.Flush();
                }
            }).Start();

        }