/// <summary> /// 删除文件夹或文件 /// </summary> protected void Delete() { string deletepath = PressRequest.GetQueryString("deletepath"); string category = PressRequest.GetQueryString("category", true).ToLower(); string return_deletepath = deletepath.Substring(0, deletepath.LastIndexOf('/') + 1); if (Jqpress.Blog.Common.BasePage.CurrentUser.UserType != (int)UserType.Administrator) { Response.Redirect(FileName + "?path=" + return_deletepath + "&result=444"); } if (deletepath.IndexOf("upfiles") != -1) { if (category.IndexOf("directory") != -1) { Directory.Delete(Server.MapPath(deletepath), true); } else if (category.IndexOf("archive") != -1) { File.Delete(Server.MapPath(deletepath)); } } Response.Redirect(FileName + "?path=" + return_deletepath + "&result=3"); }
/// <summary> /// 删除路径下相应文件 /// </summary> /// <returns></returns> public ActionResult DeleteFile() { string path = PressRequest.GetQueryString("path").Trim(); string url = PressRequest.GetQueryString("url").Trim(); if (System.IO.File.Exists(path) || Directory.Exists(path)) { if (System.IO.File.Exists(path)) { System.IO.FileInfo file = new System.IO.FileInfo(path); file.Delete(); } else { if (Directory.Exists(path)) { DirectoryInfo di = new DirectoryInfo(path); di.Delete(true); } } } var fromurl = Request.UrlReferrer.ToString(); return(Redirect(fromurl)); }
public ActionResult Upload() { var file = Request.Files["FileUpload"]; string basepath = PressRequest.GetQueryString("path"); if (file != null) { if (string.IsNullOrEmpty(urlpath)) { urlpath = rootpath; } var savepath = Server.MapPath(urlpath + "/" + file.FileName); if (FileHelper.FileExists(savepath)) { return(Content("<script>alert('此文件名已存在');location.href=\"/admin/files/list?path=" + urlpath + "\";</script>")); } else { try { file.SaveAs(savepath); } catch (Exception e) { return(Content("<script>alert('文件格式不正确,请确认图片是否能打开');location.href=\"/admin/files/list?path=" + urlpath + "\";</script>")); } } return(Content("<script>location.href=\"/admin/files/list?path=" + urlpath + "\"; </script>")); } return(JavaScript("<script>alert('上传失败');</script>")); }
public ActionResult List() { var model = new PostListModel(); string keyword = StringHelper.SqlEncode(PressRequest.GetQueryString("keyword")); int categoryId = PressRequest.GetQueryInt("categoryid", -1); int userId = PressRequest.GetQueryInt("userid", -1); int hide = PressRequest.GetQueryInt("hide", -1); var catelist = _categoryService.GetCategoryList(); const int pageSize = 10; int count = 0; int pageIndex = PressRequest.GetInt("page", 1); int cateid = PressRequest.GetQueryInt("cateid", -1); int tagid = PressRequest.GetQueryInt("tagid", -1); catelist.Add(new CategoryInfo() { CateName = "全部", CategoryId = -1 }); model.CateSelectItem = catelist.ConvertAll(c => new SelectListItem { Text = c.CateName, Value = c.CategoryId.ToString(), Selected = c.CategoryId == cateid }); if (cateid > 0) { pageIndex = pageIndex + 1; } var postlist = _postService.GetPostPageList(pageSize, pageIndex, out count, categoryId.ToString(), tagid, -1, -1, -1, -1, -1, "", "", keyword); model.PageList.LoadPagedList(postlist); model.PostList = (List <PostInfo>)postlist; return(View(model)); }
/// <summary> /// 保存主题 /// </summary> /// <returns></returns> public ActionResult UseTheme() { var themename = PressRequest.GetQueryString("themename"); var config = SiteConfig.GetSetting(); config.Theme = themename; SiteConfig.UpdateSetting(); SuccessNotification("设置成功"); return(RedirectToAction("themes")); }
public ContentResult CreateFolder() { var root = "/upfiles/"; var foldername = PressRequest.GetQueryString("folder").Trim(); if (!string.IsNullOrEmpty(foldername)) { FileHelper.CreateDir(Server.MapPath(root + foldername)); return(Content("创建成功")); } return(Content("创建失败")); }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle("数据管理"); if (!System.IO.Directory.Exists(Server.MapPath(BackupPath))) { System.IO.Directory.CreateDirectory(Server.MapPath(BackupPath)); } // DbPath = Server.MapPath(ConfigHelper.SitePath + ConfigHelper.DbConnection); // System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath(ConfigHelper.SitePath + ConfigHelper.DbConnection)); // DbSize = ConvertUnit(file.Length); DbInfo = new FileInfo(Server.MapPath(ConfigHelper.SitePath + ConfigHelper.DbConnection)); string name = PressRequest.GetQueryString("name"); switch (OperateString) { //下载 case "down": FileInfo downFile = new FileInfo(Server.MapPath(BackupPath + name)); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment;filename=" + downFile.Name); Response.TransmitFile(downFile.FullName); Response.End(); break; //删除 case "delete": System.IO.File.Delete(Server.MapPath(BackupPath + name)); Response.Redirect("blog_db.aspx?result=3"); break; //还原 case "restore": File.Copy(Server.MapPath(BackupPath + name), DbInfo.FullName, true); Response.Redirect("blog_db.aspx?result=4"); break; default: break; } ShowResult(); }
public Site() { var theme = PressRequest.GetQueryString("theme"); if (!string.IsNullOrEmpty(theme)) { this.ThemeName = theme; } else { this.ThemeName = SiteConfig.GetSetting().Theme; } this.SiteName = SiteConfig.GetSetting().SiteName; this.SiteUrl = ConfigHelper.SiteUrl; this.MetaKeywords = SiteConfig.GetSetting().MetaKeywords; this.MetaDescription = SiteConfig.GetSetting().MetaDescription; this.SiteDescription = SiteConfig.GetSetting().SiteDescription; this.FooterHtml = SiteConfig.GetSetting().FooterHtml; }
/// <summary> /// batch delete post /// </summary> public ActionResult Deletes() { if (CurrentUser.Role != (int)UserRole.Administrator) { return(Content("没有权限")); } else { string strid = PressRequest.GetQueryString("strid"); if (strid.Length > 0) { foreach (string id in strid.Split(',')) { if (id != "") { _postService.DeletePost(Convert.ToInt32(id)); } } } return(Content("success")); } }
/// <summary> /// 绑定 /// </summary> protected void BindPostList() { string keyword = StringHelper.SqlEncode(PressRequest.GetQueryString("keyword")); int categoryId = PressRequest.GetQueryInt("categoryid", -1); int userId = PressRequest.GetQueryInt("userid", -1); int recommend = PressRequest.GetQueryInt("recommend", -1); int hide = PressRequest.GetQueryInt("hide", -1); // txtKeyword.Text = keyword; 暂时注释 ddlCategory.SelectedValue = categoryId.ToString(); //ddlAuthor.SelectedValue = userId.ToString(); // chkRecommend.Checked = recommend == 1 ? true : false; 暂时注释 //chkHideStatus.Checked = hide == 1 ? true : false; 暂时注释 int totalRecord = 0; List <PostInfo> list = PostService.GetPostList(Pager1.PageSize, Pager1.PageIndex, out totalRecord, categoryId, -1, userId, recommend, -1, -1, hide, string.Empty, string.Empty, keyword); rptPost.DataSource = list; rptPost.DataBind(); Pager1.RecordCount = totalRecord; }
/// <summary> /// 批量删除 /// </summary> protected void Deletes() { if (CurrentUser.UserType != (int)UserType.Administrator) { Response.Write("没有权限"); } else { string strid = PressRequest.GetQueryString("strid"); if (strid.Length > 0) { foreach (string id in strid.Split(',')) { if (id != "") { PostService.DeletePost(Convert.ToInt32(id)); } } } Response.Write("success"); } Response.End(); }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle("文章管理"); if (Operate == OperateType.Delete) { Delete(); } if (PressRequest.GetQueryString("action") == "deletes")//ajax批量删除 { Deletes(); } if (!IsPostBack) { LoadDefaultData(); BindPostList(); } ShowResult(); }
protected void Page_Load(object sender, EventArgs e) { SetPageTitle("主题管理"); string[] filelist = Directory.GetFileSystemEntries(Server.MapPath("../../themes/default")); foreach (string str in filelist) { // Response.Write(str+"<br>"); } // System.IO.Directory.Delete(Server.MapPath("../themes/test"),true); string type = PressRequest.GetQueryString("type", true); if (Operate == OperateType.Update) { BlogConfigInfo s = BlogConfig.GetSetting(); switch (type) { case "mobile": s.MobileTheme = themename; break; case "pc": default: s.Theme = themename; break; } BlogConfig.UpdateSetting(); Response.Redirect("theme_list.aspx?result=2"); } else if (Operate == OperateType.Insert) { string srcPath = Server.MapPath("../themes/" + themename); if (!string.IsNullOrEmpty(themename) && System.IO.Directory.Exists(srcPath)) { string aimPath = string.Empty; int count = 1; while (true) { count++; aimPath = Server.MapPath("../themes/" + themename + "-" + count); if (!System.IO.Directory.Exists(aimPath)) { break; } } CopyDir(srcPath, aimPath); Response.Redirect("theme_list.aspx?result=1"); } } else if (Operate == OperateType.Delete) { if (themename == "default") { Response.Redirect("theme_list.aspx?result=5"); } else { string path = Server.MapPath("../themes/" + themename); if (System.IO.Directory.Exists(path)) { System.IO.Directory.Delete(path, true); Response.Redirect("theme_list.aspx?result=3"); } } } ShowResult(); }
public HomeController() { var theme = PressRequest.GetQueryString("theme"); _themeService.InitTheme(theme); }