Exemple #1
0
        private void UpLoadFile(HttpContext context)
        {
            string _delfile = DTRequest.GetString("DelFilePath");                                    //要删除的文件
            string fileName = DTRequest.GetString("name");                                           //文件名

            byte[] byteData     = FileHelper.ConvertStreamToByteBuffer(context.Request.InputStream); //获取文件流
            bool   _iswater     = false;                                                             //默认不打水印
            bool   _isthumbnail = false;                                                             //默认不生成缩略图

            if (DTRequest.GetQueryString("IsWater") == "1")
            {
                _iswater = true;
            }
            if (DTRequest.GetQueryString("IsThumbnail") == "1")
            {
                _isthumbnail = true;
            }
            if (byteData.Length == 0)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}");
                return;
            }
            UpLoad upLoad = new UpLoad();
            string msg    = upLoad.FileSaveAs(byteData, fileName, _isthumbnail, _iswater);

            //删除已存在的旧文件
            if (!string.IsNullOrEmpty(_delfile))
            {
                upLoad.DeleteFile(_delfile);
            }
            //返回成功信息
            context.Response.Write(msg);
            context.Response.End();
        }
Exemple #2
0
        public async Task <IApiOut> UpLoadFile([ApiVal(Val.File)] IFormFile file, [ApiVal(Val.Service)] UpLoad upFiles, string DelFilePath)//string DelFilePath, string Filedata, string IsWater, string IsThumbnail
        {
            AjaxJson _ajv         = new();
            string   _delfile     = DelFilePath?.TrimStart('/');
            bool     _iswater     = false; //默认不打水印
            bool     _isthumbnail = false; //默认不生成缩略图

            //if (IsWater == "1")
            //    _iswater = true;
            //if (IsThumbnail == "1")
            //    _isthumbnail = true;

            if (file == null)
            {
                //Json("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}");
                _ajv.code = 1;
                _ajv.msg  = "请选择要上传文件!";
                return(await ApiOut.JsonAsync(_ajv));
            }
            //UpLoad upFiles = new();
            //删除已存在的旧文件,旧文件不为空且应是上传文件,防止跨目录删除
            if (upFiles.FileSaveAs(file, _isthumbnail, _iswater, ref _ajv) && !string.IsNullOrEmpty(_delfile) && _delfile.StartsWith(upFiles.Config.Webpath + upFiles.Config.Filepath, StringComparison.OrdinalIgnoreCase))
            {
                upFiles.DeleteUpFile(_delfile);
            }
            //返回成功信息
            return(await ApiOut.JsonAsync(_ajv));
        }
Exemple #3
0
 // Token: 0x06000018 RID: 24 RVA: 0x0000336C File Offset: 0x0000156C
 protected override void View()
 {
     if (this.id > 0)
     {
         this.desktopinfo = DbHelper.ExecuteModel <DesktopInfo>(this.id);
     }
     if (this.desktopinfo.system == 1 && !this.isperm)
     {
         this.ShowErr("对不起,您没有权限更改系统图标");
     }
     else
     {
         if (this.ispost)
         {
             this.desktopinfo        = FPRequest.GetModel <DesktopInfo>();
             this.desktopinfo.system = (this.isperm ? FPRequest.GetInt("system") : 0);
             if (this.desktopinfo.id == 0)
             {
                 this.desktopinfo.uid = this.userid;
             }
             if (this.isfile)
             {
                 HttpPostedFile postedFile = FPRequest.Files["uploadicon"];
                 UpLoad         upLoad     = new UpLoad();
                 string         json       = upLoad.FileSaveAs(postedFile, "image", this.user, false, false, 32, 32);
                 JsonData       jsonData   = JsonMapper.ToObject(json);
                 if (jsonData["error"].ToString() == "")
                 {
                     if (this.desktopinfo.icon != "")
                     {
                         if (File.Exists(FPUtils.GetMapPath(this.desktopinfo.icon)))
                         {
                             File.Delete(FPUtils.GetMapPath(this.desktopinfo.icon));
                         }
                     }
                     this.desktopinfo.icon = jsonData["filename"].ToString();
                 }
             }
             if (this.desktopinfo.id > 0)
             {
                 DbHelper.ExecuteUpdate <DesktopInfo>(this.desktopinfo);
             }
             else
             {
                 DbHelper.ExecuteInsert <DesktopInfo>(this.desktopinfo);
             }
             base.Response.Redirect("desktopmanage.aspx");
         }
         base.SaveRightURL();
     }
 }
Exemple #4
0
        // Token: 0x060002D8 RID: 728 RVA: 0x0000AE88 File Offset: 0x00009088
        private void EditorFile()
        {
            HttpPostedFile httpPostedFile = FPRequest.Files["imgfile"];

            if (httpPostedFile == null)
            {
                this.ShowErrMsg("请选择要上传文件!");
            }
            else
            {
                UpLoad   upLoad   = new UpLoad();
                string   json     = upLoad.FileSaveAs(httpPostedFile, this.dir, this.user);
                JsonData jsonData = JsonMapper.ToObject(json);
                string   text     = jsonData["error"].ToString();
                if (text != "")
                {
                    this.ShowErrMsg(text);
                }
                else
                {
                    AttachInfo attachInfo = new AttachInfo();
                    attachInfo.uid          = this.userid;
                    attachInfo.sortid       = this.sortid;
                    attachInfo.filename     = jsonData["filename"].ToString();
                    attachInfo.filesize     = (long)FPUtils.StrToInt(jsonData["filesize"].ToString(), 0);
                    attachInfo.originalname = jsonData["originalname"].ToString();
                    attachInfo.postdatetime = DbUtils.GetDateTime();
                    attachInfo.filetype     = this.dir;
                    if (DbHelper.ExecuteInsert <AttachInfo>(attachInfo) == 0)
                    {
                        this.ShowErrMsg("数据库更新失败。");
                    }
                    else
                    {
                        Hashtable hashtable = new Hashtable();
                        hashtable["error"] = 0;
                        hashtable["url"]   = attachInfo.filename;
                        hashtable["title"] = attachInfo.originalname;
                        base.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                        base.Response.Write(JsonMapper.ToJson(hashtable));
                        base.Response.End();
                    }
                }
            }
        }
Exemple #5
0
        private void UpLoadFile(HttpContext context)
        {
            Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig();
            //检查是否允许匿名上传

            /*if (sysConfig.fileanonymous == 0 && !new ManagePage().IsAdminLogin() && !new BasePage().IsUserLogin())
             * {
             *  context.Response.Write("{\"status\": 0, \"msg\": \"禁止匿名非法上传!\"}");
             *  return;
             * }*/

            string _delfile = DTRequest.GetString("DelFilePath");                                    //要删除的文件
            string fileName = DTRequest.GetString("name");                                           //文件名

            byte[] byteData     = FileHelper.ConvertStreamToByteBuffer(context.Request.InputStream); //获取文件流
            bool   _iswater     = false;                                                             //默认不打水印
            bool   _isthumbnail = false;                                                             //默认不生成缩略图

            if (DTRequest.GetQueryString("IsWater") == "1")
            {
                _iswater = true;
            }
            if (DTRequest.GetQueryString("IsThumbnail") == "1")
            {
                _isthumbnail = true;
            }
            if (byteData.Length == 0)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"请选择要上传文件!\"}");
                return;
            }
            UpLoad upLoad = new UpLoad();
            string msg    = upLoad.FileSaveAs(byteData, fileName, _isthumbnail, _iswater);

            //删除已存在的旧文件
            if (!string.IsNullOrEmpty(_delfile))
            {
                upLoad.DeleteFile(_delfile);
            }
            //返回成功信息
            context.Response.Write(msg);
            context.Response.End();
        }
Exemple #6
0
 // Token: 0x06000301 RID: 769 RVA: 0x0000BDE4 File Offset: 0x00009FE4
 protected override void View()
 {
     this.iuser = DbHelper.ExecuteModel <UserInfo>(this.userid);
     if (this.iuser.id == 0)
     {
         this.ShowErr("用户不存在。");
     }
     else if (this.ispost)
     {
         if (this.isfile)
         {
             HttpPostedFile postedFile = FPRequest.Files["uploadimg"];
             UpLoad         upLoad     = new UpLoad();
             string         json       = upLoad.FileSaveAs(postedFile, "image", this.user, false, false, 100, 100);
             JsonData       jsonData   = JsonMapper.ToObject(json);
             if (jsonData["error"].ToString() == "")
             {
                 if (this.iuser.avatar != "")
                 {
                     if (File.Exists(FPUtils.GetMapPath(this.iuser.avatar)))
                     {
                         File.Delete(FPUtils.GetMapPath(this.iuser.avatar));
                     }
                 }
                 this.iuser.avatar = jsonData["filename"].ToString();
                 DbHelper.ExecuteUpdate <UserInfo>(this.iuser);
                 base.ResetUser();
                 base.AddMsg("更新头像成功。");
             }
             else
             {
                 this.ShowErr(jsonData["error"].ToString());
             }
         }
         else
         {
             this.ShowErr("请选择要上传的头像文件");
         }
     }
 }
Exemple #7
0
        // Token: 0x0600006D RID: 109 RVA: 0x00009C14 File Offset: 0x00007E14
        protected override void View()
        {
            if (this.id > 0)
            {
                this.sortinfo  = DbHelper.ExecuteModel <SortInfo>(this.id);
                this.parentid  = this.sortinfo.parentid;
                this.channelid = this.sortinfo.channelid;
                this.appid     = this.sortinfo.appid;
            }
            else
            {
                SortInfo sortInfo = SortBll.GetSortInfo(this.parentid);
                this.appid = sortInfo.appid;
            }
            if (this.ispost)
            {
                this.sortinfo.hidden = 0;
                this.sortinfo.types  = "";
                this.sortinfo        = FPRequest.GetModel <SortInfo>(this.sortinfo);
                if (this.sortinfo.channelid == 0)
                {
                    this.ShowErr("请选择栏目频道。");
                    return;
                }
                if (this.sortinfo.name == "")
                {
                    this.ShowErr("栏目名称不能为空。");
                    return;
                }
                if (this.isfile)
                {
                    HttpPostedFile postedFile = FPRequest.Files["uploadimg"];
                    UpLoad         upLoad     = new UpLoad();
                    string         json       = upLoad.FileSaveAs(postedFile, "image", this.user, false, false, 16, 16);
                    JsonData       jsonData   = JsonMapper.ToObject(json);
                    if (jsonData["error"].ToString() == "")
                    {
                        if (this.sortinfo.icon != "")
                        {
                            if (File.Exists(FPUtils.GetMapPath(this.sortinfo.icon)))
                            {
                                File.Delete(FPUtils.GetMapPath(this.sortinfo.icon));
                            }
                        }
                        this.sortinfo.icon = jsonData["filename"].ToString();
                    }
                }
                string   text      = "0";
                SortInfo sortInfo2 = new SortInfo();
                if (this.sortinfo.id > 0)
                {
                    if (DbHelper.ExecuteUpdate <SortInfo>(this.sortinfo) > 0)
                    {
                        if (this.sortinfo.parentid != this.parentid)
                        {
                            text = this.sortinfo.parentlist;
                            if (this.sortinfo.parentid > 0)
                            {
                                sortInfo2 = DbHelper.ExecuteModel <SortInfo>(this.sortinfo.parentid);
                                this.sortinfo.parentlist = sortInfo2.parentlist + "," + this.sortinfo.id;
                            }
                            else
                            {
                                this.sortinfo.parentlist = "0," + this.sortinfo.id.ToString();
                            }
                            StringBuilder stringBuilder = new StringBuilder();
                            stringBuilder.AppendFormat("UPDATE [{0}WMS_SortInfo] SET [parentlist]='{1}' WHERE [id]={2}|", DbConfigs.Prefix, this.sortinfo.parentlist, this.sortinfo.id);
                            if (DbConfigs.DbType == DbType.Access)
                            {
                                stringBuilder.AppendFormat("UPDATE [{0}WMS_SortInfo] SET [parentlist] =REPLACE([parentlist], '{1}', '{2}', 1, 1) WHERE [id] IN (SELECT [id] FROM [{0}WMS_SortInfo]  WHERE [parentlist] LIKE '{3},%')|", new object[]
                                {
                                    DbConfigs.Prefix,
                                    text,
                                    this.sortinfo.parentlist,
                                    text
                                });
                            }
                            else
                            {
                                stringBuilder.AppendFormat("UPDATE [{0}WMS_SortInfo] SET [parentlist] =STUFF([parentlist],1,{1},'{2}') WHERE [id] IN (SELECT [id] FROM [{0}WMS_SortInfo]  WHERE [parentlist] LIKE '{3},%')|", new object[]
                                {
                                    DbConfigs.Prefix,
                                    text.Length,
                                    this.sortinfo.parentlist,
                                    text
                                });
                            }
                            stringBuilder.AppendFormat("UPDATE [{0}WMS_SortInfo] SET [subcounts]=[subcounts]-1 WHERE [id]={1}|", DbConfigs.Prefix, this.parentid);
                            stringBuilder.AppendFormat("UPDATE [{0}WMS_SortInfo] SET [subcounts]=[subcounts]+1 WHERE [id]={1}", DbConfigs.Prefix, this.sortinfo.parentid);
                            DbHelper.ExecuteSql(stringBuilder.ToString());
                        }
                        if (this.sortinfo.channelid != this.channelid && this.parentid == 0)
                        {
                            string sqlstring = string.Format("UPDATE [{0}WMS_SortInfo] SET [channelid]={1} WHERE [id] IN (SELECT [id] FROM [{0}WMS_SortInfo]  WHERE [parentlist] LIKE '{2},%')", DbConfigs.Prefix, this.sortinfo.channelid, this.sortinfo.parentlist);
                            DbHelper.ExecuteSql(sqlstring);
                        }
                    }
                    base.AddMsg("更新栏目成功!");
                }
                else
                {
                    SqlParam[] sqlparams = new SqlParam[]
                    {
                        DbHelper.MakeAndWhere("parentid", this.parentid),
                        DbHelper.MakeAndWhere("channelid", this.channelid)
                    };
                    this.sortinfo.display = FPUtils.StrToInt(DbHelper.ExecuteMax <SortInfo>("display", sqlparams).ToString()) + 1;
                    this.id = DbHelper.ExecuteInsert <SortInfo>(this.sortinfo);
                    if (this.id > 0)
                    {
                        if (this.sortinfo.parentid > 0)
                        {
                            sortInfo2 = DbHelper.ExecuteModel <SortInfo>(this.sortinfo.parentid);
                            text      = sortInfo2.parentlist + "," + this.id;
                        }
                        else
                        {
                            text = text + "," + this.id;
                        }
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.AppendFormat("UPDATE [{0}WMS_SortInfo] SET [parentlist]='{1}' WHERE [id]={2}|", DbConfigs.Prefix, text, this.id);
                        stringBuilder.AppendFormat("UPDATE [{0}WMS_SortInfo] SET [subcounts]=[subcounts]+1 WHERE [id]={1}", DbConfigs.Prefix, this.sortinfo.parentid);
                        DbHelper.ExecuteSql(stringBuilder.ToString());
                    }
                    base.AddMsg("添加栏目成功!");
                }
                FPCache.Remove("FP_SORTTREE" + this.sortinfo.channelid);
                this.link = "sortmanage.aspx?channelid=" + this.sortinfo.channelid;
            }
            SqlParam[] sqlparams2 = new SqlParam[]
            {
                DbHelper.MakeAndWhere("parentid", 0),
                DbHelper.MakeAndWhere("channelid", this.channelid),
                DbHelper.MakeAndWhere("id", WhereType.NotEqual, this.id)
            };
            OrderByParam orderby = DbHelper.MakeOrderBy("display", OrderBy.ASC);

            this.channellist = DbHelper.ExecuteList <ChannelInfo>(orderby, new SqlParam[0]);
            this.sortlist    = DbHelper.ExecuteList <SortInfo>(orderby, sqlparams2);
            this.sortapplist = DbHelper.ExecuteList <SortAppInfo>(OrderBy.ASC);
            SqlParam sqlParam = DbHelper.MakeAndWhere("parentid", 0);

            this.typelist = DbHelper.ExecuteList <TypeInfo>(orderby, new SqlParam[]
            {
                sqlParam
            });
            base.SaveRightURL();
        }