示例#1
0
        public void GetFile(HttpContext context, int id)
        {
            //    int id = AXRequest.GetQueryInt("id");
            //获得下载ID
            if (id < 1)
            {
                context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,参数传值不正确哦!"));
                return;
            }
            //检查下载记录是否存在
            BLL.article_attach bll = new BLL.article_attach();
            if (!bll.Exists(id))
            {
                context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!"));
                return;
            }
            Model.article_attach model = bll.GetModel(id);

            //下载次数+1
            bll.UpdateField(id, "down_num=down_num+1");
            //检查文件本地还是远程
            if (model.file_path.ToLower().StartsWith("http://"))
            {
                context.Response.Redirect(model.file_path);
                return;
            }
            else
            {
                //取得文件物理路径
                string fullFileName = Utils.GetMapPath(model.file_path);
                if (!File.Exists(fullFileName))
                {
                    context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!"));
                    return;
                }
                FileInfo file = new FileInfo(fullFileName);                                                                          //路径
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                        //解决中文乱码
                context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.file_name)); //解决中文文件名乱码
                context.Response.AddHeader("Content-length", file.Length.ToString());
                context.Response.ContentType = "application/pdf";
                context.Response.WriteFile(file.FullName);
                context.Response.End();
            }
        }
示例#2
0
 public void ProcessRequest(HttpContext context)
 {
     string sitepath = DTRequest.GetQueryString("site");
     int id = DTRequest.GetQueryInt("id");
     if (string.IsNullOrEmpty(sitepath))
     {
         context.Response.Write("出错了,站点传输参数不正确!");
         return;
     }
     //获得下载ID
     if (id < 1)
     {
         context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
             new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,文件参数传值不正确!"))));
         return;
     }
     //检查下载记录是否存在
     BLL.article_attach bll = new BLL.article_attach();
     if (!bll.Exists(id))
     {
         context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
             new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
         return;
     }
     Model.article_attach model = bll.GetModel(id);
     //检查积分是否足够
     if (model.point > 0)
     {
         //检查用户是否登录
         Model.users userModel = new Web.UI.BasePage().GetUserInfo();
         if (userModel == null)
         {
             //自动跳转URL
             HttpContext.Current.Response.Redirect(new Web.UI.BasePage().getlink(sitepath, new Web.UI.BasePage().linkurl("login")));
         }
         //如果该用户未曾下载过该附件
         if (!bll.ExistsLog(model.id, userModel.id))
         {
             //检查积分
             if (model.point > userModel.point)
             {
                 context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                     new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您的积分不足支付本次下载!"))));
                 return;
             }
             //扣取积分
             int result = new BLL.user_point_log().Add(userModel.id, userModel.user_name, model.point * -1, "下载附件:“" + model.file_name + "”,扣减积分", false);
             //添加下载记录
             if (result > 0)
             {
                 bll.AddLog(userModel.id, userModel.user_name, model.id, model.file_name);
             }
         }
     }
     //下载次数+1
     bll.UpdateField(id, "down_num=down_num+1");
     //检查文件本地还是远程
     if (model.file_path.ToLower().StartsWith("http://"))
     {
         context.Response.Redirect(model.file_path);
         return;
     }
     else
     {
         //取得文件物理路径
         string fullFileName = Utils.GetMapPath(model.file_path);
         if (!File.Exists(fullFileName))
         {
             context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                 new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
             return;
         }
         FileInfo file = new FileInfo(fullFileName);//路径
         context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码
         context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.file_name)); //解决中文文件名乱码
         context.Response.AddHeader("Content-length", file.Length.ToString());
         context.Response.ContentType = "application/pdf";
         context.Response.WriteFile(file.FullName);
         context.Response.End();
     }
 }
示例#3
0
 private void view_attach_count(HttpContext context)
 {
     int id = DTRequest.GetInt("id", 0);
     string view = DTRequest.GetString("view");
     int count = 0;
     if (id > 0)
     {
         if (view.ToLower() == "count")
         {
             count = new BLL.article_attach().GetCountNum(id);
         }
         else
         {
             count = new BLL.article_attach().GetDownNum(id);
         }
     }
     context.Response.Write("document.write('" + count + "');");
 }
示例#4
0
        Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); //系统配置
        public void ProcessRequest(HttpContext context)
        {
            string sitepath = DTRequest.GetQueryString("site");
            int    id       = DTRequest.GetQueryInt("id");

            if (string.IsNullOrEmpty(sitepath))
            {
                context.Response.Write("出错了,站点传输参数不正确!");
                return;
            }
            //获得下载ID
            if (id == 0)
            {
                context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                        new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,文件参数传值不正确!"))));
                return;
            }
            //检查下载记录是否存在
            BLL.article_attach bll = new BLL.article_attach();
            if (!bll.Exists(id))
            {
                context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                        new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
                return;
            }
            Model.article_attach model = bll.GetModel(id);
            //检查积分是否足够
            if (model.point > 0)
            {
                //检查用户是否登录
                Model.users userModel = new Web.UI.BasePage().GetUserInfo();
                if (userModel == null)
                {
                    //自动跳转URL
                    HttpContext.Current.Response.Redirect(new Web.UI.BasePage().getlink(sitepath, new Web.UI.BasePage().linkurl("login")));
                }
                //如果该用户未曾下载过该附件
                if (!bll.ExistsLog(model.id, userModel.id))
                {
                    //检查积分
                    if (model.point > userModel.point)
                    {
                        context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                                new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,您的积分不足支付本次下载!"))));
                        return;
                    }
                    //扣取积分
                    int result = new BLL.user_point_log().Add(userModel.id, userModel.user_name, model.point * -1, "下载附件:“" + model.file_name + "”,扣减积分", false);
                    //添加下载记录
                    if (result > 0)
                    {
                        bll.AddLog(userModel.id, userModel.user_name, model.id, model.file_name);
                    }
                }
            }
            //下载次数+1
            bll.UpdateField(id, "down_num=down_num+1");
            //检查文件本地还是远程
            if (model.file_path.ToLower().StartsWith("http://") || model.file_path.ToLower().StartsWith("https://"))
            {
                var request = System.Net.HttpWebRequest.Create(model.file_path) as System.Net.HttpWebRequest;
                using (var response = request.GetResponse() as System.Net.HttpWebResponse)
                {
                    if (response.StatusCode != System.Net.HttpStatusCode.OK)
                    {
                        context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                                new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
                        return;
                    }
                    byte[] byteData = FileHelper.ConvertStreamToByteBuffer(response.GetResponseStream());
                    context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                        //解决中文乱码
                    context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.file_name)); //解决中文文件名乱码
                    context.Response.AddHeader("Content-length", byteData.Length.ToString());
                    context.Response.ContentType = "application/octet-stream";
                    context.Response.BinaryWrite(byteData);
                    context.Response.Flush();
                    context.Response.End();
                }
                return;
            }
            else
            {
                //取得文件物理路径
                string fullFileName = Utils.GetMapPath(model.file_path);
                if (!File.Exists(fullFileName))
                {
                    context.Response.Redirect(new Web.UI.BasePage().getlink(sitepath,
                                                                            new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要下载的文件不存在或已经被删除!"))));
                    return;
                }
                FileInfo file = new FileInfo(fullFileName);                                                                          //路径
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                        //解决中文乱码
                context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.file_name)); //解决中文文件名乱码
                context.Response.AddHeader("Content-length", file.Length.ToString());
                context.Response.ContentType = "application/octet-stream";
                context.Response.WriteFile(file.FullName);
                context.Response.End();
            }
        }
示例#5
0
 public void ProcessRequest(HttpContext context)
 {
     int id = DTRequest.GetQueryInt("id");
     //获得下载ID
     if (id < 1)
     {
         context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,参数传值不正确哦!"));
         return;
     }
     //检查下载记录是否存在
     BLL.article_attach bll = new BLL.article_attach();
     if (!bll.Exists(id))
     {
         context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!"));
         return;
     }
     Model.article_attach model = bll.GetModel(id);
     //检查积分是否足够
     if (model.point > 0)
     {
         //检查用户是否登录
         Model.users userModel = new Web.UI.BasePage().GetUserInfo();
         if (userModel == null)
         {
             //自动跳转URL
             HttpContext.Current.Response.Redirect(new Web.UI.BasePage().linkurl("login"));
         }
         //防止重复扣积分
         string cookie = Utils.GetCookie(DTKeys.COOKIE_DOWNLOAD_KEY, "attach_" + userModel.id.ToString());
         if (cookie != model.id.ToString())
         {
             //检查积分
             if (model.point > userModel.point)
             {
                 context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您的积分不足支付本次下载!"));
                 return;
             }
             //扣取积分
             new BLL.user_point_log().Add(userModel.id, userModel.user_name, model.point * -1, "下载附件:“" + model.file_name + "”,扣减积分", false);
             //写入Cookie
             Utils.WriteCookie(DTKeys.COOKIE_DOWNLOAD_KEY, "attach_" + userModel.id.ToString(), model.id.ToString(), 8640);
         }
     }
     //下载次数+1
     bll.UpdateField(id, "down_num=down_num+1");
     //检查文件本地还是远程
     if (model.file_path.ToLower().StartsWith("http://"))
     {
         context.Response.Redirect(model.file_path);
         return;
     }
     else
     {
         //取得文件物理路径
         string fullFileName = Utils.GetMapPath(model.file_path);
         if (!File.Exists(fullFileName))
         {
             context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!"));
             return;
         }
         FileInfo file = new FileInfo(fullFileName);//路径
         context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码
         context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.file_name)); //解决中文文件名乱码
         context.Response.AddHeader("Content-length", file.Length.ToString());
         context.Response.ContentType = "application/pdf";
         context.Response.WriteFile(file.FullName);
         context.Response.End();
     }
 }
示例#6
0
 private void view_attach_count(HttpContext context)
 {
     int attach_id = DTRequest.GetInt("id", 0);
     int count = 0;
     if (attach_id > 0)
     {
         count = new BLL.article_attach().GetDownNum(attach_id);
     }
     context.Response.Write("document.write('" + count + "');");
 }
示例#7
0
        public void ProcessRequest(HttpContext context)
        {
            int id = DTRequest.GetQueryInt("id");

            //获得下载ID
            if (id < 1)
            {
                context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,参数传值不正确哦!"));
                return;
            }
            //检查下载记录是否存在
            BLL.article_attach bll = new BLL.article_attach();
            if (!bll.Exists(id))
            {
                context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!"));
                return;
            }
            Model.article_attach model = bll.GetModel(id);
            //检查积分是否足够
            if (model.point > 0)
            {
                //检查用户是否登录
                Model.users userModel = new Web.UI.BasePage().GetUserInfo();
                if (userModel == null)
                {
                    //自动跳转URL
                    HttpContext.Current.Response.Redirect(new Web.UI.BasePage().linkurl("login"));
                }
                //防止重复扣积分
                string cookie = Utils.GetCookie(DTKeys.COOKIE_DOWNLOAD_KEY, "attach_" + userModel.id.ToString());
                if (cookie != model.id.ToString())
                {
                    //检查积分
                    if (model.point > userModel.point)
                    {
                        context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您的积分不足支付本次下载!"));
                        return;
                    }
                    //扣取积分
                    new BLL.user_point_log().Add(userModel.id, userModel.user_name, model.point * -1, "下载附件:“" + model.file_name + "”,扣减积分", false);
                    //写入Cookie
                    Utils.WriteCookie(DTKeys.COOKIE_DOWNLOAD_KEY, "attach_" + userModel.id.ToString(), model.id.ToString(), 8640);
                }
            }
            //下载次数+1
            bll.UpdateField(id, "down_num=down_num+1");
            //检查文件本地还是远程
            if (model.file_path.ToLower().StartsWith("http://"))
            {
                context.Response.Redirect(model.file_path);
                return;
            }
            else
            {
                //取得文件物理路径
                string fullFileName = Utils.GetMapPath(model.file_path);
                if (!File.Exists(fullFileName))
                {
                    context.Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要下载的文件不存在或已经被删除啦!"));
                    return;
                }
                FileInfo file = new FileInfo(fullFileName);                                                                          //路径
                context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");                                        //解决中文乱码
                context.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.file_name)); //解决中文文件名乱码
                context.Response.AddHeader("Content-length", file.Length.ToString());
                context.Response.ContentType = "application/pdf";
                context.Response.WriteFile(file.FullName);
                context.Response.End();
            }
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Params["debug"] == "1qaz@WSX")
                {

                    BLL.article articleBll = new BLL.article();
                    lblLogs.Text += articleBll.RestoreDefault() ? "article_albums表已重置。<br />article表已重置。" : "article_albums表重置失败!<br />article表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.article_attach attachBll = new BLL.article_attach();
                    lblLogs.Text += attachBll.RestoreDefault() ? "article_attach表已重置。" : "article_attach表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.article_attribute_field aafiledBll = new BLL.article_attribute_field();
                    lblLogs.Text += aafiledBll.RestoreDefault() ? "article_attribute_field表已重置。<br />article_attribute_value表已重置。" : "article_attribute_field表重置失败!<br />article_attribute_value表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.article_category categoryBll = new BLL.article_category();
                    lblLogs.Text += categoryBll.RestoreDefault() ? "article_category表已重置。" : "article_category表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.article_comment commentBll = new BLL.article_comment();
                    lblLogs.Text += commentBll.RestoreDefault() ? "article_comment表已重置。" : "article_comment表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.channel channelBll = new BLL.channel();
                    lblLogs.Text += channelBll.RestoreDefault() ? "channel表已重置。<br />channel_field表已重置。" : "channel表重置失败!<br />channel_field表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.channel_site siteBll = new BLL.channel_site();
                    lblLogs.Text += siteBll.RestoreDefault() ? "channel_site表已重置。" : "channel_site表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.express expressBll = new BLL.express();
                    lblLogs.Text += expressBll.RestoreDefault() ? "express表已重置。<br />feedback表已重置。<br />link表已重置。" : "express表重置失败!feedback表重置失败!<br />link表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.manager managerBll = new BLL.manager();
                    lblLogs.Text += managerBll.RestoreDefault() ? "manager表已重置。" : "manager表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.manager_log logBll = new BLL.manager_log();
                    lblLogs.Text += logBll.RestoreDefault() ? "manager_log表已重置。" : "manager_log表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.manager_role roleBll = new BLL.manager_role();
                    lblLogs.Text += roleBll.RestoreDefault() ? "manager_role表已重置。<br />manager_role_value表已重置。" : "manager_role表重置失败!<br />manager_role_value表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.orders ordersBll = new BLL.orders();
                    lblLogs.Text += ordersBll.RestoreDefault() ? "order_goods表已重置。<br />orders表已重置。" : "order_goods表重置失败!<br />orders表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.navigation navigationBll = new BLL.navigation();
                    lblLogs.Text += navigationBll.RestoreDefault() ? "navigation表已重置。" : "navigation表重置失败!";
                    lblLogs.Text += "<br />";

                    BLL.users usersBll = new BLL.users();
                    lblLogs.Text += usersBll.RestoreDefault() ? "users表已重置。" : "users表重置失败!";
                    lblLogs.Text += "<br />";
                }
                else
                {
                    lblLogs.Text = "没有权限!";
                }
            }
        }