/// <summary> /// 相册相关页面的弹出导航菜单HTML内容 /// </summary> /// <returns></returns> public static string GetPhotoListMenuDivCache() { string val = DNTCache.GetCacheService().RetrieveObject("/Photo/AlbumCategoryMenu") as string; if (val != null) { return(val); } StringBuilder sb = new StringBuilder(); Discuz.Common.Generic.List <AlbumCategoryInfo> acic = DTOProvider.GetAlbumCategory(); if (acic.Count > 0) { sb.Append("<div id=\"NavHome_menu\" class=\"NavHomeMenu\" style=\"display:none\"><div id=\"NavHomeWindow\"><ul>"); foreach (AlbumCategoryInfo aci in acic) { sb.AppendLine("<li><a href=\"showalbumlist.aspx?cate="); sb.AppendLine(aci.Albumcateid.ToString()); sb.Append("\">"); sb.AppendLine(aci.Title); sb.AppendLine("</a></li>"); } sb.Append("</ul></div></div>"); } DNTCache.GetCacheService().AddObject("/Photo/AlbumCategoryMenu", sb.ToString()); return(sb.ToString()); }
protected override string OnAttachCreated(Discuz.Entity.AttachmentInfo[] attachs, int usergroupid, int userid, string username) { if (attachs == null) { return(""); } string[] albumsid = DNTRequest.GetString("albums") == "" ? null : DNTRequest.GetString("albums").Split(','); if (albumsid == null) { return(""); } int maxphotosize = UserGroups.GetUserGroupInfo(usergroupid).Maxspacephotosize; int currentphotisize = DbProvider.GetInstance().GetPhotoSizeByUserid(userid); if (attachs.Length + 2 == albumsid.Length)//验证提交上来的albums数据是否是合法可用数据,因为albums数据提交逗号数组头尾各有一个0,则合法数据位附件list长度加2==albums元素个数 { for (int i = 0; i < attachs.Length; i++) { if (attachs[i].Filename != "" && (attachs[i].Filetype == "image/pjpeg") || (attachs[i].Filetype == "image/gif") || (attachs[i].Filetype == "image/x-png")) { //由于提交上来的albums数据是头尾各含有一个值为0的元素的数组,则和第一个附件对应的相册ID其实是第二个值 string aid = albumsid[i + 1]; if (aid != "0") { if ((maxphotosize - currentphotisize - (int)attachs[i].Filesize) > 0) { string filename = Utils.GetMapPath(BaseConfigs.GetForumPath + "upload/" + attachs[i].Filename.Replace('\\', '/')); string extension = Path.GetExtension(filename); Common.Thumbnail.MakeThumbnailImage(filename, filename.Replace(extension, "_thumbnail" + extension), 150, 150); Common.Thumbnail.MakeSquareImage(filename, filename.Replace(extension, "_square" + extension), 100); PhotoInfo photoinfo = new PhotoInfo(); photoinfo.Filename = "upload/" + attachs[i].Filename.Replace('\\', '/'); photoinfo.Attachment = attachs[i].Attachment; photoinfo.Filesize = (int)attachs[i].Filesize; photoinfo.Title = attachs[i].Attachment.Remove(attachs[i].Attachment.IndexOf(".")); photoinfo.Description = attachs[i].Description; photoinfo.Albumid = int.Parse(aid); photoinfo.Userid = userid; photoinfo.Username = username; photoinfo.Views = 0; photoinfo.Commentstatus = 0; photoinfo.Tagstatus = 0; photoinfo.Comments = 0; photoinfo.IsAttachment = 1; DbProvider.GetInstance().AddSpacePhoto(photoinfo); AlbumInfo albumInfo = DTOProvider.GetAlbumInfo(Convert.ToInt32(aid)); albumInfo.Imgcount = DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(int.Parse(aid)); DbProvider.GetInstance().SaveSpaceAlbum(albumInfo); currentphotisize += (int)attachs[i].Filesize; } else { return("相册空间不足,可能有图片未能加入相册"); } } } } } return(""); }
protected override void ShowPage() { if (config.Enablealbum != 1) { AddErrLine("相册功能已被关闭"); return; } pagetitle = "图片排行"; announcementlist = Announcements.GetAnnouncementList(Utils.GetDateTime(), "2999-01-01 00:00:00"); if (announcementlist != null) { announcementcount = announcementlist.Rows.Count; } type = type < 0 ? 0 : type; type = type > 3 ? 3 : type; if (type < 3) { photolist = DTOProvider.GetPhotoRankList(type, photocount); } else { albumlist = DTOProvider.GetAlbumRankList(photocount); } //一周热图总排行 weekhotphotolist = AggregationFacade.AlbumAggregation.GetWeekHotPhotoList(photoconfig.Weekhot); //相册分类 albumcategorylist = DTOProvider.GetAlbumCategory(); recentupdatespaceList = AggregationFacade.SpaceAggregation.GetRecentUpdateSpaceList(AggregationConfig.GetConfig().RecentUpdateSpaceAggregationListCount); }
private void ChangeAlbum() { int targetAlbumId = TypeConverter.StrToInt(DNTRequest.GetFormString("alibumList")); int sourceAlbumId = albumid; string photoIdList = DNTRequest.GetFormString("photoid"); if (!Utils.IsNumericList(photoIdList)) { return; } if (DTOProvider.GetAlbumInfo(targetAlbumId).Userid != userid) { AddErrLine("您所选的目标相册不存在"); return; } DbProvider.GetInstance().ChangeAlbum(targetAlbumId, photoIdList, userid); AlbumInfo _sourceAlbum = DTOProvider.GetAlbumInfo(sourceAlbumId); _sourceAlbum.Imgcount = DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(sourceAlbumId); DbProvider.GetInstance().SaveSpaceAlbum(_sourceAlbum); AlbumInfo _targetAlbum = DTOProvider.GetAlbumInfo(targetAlbumId); _targetAlbum.Imgcount = DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(targetAlbumId); DbProvider.GetInstance().SaveSpaceAlbum(_targetAlbum); //生成json数据 Albums.CreateAlbumJsonData(albumid); SetUrl("usercpspacemanagephoto.aspx?albumid=" + albumid); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("照片转移完毕"); }
protected void DeleteApply_Click(object sender, EventArgs e) { #region ɾ³ýÏà²á string albumid = DNTRequest.GetString("albumid"); if (albumid.Trim() == "") { return; } foreach (string id in albumid.Split(',')) { #if NET1 PhotoInfoCollection _spacephotoinfoarray = BlogProvider.GetSpacePhotosInfo(DbProvider.GetInstance().GetSpacePhotoByAlbumID(int.Parse(id))); #else Discuz.Common.Generic.List <PhotoInfo> _spacephotoinfoarray = DTOProvider.GetSpacePhotosInfo(DbProvider.GetInstance().GetSpacePhotoByAlbumID(int.Parse(id))); #endif string photoidList = ""; int uid = DbProvider.GetInstance().GetUidByAlbumid(int.Parse(id)); if (_spacephotoinfoarray != null) { foreach (PhotoInfo _s in _spacephotoinfoarray) { photoidList += _s.Photoid + ","; } } if (photoidList != "") { photoidList = photoidList.Substring(0, photoidList.Length - 1); DbProvider.GetInstance().DeleteSpacePhotoByIDList(photoidList, int.Parse(id), uid); } DbProvider.GetInstance().DeleteSpaceAlbum(int.Parse(id), uid); } Response.Redirect("album_manage.aspx"); #endregion }
private void ModifyAlbumInfo() { string errorinfo = ""; string id = DNTRequest.GetFormString("albumid"); if (id == "0") { AlbumInfo albumInfo = new AlbumInfo(); albumInfo.Userid = userid; albumInfo.Username = username; albumInfo.Albumcateid = DNTRequest.GetFormInt("albumcate", 0); albumInfo.Title = Utils.HtmlEncode(DNTRequest.GetFormString("albumtitle")); albumInfo.Description = Utils.HtmlEncode(DNTRequest.GetFormString("albumdescription")); albumInfo.Password = DNTRequest.GetFormString("password"); albumInfo.Type = DNTRequest.GetFormInt("type", 0); Data.DbProvider.GetInstance().AddSpaceAlbum(albumInfo); } else { AlbumInfo albumInfo = DTOProvider.GetAlbumInfo(Convert.ToInt32(id)); if (albumInfo.Userid != userid) { AddErrLine("您所编辑的相册不存在"); return; } albumInfo.Title = Utils.HtmlEncode(DNTRequest.GetFormString("albumtitle")); albumInfo.Albumcateid = DNTRequest.GetFormInt("albumcate", 0); albumInfo.Description = Utils.HtmlEncode(DNTRequest.GetFormString("albumdescription")); albumInfo.Password = DNTRequest.GetFormString("password"); albumInfo.Type = DNTRequest.GetFormInt("type", 0); Data.DbProvider.GetInstance().SaveSpaceAlbum(albumInfo); } if (errorinfo == "") { SetUrl(string.Format("usercpspacemanagealbum.aspx?page={0}", DNTRequest.GetInt("page", 1))); SetMetaRefresh(); SetShowBackLink(true); if (id == "0") { AddMsgLine("相册增加成功"); } else { AddMsgLine("相册修改成功"); } return; } else { AddErrLine(errorinfo); return; } }
private void LoadAlbumInfo() { mod = "修改相册"; AlbumInfo albumInfo = DTOProvider.GetAlbumInfo(DNTRequest.GetInt("albumid", 0)); if (albumInfo.Userid != userid) { AddErrLine("您所编辑的相册不存在"); return; } title = albumInfo.Title; albumcateid = albumInfo.Albumcateid; description = albumInfo.Description; type = albumInfo.Type; albumpassword = albumInfo.Password; }
protected void DeleteApply_Click(object sender, EventArgs e) { #region ╔Й│§¤Я▓р int albumid = DNTRequest.GetInt("albumid", 0); int uid = DbProvider.GetInstance().GetUidByAlbumid(albumid); if (DNTRequest.GetFormString("photoid") == "") { return; } DbProvider.GetInstance().DeleteSpacePhotoByIDList(DNTRequest.GetFormString("photoid"), albumid, uid); AlbumInfo _AlbumInfo = DTOProvider.GetAlbumInfo(albumid); _AlbumInfo.Imgcount = DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(albumid);; DbProvider.GetInstance().SaveSpaceAlbum(_AlbumInfo); Response.Redirect("album_manage.aspx"); #endregion }
private void SetLogo() { int photoId = Convert.ToInt32(DNTRequest.GetFormString("logoList")); if (photoId == -1) { return; } PhotoInfo _spacephotoinfo = DTOProvider.GetPhotoInfo(DbProvider.GetInstance().GetPhotoByID(photoId, 0, 0)); AlbumInfo _AlbumInfo = DTOProvider.GetAlbumInfo(albumid); _AlbumInfo.Logo = Globals.GetThumbnailImage(_spacephotoinfo.Filename); DbProvider.GetInstance().SaveSpaceAlbum(_AlbumInfo); SetUrl("usercpspacemanagephoto.aspx?albumid=" + albumid); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("封面已经设置成功"); }
private void DeleteAlbumInfo() { int albumid = DNTRequest.GetInt("albumid", 0); if (DTOProvider.GetAlbumInfo(albumid).Userid != userid) { AddErrLine("您所删除的相册不存在"); return; } string errorinfo = ""; List <PhotoInfo> _spacephotoinfoarray = DTOProvider.GetSpacePhotosInfo(DbProvider.GetInstance().GetSpacePhotoByAlbumID(albumid)); string photoidList = ""; if (_spacephotoinfoarray != null) { foreach (PhotoInfo _s in _spacephotoinfoarray) { if (_s.Userid == userid) { photoidList += _s.Photoid + ","; } } } if (photoidList != "") { photoidList = photoidList.Substring(0, photoidList.Length - 1); Data.DbProvider.GetInstance().DeleteSpacePhotoByIDList(photoidList, albumid, userid); } Data.DbProvider.GetInstance().DeleteSpaceAlbum(albumid, userid); if (errorinfo == "") { SetUrl("usercpspacemanagealbum.aspx"); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("删除成功"); return; } else { AddErrLine(errorinfo); return; } }
protected void DataGrid1_EditCommand(object source, DataGridCommandEventArgs e) { #region 加载编辑分类 if (this.CheckCookie()) { //编辑一个分类 BindData(); int albumcateid = Utils.StrToInt(DataGrid1.DataKeys[e.Item.ItemIndex], 0); if (albumcateid > 0) { AlbumCategoryInfo aci = DTOProvider.GetAlbumCategory(albumcateid); this.albumcateTitle.Text = aci.Title; this.description.Text = aci.Description; this.displayorder.Text = aci.Displayorder.ToString(); } prompt.Text = "编辑相册分类"; } #endregion }
protected override void ShowPage() { pagetitle = config.Albumname + "首页"; if (config.Enablealbum != 1) { AddErrLine("相册功能已被关闭"); return; } if (config.Rssstatus == 1) { AddLinkRss("tools/photorss.aspx", "最新图片"); } announcementlist = Announcements.GetAnnouncementList(Utils.GetDateTime(), "2999-01-01 00:00:00"); if (announcementlist != null) { announcementcount = announcementlist.Rows.Count; } //轮显图片 rotatepicdata = AggregationFacade.AlbumAggregation.GetRotatePicData(); //推荐图片 recommendphotolist = AggregationFacade.AlbumAggregation.GetRecommandPhotoList("Albumindex"); //焦点图片 focusphotolist = AggregationFacade.AlbumAggregation.GetFocusPhotoList(photoconfig.Focusphotoshowtype, photoconfig.Focusphotocount, photoconfig.Focusphotodays); //推荐相册 recommendalbumlist = AggregationFacade.AlbumAggregation.GetRecommandAlbumList("Albumindex"); //焦点相册 focusalbumlist = AggregationFacade.AlbumAggregation.GetAlbumList(photoconfig.Focusalbumshowtype, photoconfig.Focusalbumcount, photoconfig.Focusalbumdays); //一周热图总排行 weekhotphotolist = AggregationFacade.AlbumAggregation.GetWeekHotPhotoList(photoconfig.Weekhot); //相册分类 albumcategorylist = DTOProvider.GetAlbumCategory(); if (config.Enablespace == 1) { recentupdatespaceList = AggregationFacade.SpaceAggregation.GetRecentUpdateSpaceList(AggregationConfig.GetConfig().RecentUpdateSpaceAggregationListCount); } }
/// <summary> /// 自定义模块加载时的行为 /// </summary> /// <param name="content"></param> /// <returns></returns> public override string OnMouduleLoad(string content) { if (AlbumPluginProvider.GetInstance() == null || GeneralConfigs.GetConfig().Enablealbum != 1) { return("相册插件未安装,模块暂不可用"); } UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref); int photocount = Utils.StrToInt(userprefs.GetValueByName("photocount"), 10); int albumid = Utils.StrToInt(userprefs.GetValueByName("albumid"), 0); List <PhotoInfo> photolist = DTOProvider.GetPhotoListByUserId(this.Module.Uid, albumid, photocount); StringBuilder sb = new StringBuilder(StaticFileProvider.GetContent(jsFile)); StringBuilder sbImgList = new StringBuilder(); for (int i = 0; i < photolist.Count; i++) { sbImgList.AppendFormat("data[\"-1_{0}\"] = \"img: {1}; url: {2}; target: _blank; \"\r\n", i + 1, BaseConfigs.GetForumPath + Discuz.Album.Globals.GetSquareImage(photolist[i].Filename), BaseConfigs.GetForumPath + "showalbumlist.aspx?uid=" + this.Module.Uid); } sb.Replace("{$templatepath}", BaseConfigs.GetForumPath + "templates/" + Templates.GetTemplateItem(GeneralConfigs.GetConfig().Templateid).Directory); sb.Replace("{$photolist}", sbImgList.ToString()); content = sb.ToString(); return(base.OnMouduleLoad(content)); }
private void DeletePhoto() { string photoIdList = DNTRequest.GetFormString("photoid"); if (!Utils.IsNumericList(photoIdList)) { return; } DbProvider.GetInstance().DeleteSpacePhotoByIDList(photoIdList, albumid, userid); AlbumInfo _AlbumInfo = DTOProvider.GetAlbumInfo(albumid); _AlbumInfo.Imgcount = DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(albumid); DbProvider.GetInstance().SaveSpaceAlbum(_AlbumInfo); //生成json数据 Albums.CreateAlbumJsonData(albumid); SetUrl("usercpspacemanagephoto.aspx?albumid=" + albumid); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("照片删除完毕"); }
protected override void ShowPage() { pagetitle = "编辑图片信息"; #region 验证 if (userid == -1) { AddErrLine("请先登录"); return; } user = Users.GetUserInfo(userid); if (config.Enablealbum != 1) { AddErrLine("相册功能已被关闭"); return; } if (photoid < 1) { AddErrLine("不存在的图片Id"); return; } photo = DTOProvider.GetPhotoInfo(photoid, 0, 0); if (photo == null) { AddErrLine("图片不存在"); return; } if (photo.Userid != userid) { AddErrLine("您没有编辑此图片的权限"); return; } #endregion if (!DNTRequest.IsPost()) { photo.Filename = Globals.GetThumbnailImage(photo.Filename); commentstatus = (int)photo.Commentstatus; tagstatus = (int)photo.Tagstatus; tags = AlbumTags.GetTagsByPhotoId(photoid); } else { photo.Title = DNTRequest.GetString("title"); photo.Description = DNTRequest.GetString("description"); if (commentstatus < 0 || commentstatus > 2) { commentstatus = 2; } photo.Commentstatus = (PhotoStatus)commentstatus; string newtags = DNTRequest.GetString("phototag").Trim(); string[] tagsArray = null; if (config.Enabletag == 1 && newtags != string.Empty && newtags != tags) { tagsArray = Utils.SplitString(newtags, " ", true, 10); if (tagsArray.Length > 0 && string.Join(" ", tagsArray) != tags) { DbProvider.GetInstance().DeletePhotoTags(photoid); DbProvider.GetInstance().CreatePhotoTags(string.Join(" ", tagsArray), photoid, userid, Utils.GetDateTime()); AlbumTags.WritePhotoTagsCacheFile(photoid); } } DTOProvider.UpdatePhotoInfo(photo); //生成json数据 Albums.CreateAlbumJsonData(photo.Albumid); //生成图片标题 Albums.CreatePhotoTitleImage(photo.Photoid, photo.Title); //生成用户名图片 Albums.CreateUserImage(photo.Userid, photo.Username); AddMsgLine("图片信息修改成功, 将返回图片列表"); SetUrl("usercpspacemanagephoto.aspx?albumid=" + photo.Albumid); SetMetaRefresh(); } }
protected override void ShowPage() { pagetitle = "用户控制面板"; if (userid == -1) { AddErrLine("你尚未登录"); return; } user = Users.GetUserInfo(userid); if (config.Enablealbum != 1) { AddErrLine("相册功能已被关闭"); return; } AlbumInfo albuminfo = DTOProvider.GetAlbumInfo(albumid); if (this.userid != albuminfo.Userid) { AddErrLine("您无权管理该相册"); return; } if (DNTRequest.IsPost()) { if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } string active = DNTRequest.GetFormString("active"); if (active == "delete") { DeletePhoto(); } else if (active == "change") { ChangeAlbum(); } else if (active == "setlogo") { SetLogo(); } return; } albumList = DbProvider.GetInstance().GetSpaceAlbumByUserId(userid); foreach (DataRow dr in albumList.Rows) { if (dr["albumid"].ToString() == albumid.ToString()) { currentalbumname = dr["title"].ToString().Trim(); albumList.Rows.Remove(dr); break; } } //获取主题总数 photocount = DbProvider.GetInstance().GetSpacePhotosCount(albumid); //获取总页数 pagecount = photocount % pagesize == 0 ? photocount / pagesize : photocount / pagesize + 1; if (pagecount == 0) { pagecount = 1; } //修正请求页数中可能的错误 if (pageid < 1) { pageid = 1; } if (pageid > pagecount) { pageid = pagecount; } //获取收入记录并分页显示 logoList.Columns.Add("photoid"); logoList.Columns.Add("PhotoOrder"); photoList = DbProvider.GetInstance().SpacePhotosList(pagesize, pageid, userid, albumid); if (photoList.Rows.Count == 0) { DataRow dr = logoList.NewRow(); dr["PhotoOrder"] = "无照片"; dr["photoid"] = "-1"; logoList.Rows.Add(dr); return; } int i = 1; photoList.Columns.Add("TFileName"); photoList.Columns.Add("PhotoOrder"); foreach (DataRow singlePhotoInfo in photoList.Rows) { //当是远程照片时 if (singlePhotoInfo["FileName"].ToString().Trim().ToLower().IndexOf("http") == 0) { singlePhotoInfo["TFileName"] = Globals.GetThumbnailImage(singlePhotoInfo["FileName"].ToString().Trim()); } else { singlePhotoInfo["TFileName"] = Globals.GetThumbnailImage(BaseConfigs.GetForumPath + singlePhotoInfo["FileName"].ToString().Trim()); } DataRow dr = logoList.NewRow(); dr["photoid"] = singlePhotoInfo["photoid"]; singlePhotoInfo["photoorder"] = "NO." + i; dr["PhotoOrder"] = "NO." + i; logoList.Rows.Add(dr); i++; } pagenumbers = Utils.GetPageNumbers(pageid, pagecount, "usercpspacemanagephoto.aspx?albumid=" + albumid, 8); }
public override Discuz.Entity.AlbumInfo GetAlbumInfo(int albumid) { return(DTOProvider.GetAlbumInfo(albumid)); }
public override Discuz.Entity.AlbumInfo GetAlbumEntity(System.Data.IDataReader reader) { return(DTOProvider.GetAlbumEntity(reader)); }
public override Discuz.Entity.PhotoInfo GetPhotoEntity(System.Data.IDataReader reader) { return(DTOProvider.GetPhotoEntity(reader)); }
/// <summary> /// 自定义编辑设置框内容 /// </summary> /// <param name="editbox">编辑框原内容</param> /// <returns></returns> public override string OnEditBoxLoad(string editbox) { if (GeneralConfigs.GetConfig().Enablealbum != 1) { this.Editable = false; return(""); } this.Editable = true; UserPrefsSaved userprefs = new UserPrefsSaved(this.Module.UserPref); editbox = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">"; //显示的相册Id,0为全部相册 string value = userprefs.GetValueByName("albumid"); value = value == string.Empty ? "0" : value; int albumid = Utils.StrToInt(value, 0); List <AlbumInfo> albumlist = DTOProvider.GetSpaceAlbumList(this.Module.Uid, 0, Utils.StrToInt(AlbumConfigs.GetConfig().MaxAlbumCount, 0), 1); string options = string.Empty; if (albumid == 0) { options += "<option value=\"0\" selected>全部" + GeneralConfigs.GetConfig().Albumname + "</option>"; } else { options += "<option value=\"0\">全部" + GeneralConfigs.GetConfig().Albumname + "</option>"; } foreach (AlbumInfo album in albumlist) { if (album.Albumid == albumid) { options += string.Format("<option value=\"{0}\" selected>{1}</option>", album.Albumid, album.Title); this.ModulePref.Title = album.Title; } else { options += string.Format("<option value=\"{0}\">{1}</option>", album.Albumid, album.Title); } } editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{3}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\"> <select id=\"m___MODULE_ID___0\" name=\"m___MODULE_ID___up_{1}\">{2}</select></td></tr>", "选择" + GeneralConfigs.GetConfig().Albumname + ": ", "albumid", options, ""); //显示图片数 value = userprefs.GetValueByName("photocount"); value = value == "" ? "10" : value; int photocount = Utils.StrToInt(value, 10); if (photocount > 10 || photocount < 3) { photocount = 10; } options = string.Empty; for (int i = 3; i <= 10; i++) { if (photocount == i) { options += string.Format("<option value=\"{0}\" selected>{0} 张</option>", i); } else { options += string.Format("<option value=\"{0}\">{0} 张</option>", i); } } editbox += string.Format("<tr><td colspan=\"1\" align=\"right\" width=\"35%\"><nobr>{0}{3}</nobr></td><td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" width=\"65%\"> <select id=\"m___MODULE_ID___0\" name=\"m___MODULE_ID___up_{1}\">{2}</select></td></tr>", "展示图片数量: ", "photocount", options, ""); editbox += "</table>"; return(base.OnEditBoxLoad(editbox)); }
protected override void ShowPage() { pagetitle = "用户控制面板"; if (userid == -1) { AddErrLine("你尚未登录"); return; } user = Users.GetUserInfo(userid); if (config.Enablealbum != 1) { AddErrLine("相册功能已被关闭"); return; } if (albumid < 1) { AddErrLine("指定的相册不存在"); return; } AlbumInfo albuminfo = DTOProvider.GetAlbumInfo(albumid); if (this.userid != albuminfo.Userid) { AddErrLine("您无权限在该相册内添加照片"); return; } enabletag = config.Enabletag == 1; freephotosize = UserGroups.GetUserGroupInfo(usergroupid).Maxspacephotosize - Data.DbProvider.GetInstance().GetPhotoSizeByUserid(userid); albumname = albuminfo.Title; if (DNTRequest.IsPost()) { if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } HttpFileCollection files = HttpContext.Current.Request.Files; int imgcount = 0; for (int iFile = 0; iFile < files.Count; iFile++) { HttpPostedFile postedFile = files[iFile]; if (postedFile == null || postedFile.FileName == "") { continue; } string fileName, fileExtension; fileName = Path.GetFileName(postedFile.FileName); fileExtension = Path.GetExtension(fileName).ToLower(); if (fileExtension != ".jpg" && fileExtension != ".gif" && fileExtension != ".png" && fileExtension != ".jpeg") { continue; } //判断用户是否达到了照片最大上传数 int filesize = postedFile.ContentLength; if (freephotosize < filesize) { AddErrLine("照片上传空间数已满,某些照片不能再上传!<br />如果想继续上传,请删除以前旧照片!"); return; } string phototitle = Utils.HtmlEncode(DNTRequest.GetFormString("phototitle" + (iFile + 1))); PhotoInfo spacephotoinfo = new PhotoInfo(); spacephotoinfo.Title = Utils.StrIsNullOrEmpty(phototitle) ? fileName.Remove(fileName.IndexOf("."), 1) : phototitle; spacephotoinfo.Albumid = albumid; spacephotoinfo.Userid = userid; string[] currentdate = DateTime.Now.ToString("yyyy-MM-dd").Split('-'); string uploaddir = ""; //当支持FTP上传远程照片 if (FTPs.GetAlbumAttachInfo.Allowupload == 1) { //当不保留本地附件模式时 if (FTPs.GetAlbumAttachInfo.Reservelocalattach == 0) { uploaddir = Utils.GetMapPath(BaseConfigs.GetForumPath + "space/upload/temp/"); } else { uploaddir = Utils.GetMapPath(BaseConfigs.GetForumPath + "space/upload/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/"); } if (!Directory.Exists(uploaddir)) { Utils.CreateDir(uploaddir); } string ftpfilename = Globals.UploadSpaceFile(postedFile, uploaddir, true); spacephotoinfo.Filename = FTPs.GetAlbumAttachInfo.Remoteurl + "/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/" + ftpfilename; FTPs ftps = new FTPs(); ftps.UpLoadFile("/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/", uploaddir + ftpfilename, FTPs.FTPUploadEnum.AlbumAttach); ftps = new FTPs(); ftps.UpLoadFile("/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/", uploaddir + Globals.GetThumbnailImage(ftpfilename), FTPs.FTPUploadEnum.AlbumAttach); ftps = new FTPs(); ftps.UpLoadFile("/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/", uploaddir + Globals.GetSquareImage(ftpfilename), FTPs.FTPUploadEnum.AlbumAttach); } else { uploaddir = Utils.GetMapPath(BaseConfigs.GetForumPath + "space/upload/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/"); if (!Directory.Exists(uploaddir)) { Utils.CreateDir(uploaddir); } spacephotoinfo.Filename = "space/upload/" + currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/" + Globals.UploadSpaceFile(postedFile, uploaddir, true); } spacephotoinfo.Attachment = fileName; spacephotoinfo.Description = Utils.HtmlEncode(DNTRequest.GetFormString("description" + (iFile + 1))); spacephotoinfo.Filesize = filesize; spacephotoinfo.Username = username; spacephotoinfo.IsAttachment = 0; freephotosize -= filesize; int photoid = Data.DbProvider.GetInstance().AddSpacePhoto(spacephotoinfo); string tags = DNTRequest.GetHtmlEncodeString("phototag" + (iFile + 1)).Trim(); string[] tagsArray = null; if (enabletag && tags != string.Empty) { tagsArray = Utils.SplitString(tags, " ", true, 10); if (tagsArray.Length > 0) { Data.DbProvider.GetInstance().CreatePhotoTags(string.Join(" ", tagsArray), photoid, userid, Utils.GetDateTime()); AlbumTags.WritePhotoTagsCacheFile(photoid); } } imgcount++; } if (imgcount != 0) { AlbumInfo albumInfo = DTOProvider.GetAlbumInfo(albumid); albumInfo.Imgcount = Data.DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(albumid); Data.DbProvider.GetInstance().SaveSpaceAlbum(albumInfo); } else { AddErrLine("没有符合要求的图片,请上传jpg,jpeg,gif,png格式的图片"); return; } //生成json数据 Albums.CreateAlbumJsonData(albumid); Albums.CreatePhotoImageByAlbum(albumid); SetUrl(string.Format("usercpspacemanagephoto.aspx?albumid={0}", albumid)); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("照片增加完毕"); } }
protected override void ShowPage() { pagetitle = "相册列表"; if (config.Enablealbum != 1) { AddErrLine("相册功能已被关闭"); return; } if (albumsuserid == -1 && userid != -1) { albumsuserid = userid; } if (currentcate != 0) { currentalbumcategory = DTOProvider.GetAlbumCategory(currentcate); pagetitle = currentalbumcategory.Title; } if (albumsuserid != 0) { ShortUserInfo shortUserInfo = Users.GetShortUserInfo(albumsuserid); albumusername = shortUserInfo == null ? "" : shortUserInfo.Username; pagetitle = albumusername + "的" + pagetitle; } albumscount = DTOProvider.GetSpaceAlbumListCount(albumsuserid, currentcate); pagecount = albumscount % pageSize == 0 ? albumscount / pageSize : albumscount / pageSize + 1; if (pagecount == 0) { pagecount = 1; } if (currentpage < 1) { currentpage = 1; } if (currentpage > pagecount) { currentpage = pagecount; } string parm = string.Empty; if (currentcate != 0) { parm = "cate=" + currentcate; if (albumsuserid != 0) { parm += "&uid=" + albumsuserid; } } else if (albumsuserid != 0) { parm += "uid=" + albumsuserid; } if (parm != string.Empty) { parm += "&page="; } else { parm += "page="; } if (currentpage > 1) { prevpage = "<a href='showalbumlist.aspx?" + parm + (currentpage - 1) + "'>上一页</a>"; } if (currentpage < pagecount) { nextpage = "<a href='showalbumlist.aspx?" + parm + (currentpage + 1) + "'>下一页</a>"; } pagenumbers = Utils.GetPageNumbers(currentpage, pagecount, "showalbumlist.aspx", 8); albumlist = DTOProvider.GetSpaceAlbumList(albumsuserid, currentcate, pageSize, currentpage); if (albumlist.Count == 0) { AddMsgLine("暂无相册"); } }
protected override void ShowPage() { if (config.Enablealbum != 1) { AddErrLine("相册功能已被关闭"); return; } forumpath = BaseConfigs.GetForumPath; if (albumid < 1) { AddErrLine("指定的相册不存在"); return; } album = DTOProvider.GetAlbumInfo(albumid); if (album == null) { AddErrLine("指定的相册不存在"); return; } if (config.Rssstatus == 1) { if (GeneralConfigs.GetConfig().Aspxrewrite == 1) { photorssurl = string.Format("photorss-{0}{1}", album.Userid, GeneralConfigs.GetConfig().Extname); } else { photorssurl = string.Format("rss.aspx?uid={0}&type=photo", album.Userid); } AddLinkRss(string.Format("tools/{0}", photorssurl), "最新图片"); } pagetitle = album.Title; //权限验证部分,私有相册,不是相册所有者 if (album.Type == 1 && album.Userid != userid) { if (ForumUtils.GetCookie("album" + albumid + "password") != Utils.MD5(album.Password)) { //首先验证Cookie中如果相册密码不正确,则要求输入密码,并以输入值验证 string password = DNTRequest.GetFormString("albumpassword"); if (album.Password == password) { ForumUtils.WriteCookie("album" + albumid + "password", Utils.MD5(password)); needpassword = false; } } else { needpassword = false; } } else { needpassword = false; } if (Utils.InArray(usergroupid.ToString(), config.Photomangegroups)) { needpassword = false; } albumcategory = DTOProvider.GetAlbumCategory(album.Albumcateid); photoscount = DTOProvider.GetSpacePhotosCount(albumid); pageCount = photoscount % pageSize == 0 ? photoscount / pageSize : photoscount / pageSize + 1; if (pageCount == 0) { pageCount = 1; } if (currentpage < 1) { currentpage = 1; } if (currentpage > pageCount) { currentpage = pageCount; } pagenumbers = Utils.GetPageNumbers(currentpage, pageCount, string.Format("showalbum.aspx?albumid={0}", albumid), 8); photolist = DTOProvider.GetSpacePhotosInfo(DbProvider.GetInstance().SpacePhotosList(pageSize, currentpage, album.Userid, album.Albumid)); foreach (PhotoInfo photo in photolist) { //当是远程照片时 if (photo.Filename.IndexOf("http") < 0) { photo.Filename = forumpath + Globals.GetThumbnailImage(photo.Filename); } else { photo.Filename = Globals.GetThumbnailImage(photo.Filename); } } if (photolist.Count == 0) { AddMsgLine("暂无图片"); } ForumUtils.WriteCookie("referer", string.Format("showalbum.aspx?albumid={0}&page={1}", albumid, currentpage)); }
protected override void ShowPage() { if (config.Enablealbum != 1) { AddErrLine("相册功能已被关闭"); return; } //一周热图总排行 weekhotphotolist = AggregationFacade.AlbumAggregation.GetWeekHotPhotoList(photoconfig.Weekhot); string go = DNTRequest.GetString("go"); switch (go) { case "prev": mode = 1; break; case "next": mode = 2; break; default: mode = 0; break; } if (photoid < 1) { AddErrLine("指定的图片不存在"); return; } photo = DTOProvider.GetPhotoInfo(photoid, 0, 0); if (photo == null) { AddErrLine("指定的图片不存在"); return; } album = DTOProvider.GetAlbumInfo(photo.Albumid); if (album == null) { AddErrLine("指定的相册不存在"); return; } if (mode != 0) { photo = DTOProvider.GetPhotoInfo(photoid, photo.Albumid, mode); if (photo == null) { AddErrLine("指定的图片不存在"); return; } } if (config.Rssstatus == 1) { if (GeneralConfigs.GetConfig().Aspxrewrite == 1) { photorssurl = string.Format("photorss-{0}{1}", photo.Userid, GeneralConfigs.GetConfig().Extname); } else { photorssurl = string.Format("rss.aspx?uid={0}&type=photo", photo.Userid); } AddLinkRss(string.Format("tools/{0}", photorssurl), "最新图片"); } comments = DTOProvider.GetPhotoCommentCollection(photo.Photoid); pagetitle = photo.Title; //权限验证部分,私有相册,不是相册所有者 if (album.Type == 1 && album.Userid != userid) { if (ForumUtils.GetCookie("album" + photo.Albumid + "password") != Utils.MD5(album.Password)) { //首先验证Cookie中如果相册密码不正确,则要求输入密码,并以输入值验证 string password = DNTRequest.GetFormString("albumpassword"); if (album.Password == password) { ForumUtils.WriteCookie("album" + photo.Albumid + "password", Utils.MD5(password)); needpassword = false; } } else { needpassword = false; } } else { needpassword = false; } if (Utils.InArray(usergroupid.ToString(), config.Photomangegroups)) { needpassword = false; } albumcategory = DTOProvider.GetAlbumCategory(album.Albumcateid); jsonfilename = "cache/album/" + (album.Albumid / 1000 + 1).ToString() + "/" + album.Albumid.ToString() + "_json.txt"; //非图片所有者时更新图片浏览量 if (userid != photo.Userid) { DTOProvider.UpdatePhotoViews(photoid); } //判断权限 { switch (photo.Commentstatus) { case PhotoStatus.Owner: if (userid != photo.Userid) { commentable = false; } break; } if (userid < 1) { commentable = false; } //重构时加入指定管理用户组 if (userid == photo.Userid || Utils.InArray(usergroupid.ToString(), config.Photomangegroups)) { editable = true; } } // 如果评论数不同步则同步 if (photo.Comments != comments.Count) { DbProvider.GetInstance().UpdatePhotoComments(photo.Photoid, comments.Count - photo.Comments);//更新评论数 } if (ispost) { string message = DNTRequest.GetFormString("message").Trim(); int delcid = DNTRequest.GetFormInt("delcommentid", 0); if (message != string.Empty) { SavePhotoComment(message); return; } else if (delcid > 0) { if (editable) { DbProvider.GetInstance().DeletePhotoComment(delcid); //更新评论数 DbProvider.GetInstance().UpdatePhotoComments(photo.Photoid, -1); AddMsgLine("删除成功!"); SetUrl("showphoto.aspx?photoid=" + photo.Photoid); SetMetaRefresh(); return; } } AddErrLine("非法操作"); SetMetaRefresh(); } }