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

📄 selectuserpic.aspx.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
📖 第 1 页 / 共 2 页
字号:
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 NetCMS.Content;
using System.IO;

public partial class configuration_system_selectuserpic : NetCMS.Web.UI.DialogPage
{
    public configuration_system_selectuserpic()
    {
        BrowserAuthor = EnumDialogAuthority.ForAdmin | EnumDialogAuthority.ForPerson;
    }
    private string str_dirMana = NetCMS.Config.UIConfig.dirDumm;
    private string str_dirSite = NetCMS.Config.UIConfig.dirSite;
    private string str_dirUserFile = NetCMS.Config.UIConfig.UserdirFile;
    private string str_dirFile = "";  //获取图片或者文件路径
    private string str_FilePath = "";
    bool tf = false;
    protected void Page_Load(object sender, EventArgs e)
    {
        str_dirFile = str_dirUserFile + "\\" + NetCMS.Global.Current.UserNum;
        
        Response.CacheControl = "no-cache";
        if (str_dirMana != "" && str_dirMana != null && str_dirMana != string.Empty)//判断虚拟路径是否为空,如果不是则加上//
            str_dirMana = "//" + str_dirMana;

        if (Request.QueryString["FileType"] == "user_Hpic")
        {
            getDefaultHead();
        }
        else
        {
            if (Request.QueryString["FileType"] == "user_pic")
                tf = true;

            string type = Request.Form["Type"];
            if (NetCMS.Global.Current.SiteID == "0")
            {
                str_FilePath = Server.MapPath(str_dirMana + "\\" + str_dirFile);
            }
            else
            {
                string _sitePath = str_dirMana + "\\" + str_dirSite + "\\" + str_dirFile;
                if (!Directory.Exists(Server.MapPath(_sitePath))) { Directory.CreateDirectory(Server.MapPath(_sitePath)); }
                str_FilePath = Server.MapPath(_sitePath);
            }
            string Path = str_FilePath + Request.Form["Path"];
            string ParentPath = str_FilePath + Request.Form["ParentPath"]; //父级
            try
            {
                if (Path.IndexOf(str_FilePath, 0) == -1 || ParentPath.IndexOf(str_FilePath, 0) == -1)
                    Response.End();
            }
            catch { }

            switch (type)
            {
                case "EidtDirName":     //修改文件夹名称
                    EidtDirName(Path);
                    break;
                case "EidtFileName":    //修改文件名称
                    EidtFileName(Path);
                    break;
                case "DelDir":          //删除文件夹
                    DelDir(Path);
                    break;
                case "DelFile":          //删除文件
                    DelFile(Path);
                    break;
                case "AddDir":
                    AddDir(Path);        //添加文件夹
                    break;
                default:
                    break;
            }

            ShowFile(str_FilePath, Path, 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 (!System.IO.Directory.Exists(defaultpath))
        {
            Directory.CreateDirectory(defaultpath);
        }

        if (path != "" && path != null && path != string.Empty)
        {
            defaultpath = path;
        }
        if (Directory.Exists(defaultpath) == false)            //判断模板目录是否存在
        {
            PageError("目录不存在", "selectuserpic.aspx");
        }
        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)
    {
        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_dirFileTF = "";
            if (NetCMS.Global.Current.SiteID == "0")
            {
                _str_dirFileTF = str_dirMana + "\\" + str_dirFile;
            }
            else
            {
                _str_dirFileTF = str_dirMana + "\\" + str_dirSite + "\\" + str_dirFile;
            }
            if (dir == Server.MapPath(_str_dirFileTF))      //判断是否是模板目录,如果是则不显示返回上级目录
            {
                Str_TempParentstr = "当前目录:" + _str_dirFileTF.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 = "<div style=\"padding-left:10px;\">" + Str_TempParentstr + "</div>";
        str_TempFileStr += "<div style=\"padding-left:10px;\">地址:<input type=\"text\" id=\"sUrl\" name=\"sUrl\" style=\"width:60%\" />&nbsp;<input type=\"button\" class=\"form\" name=\"Submit\" value=\"选择此文件\" onclick=\"ReturnValue(document.Templetslist.sUrl.value);\" /></div>";

        str_TempFileStr += "<table border=\"0\" class=\"table\" width=\"100%\" cellpadding=\"5\" cellspacing=\"1\">";
        //---------------获取目录信息
        TempParentPath = TempParentPath.Replace(str_FilePath.Replace("\\", "\\\\"), "");

        string str_parpath = TempParentPath.Replace("\\\\", "/");

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

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

            str_TempFileStr += str_TdStart + "<a href=\"javascript:EditFolder('" + TempParentPath + "','" + dirInfo.Name + "');\" class=\"list_link\"><img src=\"../../sysimages/folder/re.gif\" border=\"0\" alt=\"改名\" /></a><a href=\"javascript:DelDir('" + TempPath + "');\" class=\"list_link\"><img src=\"../../sysimages/folder/del.gif\" border=\"0\" alt=\"删除\" /></a> ";
            str_TempFileStr += " <img src=\"../../sysImages/FileIcon/folder.gif\" alt=\"点击进入下级目录\" border=\"0\"><a href=\"javascript:ListGo('" + TempPath + "','" + TempParentPath + "');\" class=\"list_link\" title=\"点击进入下级目录\">" + dirInfo.Name.ToString() + "</a></td>";
            str_TempFileStr += str_TrEnd;
        }

        //--------------获取文件信息
        foreach (FileInfo DirFile in NewFileInfo)                    //获取此级目录下的所有文件
        {
            if (SelectFile(DirFile.Extension))                       //传入文件后缀名,判断是否是被显示的文件类型,默认显示html,htm,css
            {
                string str_replace = "{@UserdirFile}";

                string str_picadress = str_dirMana + "/" + str_replace + "/" + NetCMS.Global.Current.UserNum + "/" + str_parpath + "/" + DirFile.Name;
                str_picadress = str_picadress.Replace("//", "/");

                string str_picshowadress = str_dirMana + "/" + str_dirFile + "/" + str_parpath + "/" + DirFile.Name;
                str_picshowadress = str_picshowadress.Replace("//", "/");
                str_picshowadress = str_picshowadress.Replace("\\", "/");
                string str_showpic = "";
                if (tf == true)
                    str_showpic = "onmouseover=\"javascript:ShowDivPic(this,'" + str_picshowadress + "','" + DirFile.Extension + "'," + DirFile.Length + ");\" onmouseout=\"javascript:hiddDivPic();\"";

                str_TempFileStr += str_TrStart;
                str_TempFileStr += str_TdStart + "<a href=\"javascript:EditFile('" + TempParentPath + "','" + DirFile.Name + "')\" class=\"list_link\"><img src=\"../../sysimages/folder/re.gif\" border=\"0\" alt=\"改名\" /></a><a href=\"javascript:DelFile('" + TempParentPath + "','" + DirFile.Name + "')\" class=\"list_link\"><img src=\"../../sysimages/folder/del.gif\" border=\"0\" alt=\"删除\" /></a> ";
                str_TempFileStr += " <img src=\"../../sysImages/FileIcon/" + GetFileIco(DirFile.Extension.ToString()) + "\"><a class=\"list_link\" href=\"javascript:sFiles('" + str_picadress + "');\" " + str_showpic + "  ondblclick=\"ReturnValue(document.Templetslist.sUrl.value);\">" + DirFile.Name.ToString() + str_TdEnd;
                str_TempFileStr += str_TrEnd;
            }
        }

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

    protected void getDefaultHead()
    {
        tf = true;
        FileInfo[] NewFileInfo;                                 //当前所有文件

        DirectoryInfo FatherDirectory = new DirectoryInfo(Server.MapPath(str_dirMana + "/sysImages/user/face")); //当前目录
        NewFileInfo = FatherDirectory.GetFiles();               //得到文件集,可以进行操作
        //--------------获取文件信息
        string str_TempFileStr = "<input type=\"hidden\" id=\"sUrl\" name=\"sUrl\" style=\"width:60%\" />" +
                                 "<table border=\"0\" class=\"table\" width=\"100%\" cellpadding=\"5\" cellspacing=\"1\">";
        foreach (FileInfo DirFile in NewFileInfo) 
        {
            if (SelectFile(DirFile.Extension))
            {
                string str_picshowadress = "/sysImages/user/face/" + DirFile.Name;
                string str_showpic = "onmouseover=\"javascript:ShowDivPic(this,'" + str_picshowadress + "','" + DirFile.Extension + "'," + DirFile.Length + ");\" onmouseout=\"javascript:hiddDivPic();\"";

                str_TempFileStr += "<tr class=\"TR_BG_list\" onmouseover=\"javascript:overColor(this);\" onmouseout=\"javascript:outColor(this);\">";
                str_TempFileStr += "<td class=\"list_link\" align=\"left\"><img src=\"../../sysImages/FileIcon/" + GetFileIco(DirFile.Extension.ToString()) + "\"><a class=\"list_link\" href=\"javascript:ReturnValue('" + str_dirMana + "/sysImages/user/face/" + DirFile.Name + "');\" " + str_showpic + ">" + DirFile.Name.ToString() + "</td>";
                str_TempFileStr += "</tr>";
            }
        }
        str_TempFileStr += "</table>";
        File_List.InnerHtml = str_TempFileStr;
    }


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

    string PathPre()
    {
        NetCMS.Content.Templet.Templet tpClass = new NetCMS.Content.Templet.Templet();
        string str_path = tpClass.PathPre(str_FilePath + Request.Form["Path"], str_dirFile);
        return str_path;
    }

    /// <summary>
    /// 判断文件后缀名,选取要列举出来的文件
    /// </summary>
    /// <param name="Extension">文件后缀名</param>
    /// <returns>如果是所列举的类型,则返回true,否则为false</returns>
    /// Code By DengXi

    protected bool SelectFile(string Extension)
    {
        bool value = false;
        if (tf == false)
        {
            switch (Extension.ToLower())
            {
                case ".htm":
                    value = true;
                    break;
                case ".html":
                    value = true;
                    break;
                case ".shtm":
                    value = true;
                    break;
                case ".shtml":
                    value = true;

⌨️ 快捷键说明

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