Esempio n. 1
0
        public static List <FBImageInfo> LoadFBImage(string path)
        {
            List <FBImageInfo> list = new List <FBImageInfo>();
            List <string>      ls   = VTSCommon.LoadTextToList(path, true);

            //字段分割数组
            string[]    arr;
            FBImageInfo info = null;

            foreach (string item in ls)
            {
                arr = item.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                //为了兼容以前的需要判断
                if (arr != null)
                {
                    if (arr.Length == 4)
                    {
                        info = new FBImageInfo()
                        {
                            ImageID      = long.Parse(arr[0]),
                            ImageName    = arr[1],
                            RelativePath = arr[2],
                            ImageSkipUrl = arr[3],
                            ImageTitle   = "title",
                            ImageAlt     = "alt"
                        };
                    }

                    if (arr.Length == 6)
                    {
                        info = new FBImageInfo()
                        {
                            ImageID      = long.Parse(arr[0]),
                            ImageName    = arr[1],
                            RelativePath = arr[2],
                            ImageSkipUrl = arr[3],

                            ImageTitle = arr[4],
                            ImageAlt   = arr[5]
                        };
                    }
                }
                list.Add(info);
            }
            return(list.OrderByDescending(x => x.ImageID).ToList());
        }
Esempio n. 2
0
        public void ProcessRequest(HttpContext Context)
        {
            #region 阻止缓存
            Context.Response.Clear();
            Context.Response.ClearHeaders();
            Context.Response.ClearContent();
            Context.Response.ContentType = "text/html";

            //页面后退刷新的关键
            Context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Context.Response.Cache.SetNoStore();
            #endregion

            #region 定义变量
            //请求文件 /imageslib/a.jpg
            string imagefile = Context.Request.Path;
            #endregion

            #region 跳转判断
            //来源判断
            Uri url = Context.Request.UrlReferrer;

            if (url != null)
            {
                string refurl = url.ToString().ToLower();

                if (!string.IsNullOrEmpty(refurl))
                {
                    LogOut.Info("UrlReferrer:" + refurl);

                    if (refurl.Contains("facebook.com"))
                    {
                        //获取图片
                        FBImageInfo image = FBCommon.GetFBImageInfo(imagefile, imageDataPath);

                        if (image != null)
                        {
                            if (image.ImageSkipUrl != "skipurl")
                            {
                                #region 记录日志
                                LogOut.Info(("Images:" + imagefile).PadRight(100) + "," + url.ToString());
                                #endregion

                                #region 301 跳转
                                //301跳转方式
                                Utils.SetURL301(Context, image.ImageSkipUrl);
                                #endregion

                                #region 脚本跳转
                                //响应脚本跳转
                                //Context.Response.ContentType = "application/x-javascript";
                                //Context.Response.ContentType = "text/html";
                                //Context.Response.Write(Common.ReadTextToendByUTF8(js));
                                //VTSCommon.TraceLog("图片:" + imagefile + "," + url.ToString(), logPath, true, null);
                                //Context.Response.End();
                                #endregion
                            }
                        }
                    }
                }
            }
            #endregion

            #region 展示图片
            string filePath = Context.Server.MapPath(imagefile);//Context.Request.PhysicalPath;

            if (File.Exists(filePath))
            {
                InitContentType(Context, filePath);
                int Length;
                Context.Response.OutputStream.Write(CacheImage(filePath, out Length), 0, Length);
            }
            else
            {
                Context.Response.ContentType = "text/html";
                Context.Response.Write("No found!");
            }
            #endregion
        }