Exemple #1
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var uNameStr = filterContext.RequestContext.HttpContext.Request.Cookies.AllKeys.FirstOrDefault(x => x == "uName");
            var tokenStr = filterContext.RequestContext.HttpContext.Request.Cookies.AllKeys.FirstOrDefault(x => x == "token");

            if (uNameStr != null && tokenStr != null)
            {
                var uName = filterContext.RequestContext.HttpContext.Request.Cookies.Get("uName");
                var token = filterContext.RequestContext.HttpContext.Request.Cookies.Get("token");

                var guid = CacheTools.GetCache <string>(uName.Value);

                if (token.Value == guid)
                {
                    base.OnActionExecuting(filterContext);
                }
                else
                {
                    filterContext.RequestContext.HttpContext.Response.Redirect("/webav/NoRights");
                }
            }
            else
            {
                filterContext.RequestContext.HttpContext.Response.Redirect("/webav/NoRights");
            }
        }
Exemple #2
0
        public static List <AV> GetClosetMatch(string inputName)
        {
            List <AV>     ret = new List <AV>();
            List <string> allPossibleMatch = new List <string>();

            inputName = inputName.ToUpper();

            if (!CacheTools.HasCache("cache-prefix"))
            {
                UpdateCache();
            }

            var allPrefix = CacheTools.GetCache <List <string> >("cache-prefix");

            foreach (var prefix in allPrefix)
            {
                if (inputName.Contains(prefix))
                {
                    var pattern    = prefix + "{1}-?\\d{1,5}";
                    var possibleId = Regex.Match(inputName, pattern).Value;

                    if (possibleId.Contains("-"))
                    {
                        allPossibleMatch.Add(possibleId);
                    }
                    else
                    {
                        bool          isFirst = true;
                        StringBuilder sb      = new StringBuilder();

                        foreach (var c in possibleId)
                        {
                            if (c >= '0' && c <= '9')
                            {
                                if (isFirst)
                                {
                                    sb.Append("-");
                                    isFirst = false;
                                }
                            }
                            sb.Append(c);
                        }

                        allPossibleMatch.Add(sb.ToString());
                    }
                }
            }

            ret = JavDataBaseManager.GetAllAV(allPossibleMatch);
            ret = ret.OrderByDescending(x => x.AvLength).ToList();

            return(ret);
        }
Exemple #3
0
        public ActionResult Catelog(int limitGiga = 0, int page = 1, int pageSize = 200)
        {
            var    scanResult = new List <ScanResult>();
            var    toBe       = new List <ScanResult>();
            string scanCache  = "scan";

            if (CacheTools.HasCache(scanCache))
            {
                scanResult = CacheTools.GetCache <List <ScanResult> >(scanCache);
            }
            else
            {
                scanResult = ScanDataBaseManager.GetMatchScanResult();
                CacheTools.CacheInsert(scanCache, scanResult, DateTime.Now.AddHours(3));
            }

            scanResult = scanResult.Where(x => !string.IsNullOrEmpty(x.Location)).ToList();

            if (limitGiga > 0)
            {
                double limit = (double)limitGiga * 1024 * 1024 * 1024;
                ApplicationLog.Debug("catelog -> limitGiga: " + limitGiga + " limit: " + limit);
                ApplicationLog.Debug("catelog -> beforeCount: " + scanResult.Count);

                foreach (var s in scanResult)
                {
                    if (new FileInfo(s.AvFilePath).Length >= limit)
                    {
                        toBe.Add(s);
                    }
                }

                ApplicationLog.Debug("catelog -> afterCount: " + toBe.Count);
            }
            else
            {
                toBe = scanResult;
            }

            var pageContent = toBe.OrderByDescending(x => x.ReleaseDate).Skip((page - 1) * pageSize).Take(pageSize).ToList();

            ViewData.Add("avs", pageContent);
            ViewData.Add("count", (int)Math.Ceiling((decimal)toBe.Count / pageSize));
            ViewData.Add("size", pageSize);
            ViewData.Add("current", page);
            ViewData.Add("total", toBe.Count);
            ViewData.Add("limit", limitGiga);

            return(View());
        }
Exemple #4
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            WebViewLog log = new WebViewLog();

            log.IPAddress  = filterContext.RequestContext.HttpContext.Request.UserHostAddress;
            log.Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            log.UserAgent  = filterContext.RequestContext.HttpContext.Request.UserAgent;
            log.Action     = filterContext.ActionDescriptor.ActionName;

            var    arrParameter = filterContext.ActionDescriptor.GetParameters();
            string paramter     = "?";

            foreach (var pName in arrParameter)
            {
                var parameterValue = filterContext.ActionParameters[pName.ParameterName];

                paramter += pName.ParameterName + "=" + parameterValue.ToString() + "&";
            }
            log.Parameter = paramter;

            var uNameStr = filterContext.RequestContext.HttpContext.Request.Cookies.AllKeys.FirstOrDefault(x => x == "uName");
            var tokenStr = filterContext.RequestContext.HttpContext.Request.Cookies.AllKeys.FirstOrDefault(x => x == "token");

            if (uNameStr != null && tokenStr != null)
            {
                var uName = filterContext.RequestContext.HttpContext.Request.Cookies.Get("uName");
                var token = filterContext.RequestContext.HttpContext.Request.Cookies.Get("token");

                var guid = CacheTools.GetCache <string>(uName.Value);

                if (token.Value == guid)
                {
                    log.IsLogin = 1;
                    ScanDataBaseManager.InserWebViewLog(log);
                    base.OnActionExecuting(filterContext);
                }
                else
                {
                    ScanDataBaseManager.InserWebViewLog(log);
                    filterContext.RequestContext.HttpContext.Response.Redirect("/webav/NoRights");
                }
            }
            else
            {
                ScanDataBaseManager.InserWebViewLog(log);
                filterContext.RequestContext.HttpContext.Response.Redirect("/webav/NoRights");
            }

            ScanDataBaseManager.InserWebViewLog(log);
        }
Exemple #5
0
        public ActionResult GetAv(string search, bool onlyExist = false, string searchType = "all", int page = 1, int pageSize = 20)
        {
            var    scanResult = new List <ScanResult>();
            string scanCache  = "scan";

            if (CacheTools.HasCache(scanCache))
            {
                scanResult = CacheTools.GetCache <List <ScanResult> >(scanCache);
            }
            else
            {
                scanResult = ScanDataBaseManager.GetMatchScanResult();
                CacheTools.CacheInsert(scanCache, scanResult, DateTime.Now.AddHours(3));
            }

            if (onlyExist)
            {
                scanResult = scanResult.Where(x => !string.IsNullOrEmpty(x.Location)).ToList();
            }

            var toBePlay = new List <ScanResult>();
            List <ScanResult> namePlay     = new List <ScanResult>();
            List <ScanResult> actressPlay  = new List <ScanResult>();
            List <ScanResult> categoryPlay = new List <ScanResult>();
            List <ScanResult> prefixPlay   = new List <ScanResult>();
            List <ScanResult> direPlay     = new List <ScanResult>();

            if (searchType == "all" || searchType == "id")
            {
                foreach (var r in scanResult)
                {
                    if (r.AvId == search.ToUpper())
                    {
                        toBePlay.Add(r);
                    }
                }
            }

            if (searchType == "all" || searchType == "actress")
            {
                foreach (var r in scanResult)
                {
                    foreach (var ac in r.ActressList)
                    {
                        if (ac.Contains(search))
                        {
                            toBePlay.Add(r);
                        }
                    }
                }
            }

            if (searchType == "all" || searchType == "category")
            {
                foreach (var r in scanResult)
                {
                    foreach (var ca in r.CategoryList)
                    {
                        if (ca.Contains(search))
                        {
                            toBePlay.Add(r);
                        }
                    }
                }
            }

            if (searchType == "all" || searchType == "prefix")
            {
                foreach (var r in scanResult)
                {
                    if (r.Prefix.Contains(search.ToUpper()))
                    {
                        toBePlay.Add(r);
                    }
                }
            }

            if (searchType == "all" || searchType == "director")
            {
                foreach (var r in scanResult)
                {
                    if (r.Director.Contains(search))
                    {
                        toBePlay.Add(r);
                    }
                }
            }

            var pageContent = toBePlay.OrderByDescending(x => x.ReleaseDate).Skip((page - 1) * pageSize).Take(pageSize).ToList();

            ViewData.Add("avs", pageContent);
            ViewData.Add("search", search);
            ViewData.Add("count", (int)Math.Ceiling((decimal)toBePlay.Count / pageSize));
            ViewData.Add("size", pageSize);
            ViewData.Add("current", page);
            ViewData.Add("total", toBePlay.Count);

            return(View());
        }