コード例 #1
0
        /// <summary>
        /// 生成文件所在目录
        /// </summary>
        /// <param name="nodeid"></param>
        /// <param name="Nodeinfo"></param>
        /// <param name="HtmlPosition"></param>
        private string MakeHtmlFile(M_Node Nodeinfo)
        {
            string allFolder = "";

            //获得节点目录路径
            switch (Nodeinfo.HtmlPosition)
            {
            case 0:
                allFolder = "/site";    //0-根目录下
                break;

            case 1:
                Pardir    = "/site" + nll.GetDir(Nodeinfo.ParentID, ""); //继承父节点目录
                allFolder = Pardir;
                break;
            }
            //end
            allFolder = this.SiteMapath + "/" + allFolder + "/" + Nodeinfo.NodeDir;

            if (!FileSystemObject.IsExist(allFolder, FsoMethod.Folder))
            {
                FileSystemObject.CreateFileFolder(allFolder);
            }
            return(allFolder);//返回路径
        }
コード例 #2
0
ファイル: B_Label.cs プロジェクト: linrb/CMS-Source-code
 /// <summary>
 /// 验证目录是否存在
 /// </summary>
 private void ExistLabelDir(M_Label label)
 {
     if (!FileSystemObject.IsExist(dir + label.LabelCate, FsoMethod.Folder))
     {
         FileSystemObject.CreateFileFolder(dir + label.LabelCate);
     }
 }
コード例 #3
0
        protected void BtnUpload_Click(object sender, EventArgs e)
        {
            int sizes = 0;

            if (!FupFile.HasFile)
            {
                ReturnManage("请指定一个上传文件");
                return;
            }
            //if (!SafeSC.IsImage(FupFile.FileName)) { function.WriteErrMsg("只能上传图片文件"); }
            string ext = Path.GetExtension(FupFile.FileName).ToLower();

            m_MaxFileSize = DataConverter.CLng(SiteConfig.SiteOption.UploadPicMaxSize);
            if (((int)FupFile.FileContent.Length) > (m_MaxFileSize * 0x400))
            {
                ReturnManage("上传的文件超过限制的" + m_MaxFileSize + "KB大小");
                return;
            }
            string ranFName   = DataSecurity.MakeFileRndName() + ext;//文件名
            string foldername = base.Request.PhysicalApplicationPath.TrimEnd('\\') + (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + FileSavePath()).Replace("/", "\\");
            string fileName   = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current);
            string savePath   = SafeSC.SaveFile(function.PToV(fileName), FupFile, ranFName);

            if (WaterModuleConfig.WaterConfig.IsUsed && SafeSC.IsImage(FupFile.FileName) && RadioButtonList1.SelectedValue == "1")
            {
                savePath = ImgHelper.AddWater(savePath);
            }
            sizes = (int)FupFile.FileContent.Length;
            GetScriptByModuleName(savePath.Replace(SiteConfig.SiteOption.UploadDir, ""), sizes);
            ReturnManage("文件上传成功");
        }
コード例 #4
0
ファイル: Upload.aspx.cs プロジェクト: zwt-zf/cms
 protected void BtnUpload_Click(object sender, EventArgs e)
 {
     if (!this.FupFile.HasFile)
     {
         this.ReturnManage("请指定一个上传文件");
     }
     else
     {
         int ftype = DataConverter.CLng(this.HdnType.Value);
         if (ftype == 1)
         {
             this.m_FileExtArr = "gif|jpg|png";
         }
         else
         {
             this.m_FileExtArr = "swf";
         }
         string str2 = Path.GetExtension(this.FupFile.FileName).ToLower();
         if (!this.CheckFilePostfix(str2.Replace(".", "")))
         {
             this.ReturnManage("上传的文件不是符合扩展名" + this.m_FileExtArr + "的文件");
         }
         else
         {
             string str3       = DataSecurity.MakeFileRndName();
             string foldername = base.Request.PhysicalApplicationPath + this.FileSavePath().Replace("/", "\\");
             string filename   = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current) + str3 + str2;
             this.FupFile.SaveAs(filename);
             string thumbnailPath = this.m_ShowPath + str3 + str2;
             this.GetScriptByModuleName(thumbnailPath);
             this.ReturnManage("文件上传成功");
         }
     }
 }
コード例 #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            this.m_FileExtArr = "doc|docx|txt";
            string str3       = "";
            string foldername = "";
            string filename   = "";
            string str2       = "";

            System.Web.UI.WebControls.FileUpload upload = (System.Web.UI.WebControls.FileUpload) this.FindControl("FileUpload1");
            StringBuilder builder2 = new StringBuilder();

            string uploadFile;

            if (SiteConfig.SiteOption.UploadDir == null)
            {
                uploadFile = "UploadFiles";
            }
            else
            {
                uploadFile = SiteConfig.SiteOption.UploadDir;
            }

            if (upload.HasFile)
            {
                str2 = Path.GetExtension(upload.FileName).ToLower();
                if (!this.CheckFilePostfix(str2.Replace(".", "")))
                {
                    builder2.Append("文档" + upload.FileName + "不符合图片扩展名规则" + this.m_FileExtArr + @"\r\n");
                }
                else
                {
                    if (((int)upload.FileContent.Length) > (100 * 0x400))
                    {
                        builder2.Append("文档" + upload.FileName + "大小超过100" + @"KB\r\n");
                    }
                    else
                    {
                        str3       = DataSecurity.MakeFileRndName();
                        foldername = base.Request.PhysicalApplicationPath + (VirtualPathUtility.AppendTrailingSlash("/" + uploadFile + "/Project")).Replace("/", "\\");// + this.FileSavePath()
                        filename   = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current) + str3 + str2;
                        //SafeSC.SaveFile(filename,upload);
                        if (!FileUpload1.SaveAs(filename))
                        {
                            function.WriteErrMsg(FileUpload1.ErrorMsg);
                        }
                        builder2.Append("文档" + upload.FileName + @"上传成功\r\n");
                        this.TxtColumnDefault.Text = uploadFile + "/Project/" + str3 + str2;
                    }
                }
            }
            if (builder2.Length > 0)
            {
                string message = "<script language=\"javascript\" type=\"text/javascript\">alert('" + builder2.ToString() + "');</script>";
                function.Script(Page, "alert(message)");
            }
        }
コード例 #6
0
        public string UpPhontoFile()
        {
            string foldername = "";
            string filename   = "";

            foldername       = base.Request.PhysicalApplicationPath + (VirtualPathUtility.AppendTrailingSlash("/" + SiteConfig.SiteOption.UploadDir + "/Author")).Replace("/", "\\");// + this.FileSavePath()
            filename         = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current);
            SFile_UP.SaveUrl = function.PToV(filename);
            return(SFile_UP.SaveFile());
        }
コード例 #7
0
        public string UpFiles()
        {
            this.m_FileExtArr = "jpg|gif|png|bmp|jpeg|swf|rar";
            string foldername = "";
            string filename   = "";

            foldername           = base.Request.PhysicalApplicationPath + (VirtualPathUtility.AppendTrailingSlash("/Uploadfiles/Source")).Replace("/", "\\");// + this.FileSavePath()
            filename             = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current);
            SFileUp_File.SaveUrl = function.PToV(filename);
            return(SFileUp_File.SaveFile());
        }
コード例 #8
0
        public string getFilePath()
        {
            string upload;

            upload = SiteConfig.SiteOption.UploadDir;
            string filepath = Server.MapPath("/" + upload + "/Teacher/");

            FileSystemObject.CreateFileFolder(filepath, HttpContext.Current);
            SFile_Up.SaveUrl = function.PToV(filepath);
            return(SFile_Up.SaveFile());
        }
コード例 #9
0
        protected void BtnUpload_Click(object sender, EventArgs e)
        {
            long size = FupFile.FileContent.Length;

            if (!this.FupFile.HasFile)
            {
                this.ReturnManage("请指定一个上传文件");
            }
            else
            {
                if (!SiteConfig.SiteOption.EnableUploadFiles)
                {
                    this.ReturnManage("本站不允许上传文件!");
                }
                else
                {
                    string str2 = Path.GetExtension(this.FupFile.FileName).ToLower();

                    this.m_FileExtArr  = SiteConfig.SiteOption.UploadFileExts;
                    this.m_MaxFileSize = SiteConfig.SiteOption.UploadPicMaxSize;//DataConverter.CLng(this.ViewState["MaxFileSize"].ToString());

                    if (((int)this.FupFile.FileContent.Length) > (this.m_MaxFileSize * 0x400))
                    {
                        this.ReturnManage("上传的文件超过限制的" + this.m_MaxFileSize + "KB大小");
                        return;
                    }
                    string str3       = function.GetRandomString(6);
                    string foldername = SiteConfig.SiteOption.UploadDir + this.FileSavePath();
                    string filename   = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current) + str3 + str2;//文件名+后缀名

                    if (WaterModuleConfig.WaterConfig.IsUsed && (str2 == ".jpg" || str2 == ".png") && HiddenNodeDir.Value != null && HiddenNodeDir.Value != "")
                    {
                        string allvpath = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current) + str3 + str2;
                        allvpath        = SafeSC.SaveFile(function.PToV(foldername), FupFile, str3 + str2);
                        allvpath        = ImgHelper.AddWater(allvpath);
                        this.m_ShowPath = allvpath.Replace(SiteConfig.SiteOption.UploadDir, "");
                    }
                    else
                    {
                        string allvpath = SafeSC.SaveFile(function.PToV(filename), FupFile, str3 + str2);
                        this.m_ShowPath = allvpath.Replace(SiteConfig.SiteOption.UploadDir, "");
                    }
                    int    sizes         = (int)this.FupFile.FileContent.Length;
                    string thumbnailPath = this.m_ShowPath;//fsxm/jpg/2015/5/:OPjUWd:.jpg
                    this.GetScriptByModuleName(thumbnailPath, sizes);
                    this.ReturnManage("文件上传成功");
                }
            }
        }
コード例 #10
0
ファイル: FileUpload.aspx.cs プロジェクト: zwt-zf/cms
        protected void BtnUpload_Click(object sender, EventArgs e)
        {
            if (!this.FupFile.HasFile)
            {
                this.ReturnManage("请指定一个上传文件");
            }
            else
            {
                this.m_FileExtArr  = this.ViewState["FileExtArr"].ToString();
                this.m_MaxFileSize = DataConverter.CLng(this.ViewState["MaxFileSize"].ToString());
                if (!SiteConfig.SiteOption.EnableUploadFiles)
                {
                    this.ReturnManage("本站不允许上传文件!");
                }
                else
                {
                    string str2 = Path.GetExtension(this.FupFile.FileName).ToLower();
                    if (string.IsNullOrEmpty(this.m_FileExtArr))
                    {
                        this.ReturnManage("要上传文件的字段没有指定上传文件类型");
                    }
                    else if (!this.CheckFilePostfix(str2.Replace(".", "")))
                    {
                        this.ReturnManage("上传的文件不是符合扩展名" + this.m_FileExtArr + "的文件");
                    }
                    else
                    {
                        if (((int)this.FupFile.FileContent.Length) > (this.m_MaxFileSize * 0x400))
                        {
                            this.ReturnManage("上传的文件超过限制的" + this.m_MaxFileSize + "KB大小");
                            return;
                        }
                        string str3       = DataSecurity.MakeFileRndName();
                        string foldername = base.Request.PhysicalApplicationPath + (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + this.FileSavePath()).Replace("/", "\\");
                        string filename   = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current) + str3 + str2;
                        int    sizes      = (int)this.FupFile.FileContent.Length;
                        this.FupFile.SaveAs(filename);
                        string thumbnailPath = "";

                        thumbnailPath = this.m_ShowPath + str3 + str2;

                        this.GetScriptByModuleName(thumbnailPath, sizes);

                        this.ReturnManage("文件上传成功");
                    }
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// 获得内容生成路径
        /// </summary>
        /// <param name="NodeID"></param>
        /// <param name="GeneralID"></param>
        /// <returns></returns>
        private string GetPath(string NodeID, int GeneralID)
        {
            M_Node       Nodeinfo      = nll.SelReturnModel(DataConverter.CLng(NodeID));
            string       ContentFileEx = GetNodeContentEx(Nodeinfo);//内容页文件扩展名
            string       ContentRoot   = "";
            M_CommonData Cdata         = cll.GetCommonData(GeneralID);

            int ContentPageHtmlRule = Nodeinfo.ContentPageHtmlRule;//内容页文件名规则

            switch (ContentPageHtmlRule)
            {
            case 0:
                string filepath = MakeHtmlFile(Nodeinfo) + "/" + Cdata.CreateTime.Year + "/" + Cdata.CreateTime.Month + "/" + Cdata.CreateTime.Day;
                if (!FileSystemObject.IsExist(filepath, FsoMethod.Folder))
                {
                    FileSystemObject.CreateFileFolder(filepath);
                }
                ContentRoot = "/" + Cdata.CreateTime.Year + "/" + Cdata.CreateTime.Month + "/" + Cdata.CreateTime.Date.ToShortDateString() + "/" + Cdata.GeneralID.ToString();
                break;

            case 1:
                filepath = MakeHtmlFile(Nodeinfo) + "/" + Cdata.CreateTime.Year + "-" + Cdata.CreateTime.Month;
                if (!FileSystemObject.IsExist(filepath, FsoMethod.Folder))
                {
                    FileSystemObject.CreateFileFolder(filepath);
                }
                ContentRoot = filepath + Cdata.GeneralID.ToString();
                break;

            case 2:
                ContentRoot = "/" + Cdata.GeneralID.ToString();
                break;

            case 3:
                filepath = MakeHtmlFile(Nodeinfo) + "/" + Cdata.CreateTime.Year + Cdata.CreateTime.Month + Cdata.CreateTime.Day;
                if (!FileSystemObject.IsExist(filepath, FsoMethod.Folder))
                {
                    FileSystemObject.CreateFileFolder(filepath);
                }
                ContentRoot = "/" + Cdata.CreateTime.Year + Cdata.CreateTime.Month + Cdata.CreateTime.Day + "/" + Cdata.Title;
                break;
            }
            return(ContentRoot + "." + GetNodeContentEx(Nodeinfo));
        }
コード例 #12
0
ファイル: AddSource.aspx.cs プロジェクト: zwt-zf/cms
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.m_FileExtArr = "jpg|gif|png|bmp|jpeg|swf|rar";
        string str3       = "";
        string foldername = "";
        string filename   = "";
        string str2       = "";

        System.Web.UI.WebControls.FileUpload upload = (System.Web.UI.WebControls.FileUpload) this.FindControl("FileUpload1");
        StringBuilder builder2 = new StringBuilder();

        if (upload.HasFile)
        {
            str2 = Path.GetExtension(upload.FileName).ToLower();
            if (!this.CheckFilePostfix(str2.Replace(".", "")))
            {
                builder2.Append("照片" + upload.FileName + "不符合图片扩展名规则" + this.m_FileExtArr + @"\r\n");
            }
            else
            {
                if (((int)upload.FileContent.Length) > (20 * 0x400))
                {
                    builder2.Append("照片" + upload.FileName + "大小超过20" + @"KB\r\n");
                }
                else
                {
                    str3       = DataSecurity.MakeFileRndName();
                    foldername = base.Request.PhysicalApplicationPath + (VirtualPathUtility.AppendTrailingSlash("/Uploadfiles/Source")).Replace("/", "\\");// + this.FileSavePath()
                    filename   = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current) + str3 + str2;
                    upload.SaveAs(filename);
                    builder2.Append("照片" + upload.FileName + @"上传成功\r\n");
                    this.txtpic.Text = "UpLoadFiles/Source/" + str3 + str2;
                    showphoto.Src    = "../../UpLoadFiles/Source/" + str3 + str2;
                }
            }
        }
        //if (builder2.Length > 0)
        //{
        //    Response.Write("<script language=\"javascript\" type=\"text/javascript\">alert('" + builder2.ToString() + "');/script>");
        //    Page.Response.Redirect("Advertisement.aspx");
        //    this.txtpic.Text = "UpLoadFiles/Plus/" + str3 + str2;

        //}
    }
コード例 #13
0
        private string ImportExcel()//上传后保存,返回保存路径
        {
            string fileName = this.fileImp.FileName;
            string path     = Server.MapPath("~" + "/xls/");

            if (!FileSystemObject.IsExist(path, FsoMethod.Folder))
            {
                FileSystemObject.CreateFileFolder(path);
            }
            try
            {
                string fpath = path + fileName;
                //SafeSC.SaveFile(path + fileName, fileImp);
                if (!fileImp.SaveAs(fpath))
                {
                    function.WriteErrMsg(fileImp.ErrorMsg);
                }
                return(fpath);
            }
            catch
            {
                return("");
            }
        }
コード例 #14
0
        public static DataTable SavePemotePic(DataTable dtContent, NodeInfo nodeInfo, string content)
        {
            string        str     = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir);
            string        str2    = dtContent.Rows[0][content].ToString();
            string        str3    = dtContent.Rows[0]["DefaultPicUrl"].ToString();
            StringBuilder builder = new StringBuilder();

            builder.Append(dtContent.Rows[0]["UploadFiles"].ToString());
            str2 = PathReplaceLable(str2);
            WebClient       client = new WebClient();
            MatchCollection matchs = new Regex(@"((http|https|ftp|rtsp|mms):(\/\/|\\\\){1}([\w\-]+[.]){1,}(net|com|cn|org|cc|tv|[0-9]{1,3})(([^.])+[.]{1}(gif|jpg|jpeg|jpe|bmp|png)))", RegexOptions.IgnoreCase).Matches(str2);

            if (matchs.Count > 0)
            {
                HttpContext.Current.Response.Write("字段" + content + ":总共有 <span style='color:blue'><b>" + matchs.Count.ToString() + " </b></span>张远程图片, 请等待不要刷新!<br/>");
            }
            int num = 0;

            foreach (Match match in matchs)
            {
                num++;
                string path = match.Groups[1].Value;
                try
                {
                    string        str5     = DataSecurity.MakeFileRndName();
                    string        str6     = Path.GetExtension(path).ToLower();
                    string        str7     = EasyOne.Contents.Nodes.UploadPathParse(nodeInfo, str5 + str6).Replace("//", "/");
                    StringBuilder builder2 = new StringBuilder();
                    builder2.Append(FileSystemObject.CreateFileFolder(str + str7, HttpContext.Current));
                    builder2.Append(str5 + str6);
                    string str8 = str7 + str5 + str6;
                    client.DownloadFile(path, builder2.ToString());
                    str2 = str2.Replace(path, "{PE.SiteConfig.ApplicationPath/}{PE.SiteConfig.uploaddir/}/" + str8);
                    if (builder.Length > 0)
                    {
                        builder.Append("|" + str8);
                    }
                    else
                    {
                        builder.Append(str8);
                    }
                    if (string.IsNullOrEmpty(str3))
                    {
                        str3 = str8;
                    }
                    HttpContext.Current.Response.Write("保存远程图片第 <span style='color:blue'><b>" + num + " </b></span> 张成功。<br/>");
                }
                catch (WebException)
                {
                    HttpContext.Current.Response.Write("获取保存远程图片第 <b>" + num + " </b> 张失败。<br/>");
                }
                catch (Exception)
                {
                    HttpContext.Current.Response.Write("获取保存远程图片第 <b>" + num + " </b> 张失败。<br/>");
                }
                client.Dispose();
                HttpContext.Current.Response.Flush();
            }
            str2 = str2.Replace(SiteConfig.SiteOption.UploadDir, "{PE.SiteConfig.uploaddir/}");
            if (string.CompareOrdinal(SiteConfig.SiteInfo.VirtualPath, "/") != 0)
            {
                str2 = str2.Replace(SiteConfig.SiteInfo.VirtualPath, "{PE.SiteConfig.ApplicationPath/}");
            }
            dtContent.Rows[0][content]         = str2;
            dtContent.Rows[0]["DefaultPicUrl"] = str3;
            dtContent.Rows[0]["UploadFiles"]   = builder.ToString();
            return(dtContent);
        }
コード例 #15
0
        protected void BtnUpload_Click(object sender, EventArgs e)
        {
            if (!this.FupFile.HasFile)
            {
                this.ReturnManage("上传失败,重新上传。");
                return;
            }
            int  uploadFileMaxSize = 0;
            int  uploadSize        = 0;
            bool flag  = false;
            bool flag2 = false;

            if (!SiteConfig.SiteOption.EnableUploadFiles)
            {
                this.ReturnManage("权限错误:对不起网站没有开启上传权限。");
                return;
            }
            if (!PEContext.Current.Admin.Identity.IsAuthenticated)
            {
                if (!PEContext.Current.User.Identity.IsAuthenticated)
                {
                    UserGroupsInfo userGroupById = UserGroups.GetUserGroupById(-2);
                    if (string.IsNullOrEmpty(userGroupById.GroupSetting))
                    {
                        this.ReturnManage("匿名会员组不存在!");
                        return;
                    }
                    UserPurviewInfo groupSetting = UserGroups.GetGroupSetting(userGroupById.GroupSetting);
                    if (groupSetting.IsNull)
                    {
                        this.ReturnManage("匿名会员组没有进行权限设置!");
                        return;
                    }
                    if (!groupSetting.EnableUpload)
                    {
                        this.ReturnManage("匿名会员组没有开启上传权限!");
                        return;
                    }
                    uploadSize = groupSetting.UploadSize;
                }
                else
                {
                    if (!PEContext.Current.User.UserInfo.UserPurview.EnableUpload)
                    {
                        this.ReturnManage("所属会员组没有开启上传权限!");
                        return;
                    }
                    uploadSize = PEContext.Current.User.UserInfo.UserPurview.UploadSize;
                }
            }
            string str = Path.GetExtension(this.FupFile.FileName).ToLower();

            if (!this.CheckFilePostfix(str.Replace(".", "")))
            {
                this.ReturnManage("上传文件类型不对!必须上传" + this.m_FileExtArr + "的后缀名!");
                return;
            }
            if (string.Compare(this.m_ModuleName, "Node", StringComparison.OrdinalIgnoreCase) == 0)
            {
                FieldInfo           fieldInfoByFieldName = Field.GetFieldInfoByFieldName(this.m_ModelId, this.m_FieldName);
                Collection <string> settings             = fieldInfoByFieldName.Settings;
                switch (fieldInfoByFieldName.FieldType)
                {
                case FieldType.PictureType:
                    uploadFileMaxSize = DataConverter.CLng(settings[1]);
                    flag2             = DataConverter.CBoolean(settings[4]);
                    flag = DataConverter.CBoolean(settings[5]);
                    goto Label_01EA;

                case FieldType.FileType:
                    uploadFileMaxSize = DataConverter.CLng(settings[0]);
                    goto Label_01EA;
                }
            }
            else
            {
                uploadFileMaxSize = SiteConfig.SiteOption.UploadFileMaxSize;
            }
Label_01EA:
            if (!PEContext.Current.Admin.Identity.IsAuthenticated && (uploadFileMaxSize > uploadSize))
            {
                uploadFileMaxSize = uploadSize;
            }
            if (((int)this.FupFile.FileContent.Length) > (uploadFileMaxSize * 0x400))
            {
                this.ReturnManage("请上传小于" + uploadFileMaxSize.ToString() + "KB的文件!");
            }
            else
            {
                string str2     = DataSecurity.MakeFileRndName();
                string filename = FileSystemObject.CreateFileFolder((VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + this.FileSavePath()).Replace("//", "/"), HttpContext.Current) + str2 + str;
                this.FupFile.SaveAs(filename);
                string thumbnailPath = "";
                if (flag)
                {
                    thumbnailPath = this.m_ShowPath + str2 + "_S" + str;
                    Thumbs.GetThumbsPath(this.m_ShowPath + str2 + str, thumbnailPath);
                }
                else
                {
                    thumbnailPath = this.m_ShowPath + str2 + str;
                }
                if (flag2)
                {
                    WaterMark.AddWaterMark(this.m_ShowPath + str2 + str);
                }
                EasyOne.Model.Accessories.FileInfo fileInfo = new EasyOne.Model.Accessories.FileInfo();
                fileInfo.Name  = this.FupFile.FileName;
                fileInfo.Path  = thumbnailPath;
                fileInfo.Size  = (int)this.FupFile.FileContent.Length;
                fileInfo.Quote = 1;
                if (string.Compare(this.m_ModuleName, "soft", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Files.Add(fileInfo);
                }
                this.GetScriptByModuleName(fileInfo);
                this.ReturnManage("上传成功!");
            }
        }
コード例 #16
0
        protected void BtnUpload_Click(object sender, EventArgs e)
        {
            long size = FupFile.FileContent.Length;

            if (!this.FupFile.HasFile)
            {
                this.ReturnManage("请指定一个上传文件");
            }
            else
            {
                if (!SiteConfig.SiteOption.EnableUploadFiles)
                {
                    this.ReturnManage("本站不允许上传文件!");
                }
                else
                {
                    string str2 = Path.GetExtension(this.FupFile.FileName).ToLower();
                    if (!SafeSC.IsImage(str2))
                    {
                        this.ReturnManage("上传的文件不是符合扩展名" + this.m_FileExtArr + "格式的文件");
                    }
                    else
                    {
                        this.m_FileExtArr  = SiteConfig.SiteOption.UploadFileExts;
                        this.m_MaxFileSize = SiteConfig.SiteOption.UploadPicMaxSize;//DataConverter.CLng(this.ViewState["MaxFileSize"].ToString());
                        if (string.IsNullOrEmpty(this.m_FileExtArr))
                        {
                            this.ReturnManage("要上传文件的字段没有指定上传文件类型");
                        }
                        else
                        {
                            if (((int)this.FupFile.FileContent.Length) > (this.m_MaxFileSize * 0x400))
                            {
                                this.ReturnManage("上传的文件超过限制的" + this.m_MaxFileSize + "KB大小");
                                return;
                            }
                            string str3       = DataSecurity.MakeFileRndName();
                            string foldername = base.Request.PhysicalApplicationPath + (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + this.FileSavePath()).Replace("/", @"\");
                            foldername = foldername.Replace(@"\\", @"\");

                            string filename = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current) + str3 + str2;


                            if (WaterModuleConfig.WaterConfig.IsUsed && (str2 == ".jpg" || str2 == ".png") && HiddenNodeDir.Value != null && HiddenNodeDir.Value != "")
                            {
                                string Testfoldername = "";
                                if (NodeID <= 0)
                                {
                                    Testfoldername = foldername.Replace("UserUpload", "test");
                                }
                                else
                                {
                                    Testfoldername = foldername.Replace(HiddenNodeDir.Value, "test");
                                }
                                string Testfilename = FileSystemObject.CreateFileFolder(Testfoldername, HttpContext.Current) + str3 + str2;
                                this.FupFile.SaveAs(Testfilename);

                                WaterImages dd = new WaterImages();
                                if (WaterModuleConfig.WaterConfig.WaterClass == "1")
                                {
                                    string imgurl = Server.MapPath(WaterModuleConfig.WaterConfig.imgLogo);
                                    int    post   = DataConverter.CLng(WaterModuleConfig.WaterConfig.lopostion);
                                    dd.DrawImage(Testfilename, imgurl, filename);
                                }
                                else
                                {
                                    string waterword = WaterModuleConfig.WaterConfig.WaterWord;
                                    string ziti      = WaterModuleConfig.WaterConfig.WaterWordType;
                                    dd.DrawFont(Testfilename, filename);
                                }
                            }
                            else
                            {
                                this.FupFile.SaveAs(filename);
                            }
                            int    sizes         = (int)this.FupFile.FileContent.Length;
                            string thumbnailPath = "";
                            thumbnailPath = this.m_ShowPath + str3 + str2;
                            this.GetScriptByModuleName(thumbnailPath, sizes);
                            this.ReturnManage("文件上传成功");
                        }
                    }
                }
            }
        }
コード例 #17
0
 public static string UploadFolder()
 {
     return(FileSystemObject.CreateFileFolder("Temp"));
 }
コード例 #18
0
        protected void BtnUpload_Click(object sender, EventArgs e)
        {
            this.m_FileExtArr  = this.ViewState["FileExtArr"].ToString();
            this.m_MaxFileSize = DataConverter.CLng(this.ViewState["MaxFileSize"].ToString());
            if (!SiteConfig.SiteOption.EnableUploadFiles)
            {
                this.ReturnManage("本站不允许上传文件!");
            }
            else
            {
                if (string.IsNullOrEmpty(this.m_FileExtArr))
                {
                    this.ReturnManage("要上传文件的字段没有指定上传文件类型");
                }
                else
                {
                    int           num     = DataConverter.CLng(base.Request.Form["ThumbIndex"]);
                    string        id      = this.ViewState["FieldName"].ToString();
                    string        thumbid = this.ViewState["ThumbField"].ToString();
                    StringBuilder builder = new StringBuilder();
                    builder.Append("<script language=\"javascript\" type=\"text/javascript\">");
                    int           num2     = 0;
                    StringBuilder builder2 = new StringBuilder();
                    for (int i = 0; i < 10; i++)
                    {
                        num2++;
                        System.Web.UI.WebControls.FileUpload upload = (System.Web.UI.WebControls.FileUpload) this.FindControl("FileUpload" + i.ToString());
                        if (upload.HasFile)
                        {
                            string str2 = Path.GetExtension(upload.FileName).ToLower();
                            if (!this.CheckFilePostfix(str2.Replace(".", "")))
                            {
                                builder2.Append("文件" + upload.FileName + "不符合扩展名规则" + this.m_FileExtArr + @"\r\n");
                            }
                            else
                            {
                                if (((int)upload.FileContent.Length) > (this.m_MaxFileSize * 0x400))
                                {
                                    builder2.Append("文件" + upload.FileName + "大小超过" + this.m_MaxFileSize + @"KB\r\n");
                                }
                                else
                                {
                                    string str3       = DataSecurity.MakeFileRndName() + i.ToString();
                                    string foldername = base.Request.PhysicalApplicationPath + (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + this.FileSavePath(upload.FileName)).Replace("/", "\\");
                                    string filename   = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current) + str3 + str2;
                                    int    sizes      = (int)upload.FileContent.Length;
                                    upload.SaveAs(filename);
                                    string thumbnailPath = "";

                                    thumbnailPath = this.m_ShowPath + str3 + str2;

                                    if (i == num)
                                    {
                                        builder.Append("parent.ChangeThumbField(\"" + thumbnailPath + "\",\"sel_" + id + "\",\"txt_" + id + "\",\"txt_" + thumbid + "\");");
                                    }
                                    else
                                    {
                                        builder.Append("parent.DealwithPhotoUpload(\"" + thumbnailPath + "\",\"sel_" + id + "\",\"txt_" + id + "\");");
                                    }
                                    builder2.Append("文件" + upload.FileName + @"上传成功\r\n");
                                }
                            }
                        }
                    }
                    if (builder2.Length > 0)
                    {
                        builder.Append("parent.DealwithUploadErrMessage(\"" + builder2.ToString() + "\");");
                    }
                    builder.Append("</script>");
                    this.Page.ClientScript.RegisterStartupScript(base.GetType(), "UpdateParent", builder.ToString());
                }
            }
        }
コード例 #19
0
ファイル: SiteOption.aspx.cs プロジェクト: zoomlacms/web032
    public void bindShengji()
    {
        try
        {
            //升级节点
            DataSet nodelist = nll.GetDirectory();
            if (nodelist != null)
            {
                //生成目录
                if (!FileSystemObject.IsExist(base.Request.PhysicalApplicationPath + @"\" + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\节点\", FsoMethod.Folder))
                {
                    FileSystemObject.CreateFileFolder(base.Request.PhysicalApplicationPath + @"\" + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\节点\");
                }
                nodelist.WriteXml(base.Request.PhysicalApplicationPath + @"\" + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\节点\Directory.node");

                if (!FileSystemObject.IsExist(base.Request.PhysicalApplicationPath + @"\" + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\节点\NodeList", FsoMethod.Folder))
                {
                    FileSystemObject.CreateFileFolder(base.Request.PhysicalApplicationPath + @"\" + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\节点\NodeList");
                }

                for (int i = 0; i < nodelist.Tables[0].Rows.Count; i++)
                {
                    int     NodeID   = DataConverter.CLng(nodelist.Tables[0].Rows[i]["NodeID"]);
                    string  NodeName = nodelist.Tables[0].Rows[i]["NodeName"].ToString();
                    DataSet nodeset  = nll.GetNodeSet(NodeID);
                    nodeset.WriteXml(base.Request.PhysicalApplicationPath + @"\" + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\节点\NodeList\" + NodeID.ToString() + ".node");
                }
            }
            nodelist.Dispose();
            if (!FileSystemObject.IsExist(base.Request.PhysicalApplicationPath + @"\" + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\标签\", FsoMethod.Folder))
            {
                FileSystemObject.CreateFileFolder(base.Request.PhysicalApplicationPath + @"\" + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\标签\");
            }
            string    dirfilename = base.Request.PhysicalApplicationPath + @"\" + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\标签\Directory.label";
            DataSet   nodedir     = new DataSet("NewDataSet");
            DataTable dttemp      = labelBll.GetLabelCateListXML();
            DataSet   dsLabals    = new DataSet("NewDataSet");
            DataTable dtLabals    = new DataTable("DataTable");
            dsLabals.Tables.Add(dtLabals);
            for (int i = 0; i < dttemp.Rows.Count; i++)
            {
                DataRow   dr          = dttemp.Rows[i];
                DataSet   labeltable1 = new DataSet("NewDataSet");
                DataTable dtFIle      = FileSystemObject.GetDirectoryInfos(base.Request.PhysicalApplicationPath + @"\" + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\标签\" + dr["name"].ToString(), FsoMethod.File);
                for (int ss = 0; ss < dtFIle.Rows.Count; ss++)
                {
                    if (dtFIle.Rows[ss]["content_type"].ToString().ToLower() == "label")
                    {
                        string  filenameLabel = SiteConfig.SiteMapath().Substring(0, SiteConfig.SiteMapath().Length - 1) + SiteConfig.SiteOption.TemplateDir.Replace("/", @"\") + @"\配置库\标签\" + dr["name"] + @"\" + dtFIle.Rows[ss]["name"];
                        DataSet tempset       = new DataSet();
                        tempset.ReadXml(filenameLabel);
                        DataTable converttable = tempset.Tables[0].Copy();
                        tempset.Dispose();
                        if (dtLabals.Columns.Count <= 0)
                        {
                            for (int jj = 0; jj < converttable.Columns.Count; jj++)
                            {
                                dtLabals.Columns.Add(converttable.Columns[jj].ColumnName, converttable.Columns[jj].DataType);
                            }
                        }
                        dtLabals.ImportRow(converttable.Rows[0]);
                    }
                }
                if (labeltable1.Tables.Count <= 0)
                {
                    DataTable  dtnew = new DataTable("Table");
                    DataColumn dc    = new DataColumn("LabelID", typeof(string));
                    dtnew.Columns.Add(dc);
                    dc = new DataColumn("LabelName", typeof(string));
                    dtnew.Columns.Add(dc);
                    dc = new DataColumn("LabelType", typeof(string));
                    dtnew.Columns.Add(dc);
                    dc = new DataColumn("LabelCate", typeof(string));
                    dtnew.Columns.Add(dc);
                    labeltable1.Tables.Add(dtnew);
                }
            }
            for (int i = dtLabals.Columns.Count - 1; i >= 4; i--)
            {
                dtLabals.Columns.RemoveAt(i);
            }
            DataTable labeltoptable = dsLabals.Tables[0].Copy();
            labeltoptable.TableName = "Table";
            nodedir.Tables.Add(labeltoptable);
            nodedir.WriteXml(dirfilename);
            nodedir.Dispose();
            mll.UpModel();
            lblKai.Text = "一键开销成功";
        }
        catch
        {
            lblKai.Text = "一键开销成功";
            throw;
        }
    }
コード例 #20
0
 protected void BtnUpload_Click(object sender, EventArgs e)
 {
     if (!SiteConfig.SiteOption.EnableUploadFiles)
     {
         this.LblMessage.Text = "权限错误:你当前的网站没有开启上传功能,请检查你的网站配置。";
     }
     else
     {
         string str = BasePage.RequestString("ReturnJSFunction");
         int    num = DataConverter.CLng(base.Request.Form["ThumbIndex"]);
         if (string.IsNullOrEmpty(str))
         {
             str = "DealwithUpload";
         }
         StringBuilder builder = new StringBuilder();
         builder.Append("<script language=\"javascript\" type=\"text/javascript\">");
         int           num2     = 0;
         StringBuilder builder2 = new StringBuilder();
         if (!PEContext.Current.Admin.Identity.IsAuthenticated)
         {
             int uploadSize = PEContext.Current.User.UserInfo.UserPurview.UploadSize;
             if (this.m_PhotoSize > uploadSize)
             {
                 this.m_PhotoSize = uploadSize;
             }
         }
         for (int i = 0; i < 10; i++)
         {
             num2++;
             System.Web.UI.WebControls.FileUpload upload = (System.Web.UI.WebControls.FileUpload) this.FindControl("FileUpload" + i.ToString());
             if (upload.HasFile)
             {
                 string str2 = Path.GetExtension(upload.FileName).ToLower();
                 if (!this.CheckFilePostfix(str2.Replace(".", "")))
                 {
                     builder2.Append("文件" + upload.FileName + "上传文件类型不对!必须上传" + this.m_FileExtArr + @"的后缀名!\n");
                 }
                 else if (((int)upload.FileContent.Length) > (this.m_PhotoSize * 0x400))
                 {
                     builder2.Append("文件" + upload.FileName + "请上传小于" + this.m_PhotoSize.ToString() + @"KB的文件!\n");
                 }
                 else
                 {
                     string str3     = DataSecurity.MakeFileRndName() + i.ToString();
                     string filename = FileSystemObject.CreateFileFolder((VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + this.FileSavePath(upload.FileName)).Replace("//", "/"), HttpContext.Current) + str3 + str2;
                     upload.SaveAs(filename);
                     Thumbs.GetThumbsPath(this.m_ShowPath + str3 + str2, this.m_ShowPath + str3 + "_S" + str2);
                     if (this.m_Watermark)
                     {
                         WaterMark.AddWaterMark(this.m_ShowPath + str3 + str2);
                     }
                     EasyOne.Model.Accessories.FileInfo fileInfo = new EasyOne.Model.Accessories.FileInfo();
                     fileInfo.Name  = upload.FileName;
                     fileInfo.Path  = this.m_ShowPath + str3 + str2;
                     fileInfo.Size  = (int)upload.FileContent.Length;
                     fileInfo.Quote = 1;
                     Files.Add(fileInfo);
                     if (i == num)
                     {
                         builder.Append("parent." + str + "ChangeThumbField(\"" + fileInfo.Path + "\",\"" + this.m_ShowPath + str3 + "_S" + str2 + "\");");
                     }
                     else
                     {
                         builder.Append("parent." + str + "DealwithUpload(\"" + fileInfo.Path + "\",\"" + fileInfo.Size.ToString() + "\",\"" + fileInfo.Id.ToString() + "\",\"" + this.m_ShowPath + str3 + "_S" + str2 + "\");");
                     }
                     builder2.Append("文件" + upload.FileName + @"上传成功!\n");
                 }
             }
         }
         if (builder2.Length > 0)
         {
             builder.Append("parent." + str + "ErrMessage(\"" + builder2.ToString() + "\");");
         }
         builder.Append("</script>");
         this.Page.ClientScript.RegisterStartupScript(base.GetType(), "UpdateParent", builder.ToString());
     }
 }