protected void Page_Load(object sender, EventArgs e) { LoginCheck.AdminManage(); //if (Session["FileName"] == null) //{ // Response.Redirect("../Default.aspx"); //} //// 注销 //if (Request.QueryString["act"] == "logout") //{ // Session.Clear(); // Response.Redirect("../Default.aspx"); //} // 操作处理 FileManagerProcessor fileManage = new FileManagerProcessor(Request.QueryString["act"]); builder.Append(fileManage.Value); if (string.IsNullOrEmpty(folderPath)) { folderPath = FileManagerProcessor.PagePath(); } // 组合路径, 快速导航 string comePath = ""; foreach (string q in folderPath.Split('\\')) { comePath += q; currPath.AppendFormat("<a href=\"Main.aspx?path={1}\">{0}</a>", q + "\\", comePath); comePath += "\\"; } // 返回上级 if (new DirectoryInfo(folderPath).Root.ToString().Replace("\\", "") != folderPath.ToUpper()) { string previousFolder = folderPath.Substring(0, folderPath.LastIndexOf("\\")); backHtml = "<tr class=\"m-row2\"><td colspan=\"5\"><a href=\"Main.aspx?path=" + Server.UrlEncode(previousFolder) + "\"><img src=\"../Images/IcoLeft.gif\" alt=\"返回上级\" align=\"absmiddle\" /> 返回上级</a></td></tr>"; } else { folderPath += "\\"; } // 绑定数据 fileManage = new FileManagerProcessor(); List <FileFolderInfo> files = fileManage.GetDirectories(folderPath.Replace(FileManagerProcessor.PagePath1(), "")); if (fileManage.Access) { folderNum = fileManage.FolderNum; fileNum = fileManage.FileNum; rptList.DataSource = files; rptList.DataBind(); } else { builder.Append("无权限访问该目录. <a href='javascript:history.go(-1);' style='font-weight: normal'>后退</a>"); } if (builder.ToString() != "") { string builderResult = builder.ToString(); builder = new System.Text.StringBuilder(""); builder.AppendFormat("<script type=\"text/javascript\">$(\"#tips\").show(); $(\"#tipsMsg\").html(\"{0}\"); </script>", builderResult.Replace(@"\", @"\\")); } }
private void ReloadPage() { builder.Append(Out.Div("title", "在线FTP系统")); string act = Utils.GetRequest("act", "all", 1, "", ""); //建立文件 if (act == "createtext") { bool isfile = bool.Parse(Utils.GetRequest("isfile", "all", 1, @"^True|False#", "False")); string txtFilePath = Utils.GetRequest("txtFilePath", "all", 2, @"^[(A-Za-z0-9_)]{1,50}$", "文件名必须为1-50位字母或数字"); string txtFileExt = Utils.GetRequest("txtFileExt", "all", 2, @"^.txt|.wml|.html|.htm$", "扩展名选择出错"); string ddlEncode = Utils.GetRequest("ddlEncode", "all", 1, "", ""); string txtFileContent = Request["txtFileContent"]; if (txtFileContent.Length > 10000) { Utils.Error("文件内容不能超10000字", ""); } //拼接路径 string filePath = Server.UrlDecode(folderPath + "\\" + txtFilePath) + txtFileExt; if (isfile == false) { if (File.Exists(filePath)) { Utils.Success("此文件名在文件夹中已存在", Utils.getUrl("filemanager.aspx?path=" + folderPath)); } } string str = new FileManagerProcessor().SaveTextFile(filePath, txtFileContent, ddlEncode); Utils.Success(str, Utils.getUrl("filemanager.aspx?path=" + folderPath)); } // 其它操作处理 FileManagerProcessor fileManage = new FileManagerProcessor(act); if (!string.IsNullOrEmpty(fileManage.Value)) { //得到上一级的文件夹 string ordpath = ""; string Temps = ""; ordpath = Request["objfolder"]; if (string.IsNullOrEmpty(ordpath)) { ordpath = Request["objfile"]; } if (!string.IsNullOrEmpty(ordpath)) { string[] sTemp = ordpath.Split("\\".ToCharArray()); for (int i = 0; i < sTemp.Length - 1; i++) { Temps += "\\" + sTemp[i]; } Temps = Utils.Mid(Temps, 1, Temps.Length); Utils.Success(fileManage.Value, Utils.getUrl("filemanager.aspx?path=" + Server.UrlEncode(Temps))); } else { Utils.Success(fileManage.Value, Utils.getUrl("filemanager.aspx?path=" + folderPath)); } } if (string.IsNullOrEmpty(folderPath) || folderPath.ToUpper().IndexOf("\\FILES\\") == -1) { folderPath = Server.MapPath("\\FILES"); } // 组合路径, 快速导航 string comePath = ""; foreach (string q in folderPath.Split("\\".ToCharArray())) { comePath += q; //builder.AppendFormat("<br />当前路径:<a href=\"" + Utils.getUrl("filemanager.aspx?path={1}") + "\">{0}</a>", q + "\\", comePath); comePath += "\\"; } // 返回上一级 if (new DirectoryInfo(folderPath).Root.ToString().Replace("\\", "") != folderPath.ToUpper()) { //string previousFolder = folderPath.Substring(0, folderPath.LastIndexOf("\\")); //builder.Append("<br /><a href=\""+Utils.getUrl("filemanager.aspx?path=" + Server.UrlEncode(previousFolder) + "")+"\">返回上一级</a>"); } else { folderPath += "\\"; } int pageIndex; int recordCount; string path = comePath; int pageSize = Convert.ToInt32(ub.Get("SiteListNo")); string[] pageValUrl = { "path" }; pageIndex = Utils.ParseInt(Request.QueryString["page"]); if (pageIndex == 0) { pageIndex = 1; } // 列表数据 fileManage = new FileManagerProcessor(); List <FileFolderInfo> files = fileManage.GetDirectories(folderPath); if (fileManage.Access) { folderNum = fileManage.FolderNum; fileNum = fileManage.FileNum; recordCount = folderNum + fileNum; if (files.Count > 0) { builder.Append(Out.Tab("<div class=\"text\">", "<br />")); builder.Append("本文件夹共" + folderNum + "文件夹," + fileNum + "文件"); builder.Append(Out.Tab("</div>", "<br />~~~~~~")); int stratIndex = (pageIndex - 1) * pageSize; int endIndex = pageIndex * pageSize; int k = 0; foreach (FileFolderInfo n in files) { if (k >= stratIndex && k < endIndex) { if ((k + 1) % 2 == 0) { builder.Append(Out.Tab("<div class=\"text\">", "<br />")); } else { builder.Append(Out.Tab("<div>", "<br />")); } if (!string.IsNullOrEmpty(n.Ext)) { builder.AppendFormat("{0}大小:{1}", n.FormatName, n.Size); } else { builder.AppendFormat("{0}", n.FormatName); } if (Utils.Isie()) { builder.Append("<a href=\"" + Utils.getUrl("filemanager.aspx?info=rename&path=" + Server.UrlEncode(folderPath) + "&file=" + n.FullName + "&filename=" + n.Name + "") + "\"><img src=\"/Files/sys/IcoAdd.gif\"/></a>"); builder.Append("<a href=\"" + Utils.getUrl("filemanager.aspx?info=delete&path=" + Server.UrlEncode(folderPath) + "&file=" + n.FullName + "&filename=" + n.Name + "&type=" + n.Type + "") + "\"><img src=\"/Files/sys/IcoDelete.gif\"/></a>"); } else { builder.Append("<a href=\"" + Utils.getUrl("filemanager.aspx?info=rename&path=" + Server.UrlEncode(folderPath) + "&file=" + n.FullName + "&filename=" + n.Name + "") + "\">[改名]</a>"); builder.Append("<a href=\"" + Utils.getUrl("filemanager.aspx?info=delete&path=" + Server.UrlEncode(folderPath) + "&file=" + n.FullName + "&filename=" + n.Name + "&type=" + n.Type + "") + "\">[删除]</a>"); } builder.AppendFormat("修改时间:{0}", n.ModifyDate); builder.Append(Out.Tab("</div>", "")); } if (k == endIndex) { break; } k++; } } // 分页 builder.Append(BasePage.MultiPage(pageIndex, pageSize, recordCount, Utils.getPageUrl(), pageValUrl, "page", 0)); } else { builder.Append(Out.Tab("", "<br />")); builder.Append(Out.Div("text", "无权限访问该文件夹")); } builder.Append(Out.Tab("<div class=\"hr\"></div>", Out.Hr())); builder.Append(Out.Tab("<div>", "")); if (folderPath.ToUpper().IndexOf("\\FILES\\") != -1) { builder.Append("新建:<a href=\"" + Utils.getUrl("filemanager.aspx?info=directory&path=" + Server.UrlEncode(folderPath) + "") + "\">文件夹</a> "); builder.Append("<a href=\"" + Utils.getUrl("filemanager.aspx?info=text&path=" + Server.UrlEncode(folderPath) + "") + "\">文件</a> "); if (Utils.getstrVe().Contains("1")) { string VE = ConfigHelper.GetConfigString("VE"); string SID = ConfigHelper.GetConfigString("SID"); builder.Append("<a href=\"filemanager.aspx?info=file&path=" + Server.UrlEncode(folderPath) + "&" + VE + "=2a&" + SID + "=" + Utils.getstrU() + "\">上传</a> "); } else { builder.Append("<a href=\"" + Utils.getUrl("filemanager.aspx?info=file&path=" + Server.UrlEncode(folderPath) + "") + "\">上传</a> "); } builder.Append("<a href=\"" + Utils.getUrl("filemanager.aspx?info=collec&path=" + Server.UrlEncode(folderPath) + "") + "\">采集</a><br />"); } else { builder.Append("<a href=\"" + Utils.getUrl("filemanager.aspx?info=directory&path=" + Server.UrlEncode(folderPath) + "") + "\">新建文件夹</a><br />"); } // 返回上一级 if (folderPath.ToUpper().IndexOf("\\FILES\\") != -1) { string previousFolder = folderPath.Substring(0, folderPath.LastIndexOf("\\")); builder.Append("<a href=\"" + Utils.getUrl("filemanager.aspx?path=" + Server.UrlEncode(previousFolder) + "") + "\">返回上一级</a><br />"); builder.Append("<a href=\"" + Utils.getUrl("filemanager.aspx") + "\">返回主文件夹</a><br />"); } builder.Append("<a href=\"" + Utils.getUrl("default.aspx") + "\">系统服务中心</a><br />"); builder.Append(Out.Tab("</div><div class=\"title\"><a href=\"" + Utils.getUrl("../default.aspx") + "\">返回管理中心</a>", "<a href=\"" + Utils.getUrl("../default.aspx") + "\">返回管理中心</a>")); builder.Append(Out.Tab("</div>", "<br />")); }