⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filemanage.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
                case "wmv":
                case "avi":
                case "asf":
                case "mpg":
                case "rm":
                case "ra":
                case "ram":
                case "swf":
                    builder.Append(@"<object classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\'");
                    builder.Append(@" width=\'200\'");
                    builder.Append(@" height=\'120\'");
                    builder.Append(@"><param name=\'movie\' value=\'" + str + @"\'>");
                    builder.Append(@"<param name=\'wmode\' value=\'transparent\'>");
                    builder.Append(@"<param name=\'quality\' value=\'autohigh\'>");
                    builder.Append(@"<embed src=\'" + str + @"\' quality=\'autohigh\'");
                    builder.Append(@" pluginspage=\'http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\' type=\'application/x-shockwave-flash\'");
                    builder.Append(@" wmode=\'transparent\'");
                    builder.Append(@" width=\'200\'");
                    builder.Append(@" height=\'120\'");
                    builder.Append("></embed></object>");
                    break;

                default:
                    builder.Append("&nbsp;此文件非图片或动画,无预览&nbsp;");
                    break;
            }
            return builder.ToString();
        }

        protected string GetFilePath(string fileName)
        {
            fileName = fileName.Replace(@"\", "/");
            return (base.BasePath + this.m_ConfigUploadDir + this.m_CurrentDir + "/" + fileName);
        }

        private Dictionary<string, string> GetRptFilesSelectRows()
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            foreach (RepeaterItem item in this.RptFiles.Items)
            {
                CheckBox box;
                LinkButton button;
                if (BasePage.RequestString("ShowType") != "0")
                {
                    box = (CheckBox) item.FindControl("ChkListFiles");
                    button = (LinkButton) item.FindControl("LbtnDelList");
                }
                else
                {
                    box = (CheckBox) item.FindControl("ChkFiles");
                    button = (LinkButton) item.FindControl("LbtnDel");
                }
                if (box.Checked)
                {
                    dictionary.Add(button.CommandArgument, button.CommandName);
                }
            }
            return dictionary;
        }

        protected string GetShowExtension(string extension)
        {
            if (m_ExtensionImgDictionary.ContainsKey(extension))
            {
                return m_ExtensionImgDictionary[extension];
            }
            return "other";
        }

        protected string GetSize(string size)
        {
            if (!string.IsNullOrEmpty(size))
            {
                return FileSystemObject.ConvertSizeToShow(DataConverter.CLng(size));
            }
            return string.Empty;
        }

        protected string GetSortShow(string field)
        {
            string str2;
            string str = "";
            if (!(BasePage.RequestStringToLower("SortField") == field) || ((str2 = BasePage.RequestStringToLower("Sort")) == null))
            {
                return str;
            }
            if (!(str2 == "desc"))
            {
                if (str2 != "asc")
                {
                    return str;
                }
            }
            else
            {
                return "↑";
            }
            return "↓";
        }

        protected string GetSorturl(string field)
        {
            string str = "fileManage.aspx?Dir=" + base.Server.UrlEncode(this.m_CurrentDir) + "&ShowType=" + BasePage.RequestString("ShowType") + "&SortField=" + field;
            if (BasePage.RequestStringToLower("SortField") == field)
            {
                switch (BasePage.RequestStringToLower("Sort"))
                {
                    case "desc":
                        return (str + "&Sort=ASC");

                    case "asc":
                        return (str + "&Sort=DESC");
                }
            }
            return (str + "&Sort=DESC");
        }

        protected void InitTheExtensionImgDictionary()
        {
            if (m_ExtensionImgDictionary == null)
            {
                m_ExtensionImgDictionary = new Dictionary<string, string>();
                m_ExtensionImgDictionary.Add("jpeg", "img");
                m_ExtensionImgDictionary.Add("jpe", "img");
                m_ExtensionImgDictionary.Add("bmp", "img");
                m_ExtensionImgDictionary.Add("png", "img");
                m_ExtensionImgDictionary.Add("swf", "Ftype_flash");
                m_ExtensionImgDictionary.Add("dll", "img");
                m_ExtensionImgDictionary.Add("vbp", "sys");
                m_ExtensionImgDictionary.Add("wmv", "Ftype_media");
                m_ExtensionImgDictionary.Add("avi", "Ftype_media");
                m_ExtensionImgDictionary.Add("asf", "Ftype_media");
                m_ExtensionImgDictionary.Add("mpg", "Ftype_media");
                m_ExtensionImgDictionary.Add("rm", "Ftype_rm");
                m_ExtensionImgDictionary.Add("ra", "Ftype_rm");
                m_ExtensionImgDictionary.Add("ram", "Ftype_rm");
                m_ExtensionImgDictionary.Add("rar", "zip");
                m_ExtensionImgDictionary.Add("zip", "zip");
                m_ExtensionImgDictionary.Add("xml", "xml");
                m_ExtensionImgDictionary.Add("txt", "txt");
                m_ExtensionImgDictionary.Add("exe", "exe");
                m_ExtensionImgDictionary.Add("doc", "doc");
                m_ExtensionImgDictionary.Add("html", "html");
                m_ExtensionImgDictionary.Add("htm", "htm");
                m_ExtensionImgDictionary.Add("jpg", "jpg");
                m_ExtensionImgDictionary.Add("gif", "gif");
                m_ExtensionImgDictionary.Add("xls", "xls");
                m_ExtensionImgDictionary.Add("asp", "asp");
            }
        }

        private bool IsPhoto(string extension)
        {
            string str;
            if (((str = extension) == null) || (((!(str == "jpeg") && !(str == "jpe")) && (!(str == "bmp") && !(str == "png"))) && (!(str == "jpg") && !(str == "gif"))))
            {
                return false;
            }
            return true;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.InitTheExtensionImgDictionary();
            this.m_ConfigUploadDir = SiteConfig.SiteOption.UploadDir;
            this.m_CurrentDir = BasePage.RequestString("Dir");
            this.m_UrlReferrer = "FileManage.aspx?Dir=" + base.Server.UrlEncode(this.m_CurrentDir);
            if (!string.IsNullOrEmpty(this.m_ConfigUploadDir))
            {
                string path = "";
                if (!string.IsNullOrEmpty(this.m_CurrentDir) && (this.m_CurrentDir.LastIndexOf("/") > 0))
                {
                    this.m_ParentDir = base.Server.UrlEncode(this.m_CurrentDir.Remove(this.m_CurrentDir.LastIndexOf("/"), this.m_CurrentDir.Length - this.m_CurrentDir.LastIndexOf("/")));
                }
                path = this.m_ConfigUploadDir + this.m_CurrentDir + "/";
                this.LblCurrentDir.Text = path;
                path = base.Request.PhysicalApplicationPath + path;
                DirectoryInfo info = new DirectoryInfo(path);
                if (info.Exists)
                {
                    if (string.IsNullOrEmpty(this.TxtSearchKeyword.Text))
                    {
                        this.m_CurrentDirectoryInfo = FileSystemObject.GetDirectoryInfos(path, FsoMethod.All);
                    }
                    else
                    {
                        string text = this.TxtSearchKeyword.Text;
                        if (!text.Contains("*"))
                        {
                            text = "*" + text + "*.*";
                        }
                        this.m_CurrentDirectoryInfo = FileSystemObject.SearchFiles(path, text);
                    }
                }
            }
            else
            {
                this.PanContent.Visible = false;
                this.LitMessage.Text = "请在网站配置中配置上传文件目录";
                this.LitMessage.Visible = true;
            }
            if (!this.Page.IsPostBack)
            {
                this.BindData();
            }
            this.BtnSearch.Click += new EventHandler(this.BtnSearch_Click);
        }

        protected void Pager_PageChanged(object src, PageChangedEventArgs e)
        {
            this.Pager.CurrentPageIndex = e.NewPageIndex;
            this.BindData();
        }

        protected void RptFiles_ItemCommand(object source, CommandEventArgs e)
        {
            string file = this.m_ConfigUploadDir + this.m_CurrentDir + "/" + ((string) e.CommandArgument);
            file = base.Request.PhysicalApplicationPath + file.Replace("/", @"\");
            if (e.CommandName == "DelFiles")
            {
                try
                {
                    FileSystemObject.Delete(file, FsoMethod.File);
                    AdminPage.WriteSuccessMsg("删除成功!", this.m_UrlReferrer);
                }
                catch (SecurityException exception)
                {
                    AdminPage.WriteErrMsg(exception.Message);
                }
                catch (UnauthorizedAccessException exception2)
                {
                    AdminPage.WriteErrMsg(exception2.Message);
                }
            }
            if (e.CommandName == "DelDir")
            {
                base.Response.Write("<script type='text/javascript'>parent.frames[\"left\"].location.reload();</script>");
                try
                {
                    FileSystemObject.Delete(file, FsoMethod.Folder);
                }
                catch (SecurityException exception3)
                {
                    AdminPage.WriteErrMsg(exception3.Message);
                }
                catch (UnauthorizedAccessException exception4)
                {
                    AdminPage.WriteErrMsg(exception4.Message);
                }
                AdminPage.WriteSuccessMsg("<li>删除目录成功。</li>", this.m_UrlReferrer);
            }
        }

        protected void WaterMarkByFile(string filePath, string fileName, string extension)
        {
            string str = this.m_CurrentDir + "/" + filePath + "/";
            if (this.IsPhoto(extension))
            {
                WaterMark.AddWaterMark(str + fileName);
            }
        }

        protected void WaterMarkByFolder(string folderPath)
        {
            string path = this.m_ConfigUploadDir + this.m_CurrentDir + "/" + folderPath;
            path = (base.Request.PhysicalApplicationPath + path.Replace("/", @"\")).Replace(@"\\", @"\");
            DirectoryInfo info = new DirectoryInfo(path);
            if (info.Exists)
            {
                foreach (DataRow row in FileSystemObject.GetDirectoryInfos(path, FsoMethod.All).Rows)
                {
                    if (row["type"].ToString() == "2")
                    {
                        this.WaterMarkByFile(folderPath, row["name"].ToString(), row["content_type"].ToString());
                    }
                    if (row["type"].ToString() == "1")
                    {
                        this.WaterMarkByFolder(folderPath + "/" + row["name"].ToString());
                    }
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -