コード例 #1
0
		/// <summary>
		/// Copies the elements of the specified <see cref="PhotoInfo">PhotoInfo</see> array to the end of the collection.
		/// </summary>
		/// <param name="value">An array of type <see cref="PhotoInfo">PhotoInfo</see> containing the Components to add to the collection.</param>
		public void AddRange(PhotoInfo[] value) 
		{
			for (int i = 0;	(i < value.Length); i = (i + 1)) 
			{
				this.Add(value[i]);
			}
		}
コード例 #2
0
ファイル: AlbumPlugin.cs プロジェクト: khaliyo/DiscuzNT
        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 "";
        }
コード例 #3
0
ファイル: SqlDataProvider.cs プロジェクト: ZeroneBit/dnt3_src
        public int AddSpacePhoto(PhotoInfo photoinfo)
        {
            DbParameter[] parms = 
				{
					DbHelper.MakeInParam("@userid", (DbType)SqlDbType.Int, 4,photoinfo.Userid),
                    DbHelper.MakeInParam("@username", (DbType)SqlDbType.NChar, 20, photoinfo.Username),
					DbHelper.MakeInParam("@title", (DbType)SqlDbType.NChar, 20,photoinfo.Title),
					DbHelper.MakeInParam("@albumid", (DbType)SqlDbType.Int, 4,photoinfo.Albumid),
					DbHelper.MakeInParam("@filename", (DbType)SqlDbType.NVarChar, 255,photoinfo.Filename),
					DbHelper.MakeInParam("@attachment", (DbType)SqlDbType.NVarChar, 255,photoinfo.Attachment),
					DbHelper.MakeInParam("@filesize", (DbType)SqlDbType.Int, 4,photoinfo.Filesize),
					DbHelper.MakeInParam("@description", (DbType)SqlDbType.NVarChar, 200,photoinfo.Description),
                    DbHelper.MakeInParam("@isattachment",(DbType)SqlDbType.Int,4,photoinfo.IsAttachment),
                    DbHelper.MakeInParam("@commentstatus", (DbType)SqlDbType.TinyInt, 1, (byte)photoinfo.Commentstatus),
                    DbHelper.MakeInParam("@tagstatus", (DbType)SqlDbType.TinyInt, 1, (byte)photoinfo.Tagstatus)
				};
            string commandText = String.Format("INSERT INTO [{0}photos] ([userid], [username], [title], [albumid], [filename], [attachment], [filesize], [description],[isattachment],[commentstatus], [tagstatus]) VALUES ( @userid, @username, @title, @albumid, @filename, @attachment, @filesize, @description,@isattachment, @commentstatus, @tagstatus);SELECT SCOPE_IDENTITY()", BaseConfigs.GetTablePrefix);
            //向关联表中插入相关数据
            return TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.Text, commandText, parms));
        }
コード例 #4
0
		/// <summary>
		/// Gets the index in the collection of the specified <see cref="PhotoInfoCollection">PhotoInfoCollection</see>, if it exists in the collection.
		/// </summary>
		/// <param name="value">The <see cref="PhotoInfoCollection">PhotoInfoCollection</see> to locate in the collection.</param>
		/// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
		public int IndexOf(PhotoInfo value) 
		{
			return this.List.IndexOf(value);
		}
コード例 #5
0
ファイル: usercpphotoedit.cs プロジェクト: Vinna/DeepInSummer
        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.GetHtmlEncodeString("title");
                photo.Description = DNTRequest.GetHtmlEncodeString("description");

                if (commentstatus < 0 || commentstatus > 2)
                    commentstatus = 2;

                photo.Commentstatus = (PhotoStatus) commentstatus;

                string newtags = DNTRequest.GetHtmlEncodeString("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();
            }
        }
コード例 #6
0
ファイル: uploadfile.ascx.cs プロジェクト: khaliyo/DiscuzNT
        private string StartUploadFile()
        {
            string sSavePath = "";

            if (ViewState["UploadDir"] != null)
                sSavePath = ViewState["UploadDir"].ToString();
            else
                sSavePath = Server.MapPath(BaseConfigs.GetForumPath + "space/upload/");

            if (filefield1.PostedFile != null)
            {
                HttpPostedFile myFile = filefield1.PostedFile;
                int nFileLen = myFile.ContentLength;
                if (nFileLen == 0)
                    return "";

                byte[] myData = new Byte[nFileLen];
                myFile.InputStream.Read(myData, 0, nFileLen);
                Random random = new Random(unchecked((int)DateTime.Now.Ticks));
                string sFilename = (Environment.TickCount & int.MaxValue).ToString() + random.Next(1000, 9999).ToString() + System.IO.Path.GetExtension(myFile.FileName).ToLower();

                //判断sFilename的文件名称是否已存在于服务器上. 如存在, 则添加文件递增标识
                int file_append = 0;
                while (File.Exists(sSavePath + sFilename))
                {
                    file_append++;
                    sFilename = Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString() + Path.GetExtension(myFile.FileName).ToLower();
                }

                string fileExtName = Path.GetExtension(myFile.FileName).ToLower();
                string relativeFilePath = ViewState["RelativeFilePath"].ToString().Trim();

                fileExtName = fileExtName !="" ? fileExtName: ".invalidExtName";

                if ((attachextensions == null) || (attachextensions.ToLower().IndexOf(fileExtName.Remove(0,1)) >= 0))
                {
                    //上传图片文件
                    if ((fileExtName == ".jpg") || (fileExtName == ".gif") || (fileExtName == ".png") || (fileExtName == ".jpeg"))
                    { 
                        try
                        {
                            AlbumPluginBase apb = AlbumPluginProvider.GetInstance();                        
                            //上传附件同时加入相册
                            if (albums.SelectedValue != "" && apb != null)
                            {
                                int maxphotosize = UserGroups.GetUserGroupInfo(_userinfo.Groupid).Maxspacephotosize;
                                int currentphotisize = apb.GetPhotoSizeByUserid(userid);
                                if ((maxphotosize - currentphotisize - nFileLen) <= 0)  //相册的存储空间不足
                                {
                                    HttpContext.Current.Response.Write("<script>alert('" + config.Albumname + "空间不足, 上传至相册失败!');</script>");
                                    HttpContext.Current.Response.End();
                                    return "";
                                }
                                else
                                {
                                    FileStream newFile = new FileStream(sSavePath + sFilename, FileMode.Create);
                                    newFile.Write(myData, 0, myData.Length);
                                    newFile.Close();

                                    string extension = Path.GetExtension(sSavePath + sFilename);
                                    Common.Thumbnail.MakeThumbnailImage(sSavePath + sFilename, (sSavePath + sFilename).Replace(extension, "_thumbnail" + extension), 150, 150);
                                    Common.Thumbnail.MakeSquareImage(sSavePath + sFilename, (sSavePath + sFilename).Replace(extension, "_square" + extension), 100);
                                    string sPath = relativeFilePath;
                                    if (sPath.StartsWith("/"))
                                        sPath = sPath.Substring(1, sPath.Length - 1);

                                    PhotoInfo photoinfo = new PhotoInfo();
                                    photoinfo.Filename = sPath + sFilename;
                                    photoinfo.Attachment = Path.GetFileName(filefield1.PostedFile.FileName);
                                    photoinfo.Filesize = nFileLen;
                                    photoinfo.Title = sFilename.Remove(sFilename.IndexOf("."), 1);
                                    photoinfo.Description = "";
                                    photoinfo.Albumid = Utils.StrToInt(albums.SelectedValue, 0);
                                    photoinfo.Userid = userid;
                                    photoinfo.Username = username;
                                    photoinfo.Views = 0;
                                    photoinfo.Commentstatus = 0;
                                    photoinfo.Tagstatus = 0;
                                    photoinfo.Comments = 0;
                                    photoinfo.IsAttachment = 1;
                                    Space.Data.DbProvider.GetInstance().AddSpacePhoto(photoinfo);
                                    AlbumInfo albumInfo = apb.GetAlbumInfo( Utils.StrToInt((albums.SelectedValue),0));
                                    albumInfo.Imgcount = Space.Data.DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(Utils.StrToInt(albums.SelectedValue, 0));
                                    Space.Data.DbProvider.GetInstance().SaveSpaceAlbum(albumInfo);

                                    //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                                    if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                                    {
                                        FTPs ftps = new FTPs();
                                        relativeFilePath = relativeFilePath.Replace(FTPs.GetSpaceAttachInfo.Remoteurl, "");
                                        ftps.UpLoadFile(relativeFilePath, sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                                        ftps = new FTPs();
                                        ftps.UpLoadFile(relativeFilePath, (sSavePath + sFilename).Replace(extension, "_thumbnail" + extension), FTPs.FTPUploadEnum.SpaceAttach);
                                        ftps = new FTPs();
                                        ftps.UpLoadFile(relativeFilePath, (sSavePath + sFilename).Replace(extension, "_square" + extension), FTPs.FTPUploadEnum.SpaceAttach);
                                    }
                                }
                            }
                            else
                            {
                                int maxspacesize = UserGroups.GetUserGroupInfo(_userinfo.Groupid).Maxspaceattachsize;
                                int currentspaceattachmentsize = Space.Data.DbProvider.GetInstance().GetSpaceAttachmentSizeByUserid(userid);
                                if ((maxspacesize - currentspaceattachmentsize - nFileLen) <= 0)  //个人空间的存储空间不足
                                {
                                    HttpContext.Current.Response.Write("<script>alert('" + config.Spacename + "存储空间不足, 上传失败!');</script>");
                                    HttpContext.Current.Response.End();
                                    return "";
                                }
                                else
                                {
                                    FileStream newFile = new FileStream(sSavePath + sFilename, FileMode.Create);
                                    newFile.Write(myData, 0, myData.Length);
                                    newFile.Close();
                                }

                                //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                                if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                                {
                                    FTPs ftps = new FTPs();
                                    ftps.UpLoadFile(relativeFilePath.Replace(FTPs.GetSpaceAttachInfo.Remoteurl, ""), sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                                }     
                            }

                            InsertSapceAttachment(relativeFilePath + sFilename, myFile.ContentType, myData.Length, Path.GetFileName(myFile.FileName).ToLower());

                            return sFilename;
                        }
                        catch (ArgumentException errArgument)
                        {
                            File.Delete(sSavePath + sFilename);
                            HttpContext.Current.Response.Write("<script>alert('" + errArgument.Message + "!');</script>");
                            HttpContext.Current.Response.End();
                            return "";
                        }
                    }
                    else //其它类型文件
                    {  
                        int maxspacesize = UserGroups.GetUserGroupInfo(_userinfo.Groupid).Maxspaceattachsize;
                        int currentspaceattachmentsize = Space.Data.DbProvider.GetInstance().GetSpaceAttachmentSizeByUserid(userid);
                        if ((maxspacesize - currentspaceattachmentsize - nFileLen) <= 0)  //个人空间的存储空间不足
                        {
                            HttpContext.Current.Response.Write("<script>alert('" + config.Spacename + "存储空间不足, 上传失败!');</script>");
                            HttpContext.Current.Response.End();
                            return "";
                        }
                        else
                        {
                            try
                            {
                                myFile.SaveAs(sSavePath + sFilename);
                                InsertSapceAttachment(relativeFilePath + sFilename, myFile.ContentType, myData.Length, Path.GetFileName(myFile.FileName).ToLower());

                                //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                                if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                                {
                                    FTPs ftps = new FTPs();
                                    ftps.UpLoadFile(relativeFilePath.Replace(FTPs.GetSpaceAttachInfo.Remoteurl, ""), sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                                } 
                                return sFilename;
                            }
                            catch (ArgumentException errArgument)
                            {
                                File.Delete(sSavePath + sFilename);
                                HttpContext.Current.Response.Write("<script>alert('" + errArgument.Message + "!');</script>");
                                HttpContext.Current.Response.End();
                                return "";
                            }
                        }
                    }
                }
                else //当上传的附件类型无效时
                {
                    return "invalid_file";
                }
            }
            return "";
        }
コード例 #7
0
ファイル: DataProvider.cs プロジェクト: Vinna/DeepInSummer
		/// <summary>
		/// 更新图片信息(仅更新 标题、描述、评论设置和标签设置4项)
		/// </summary>
		/// <param name="photo"></param>
		public void UpdatePhotoInfo(PhotoInfo photo)
		{
			IDataParameter[] parms = { 
									  DbHelper.MakeInParam("@photoid", (DbType)SqlDbType.Int, 4, photo.Photoid),
									  DbHelper.MakeInParam("@title", (DbType)SqlDbType.NChar, 20, photo.Title),
									  DbHelper.MakeInParam("@description", (DbType)SqlDbType.NChar, 200, photo.Description),
									  DbHelper.MakeInParam("@commentstatus", (DbType)SqlDbType.TinyInt, 1, (byte)photo.Commentstatus),
									  DbHelper.MakeInParam("@tagstatus", (DbType)SqlDbType.TinyInt, 1, (byte)photo.Tagstatus)
								  };

			string sql = string.Format("UPDATE [{0}photos] SET [title]=@title, [description]=@description, [commentstatus]=@commentstatus, [tagstatus]=@tagstatus WHERE [photoid]=@photoid", BaseConfigs.GetTablePrefix);

			DbHelper.ExecuteNonQuery(CommandType.Text, sql, parms);
		}
コード例 #8
0
		/// <summary>
		/// Copies the collection Components to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index.
		/// </summary>
		/// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param>
		/// <param name="index">The index of the array at which to begin inserting.</param>
		public void CopyTo(PhotoInfo[] array, int index) 
		{
			this.List.CopyTo(array, index);
		}
コード例 #9
0
		/// <summary>
		/// Initializes a new instance of the <see cref="PhotoInfoCollection">PhotoInfoCollection</see> class containing the specified array of <see cref="PhotoInfo">PhotoInfo</see> Components.
		/// </summary>
		/// <param name="value">An array of <see cref="PhotoInfo">PhotoInfo</see> Components with which to initialize the collection. </param>
		public PhotoInfoCollection(PhotoInfo[] value)
		{
			this.AddRange(value);
		}
コード例 #10
0
 /// <summary>
 /// Gets the index in the collection of the specified <see cref="PhotoInfoCollection">PhotoInfoCollection</see>, if it exists in the collection.
 /// </summary>
 /// <param name="value">The <see cref="PhotoInfoCollection">PhotoInfoCollection</see> to locate in the collection.</param>
 /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
 public int IndexOf(PhotoInfo value)
 {
     return(this.List.IndexOf(value));
 }
コード例 #11
0
ファイル: DTOProvider.cs プロジェクト: Vinna/DeepInSummer
        public static PhotoInfo GetPhotoEntity(IDataReader reader)
        {
            PhotoInfo photoinfo = new PhotoInfo();
            photoinfo.Photoid = TypeConverter.ObjectToInt(reader["photoid"]);
            photoinfo.Filename = reader["filename"].ToString();
            photoinfo.Attachment = reader["attachment"].ToString();
            photoinfo.Filesize = TypeConverter.ObjectToInt(reader["filesize"]);
            photoinfo.Description = reader["description"].ToString();
            photoinfo.Postdate = reader["postdate"].ToString();
            photoinfo.Albumid = TypeConverter.ObjectToInt(reader["albumid"]);
            photoinfo.Userid = TypeConverter.ObjectToInt(reader["userid"]);
            photoinfo.Title = reader["title"].ToString();
            photoinfo.Views = TypeConverter.ObjectToInt(reader["views"]);
            photoinfo.Commentstatus = (PhotoStatus)TypeConverter.ObjectToInt(reader["commentstatus"]);
            photoinfo.Tagstatus = (PhotoStatus)TypeConverter.ObjectToInt(reader["tagstatus"]);
            photoinfo.Comments = TypeConverter.ObjectToInt(reader["comments"]);
            photoinfo.Username = reader["username"].ToString();

            return photoinfo;
        }
コード例 #12
0
ファイル: DTOProvider.cs プロジェクト: Vinna/DeepInSummer
        public static Discuz.Common.Generic.List<PhotoInfo> GetSpacePhotosInfo(DataTable dt)
        {
            if (dt == null || dt.Rows.Count == 0)
                return new Discuz.Common.Generic.List<PhotoInfo>();

            Discuz.Common.Generic.List<PhotoInfo> photosinfoarray = new Discuz.Common.Generic.List<PhotoInfo>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                PhotoInfo photo = new PhotoInfo();
                photo.Photoid = TypeConverter.ObjectToInt(dt.Rows[i]["photoid"]);
                photo.Filename = dt.Rows[i]["filename"].ToString();
                photo.Attachment = dt.Rows[i]["attachment"].ToString();
                photo.Filesize = TypeConverter.ObjectToInt(dt.Rows[i]["filesize"]);
                photo.Description = dt.Rows[i]["description"].ToString();
                photo.Postdate = dt.Rows[i]["postdate"].ToString();
                photo.Albumid = TypeConverter.ObjectToInt(dt.Rows[i]["albumid"]);
                photo.Userid = TypeConverter.ObjectToInt(dt.Rows[i]["userid"]);
                photo.Title = dt.Rows[i]["title"].ToString();
                photo.Views = TypeConverter.ObjectToInt(dt.Rows[i]["views"]);
                photo.Commentstatus = (PhotoStatus)TypeConverter.ObjectToInt(dt.Rows[i]["commentstatus"]);
                photo.Tagstatus = (PhotoStatus)TypeConverter.ObjectToInt(dt.Rows[i]["tagstatus"]);
                photo.Comments = TypeConverter.ObjectToInt(dt.Rows[i]["comments"]);

                photosinfoarray.Add(photo);
            }
            dt.Dispose();
            return photosinfoarray;
        }
コード例 #13
0
ファイル: DTOProvider.cs プロジェクト: Vinna/DeepInSummer
 public static void UpdatePhotoInfo(PhotoInfo photo)
 {
     Data.DbProvider.GetInstance().UpdatePhotoInfo(photo);
 }
コード例 #14
0
        /// <summary>
        /// 获得推荐图片列表
        /// </summary>
        /// <param name="nodename">节点名称</param>
        /// <returns></returns>
        public Discuz.Common.Generic.List<PhotoInfo> GetRecommandPhotoList(string nodeName)
        {
            //当文件未被修改时将直接返回相关记录
            if (__recommandPhotoList != null)
            {
                return __recommandPhotoList;
            }

            __recommandPhotoList = new Discuz.Common.Generic.List<PhotoInfo>();
            XmlNodeList xmlnodelist = xmlDoc.DocumentElement.SelectNodes("/Aggregationinfo/Aggregationpage/" + nodeName + "/" + nodeName + "_photolist/Photo");

            foreach (XmlNode xmlnode in xmlnodelist)
            {
                PhotoInfo recommandPhoto = new PhotoInfo();

                recommandPhoto.Photoid = (xmlDoc.GetSingleNodeValue(xmlnode, "photoid") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "photoid"));
                recommandPhoto.Filename = (xmlDoc.GetSingleNodeValue(xmlnode, "filename") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "filename");
                recommandPhoto.Attachment = (xmlDoc.GetSingleNodeValue(xmlnode, "attachment") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "attachment");
                recommandPhoto.Filesize = (xmlDoc.GetSingleNodeValue(xmlnode, "filesize") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "filesize"));
                recommandPhoto.Description = (xmlDoc.GetSingleNodeValue(xmlnode, "description") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "description");
                recommandPhoto.Postdate = (xmlDoc.GetSingleNodeValue(xmlnode, "postdate") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "postdate");
                recommandPhoto.Albumid = (xmlDoc.GetSingleNodeValue(xmlnode, "albumid") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "albumid"));
                recommandPhoto.Userid = (xmlDoc.GetSingleNodeValue(xmlnode, "userid") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "userid"));
                recommandPhoto.Title = (xmlDoc.GetSingleNodeValue(xmlnode, "title") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "title");
                recommandPhoto.Views = (xmlDoc.GetSingleNodeValue(xmlnode, "views") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "views"));
                recommandPhoto.Commentstatus = (xmlDoc.GetSingleNodeValue(xmlnode, "commentstatus") == null) ? PhotoStatus.Owner : (PhotoStatus)Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "commentstatus"));
                recommandPhoto.Tagstatus = (xmlDoc.GetSingleNodeValue(xmlnode, "tagstatus") == null) ? PhotoStatus.Owner : (PhotoStatus)Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "tagstatus"));
                recommandPhoto.Comments = (xmlDoc.GetSingleNodeValue(xmlnode, "comments") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "comments"));
                recommandPhoto.Username = (xmlDoc.GetSingleNodeValue(xmlnode, "username") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "username");
                __recommandPhotoList.Add(recommandPhoto);

            }
            return __recommandPhotoList;
        }
コード例 #15
0
ファイル: showphoto.cs プロジェクト: ZeroneBit/dnt3_src
        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();
            }
        }
コード例 #16
0
		public void Insert(int index, PhotoInfo value)	
		{
			List.Insert(index, value);
		}
コード例 #17
0
		public void Remove(PhotoInfo value) 
		{
			List.Remove(value);
		}
コード例 #18
0
 public void Insert(int index, PhotoInfo value)
 {
     List.Insert(index, value);
 }
コード例 #19
0
		public int Add(PhotoInfo value) 
		{
			return this.List.Add(value);
		}
コード例 #20
0
 public void Remove(PhotoInfo value)
 {
     List.Remove(value);
 }
コード例 #21
0
		/// <summary>
		/// Gets a value indicating whether the collection contains the specified <see cref="PhotoInfoCollection">PhotoInfoCollection</see>.
		/// </summary>
		/// <param name="value">The <see cref="PhotoInfoCollection">PhotoInfoCollection</see> to search for in the collection.</param>
		/// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
		public bool Contains(PhotoInfo value) 
		{
			return this.List.Contains(value);
		}
コード例 #22
0
 public int Add(PhotoInfo value)
 {
     return(this.List.Add(value));
 }
コード例 #23
0
ファイル: DataProvider.cs プロジェクト: Vinna/DeepInSummer
		public bool AddSpacePhoto(PhotoInfo photoinfo)
		{
			//try
			//{
			IDataParameter[] prams = 
				{
					DbHelper.MakeInParam("@userid", (DbType)SqlDbType.Int, 4,photoinfo.Userid),
					DbHelper.MakeInParam("@username", (DbType)SqlDbType.NChar, 20, photoinfo.Username),
					DbHelper.MakeInParam("@title", (DbType)SqlDbType.NChar, 20,photoinfo.Title),
					DbHelper.MakeInParam("@albumid", (DbType)SqlDbType.Int, 4,photoinfo.Albumid),
					DbHelper.MakeInParam("@filename", (DbType)SqlDbType.NVarChar, 255,photoinfo.Filename),
					DbHelper.MakeInParam("@attachment", (DbType)SqlDbType.NVarChar, 255,photoinfo.Attachment),
					DbHelper.MakeInParam("@filesize", (DbType)SqlDbType.Int, 4,photoinfo.Filesize),
					DbHelper.MakeInParam("@description", (DbType)SqlDbType.NVarChar, 200,photoinfo.Description),
					DbHelper.MakeInParam("@isattachment",(DbType)SqlDbType.Int,4,photoinfo.IsAttachment),
					DbHelper.MakeInParam("@commentstatus", (DbType)SqlDbType.TinyInt, 1, (byte)photoinfo.Commentstatus),
					DbHelper.MakeInParam("@tagstatus", (DbType)SqlDbType.TinyInt, 1, (byte)photoinfo.Tagstatus)
					//DbHelper.MakeInParam("@creatdatetime", (DbType)SqlDbType.DateTime, 8,spaceAlbum.Createdatetime)
				};
			string sqlstring = String.Format("INSERT INTO [{0}photos] ([userid], [username], [title], [albumid], [filename], [attachment], [filesize], [description],[isattachment],[commentstatus], [tagstatus]) VALUES ( @userid, @username, @title, @albumid, @filename, @attachment, @filesize, @description,@isattachment, @commentstatus, @tagstatus)", BaseConfigs.GetTablePrefix);

			//向关联表中插入相关数据
			DbHelper.ExecuteNonQuery(CommandType.Text, sqlstring, prams);

			return true;
			//}
			//catch (Exception ex)
			//{
			//    errormsg = Globals.TransferSqlErrorInfo(ex.Message);
			//    return false;
			//}
		}
コード例 #24
0
 /// <summary>
 /// Gets a value indicating whether the collection contains the specified <see cref="PhotoInfoCollection">PhotoInfoCollection</see>.
 /// </summary>
 /// <param name="value">The <see cref="PhotoInfoCollection">PhotoInfoCollection</see> to search for in the collection.</param>
 /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
 public bool Contains(PhotoInfo value)
 {
     return(this.List.Contains(value));
 }
コード例 #25
0
ファイル: Albums.cs プロジェクト: khaliyo/DiscuzNT
 private static PhotoInfo GetPhotoEntity(IDataReader reader)
 {
     PhotoInfo p = new PhotoInfo();
     p.Photoid = Utils.StrToInt(reader["photoid"], 0);
     p.Filename = reader["filename"].ToString();
     p.Title = reader["title"].ToString();
     p.Filesize = Utils.StrToInt(reader["filesize"], 0);
     return p;
 }
コード例 #26
0
        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 = 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 = 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.GetString("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("照片增加完毕");
            }
        }