Esempio n. 1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Response.Expires      = 0;
            Response.CacheControl = "no-cache";
            Response.AppendHeader("Pragma", "No-Cache");

            queryString = Request.RawUrl.Substring(Request.RawUrl.IndexOf("?") + 1);
            name        = Request ["q"];
            name        = name.Trim();

            bool?isdelete = null;

            if (name.StartsWith("http://") || name.StartsWith("https://"))
            {
                isdelete = false;
            }
            else if (name.StartsWith("delete") &&
                     (name.Contains("http://") || name.Contains("https://")))
            {
                isdelete = true;
            }
            if (!isdelete.HasValue)
            {
                SearchResource.searchList.Enqueue(name.Replace("<", ""));
                while (SearchResource.searchList.Count > 15)
                {
                    String t;
                    SearchResource.searchList.TryDequeue(out t);
                }
            }
            else
            {
                SearchResource.indexText(name, isdelete.Value);
                SearchResource.urlList.Enqueue(name.Replace("<", ""));
                while (SearchResource.urlList.Count > 3)
                {
                    String t;
                    SearchResource.urlList.TryDequeue(out t);
                }
            }
        }
Esempio n. 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            name = Request ["q"];

            if (name.Length > 500)
            {
                name = "";
                return;
            }
            name = name.Replace("<", " ").Replace(">", " ")
                   .Replace("\"", " ").Replace(",", " ")
                   .Replace("\\$", " ").Trim();

            bool?isdelete = null;

            if (name.StartsWith("http://") || name.StartsWith("https://"))
            {
                isdelete = false;
            }
            else if (name.StartsWith("delete") &&
                     (name.Contains("http://") || name.Contains("https://")))
            {
                isdelete = true;
            }
            if (!isdelete.HasValue)
            {
                SearchResource.searchList.Enqueue(name);
                while (SearchResource.searchList.Count > 15)
                {
                    String t;
                    SearchResource.searchList.TryDequeue(out t);
                }
            }
            else
            {
                name = SearchResource.indexText(name, isdelete.Value);
                System.GC.Collect();
            }

            pages = new List <Page> ();

            begin = DateTime.Now;


            using (var box = SDB.search_db.Cube()) {
                foreach (KeyWord kw in SearchResource.engine.searchDistinct(box, name))
                {
                    long id = kw.ID;
                    id = FTServer.Page.rankDownId(id);
                    Page p = box ["Page", id].Select <Page> ();
                    p.keyWord = kw;
                    pages.Add(p);
                    if (pages.Count > 100)
                    {
                        break;
                    }
                }
            }

            if (pages.Count == 0)
            {
                Page p = new Page();
                p.title       = "NotFound";
                p.description = "";
                p.content     = "input URL to index";
                p.url         = "./";
                pages.Add(p);
            }
        }