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

📄 manage_list.aspx.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
📖 第 1 页 / 共 2 页
字号:
//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class manage_Templet_Manage_List : NetCMS.Web.UI.ManagePage
{
    public manage_Templet_Manage_List()
    {
        Authority_Code = "T001";
    }
    private string str_dirMana = NetCMS.Config.UIConfig.dirDumm;
    private string str_Templet = NetCMS.Config.UIConfig.dirTemplet;  //获取模板路径
    private string str_FilePath = "";
    private string s_url = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        this.CheckAdminAuthority();
        Response.CacheControl = "no-cache";
        if (!IsPostBack)                                                        //判断页面是否重载
        {
            copyright.InnerHtml = CopyRight;                            //获取版权信息
        }
        if (str_dirMana != "" && str_dirMana != null && str_dirMana != string.Empty)//判断虚拟路径是否为空,如果不是则加上//
        {
            str_dirMana = "//" + str_dirMana;
        }
        string type = Request.QueryString["Type"];
        if (SiteID == "0")
        {
            str_FilePath = Server.MapPath(str_dirMana + "\\" + str_Templet);
        }
        else
        {
            string _sitePath = str_dirMana + "\\" + NetCMS.Config.UIConfig.dirSite + "\\" + NetCMS.Global.Current.SiteID + "\\" + str_Templet;
            if (!Directory.Exists(Server.MapPath(_sitePath))) { Directory.CreateDirectory(Server.MapPath(_sitePath)); }
            str_FilePath = Server.MapPath(_sitePath);
        }
        
        string Path = str_FilePath + Request.QueryString["Path"];
        string ParentPath = str_FilePath + Request.QueryString["ParentPath"]; //父级
        try
        {
            if (Path.IndexOf(str_FilePath, 0) == -1 || ParentPath.IndexOf(str_FilePath, 0) == -1)
                Response.End();
        }
        catch { }

        switch (type)
        {
            case "EidtDirName":     //修改文件夹名称
                this.Authority_Code = "T003";
                this.CheckAdminAuthority();
                EidtDirName(Path);
                break;
            case "EidtFileName":    //修改文件名称
                this.Authority_Code = "T007";
                this.CheckAdminAuthority();
                EidtFileName(Path);
                break;
            case "DelDir":          //删除文件夹
                this.Authority_Code = "T004";
                this.CheckAdminAuthority();
                DelDir(Path);
                break;
            case "DelFile":          //删除文件
                this.Authority_Code = "T004";
                this.CheckAdminAuthority();
                DelFile(Path);
                break;
            case "AddDir":
                this.Authority_Code = "T003";
                this.CheckAdminAuthority();
                AddDir(Path);        //添加文件夹
                break;
            default:
                break;
        }
        ShowFile(str_FilePath, Path, ParentPath);
        s_url = "Manage_List.aspx?Path=" + Request.QueryString["Path"] + "&ch=" + Request.QueryString["ch"] + "&ParentPath=" + Request.QueryString["ParentPath"];
    }

    /// <summary>
    /// 显示文件列表
    /// </summary>
    /// <param name="defaultpath">默认路径</param>
    /// <param name="path">当前路径</param>
    /// <param name="parentPath">父目录路径</param>
    /// <returns>显示文件列表</returns>
    /// Code By DengXi

    protected void ShowFile(string defaultpath, string path, string parentPath)
    {

        if (path != "" && path != null && path != string.Empty)
        {
            defaultpath = path;
        }
        if (Directory.Exists(defaultpath) == false)            //判断模板目录是否存在
        {
            PageError("目录不存在", "");
        }
        File_List.InnerHtml = GetDirFile(defaultpath, parentPath);
    }

    /// <summary>
    /// 显示文件列表
    /// </summary>
    /// <param name="dir">当前路径</param>
    /// <param name="ParPath">父目录路径</param>
    /// <returns>显示文件列表</returns>
    /// Code By DengXi

    protected string GetDirFile(string dir, string ParPath)
    {
        //bug修改,预览带端口不能正常显示, arjun 2008.2.17
        string DomainAndPort = Request.ServerVariables["Server_Name"];
        if (Convert.ToString(Request.ServerVariables["Server_Port"]) != "80")
        {
            DomainAndPort += ":" + Request.ServerVariables["Server_Port"];
        }
       
        DirectoryInfo[] ChildDirectory;                         //子目录集
        FileInfo[] NewFileInfo;                                 //当前所有文件

        DirectoryInfo FatherDirectory = new DirectoryInfo(dir); //当前目录

        ChildDirectory = FatherDirectory.GetDirectories("*.*"); //得到子目录集

        NewFileInfo = FatherDirectory.GetFiles();               //得到文件集,可以进行操作
        //-----------获取目录以及文件列表
        string str_TempFileStr;
        string str_TrStart = "<tr class=\"TR_BG_list\" onmouseover=\"javascript:overColor(this);\" onmouseout=\"javascript:outColor(this);\">";
        string str_TrEnd = "</tr>";
        string str_TdStart = "<td class=\"list_link\" align=\"left\">";
        string str_TdEnd = "</td>";
        string Str_TempParentstr;
        string TempParentPath = dir.Replace("\\", "\\\\");      //路径转意


        //------------取得当前所在目录
        if (ParPath == "" || ParPath == null || ParPath == string.Empty || ParPath == "undefined")
        {
            Str_TempParentstr = "当前目录:" + dir;
        }
        else
        {
            string _str_TempletTF = "";
            if (SiteID == "0")
            {
                _str_TempletTF = str_dirMana + "\\" + str_Templet;
            }
            else
            {
                _str_TempletTF = str_dirMana + "\\" + NetCMS.Config.UIConfig.dirSite + "\\" + NetCMS.Global.Current.SiteID + "\\" + str_Templet;
            }
            if (dir == Server.MapPath(_str_TempletTF))      //判断是否是模板目录,如果是则不显示返回上级目录
            {
                Str_TempParentstr = "当前目录:" + _str_TempletTF.Replace("\\", "/");
            }
            else
            {
                string str_thispath = "";
                if (str_dirMana != null && str_dirMana != "")
                    str_thispath = Server.MapPath(str_dirMana);
                else
                    str_thispath = Server.MapPath("/");

                ParPath = ParPath.Replace("\\", "\\\\");
                string Str_strpath = TempParentPath.Remove(TempParentPath.LastIndexOf("\\") - 1).Replace(str_FilePath.Replace("\\", "\\\\"), "");//获取当前目录的上级目录
                Str_TempParentstr = "<a href=\"javascript:ListGo('" + Str_strpath.Replace(str_FilePath.Replace("\\", "\\\\"), "") + "','" + TempParentPath.Replace(str_FilePath.Replace("\\", "\\\\"), "") + "');\" class=\"list_link\" title=\"点击回到上级目录\">返回上级目录</a>   |   当前目录:/" + dir.Replace(str_thispath, "").Replace("\\", "/");
            }
        }
        ShowAddfiledir(TempParentPath.Replace(str_FilePath.Replace("\\", "\\\\"), "")); //调用显示创建目录,导入文件函数

        str_TempFileStr = "<table border=\"0\" class=\"table\" width=\"100%\" cellpadding=\"5\" cellspacing=\"1\">";
        str_TempFileStr += str_TrStart + "<td class=\"list_link\" align=\"left\"colspan=\"5\">" + Str_TempParentstr + str_TrEnd;
        str_TempFileStr += "</table>";
        str_TempFileStr += "<table border=\"0\" class=\"table\" width=\"100%\" cellpadding=\"5\" cellspacing=\"1\">";
        str_TempFileStr += "<tr class=\"TR_BG\">";

        str_TempFileStr += str_TdStart + "名称" + str_TdEnd;
        str_TempFileStr += str_TdStart + "类型" + str_TdEnd;
        str_TempFileStr += str_TdStart + "大小(byte)" + str_TdEnd;
        str_TempFileStr += str_TdStart + "最后修改时间" + str_TdEnd;
        str_TempFileStr += str_TdStart + "操作" + str_TdEnd;
        str_TempFileStr += str_TrEnd;
        //---------------获取目录信息
        TempParentPath = TempParentPath.Replace(str_FilePath.Replace("\\", "\\\\"), "");

        foreach (DirectoryInfo dirInfo in ChildDirectory)       //获取此级目录下的一级目录
        {
            str_TempFileStr += str_TrStart;
            string TempPath = dirInfo.FullName.Replace("\\", "\\\\");

            TempPath = TempPath.Replace(str_FilePath.Replace("\\", "\\\\"), "");

            str_TempFileStr += "<td class=\"list_link\" align=\"left\"><img src=\"../../sysImages/FileIcon/folder.gif\" alt=\"点击进入下级目录\"><a href=\"javascript:ListGo('" + TempPath + "','" + TempParentPath + "');\" class=\"list_link\" title=\"点击进入下级目录\">" + dirInfo.Name.ToString() + "</a></td>";
            str_TempFileStr += str_TdStart + "文件夹</td>";
            str_TempFileStr += str_TdStart + "-" + str_TdEnd;
            str_TempFileStr += str_TdStart + "<span style=\"font-size:10px\">" + dirInfo.LastWriteTime.ToString() + "</span>" + str_TdEnd;
            str_TempFileStr += str_TdStart + "<a href=\"javascript:EditFolder('" + TempParentPath + "','" + dirInfo.Name + "');\" class=\"list_link\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/editname.gif\" border=\"0\" alt=\"改名\" /></a><a href=\"javascript:DelDir('" + TempPath + "');\" class=\"list_link\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/del.gif\" border=\"0\" alt=\"删除\" />" + str_TdEnd;
            str_TempFileStr += str_TrEnd;
        }

        //--------------获取文件信息
        foreach (FileInfo DirFile in NewFileInfo)                    //获取此级目录下的所有文件
        {
            if (SelectFile(DirFile.Extension))                       //传入文件后缀名,判断是否是被显示的文件类型,默认显示html,htm,css
            {
                str_TempFileStr += str_TrStart;
                str_TempFileStr += "<td class=\"list_link\" align=\"left\"><img src=\"../../sysImages/FileIcon/" + GetFileIco(DirFile.Extension.ToString()) + "\">" + DirFile.Name.ToString() + str_TdEnd;
                str_TempFileStr += str_TdStart + DirFile.Extension.ToString() + "文件" + str_TdEnd;
                str_TempFileStr += str_TdStart + DirFile.Length.ToString() + str_TdEnd;
                str_TempFileStr += str_TdStart + "<span style=\"font-size:10px\">" + DirFile.LastWriteTime.ToString() + "</span>" + str_TdEnd;

                //str_TempFileStr += str_TdStart + "<a href=\"editor.aspx?dir=" + TempParentPath + "&ch=" + Request.QueryString["ch"] + "&filename=" + DirFile.Name + "\" class=\"list_link\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/editonline.gif\" border=\"0\" alt=\"可视编辑\" /></a><a href=\"Txteditor.aspx?dir=" + TempParentPath + "&ch=" + Request.QueryString["ch"] + "&filename=" + DirFile.Name + "\" class=\"list_link\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/edittxt.gif\" border=\"0\" alt=\"文本编辑\" /></a><a href='http://" + DomainAndPort + str_dirMana + "\\" + PathPre() + "\\" + DirFile.Name + "' class=\"list_link\" target=\"_blank\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/review.gif\" border=\"0\" alt=\"预览\" /></a><a href=\"javascript:EditFile('" + TempParentPath + "','" + DirFile.Name + "')\" class=\"list_link\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/editname.gif\" border=\"0\" alt=\"改名\" /></a><a href=\"javascript:DelFile('" + TempParentPath + "','" + DirFile.Name + "')\" class=\"list_link\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/del.gif\" border=\"0\" alt=\"删除\" /></a>" + str_TdEnd;
                str_TempFileStr += str_TdStart + "<a href=\"Txteditor.aspx?dir=" + TempParentPath + "&ch=" + Request.QueryString["ch"] + "&filename=" + DirFile.Name + "\" class=\"list_link\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/edittxt.gif\" border=\"0\" alt=\"文本编辑\" /></a><a href='http://" + DomainAndPort + str_dirMana + "\\" + PathPre() + "\\" + DirFile.Name + "' class=\"list_link\" target=\"_blank\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/review.gif\" border=\"0\" alt=\"预览\" /></a><a href=\"javascript:EditFile('" + TempParentPath + "','" + DirFile.Name + "')\" class=\"list_link\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/editname.gif\" border=\"0\" alt=\"改名\" /></a><a href=\"javascript:DelFile('" + TempParentPath + "','" + DirFile.Name + "')\" class=\"list_link\"><img src=\"../../sysImages/" + NetCMS.Config.UIConfig.CssPath() + "/sysico/del.gif\" border=\"0\" alt=\"删除\" /></a>" + str_TdEnd;
                str_TempFileStr += str_TrEnd;
            }
        }

        str_TempFileStr += "</table>";
        return str_TempFileStr;
    }

    /// <summary>
    /// 获取上级目录
    /// </summary>
    /// <returns>获取上级目录</returns>
    /// Code By DengXi

    string PathPre()

⌨️ 快捷键说明

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