//验证权限 public void AuthCheck() { //---------------指定管理员权限管理 if (badmin.CheckLogin()) { //如果是管理员登录则不判断 } else if (buser.CheckLogin()) { //非管理员用户登录,开始判断 string userID = buser.GetLogin().UserID.ToString(); siteM = siteBll.SelByUserID(userID);//查找有无为该用户分配权限 if (siteM == null || !siteBll.AuthCheck(siteID, userID)) { function.WriteErrMsg("你没有管理站点的权限"); } rBtn.Visible = false; adminTR.Visible = false; userTR.Visible = true; siteList.DataSource = siteBll.SelAllByUserID(userID); siteList.DataTextField = "SiteName"; siteList.DataValueField = "SiteID"; siteList.DataBind(); siteList.SelectedValue = siteID; this.Title = "独立控制台-站点详情"; } else { function.WriteErrMsg("你无权限访问该站点!!"); } }
//验证权限 public void AuthCheck() { //---------------指定管理员权限管理 if (badmin.CheckLogin()) { //如果是管理员登录则不判断 } else if (buser.CheckLogin()) { //非管理员用户登录,开始判断 string userID = buser.GetLogin().UserID.ToString(); siteM = siteBll.SelByUserID(userID);//查找有无为该用户分配权限 if (siteM == null || !siteBll.AuthCheck(siteID, userID)) { function.WriteErrMsg("你没有管理站点的权限"); } } else { function.WriteErrMsg("你无权限访问该站点!!"); } }
protected void Page_Load(object sender, EventArgs e) { IdentityAnalogue ia = new IdentityAnalogue(); ia.CheckEnableSA(); //---------------指定管理员权限管理 M_Site_SiteList siteM = new M_Site_SiteList(); B_Site_SiteList siteBll = new B_Site_SiteList(); if (badmin.CheckLogin()) { //如果是管理员登录则不判断 } else if (buser.CheckLogin()) { string siteID = iis.Sites[siteName].Id.ToString(); //非管理员用户登录,开始判断 siteM = siteBll.SelByUserID(buser.GetLogin().UserID.ToString());//查找有无为该用户分配权限 if (siteM == null || !siteBll.AuthCheck(siteID, buser.GetLogin().UserID.ToString())) { function.WriteErrMsg("你没有管理站点的权限"); } this.Title = "独立控制台-文件浏览"; } else { function.WriteErrMsg("无权访问该页面"); return; } //-------------- if (function.isAjax())//删除 { string[] siteInfo; //站点名,索引,目标文件 string action = Request.Form["action"]; if (action.Equals("beginDown"))//开始下载 { siteInfo = Request.Form["fullPath"].Split(':'); Int32.TryParse(siteInfo[1], out index); StationGroup.RootPath = iis.Sites[siteInfo[0]].Applications[0].VirtualDirectories[index].PhysicalPath; if (!Directory.Exists(StationGroup.RootPath + StationGroup.ZipSavePath)) { Directory.CreateDirectory(StationGroup.RootPath + StationGroup.ZipSavePath); } if (File.Exists(StationGroup.RootPath + StationGroup.ZipSavePath + StationGroup.ZipName)) { File.Delete(StationGroup.RootPath + StationGroup.ZipSavePath + StationGroup.ZipName); } //ThreadPool.QueueUserWorkItem(MyThreadWork, tempPath + StationGroup.ZipName); ThreadPool.QueueUserWorkItem(MyThreadWork, sg); Response.End(); } else if (action.Equals("getProgress")) { Response.Write(progStatus); Response.End(); } else if (action.Equals("getUnZipProg")) { //根据长度 ,计算出百分比值后返回 Response.Write(ZipClass.GetPercent(ZipClass.unZipTotal, ZipClass.unZipProgress)); Response.End(); } siteInfo = Request.Form["fullPath"].Split(':'); int i = 0; if (siteInfo.Length < 3 || !Int32.TryParse(siteInfo[1], out i)) { Response.Write("信息错误,无法删除"); Response.Flush(); Response.End(); } string path = GetPath(siteInfo[0], i, siteInfo[2]);//获取全路径 if (action.Equals("del")) { try { if (!DeleteDirAndFile(path)) { Response.Write("文件不存在"); Response.Flush(); Response.End(); } } catch (Exception ex) { Response.Write(ex.Message); Response.Flush(); Response.End(); }//Response.Write("删除失败,目标文件正在使用或你无权限删除"); } else if (action.Equals("rename")) { string newPath = GetPath(siteInfo[0], i, "\\" + siteInfo[3]); //Response.Write(siteInfo[2]+":"+siteInfo[3]); if (!path.Equals(newPath)) { RenameDirAndFile(path.Trim(), newPath.Trim()); } } Response.Clear(); Response.Write(1); Response.Flush(); Response.End(); } //----------------AJAX END; siteName = Server.HtmlEncode(Request.QueryString["siteName"]); if (string.IsNullOrEmpty(siteName) || string.IsNullOrEmpty(Request.QueryString["index"]) || iis.Sites[siteName] == null) { function.WriteErrMsg("未选择要访问的站点名或该站点不存在."); } Int32.TryParse(Request.QueryString["index"], out index); StationGroup.RootPath = iis.Sites[siteName].Applications[0].VirtualDirectories[index].PhysicalPath; if (string.IsNullOrEmpty(iis.Sites[siteName].Bindings[index].Host)) { url = "http://LocalHost:" + iis.Sites[siteName].Bindings[index].EndPoint.Port; } else { url = "http://" + iis.Sites[siteName].Bindings[index].Host + ":" + iis.Sites[siteName].Bindings[index].EndPoint.Port; } if (!IsPostBack) { Call.HideBread(Master); Repeater1.DataSource = GetDirAndFileList(); Repeater1.DataBind(); string command = Request["command"];//如beginSetup开始安装等,快云安装传过来的 if (!string.IsNullOrEmpty(command)) { switch (command) { case "beginSetup": Page.ClientScript.RegisterStartupScript(this.GetType(), "", "beginDown();", true); //调用前台开始下载方法 break; default: break; } }//Command End; } }