protected void UpdatePhoto(object o, EventArgs e)
		{
			Photo p = new Photo(int.Parse(this.uiPhotoKLabel.Text));
			p.SetAsPhotoOfWeek(uiPhotoOfWeek.Checked, uiPhotoOfWeekUserCaption.Text, false, uiResetDateTime.Checked);

			p.BlockedFromPhotoOfWeekUser = uiPhotoOfWeekUserBlocked.Checked;

			p.Update();
		}
		protected void Page_Load(object sender, EventArgs e)
		{
			PhotoSet ps = getCompetitionPhotos(4);
			if (ps.Count > 0)
			{
				uiPhotoDataList.ItemTemplate = this.LoadTemplate("/Templates/GroupPhotos/CompetitionPhotoIcon.ascx");
				uiPhotoDataList.DataSource = ps;
				uiPhotoDataList.DataBind();

				Photo photo = ps[0];
				if (!Url["k"].IsNull)
				{
					int photoK = Url["k"].ValueInt;
					Photo p1 = ps.First(p => p.K == photoK);
					if (p1 != null)
					{
						photo = p1;
					}
					else
					{
						// could still be an old competition photo in which case allow it.
						Photo p2 = new Photo(photoK);
						if (p2.ChildGroupPhotos().First(g => g.GroupK == Vars.CompetitionGroupK) != null)
						{
							photo = p2;
						}
					}
				}
				uiPhoto.Src = photo.WebPath;
				uiPhoto.Width = photo.WebWidth;
				uiPhoto.Height = photo.WebHeight;
				uiPhotoUrl.HRef = photo.Url();

				uiCommentsDisplay.ParentObject = photo;
				if (photo.Thread != null)
				{
					uiCommentsDisplay.CurrentThread = photo.Thread;
					this.ThreadK.Value = photo.Thread.K.ToString();
				}
				uiCommentsDisplay.DataBind();
				currentPhotoK = photo.K;
			}

			duplicateGuid = Guid.NewGuid().ToString();
			ContainerPage.Title = competitionTitle;

			if (Usr.Current == null)
			{
				uiCaptionText.Enabled = false;
				uiCaptionText.Text = "Please sign in to post a caption!";
				uiPost.Disabled = true;
			}
			else
                uiCaptionText.Focus();
		}
		public void Disable(object o, System.EventArgs e)
		{
			Photo p = new Photo(int.Parse(Request.QueryString["PhotoK"]));
			if (!p.ContentDisabled)
			{
				p.ContentDisabled = true;
				p.Update();
				p.Gallery.UpdatePhotoOrder(null);
				OutLabel.Text = "Picture " + p.K.ToString() + " has had it's contents disabled";
			}
		}
		protected void GetPhoto(object o, EventArgs e)
		{
			Photo p = new Photo(int.Parse(this.uiPhotoK.Text));
			this.uiPhotoDetails.Visible = true;
			this.uiPhotoKLabel.Text = p.K.ToString();
			this.uiPhotoImg.Src = p.WebPath;
			this.uiPhotoImg.Width = p.WebWidth;
			this.uiPhotoImg.Height = p.WebHeight;
			this.uiPhotoOfWeek.Checked = p.PhotoOfWeekUser;
			this.uiPhotoOfWeekUserCaption.Text = p.PhotoOfWeekUserCaption;
			this.uiPhotoOfWeekUserBlocked.Checked = p.BlockedFromPhotoOfWeekUser;
		}
Esempio n. 5
0
		public void DeleteNow(object o, System.EventArgs e)
		{
			if (ObjectTypeDropDown.SelectedValue.Equals("Photo"))
			{
				Photo c = new Photo(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Gallery"))
			{
				Gallery c = new Gallery(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Venue"))
			{
				Venue c = new Venue(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Event"))
			{
				Event c = new Event(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Comment"))
			{
				Comment c = new Comment(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Thread"))
			{
				Thread c = new Thread(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Usr"))
			{
				Usr c = new Usr(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Article"))
			{
				Article c = new Article(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			DoneLabel.Visible = true;
		}
Esempio n. 6
0
		protected void Page_Load(object sender, EventArgs e)
		{
			Photo p = null;
			if (ContainerPage.Url.HasPhotoObjectFilter)
			{
				p = ContainerPage.Url.ObjectFilterPhoto;
			}
			else if (ContainerPage.Url.HasGalleryObjectFilter)
			{
				try
				{
					if (ContainerPage.Url["photok"].IsInt)
						p = new Photo(ContainerPage.Url["photok"]);
				}
				catch { }

				if (p == null)
				{
					try
					{
						if (ContainerPage.Url.ObjectFilterGallery.MainPhotoK > 0 && ContainerPage.Url.ObjectFilterGallery.MainPhoto != null)
							p = ContainerPage.Url.ObjectFilterGallery.MainPhoto;
					}
					catch { }
				}

				if (p == null)
				{
					try
					{
						if (ContainerPage.Url.ObjectFilterGallery.LivePhotos > 0)
							p = ContainerPage.Url.ObjectFilterGallery.ChildPhotos(
								Photo.EnabledQueryCondition,
								Photo.DefaultOrder
							)[0];
					}
					catch { }
				}
			}
			string page = (1 + (p.GalleryTimeOrder / Spotted.Pages.Events.Photos.NumberOfPhotosPerPage)).ToString();
			if (page == "1") { page = null; }
			if (p.EventK > 0)
			{
				Response.Redirect(p.Event.UrlApp("photos", "gallery", p.GalleryK.ToString(), "photo", p.K.ToString(), "photopage", page));
			}
			else
			{
				Response.Redirect(p.Article.UrlApp("photos", "gallery", p.GalleryK.ToString(), "photo", p.K.ToString(), "photopage", page));
			}
		}
Esempio n. 7
0
		public override bool Encode(Photo p, Photo.EncoderStatusDelegate Status, Photo.MeaningfulActivityDelegate Active, int MinutesUntilKill1)
		{
			try
			{
				StatusString = "[STRT]";


				//lets see if upload temporary file exists...
				if (Storage.ExistsInStore(Storage.Stores.Temporary, p.UploadTemporary, p.UploadTemporaryExtention))
				{
					p.SaveWeb(Photo.SaveWebFileSourceLocations.UploadTemporary, p.Rotate, Status, Active);
				}
				else if (Storage.ExistsInStore(Storage.Stores.Master, p.Master, "jpg"))
				{
					p.SaveWeb(Photo.SaveWebFileSourceLocations.Master, p.Rotate, Status, Active);
				}
				else
				{
					//We don't have the upload temporary file OR the master file... so delete the photo?
					throw new Exception("Can't find image file to encode!");
				}

				Active();

				Photo.FinishProcessUploadedFile(p, p.Gallery, p.Usr);
				
				p.IsProcessing = false;
				p.Update();

				Active();

				Status(p.K + " Updating gallery etc...");

				Status(p.K + " Done!        ************************************");

			}
			catch (Exception ex)
			{
				Status(p.K + " Caught exception XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
				Status(p.K + " Caught exception: " + ex.ToString());
				throw ex;
			}
			finally
			{
				Status(p.K + " Finalising...");
				StatusString = "[----]";
				Status(p.K + " Finalising done.");
			}
			return true;
		}
Esempio n. 8
0
		public void TestInsertsFireInvalidationTriggers()
		{
			Tag tag = new Tag();
			tag.Update();
			Photo photo = new Photo();
			photo.Update();
			Caching.Instances.Main.FlushAll();
			string version = Guid.NewGuid().ToString();
			Caching.Instances.Main.Set(Caching.CacheKeys.Tag.TagPhotos(tag.K), version);
			TagPhoto tagPhoto = new TagPhoto() { TagK = tag.K, PhotoK = photo.K};
			Assert.AreEqual(version, Caching.Instances.Main.Get(Caching.CacheKeys.Tag.TagPhotos(tag.K)));
			tagPhoto.Update();
			Assert.AreNotEqual(version, Caching.Instances.Main.Get(Caching.CacheKeys.Tag.TagPhotos(tag.K)));

		}
Esempio n. 9
0
		public void TestDeletesFireInvalidationTriggers()
		{
			Tag tag = new Tag();
			tag.Update();
			Photo photo2 = new Photo();
			photo2.Update();
			Photo photo = new Photo();
			photo.Update();
			Caching.Instances.Main.FlushAll();
			TagPhoto tagPhoto = new TagPhoto() { TagK = tag.K, PhotoK = photo.K};
			tagPhoto.Update();
			string version = Caching.Instances.Main.Get(Caching.CacheKeys.Tag.TagPhotos(tag.K)) as string;
			tagPhoto.Delete();
			Assert.AreNotEqual(version, Caching.Instances.Main.Get(Caching.CacheKeys.Tag.TagPhotos(tag.K)));

		}
		void LoadPhotoIntoView(Photo photo)
		{
			if (photo != null)
			{
				//this.view.TaggingControl.Taggable = photo;
				this.view.UsrsInPhotoHtml = service.GetUsrsInPhotoHtml(view.Photo.K);
				this.view.UsrSpotted = view.CurrentUsrK != null && service.UsrHasBeenSpotted(photo.K, view.CurrentUsrK.Value);
				this.view.IsFavouritePhoto = Usr.Current != null && service.PhotoIsFavouritedByCurrentUser(photo.K, view.CurrentUsrK.Value);
				this.view.DisplayMakeFrontPageOptions = photo.EventK > 0 && photo.Event != null && photo.Event.Venue.Place.Country.IsCurrentUsrAdmin;
				if (Usr.Current != null && Usr.Current.IsAdmin)
				{
					view.DisplayAdminOptions();
				}
			}
			else
			{
				this.view.DisplayMakeFrontPageOptions = false;
			}
		}
Esempio n. 11
0
		public void Command(object o, CommandEventArgs e)
		{
			if (CurrentPhoto.K == int.Parse(e.CommandArgument.ToString()))
			{
				if (e.CommandName.Equals("Delete"))
				{
					CurrentPhoto = new Photo(CurrentPhoto.K);
					if (Usr.Current.K == CurrentPhoto.UsrK || Usr.Current.IsSenior)
					{
						Delete.DeleteAll(CurrentPhoto);
					}
				}
				else if (e.CommandName.Equals("MakeMain"))
				{
					if (Usr.Current.K == CurrentGallery.OwnerUsrK || Usr.Current.IsSenior)
					{
						CurrentGallery.MainPhotoK = CurrentPhoto.K;
						CurrentGallery.Update();
						((Spotted.Master.DsiPage)Page).AnchorSkip("Photo" + CurrentPhoto.K.ToString());
					}
				}
				PhotoAdminPage.Refresh();
			}
		}
		public void Command(object o, CommandEventArgs e)
		{
			if (CurrentPhoto.K == int.Parse(e.CommandArgument.ToString()))
			{
				if (e.CommandName.Equals("Delete"))
				{
					CurrentPhoto = new Photo(CurrentPhoto.K);
					if (Usr.Current.K == CurrentPhoto.UsrK || Usr.Current.IsSenior)
					{
						Delete.DeleteAll(CurrentPhoto);
					}
				}
				else if (e.CommandName.Equals("Retry"))
				{
					CurrentPhoto = new Photo(CurrentPhoto.K);
					if (Usr.Current.K == CurrentPhoto.UsrK || Usr.Current.IsSenior)
					{
						CurrentPhoto.ProcessingAttempts = 0;
						CurrentPhoto.Update();
					}
				}
				PhotoAdminPage.Refresh();
			}
		}
		public void EnableSelected(object o, System.EventArgs e)
		{
			int enabled = 0;
			bool sentChatAlert = false;

			//			bool galleryEmptyBefore = false;
			//			if (CurrentGallery.LivePhotos==0)
			//				galleryEmptyBefore = true;


			SelectedOutputP.InnerHtml = "";
			foreach (string str in Request.Form.Keys)
			{
				if (str.StartsWith("ucEditGalleryPhotoSelectK") && Request.Form[str].Equals("1"))
				{
					enabled++;
					string str1 = str.Substring(25);
					SelectedOutputP.InnerHtml += "Enabling photo " + str1 + "...";
					try
					{
						int photoK = int.Parse(str1);
						Photo p = new Photo(photoK);
						if (p.GalleryK != CurrentGallery.K)
						{
							SelectedOutputP.InnerHtml += " <b>FAILED</b> - photo is not in current gallery. Please contact admin with details.";
						}
						else if (!p.Status.Equals(Photo.StatusEnum.Moderate))
						{
							SelectedOutputP.InnerHtml += " <b>FAILED</b> - photo is not new. Maybe someone already enabled it?";
						}
						else
						{
							p.Status = Photo.StatusEnum.Enabled;
							p.EnabledByUsrK = Usr.Current.K;
							p.EnabledDateTime = DateTime.Now;
							p.Update();
							if (!sentChatAlert)
							{
								p.SendPhotoChatAlerts();
								sentChatAlert = true;
							}
							SelectedOutputP.InnerHtml += " Done.";
						}

					}
					catch
					{
						SelectedOutputP.InnerHtml += " <b>FAILED</b> - exception while deleting photo. Maybe someone already deleted it?";
					}
					SelectedOutputP.InnerHtml += "<br>";
				}
			}

			if (enabled == 0)
				SelectedOutputP.InnerHtml += "<b>NO PHOTOS ENABLED</b> - You didn't select any photos.";

			SelectedOutputP.Visible = true;

			if (enabled > 0)
			{
				CurrentGallery.LastLiveDateTime = DateTime.Now;
				CurrentGallery.UpdateStats(null, true);
				CurrentGallery.UpdatePhotoOrder(null);

				CurrentGallery.Owner.UpdateTotalPhotos(null);

				if (CurrentGallery.Event != null)
				{
					CurrentGallery.Event.UpdateTotalPhotos(null);
					CurrentGallery.Event.UpdateTotalComments(null);
				}
				if (CurrentGallery.Article != null)
					CurrentGallery.Article.UpdateTotalComments(null);

				//	if (galleryEmptyBefore && CurrentGallery.LivePhotos>0)
				//	{
				//		//Send emails...
				//		new System.Threading.Thread(new ThreadStart(CurrentGallery.SendNewGalleryEmails)).Start();
				//	}
			}

			Bind();
			ContainerPage.AnchorSkip("ActionsPanel");
		}
Esempio n. 14
0
		public static Photo GetLatestTopPhoto(bool useCache, bool setCacheIfEmpty)
		{
			if (useCache)
			{
				try
				{
					int k = Caching.Instances.Main.Get(new CacheKey(CacheKeyPrefix.LatestTopPhoto), () => 0);
					if (k > 0)
					{
						Photo p = new Photo(k);
						if (p.PhotoOfWeekUser)
							return p;
					}
				}
				catch { }
			}

			Query q = new Query();
			q.TopRecords = 1;
			q.QueryCondition = new Q(Photo.Columns.PhotoOfWeekUser, true);
			q.OrderBy = new OrderBy(Photo.Columns.PhotoOfWeekUserDateTime, OrderBy.OrderDirection.Descending);
			PhotoSet ps = new PhotoSet(q);

			if (setCacheIfEmpty && ps.Count > 0)
			{
				Caching.Instances.Main.Set(new CacheKey(CacheKeyPrefix.LatestTopPhoto), ps[0].K.ToString());
			}

			return ps.Count > 0 ? ps[0] : null;
		}
Esempio n. 15
0
		public CachedSqlSelect<Photo> ChildPhotos(Q where, params KeyValuePair<object, OrderBy.OrderDirection>[] orderBy)
		{
			PhotoTableDef def = new PhotoTableDef();
			TagPhotoTableDef def2 = new TagPhotoTableDef();
			return new CachedSqlSelect<Photo>(
				new LinkedChildren<Photo>
				(
					TablesEnum.Tag,
					this.K,
					TablesEnum.Photo,
					def.TableCacheKey,
					dr =>
					{
						Photo newPhoto = new Photo();
						newPhoto.Initialise(dr);
						return newPhoto;
					},
					where,
					orderBy,
					TablesEnum.TagPhoto,
					def2.TableCacheKey
				)
			);
		}
Esempio n. 16
0
		public void SaveWeb(SaveWebFileSourceLocations fileSource, int rotate, Photo.EncoderStatusDelegate Status, Photo.MeaningfulActivityDelegate Active, bool allowEnlargedWeb)
		{
			SaveWeb(fileSource, rotate, Status, Active, Status != null, allowEnlargedWeb);
		}
Esempio n. 17
0
		private void SaveWeb(SaveWebFileSourceLocations fileSource, int rotate, Photo.EncoderStatusDelegate Status, Photo.MeaningfulActivityDelegate Active, bool updateStatus, bool allowEnlargedWeb)
		{
			int webMaxSide = 600;
			int thumbMaxSide = 180;

			System.Drawing.Image image = null;

			#region Get input image
			if (updateStatus)
			{
				Active();
				Status(this.K + " Getting image...");
				this.ProcessingProgress = 10;
				this.ProcessingLastChange = DateTime.Now;
				this.Update();
			}

			if (fileSource == SaveWebFileSourceLocations.UploadTemporary)
			{
				image = System.Drawing.Image.FromStream(new MemoryStream(Storage.GetFromStore(Storage.Stores.Temporary, this.UploadTemporary, this.UploadTemporaryExtention)));
			}
			else
			{
				image = System.Drawing.Image.FromStream(new MemoryStream(Storage.GetFromStore(Storage.Stores.Master, this.Master, "jpg")));
			}
			#endregion

			try
			{

				#region Convert any image with an indexed pixel format to JPG
				if (image.PixelFormat.Equals(PixelFormat.Format1bppIndexed)
					|| image.PixelFormat.Equals(PixelFormat.Format4bppIndexed)
					|| image.PixelFormat.Equals(PixelFormat.Format8bppIndexed)
					|| image.PixelFormat.Equals(PixelFormat.Undefined)
					|| image.PixelFormat.Equals(PixelFormat.DontCare)
					|| image.PixelFormat.Equals(PixelFormat.Format16bppArgb1555)
					|| image.PixelFormat.Equals(PixelFormat.Format16bppGrayScale))
				{

					if (updateStatus)
					{
						Active();
						Status(this.K + " Converting to indexed pixel format...");
						this.ProcessingProgress = 11;
						this.ProcessingLastChange = DateTime.Now;
						this.Update();
					}

					MemoryStream converterStream = new MemoryStream();

					ImageCodecInfo jpgEncoder = ImageCodecInfo.GetImageEncoders()[1];
					EncoderParameters encoderParams = new System.Drawing.Imaging.EncoderParameters(2);
					encoderParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
					encoderParams.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.ColorDepth, 24L);
					image.Save(converterStream, jpgEncoder, encoderParams);

					image.Dispose();
					image = null;
					image = System.Drawing.Image.FromStream(converterStream);
				}
				#endregion

				#region Rotate image
				if (rotate > 0 && updateStatus)
				{
					Active();
					Status(this.K + " Rotating...");
					this.ProcessingProgress = 12;
					this.ProcessingLastChange = DateTime.Now;
					this.Update();
				}
				if (rotate == 90) { image.RotateFlip(RotateFlipType.Rotate90FlipNone); }
				else if (rotate == 180) { image.RotateFlip(RotateFlipType.Rotate180FlipNone); }
				else if (rotate == 270) { image.RotateFlip(RotateFlipType.Rotate270FlipNone); }
				#endregion

				#region Save Master
				if (fileSource != SaveWebFileSourceLocations.Master)
				{
					if (updateStatus)
					{
						Active();
						Status(this.K + " Saving master...");
						this.ProcessingProgress = 20;
						this.ProcessingLastChange = DateTime.Now;
						this.Update();
					}

					byte[] masterBytes = SaveJPGWithCompressionSetting(image, (long)85.0);
					Storage.AddToStore(masterBytes, Storage.Stores.Master, this.Master, "jpg", this, "Master");
					this.MasterFileSize = masterBytes.Length;
				}
				#endregion

				#region Extract metadata
				if (fileSource == SaveWebFileSourceLocations.UploadTemporary)
				{
					try
					{
						if (updateStatus)
						{
							Active();
							Status(this.K + " Extracting exif meta data...");
							this.ProcessingProgress = 30;
							this.ProcessingLastChange = DateTime.Now;
							this.Update();
						}

						Cambro.Misc.ExifMetadata MyExifMetadata = new Cambro.Misc.ExifMetadata();
						Cambro.Misc.ExifMetadata.Metadata MyMetaData;
						MyMetaData = MyExifMetadata.GetExifMetadata(image);

						string date = MyMetaData.DatePictureTaken.DisplayValue;

						try
						{
							this.CameraModel = MyMetaData.CameraModel.DisplayValue.Truncate(100);
						}
						catch { }

						try
						{
							this.EquipmentMake = MyMetaData.EquipmentMake.DisplayValue.Truncate(100);
						}
						catch { }

						if (this.EquipmentMake.StartsWith("Sony Ericsson") && this.CameraModel.StartsWith("K800i"))
							this.IsSonyK800i = true;

						if (this.EquipmentMake.StartsWith("Sony Ericsson") && this.CameraModel.StartsWith("C902"))
							this.IsSonyC902 = true;

						int year = int.Parse(date.Substring(0, 4));
						int month = int.Parse(date.Substring(5, 2));
						int day = int.Parse(date.Substring(8, 2));
						int hour = int.Parse(date.Substring(11, 2));
						int min = int.Parse(date.Substring(14, 2));
						int sec = int.Parse(date.Substring(17, 2));

						DateTime newDateTime = new DateTime(year, month, day, hour, min, sec);
						DateTime parentDateTime = DateTime.Now;
						if (this.Event != null)
						{
							parentDateTime = this.Event.DateTime;
							TimeSpan difference = this.DateTime - newDateTime;
							if (Math.Abs(difference.TotalDays) < 10)
							{
								this.DateTime = newDateTime;
							}
						}
						else if (this.Article != null)
						{
							parentDateTime = this.Article.AddedDateTime;
							TimeSpan difference = this.DateTime - newDateTime;
							if (Math.Abs(difference.TotalDays) < 60)
							{
								this.DateTime = newDateTime;
							}
						}
					}
					catch
					{
						if (updateStatus)
						{
							Active();
							Status(this.K + " Assigning default meta data...");
							this.ProcessingProgress = 35;
							this.ProcessingLastChange = DateTime.Now;
							this.Update();
						}

						if (this.Event != null)
						{ this.DateTime = this.Event.DateTime; }
						else if (this.Article != null)
						{ this.DateTime = this.Article.AddedDateTime; }
						else
						{ this.DateTime = DateTime.Now; }
					}
				}
				#endregion

				#region Calculate the dimensions and landscape/portrait
				if (updateStatus)
				{
					Active();
					Status(this.K + " Calculating sizes of new images...");
					this.ProcessingProgress = 40;
					this.ProcessingLastChange = DateTime.Now;
					this.Update();
				}

				this.OriginalHeight = image.Height;
				this.OriginalWidth = image.Width;
				this.IsLandscape = !(image.Height > image.Width);
				#endregion

				#region Save Web, Thumb and Icon
				#region Overlays...
				Overlays webOverlay = Overlays.DsiLogoBottomRight;
				if (this.IsSonyK800i)
					webOverlay = Overlays.DsiLogoBottomRightSonyBottomLeft;
				else if (this.IsSonyC902)
					webOverlay = Overlays.DsiLogoBottomRightSonyC902BottomLeft;

				this.Overlay = webOverlay;
				Overlays thumbOverlay = Overlays.None;
				Overlays iconOverlay = Overlays.None;
				if (this.MediaType.Equals(MediaTypes.Video))
				{
					webOverlay = Overlays.PlayButtonLarge;
					thumbOverlay = Overlays.PlayButtonSmall;
					iconOverlay = Overlays.PlayButtonSmall;
				}
				#endregion

				#region Web
				if (updateStatus)
				{
					Active();
					Status(this.K + " Creating web image...");
					this.ProcessingProgress = 50;
					this.ProcessingLastChange = DateTime.Now;
					this.Update();
				}
				OperationReturn web = Operation(image, OperationType.MaxSide, new OperationParams() { MaxSide = webMaxSide, Overlay = webOverlay, ReturnBytes = true, AllowMaxSideToEnlarge = allowEnlargedWeb });
				this.WebWidth = web.ImageSize.Width;
				this.WebHeight = web.ImageSize.Height;
				Storage.AddToStore(web.Bytes, Storage.Stores.Pix, this.Web, "jpg", this, "Web");
				#endregion

				#region Thumb
				if (updateStatus)
				{
					Active();
					Status(this.K + " Creating thumb image...");
					this.ProcessingProgress = 60;
					this.ProcessingLastChange = DateTime.Now;
					this.Update();
				}
				OperationReturn thumb = Operation(image, OperationType.MaxSide, new OperationParams() { MaxSide = thumbMaxSide, Overlay = thumbOverlay, ReturnBytes = true, AllowMaxSideToEnlarge = true });
				this.ThumbWidth = thumb.ImageSize.Width;
				this.ThumbHeight = thumb.ImageSize.Height;
				Storage.AddToStore(thumb.Bytes, Storage.Stores.Pix, this.Thumb, "jpg", this, "Thumb");
				#endregion

				#region Icon
				if (updateStatus)
				{
					Active();
					Status(this.K + " Creating icon image...");
					this.ProcessingProgress = 70;
					this.ProcessingLastChange = DateTime.Now;
					this.Update();
				}
				OperationReturn icon = Operation(image, OperationType.FixedSize, new OperationParams() { FixedSize = new Size(100, 100), Overlay = iconOverlay, ReturnBytes = true });
				Storage.AddToStore(icon.Bytes, Storage.Stores.Pix, this.Icon, "jpg", this, "Icon");
				#endregion
				#endregion

				#region Delete temporary upload file
				if (fileSource == SaveWebFileSourceLocations.UploadTemporary)
				{
					if (updateStatus)
					{
						Active();
						Status(this.K + " Deleting temporary upload file...");
						this.ProcessingProgress = 80;
						this.ProcessingLastChange = DateTime.Now;
						this.Update();
					}

					//Delete will fail unless we dispose here as well as in the finally block!!!
					image.Dispose();

					Storage.RemoveFromStore(Storage.Stores.Temporary, this.UploadTemporary, this.UploadTemporaryExtention);
				}
				#endregion

			}
			finally
			{
				if (image != null) image.Dispose();
			}

			this.Update();

			#region Done!
			if (updateStatus)
			{
				Active();
				Status(this.K + " Done!");
				this.ProcessingProgress = 100;
				this.ProcessingLastChange = DateTime.Now;
				this.Update();
			}
			#endregion
		}
Esempio n. 18
0
		public static void FinishProcessUploadedFile(Photo p, Gallery g, Usr u)
		{

			bool reEncoded = false;
			if (p.EnabledByUsrK > 0)
				reEncoded = true;

			#region Update status
			if ((u.TotalPhotoUploads > 50 && u.AbuseAccusationsPending == 0 && !u.ModeratePhotos) || reEncoded || u.IsAdmin)
			{
				p.Status = Photo.StatusEnum.Enabled;
				if (!reEncoded)
				{
					p.EnabledDateTime = DateTime.Now;
					p.EnabledByUsrK = u.K;
				}
			}
			else
			{
				p.Status = Photo.StatusEnum.Moderate;
			}
			#endregion

			#region Set tags
			string[] tagsFromClient = p.UploadTemporaryTags.Split(',', ';', '"', '\n');
			foreach (string tagText in tagsFromClient)
			{
				string s = tagText.Trim();
				if (s.Length > 0)
				{
					try
					{
						Tag.AddTag(s, p, u);
					}
					catch { }

				}
			}
			#endregion

			p.Update();

			#region Update gallery other photos in the gallery
			if (g.TotalPhotos == 0)
				g.MainPhotoK = p.K;

			g.UpdateStats(null, false);

			if (p.Status.Equals(Photo.StatusEnum.Enabled))
			{
				g.UpdatePhotoOrder(null);
				if (!reEncoded)
					g.LastLiveDateTime = DateTime.Now;

				if (g.Event != null)
					g.Event.UpdateTotalPhotos(null);
			}

			g.Update();
			#endregion

			if (!reEncoded)
				u.LastPhotoUpload = DateTime.Now;

			u.UpdateTotalPhotos(null);

			if (p.Status == Photo.StatusEnum.Enabled)
			{
				p.SendPhotoChatAlerts();
			}

		}
Esempio n. 19
0
		public void SaveWeb(SaveWebFileSourceLocations fileSource, int rotate, Photo.EncoderStatusDelegate Status, Photo.MeaningfulActivityDelegate Active)
		{
			SaveWeb(fileSource, rotate, Status, Active, Status != null, true);
		}
		public void DeleteSelected(object o, System.EventArgs e)
		{
			SelectedOutputP.InnerHtml = "";
			int deleted = 0;
			foreach (string str in Request.Form.Keys)
			{
				if (str.StartsWith("ucEditGalleryPhotoSelectK") && Request.Form[str].Equals("1"))
				{
					deleted++;
					string str1 = str.Substring(25);
					SelectedOutputP.InnerHtml += "Deleting photo " + str1 + "...";
					try
					{
						int photoK = int.Parse(str1);
						Photo p = new Photo(photoK);
						if (p.GalleryK == CurrentGallery.K)
						{
							try
							{
								Bobs.Delete.DeleteAll(p);
								SelectedOutputP.InnerHtml += " Done.";
							}
							catch
							{
								SelectedOutputP.InnerHtml += " <b>FAILED</b> - Exception while deleting photo: " + p.K;
							}
						}
						else
						{
							SelectedOutputP.InnerHtml += " <b>FAILED</b> - photo is not in current gallery. Please contact admin with details.";
						}
					}
					catch
					{
						SelectedOutputP.InnerHtml += " <b>FAILED</b> - exception while deleting photo. Maybe a photo moderator already deleted it.";
					}
					SelectedOutputP.InnerHtml += "<br>";
				}
			}

			if (deleted == 0)
				SelectedOutputP.InnerHtml += "<b>NO PHOTOS DELETED</b> - You didn't select any photos.";

			SelectedOutputP.Visible = true;

			if (deleted > 0)
			{
				CurrentGallery.UpdateStats(null, true);
				CurrentGallery.UpdatePhotoOrder(null);

				CurrentGallery.Owner.UpdateTotalPhotos(null);

				if (CurrentGallery.Event != null)
				{
					CurrentGallery.Event.UpdateTotalPhotos(null);
					CurrentGallery.Event.UpdateTotalComments(null);
				}
				if (CurrentGallery.Article != null)
					CurrentGallery.Article.UpdateTotalComments(null);

				Mailer sm = new Mailer();
				sm.UsrRecipient = CurrentGallery.Owner;
				sm.Body = @"<p>
			Our photo moderators have deleted some of your photos. " + deleted.ToString() + " " + (deleted == 1 ? "photo was" : "photos were") + @" deleted from the <a href=""[LOGIN(" + CurrentGallery.UrlApp("edit") + @")]"">" + CurrentGallery.NameSafe + @"</a>.
Esempio n. 21
0
		public static void ProcessUploadedFile(HttpPostedFile httpPostedFile, Gallery gallery, Random random, Usr usr, int rotate, string tags)
		{
			if (usr.CanUploadTo(gallery))
			{

				Photo photo = new Photo();
				try
				{

					#region Set general stuff
					photo.UsrK = usr.K;
					photo.RandomNumber = random.NextDouble();
					photo.WeightedCoolRating = 5.0;
					photo.WeightedSexyRating = 5.0;
					photo.Order = 5.0;
					if (tags.Length > 512)
						tags = tags.Substring(0, 512);
					photo.UploadTemporaryTags = tags;
					photo.Status = Photo.StatusEnum.Processing;
					#endregion
					#region Set gallery / event / article / url fragment stuff
					photo.GalleryK = gallery.K;
					if (gallery.Event != null)
					{
						photo.EventK = gallery.EventK;
						photo.DateTime = gallery.Event.DateTime;
						photo.ParentDateTime = gallery.Event.DateTime;
					}
					else if (gallery.Article != null)
					{
						photo.ArticleK = gallery.ArticleK;
						photo.DateTime = gallery.Article.AddedDateTime;
						photo.ParentDateTime = gallery.Article.AddedDateTime;
					}
					else
					{
						photo.DateTime = DateTime.Now;
						photo.ParentDateTime = gallery.CreateDateTime;
					}
					photo.UpdateUrlFragmentNoUpdate();
					#endregion

					photo.MediaType = Photo.GetMediaType(httpPostedFile.FileName);

					if (photo.MediaType.Equals(Photo.MediaTypes.Image))
					{
						#region Initialise Guids
						photo.UploadTemporary = Guid.NewGuid();
						photo.Master = Guid.NewGuid();
						photo.Web = Guid.NewGuid();
						photo.Thumb = Guid.NewGuid();
						photo.Icon = Guid.NewGuid();
						#endregion

						photo.Rotate = rotate;
						#region Extention
						try
						{
							string s = httpPostedFile.FileName.Substring(httpPostedFile.FileName.LastIndexOf(".") + 1).ToLower();
							if (s.Length < 10)
							{
								if (s == "jpeg" || s == "jpe")
									photo.UploadTemporaryExtention = "jpg";
								else
									photo.UploadTemporaryExtention = s;
							}
							else
								photo.UploadTemporaryExtention = "jpg";
						}
						catch
						{
							photo.UploadTemporaryExtention = "jpg";
						}
						#endregion
						
					}
					else if (photo.MediaType.Equals(Photo.MediaTypes.Video))
					{
						#region Initialise Guids
						photo.UploadTemporary = Guid.NewGuid();
						photo.VideoMaster = Guid.NewGuid();
						photo.VideoMed = Guid.NewGuid();
						photo.Master = Guid.NewGuid();
						photo.Web = Guid.NewGuid();
						photo.Thumb = Guid.NewGuid();
						photo.Icon = Guid.NewGuid();
						#endregion

						#region Extention
						photo.VideoFileExtention = httpPostedFile.FileName.Substring(httpPostedFile.FileName.LastIndexOf(".") + 1).ToLower();
						photo.UploadTemporaryExtention = photo.VideoFileExtention;
						#endregion

					}

					httpPostedFile.SaveAs(Storage.TemporaryFilesystemPath(photo.UploadTemporary, photo.UploadTemporaryExtention));

					photo.Status = Photo.StatusEnum.Processing;
					photo.Update();

					if (!gallery.WatchUploads.HasValue || gallery.WatchUploads.Value)
					{
						CommentAlert.Enable(usr, photo.K, Model.Entities.ObjectType.Photo);
					}


				}
				catch (Exception exc)
				{
					#region Send an email to admin
					try
					{
					    Mailer m = new Mailer();
					    m.Subject = "Exception uploading photo from " + System.Environment.MachineName + "...";
					    m.Body = "<p>" + exc.ToString() + "</p>";
					    try
					    {
					        m.Body += "<p>The content length was " + httpPostedFile.ContentLength.ToString("#,##0") + " bytes</p>";
					    }
					    catch { }
					    m.UsrRecipient = new Usr(4);
					    m.To = "*****@*****.**";
					    m.Send();
					}
					catch { }
					#endregion

					#region Delete file
					try
					{
						Storage.RemoveFromStore(Storage.Stores.Temporary, photo.UploadTemporary, photo.UploadTemporaryExtention);
					}
					catch { }
					#endregion

					photo.Delete();

					//try
					//{
					//    if (httpPostedFile.FileName.LastIndexOf(".") > -1)
					//        httpPostedFile.SaveAs(@"C:\FailedPix\" + Guid.NewGuid() + httpPostedFile.FileName.Substring(httpPostedFile.FileName.LastIndexOf(".")));
					//    else
					//        httpPostedFile.SaveAs(@"C:\FailedPix\" + Guid.NewGuid());
					//}
					//catch (Exception ex)
					//{
					//    Utilities.AdminEmailAlert("Error writing failed photo file to disk", "Error writing failed photo file to disk", ex);
					//}

				}
				//finally
				//{
				//    CurrentGallery.UpdateStats(null, true);
				//    CurrentGallery.UpdatePhotoOrder(null);
				//    if (CurrentGallery.Event != null) CurrentGallery.Event.UpdateTotalPhotos(null);
				//}
			}
		}
Esempio n. 22
0
		private string[] SerUsrSpottedInPhoto(Usr spottedUsr, int photoK, bool isInPhoto)
		{
			Photo p = new Photo(photoK);
			spottedUsr.SetSpottedInPhoto(p, Usr.Current, isInPhoto);
			return new string[] { p.UsrsInPhotoHtml, p.RolloverMouseOverText };
		}
Esempio n. 23
0
		public void Process()
		{
			string[] arr = this.Message.ToLower().Split(' ');

			if (arr[0].StartsWith("hello"))
			{
				Photo p = new Photo(int.Parse(arr[1]));

				if (p.BlockedFromPhotoOfWeekUser)
					return;

				if (p.Status != Photo.StatusEnum.Enabled)
					return;

				//send the outgoing premium sms and await the response...

				this.ServiceType = ServiceTypes.FrontPagePhoto;
				this.Update();

				if (Common.Settings.EnablePremiumRate == Common.Settings.EnablePremiumRateOption.On)
				{

					OutgoingSms sms = new OutgoingSms();

					sms.DateTime = DateTime.Now;
					sms.Type = OutgoingSms.Types.FrontPagePhoto;
					sms.IncomingSmsK = this.K;
					sms.Message = "Your photo / video will now appear on the front page!";
					sms.ChargeType = Vars.DevEnv ? OutgoingSms.ChargeTypes.Premium012p : OutgoingSms.ChargeTypes.Premium150p;
					sms.MobileK = this.MobileK;
					sms.ServiceType = ServiceTypes.FrontPagePhoto;
					sms.Update();
					sms.Send();
				}
				else
				{
					//enable photo immediatly

					string caption = "";
					if (arr.Length > 2)
					{
						for (int i = 2; i < arr.Length; i++)
							caption += (i > 2 ? " " : "") + arr[i];

						caption = Cambro.Web.Helpers.Strip(caption, true, true, true, true);

						if (caption.Length > 200)
							caption = caption.Substring(0, 195) + "...";
					}

					p.SetAsPhotoOfWeek(true, caption, false, true);
				}

			}
			
			#region removed
			//if (arr[0].StartsWith("tonight"))
			//{
			//    #region process TONIGHT texts
			//    Mobile m = new Mobile(number, network, ServiceTypes.Tonight);
			//    this.MobileK = m.K;
			//    this.ServiceType = ServiceTypes.Tonight;
			//    this.Mobile.TotalIncoming++;
			//    this.Mobile.Update();
			//    this.Update();

			//    for (int i = 1; i < arr.Length; i++)
			//    {
			//        if (arr[i].Equals("event") || arr[i].Equals("venue"))
			//        {
			//            for (int j = 1; j < arr.Length; j++)
			//            {
			//                int eventK = 0;
			//                Event ev = null;
			//                Venue v = null;
			//                try
			//                {
			//                    eventK = int.Parse(arr[j]);
			//                    ev = new Event(eventK);
			//                    v = ev.Venue;
			//                }
			//                catch { }
			//                if (arr[i].Equals("event") && ev != null)
			//                {
			//                    ProcessTonightEventDetail(ev);
			//                    return;
			//                }
			//                else if (arr[i].Equals("venue") && ev != null && v != null)
			//                {
			//                    ProcessTonightVenueDetail(v, ev);
			//                    return;
			//                }
			//            }
			//        }
			//        else if (arr[i].Equals("help"))
			//        {
			//            ProcessTonightInfo();
			//            return;
			//        }
			//        else if (arr[i].Equals("end"))
			//        {
			//            ProcessTonightEnd();
			//            return;
			//        }
			//    }

			//    try
			//    {
			//        ArrayList placeQueryCondition = new ArrayList();
			//        ArrayList musicQueryCondition = new ArrayList();
			//        for (int i = 1; i < arr.Length; i++)
			//        {
			//            placeQueryCondition.Add(new Q(Place.Columns.Name, arr[i]));
			//            musicQueryCondition.Add(new Q(MusicType.Columns.SmsCode, arr[i]));
			//        }
			//        Q placeOr = new Or((Q[])placeQueryCondition.ToArray(typeof(Q)));
			//        Q musicOr = new Or((Q[])musicQueryCondition.ToArray(typeof(Q)));

			//        Query placeQ = new Query();
			//        placeQ.QueryCondition = new And(
			//            placeOr,
			//            new Q(Place.Columns.Enabled, true),
			//            new Q(Place.Columns.CountryK, 224)
			//            );
			//        PlaceSet ps = new PlaceSet(placeQ);

			//        Query musicQ = new Query();
			//        musicQ.QueryCondition = musicOr;
			//        MusicTypeSet mts = new MusicTypeSet(musicQ);

			//        if (mts.Count > 0 || ps.Count > 0)
			//        {
			//            ProcessTonightListings(mts, ps);
			//            return;
			//        }
			//    }
			//    catch
			//    {
			//    }

			//    ProcessTonightError();
			//    return;
			//    #endregion
			//}
			//			else if (arr[0].StartsWith("pllay"))
			//			{
			//				#region process PLLAY texts
			//				Mobile m = new Mobile(number, network, ServiceTypes.TextGuest, 1);
			//				this.MobileK = m.K;
			//				this.ServiceType=ServiceTypes.TextGuest;
			//				this.Mobile.TotalIncoming++;
			//				this.Mobile.Update();
			//				this.Update();
			//
			//				if (arr.Length>1 && arr[1].Equals("end"))
			//				{
			//					ProcessGuestEnd();
			//					return;
			//				}
			//				else
			//				{
			//					GuestPromotionSet gps = new GuestPromotionSet(new Q(GuestPromotion.Columns.Shortcut,"pllay"));
			//					GuestPromotion gp = gps[0];
			//					ProcessGuest(gp);
			//					return;
			//				}
			//				#endregion
			//			}
			//			else if (arr[0].StartsWith("guest"))
			//			{
			//				#region process GUEST texts
			//				int GuestPromotionK = 0;
			//				if (arr.Length>1)
			//				{
			//					bool numeric = true;
			//					if (arr[1].Equals("end"))
			//					{
			//						try
			//						{
			//							GuestClient c = new GuestClient(int.Parse(arr[2]));
			//							Mobile m = new Mobile(number, network, ServiceTypes.TextGuest, c.K);
			//							this.MobileK = m.K;
			//							this.ServiceType=ServiceTypes.TextGuest;
			//							this.Mobile.TotalIncoming++;
			//							this.Mobile.Update();
			//							this.Update();
			//							ProcessGuestEnd();
			//							return;
			//						}
			//						catch
			//						{
			//							return;
			//						}
			//					}
			//					else
			//					{
			//						Regex r = new Regex("[^0123456789]");
			//						try
			//						{
			//							string numbers = r.Replace(arr[1],"");
			//							GuestPromotionK = int.Parse(numbers);
			//						}
			//						catch
			//						{
			//							numeric = false;
			//						}
			//					}
			//					if (!numeric)
			//					{
			//						GuestPromotionSet gps = new GuestPromotionSet(new Q(GuestPromotion.Columns.Shortcut,arr[1].ToLower()));
			//						if (gps.Count>0)
			//							GuestPromotionK = gps[0].K;
			//					}
			//				}
			//				if (GuestPromotionK==0)
			//				{
			//					Mobile m = new Mobile(number, network, ServiceTypes.TextGuest, 0);
			//					this.MobileK = m.K;
			//					this.ServiceType=ServiceTypes.TextGuest;
			//					this.Mobile.TotalIncoming++;
			//					this.Mobile.Update();
			//					this.Update();
			//
			//					OutgoingSms.CreateOutgoingSmsSet(
			//						"Sorry, you have not entered an event code. This should be a number - it tells us which guestlist to put you on. Send GUEST followed by the code to 83248.",
			//						OutgoingSms.Types.GuestError, 
			//						this.Mobile, 
			//						this,
			//						ServiceTypes.TextGuest);
			//					return;
			//				}
			//				GuestPromotion gp = null;
			//				try
			//				{
			//					gp = new GuestPromotion(GuestPromotionK);
			//				}
			//				catch
			//				{
			//					Mobile m = new Mobile(number, network, ServiceTypes.TextGuest, 0);
			//					this.MobileK = m.K;
			//					this.ServiceType=ServiceTypes.TextGuest;
			//					this.Mobile.TotalIncoming++;
			//					this.Mobile.Update();
			//					this.Update();
			//
			//					OutgoingSms.CreateOutgoingSmsSet(
			//						"Sorry, you have entered an invalid event code. This should be a number - it tells us which guestlist to put you on. Send GUEST followed by the code to 83248.",
			//						OutgoingSms.Types.GuestError, 
			//						this.Mobile, 
			//						this,
			//						ServiceTypes.TextGuest);
			//					return;
			//				}
			//
			//				Mobile m1 = new Mobile(number, network, ServiceTypes.TextGuest, gp.Event.GuestClientK);
			//				this.MobileK = m1.K;
			//				this.ServiceType=ServiceTypes.TextGuest;
			//				this.Mobile.TotalIncoming++;
			//				this.Mobile.Update();
			//				this.Update();
			//
			//				ProcessGuest(gp);
			//				#endregion
			//			}
			#endregion
		}
Esempio n. 24
0
		public static IBob Get(Model.Entities.ObjectType type, int k)
		{
			IBob b = null;
			bool wrongType = false;
			try
			{
				switch (type)
				{
					case Model.Entities.ObjectType.Photo:
						b = new Photo(k);
						break;
					case Model.Entities.ObjectType.Event:
						b = new Event(k);
						break;
					case Model.Entities.ObjectType.Venue:
						b = new Venue(k);
						break;
					case Model.Entities.ObjectType.Place:
						b = new Place(k);
						break;
					case Model.Entities.ObjectType.Thread:
						b = new Thread(k);
						break;
					case Model.Entities.ObjectType.Country:
						b = new Country(k);
						break;
					case Model.Entities.ObjectType.Article:
						b = new Article(k);
						break;
					case Model.Entities.ObjectType.Para:
						b = new Para(k);
						break;
					case Model.Entities.ObjectType.Brand:
						b = new Brand(k);
						break;
					case Model.Entities.ObjectType.Promoter:
						b = new Promoter(k);
						break;
					case Model.Entities.ObjectType.Usr:
						b = new Usr(k);
						break;
					case Model.Entities.ObjectType.Region:
						b = new Region(k);
						break;
					case Model.Entities.ObjectType.Gallery:
						b = new Gallery(k);
						break;
					case Model.Entities.ObjectType.Group:
						b = new Group(k);
						break;
					case Model.Entities.ObjectType.Banner:
						b = new Banner(k);
						break;
					case Model.Entities.ObjectType.GuestlistCredit:
						b = new GuestlistCredit(k);
						break;
					case Model.Entities.ObjectType.Ticket:
						b = new Ticket(k);
						break;
					case Model.Entities.ObjectType.Invoice:
						b = new Invoice(k);
						break;
					case Model.Entities.ObjectType.InsertionOrder:
						b = new InsertionOrder(k);
						break;
					case Model.Entities.ObjectType.CampaignCredit:
						b = new CampaignCredit(k);
						break;
					case Model.Entities.ObjectType.UsrDonationIcon:
						b = new UsrDonationIcon(k);
						break;
					default:
						wrongType = true;
						b = null;
						break;
				}
			}
			catch { }
			if (wrongType)
				throw new Exception("Bob.Get attempted to get " + type.ToString() + " - can't do it!!! DUH!");
			return b;
		}
Esempio n. 25
0
		public string dsiTagReplacement(Match m)
		{
			string tagName = "dsi";
			try
			{
				//string[] arrParts = m.Groups[1].Value.Split[" "];
				//Dictionary<string, string> parts = new Dictionary<string, string>();
				SgmlReader sgml = new SgmlReader();
				string inStr = m.Groups[0].Value;
				if (inStr.StartsWith("<dsi:link"))
					inStr += "</dsi:link>";
				sgml.InputStream = new StringReader(inStr);
				sgml.DocType = "HTML";
				sgml.Read();

				tagName = sgml.Name;
				string uniqueId = Guid.NewGuid().ToString("N");

				#region Parse attributes
				Dictionary<string, string> attributes = new Dictionary<string, string>();
				while (sgml.MoveToNextAttribute())
				{
					attributes.Add(sgml.Name.ToLower(), sgml.Value);
				}
				#endregion

				string typeAtt = attributes.ContainsKey("type") ? attributes["type"] : null;
				string refAtt = attributes.ContainsKey("ref") ? attributes["ref"] : null;

				#region Parse styles
				Dictionary<string, string> style = new Dictionary<string, string>();
				if (attributes.ContainsKey("style"))
				{
					foreach (string s in attributes["style"].Split(';'))
					{
						try
						{
							if (s.Contains(":"))
								style[s.Split(':')[0].Trim()] = s.Split(':')[1].Trim();
						}
						catch
						{
						}
					}
				}
				#endregion

				#region Parse class
				List<string> classes = new List<string>();
				if (attributes.ContainsKey("class"))
				{
					foreach (string s in attributes["class"].Split(' '))
					{
						try
						{
							classes.Add(s);
						}
						catch
						{
						}
					}
				}
				#endregion

				if (tagName == "dsi:video")
				{
					#region dsi:video
					/*
					<dsi:video 
						type = [dsi | flv | youtube | google | metacafe | myspace | break | collegehumor | redtube | ebaumsworld | dailymotion] 
						ref = [dsi-photo-k | site-ref]
						src = [flv-url]
						width = [width] (optional)
						height = [height] (optional)
						nsfw = [true | false] (optional)
						/> 
					*/
					bool nsfw = attributes.ContainsKey("nsfw") ? bool.Parse(attributes["nsfw"].ToLower()) : false;
					string draw = attributes.ContainsKey("draw") ? attributes["draw"].ToLower() : "auto";
					if (typeAtt == "youtube")
					{
						#region youtube
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 425;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 355;

						//<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/8VtWo8tFdPQ&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/8VtWo8tFdPQ&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.youtube.com/v/" + refAtt + "&rel=1");
						#endregion
					}
					else if (typeAtt == "metacafe")
					{
						#region metacafe
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 400;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 345;

						//<embed src="http://www.metacafe.com/fplayer/1029494/how_to_make_fire_balls.swf" width="400" height="345" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"> </embed><br><font size = 1><a href="http://www.metacafe.com/watch/1029494/how_to_make_fire_balls/">How To Make Fire Balls</a> - <a href="http://www.metacafe.com/">The funniest videos clips are here</a></font>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.metacafe.com/fplayer/" + refAtt + ".swf");
						#endregion
					}
					else if (typeAtt == "google")
					{
						#region google
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 400;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 326;

						//<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-7477616603879486362&hl=en-GB" flashvars=""> </embed>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://video.google.com/googleplayer.swf?docId=" + refAtt + "&hl=en-GB");
						#endregion
					}
					else if (typeAtt == "flv")
					{
						#region flv
						string flvUrl = attributes.ContainsKey("src") ? attributes["src"] : null;
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 450;
						int height = attributes.ContainsKey("height") ? (int.Parse(attributes["height"]) + 20) : 357;

						return GetFlash(uniqueId, height, width, nsfw, draw, "/misc/flvplayer.swf", "file", flvUrl, "autoStart", "0");
						#endregion
					}
					else if (typeAtt == "dsi")
					{
						#region dsi
						try
						{
							Photo p = new Photo(int.Parse(refAtt));
							if (p.MediaType != Photo.MediaTypes.Video)
							{
								return "[Invalid ref " + refAtt + " - this is not a video]";
							}
							else
							{
								if (p.ContentDisabled)
								{
									return "[Invalid ref " + refAtt + " - video disabled]";
								}
								else
								{
									if (p.Status == Photo.StatusEnum.Enabled)
									{
										//int width = p.VideoMedWidth;
										//int height = p.VideoMedHeight + 20;

										int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : p.VideoMedWidth;
										int height = attributes.ContainsKey("height") ? (int.Parse(attributes["height"]) + 20) : (p.VideoMedHeight + 20);

										return GetFlash(uniqueId, height, width, nsfw, draw, "/misc/flvplayer.swf", "file", p.VideoMedPath, "autoStart", "0", "jpg", p.WebPath);
									}
									else if (p.Status == Photo.StatusEnum.Moderate)
									{
										return "[Invalid ref " + refAtt + " - video waiting for moderation]";
									}
									else if (p.Status == Photo.StatusEnum.Processing)
									{
										return "[Invalid ref " + refAtt + " - video still processing]";
									}
								}
							}
						}
						catch
						{
							return "[Invalid ref " + refAtt + " - video not found]";
						}
						return "[Invalid ref " + refAtt + " - error]";
						#endregion
					}
					else if (typeAtt == "collegehumor")
					{
						#region collegehumor
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 450;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 337;

						//<object type="application/x-shockwave-flash" data="http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=1754304&fullscreen=1" width="480" height="360" ><param name="allowfullscreen" value="true" /><param name="movie" quality="best" value="http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=1754304&fullscreen=1" /></object>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=" + refAtt + "&fullscreen=1");
						#endregion
					}
					else if (typeAtt == "myspace")
					{
						#region myspace
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 430;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 346;

						//<embed src="http://lads.myspace.com/videos/vplayer.swf" flashvars="m=25330587&v=2&type=video" type="application/x-shockwave-flash" width="430" height="346"></embed>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://lads.myspace.com/videos/vplayer.swf", "m", refAtt, "v", "2", "type", "video");
						#endregion
					}
					else if (typeAtt == "break")
					{
						#region break
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 464;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 392;

						//<object width="464" height="392"><param name="movie" value="http://embed.break.com/NDMyNjg3"></param><embed src="http://embed.break.com/NDMyNjg3" type="application/x-shockwave-flash" width="464" height="392"></embed></object>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://embed.break.com/" + refAtt);
						#endregion
					}
					else if (typeAtt == "redtube")
					{
						#region redtube
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 434;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 344;

						//<object height="344" width="434"><param name="movie" value="http://embed.redtube.com/player/"><param name="FlashVars" value="id=2394&style=redtube"><embed src="http://embed.redtube.com/player/?id=2394&style=redtube" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="344" width="434"></object>
						return GetFlash(uniqueId, height, width, true, draw, "http://embed.redtube.com/player/?id=" + refAtt + "&style=redtube", "id", refAtt, "style", "redtube");
						#endregion
					}
					else if (typeAtt == "ebaumsworld")
					{
						#region ebaumsworld
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 425;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 345;

						//<embed src="http://www.ebaumsworld.com/mediaplayer.swf" flashvars="file=http://media.ebaumsworld.com/2008/01/trouble-leaving-parking-lot.flv&displayheight=321&image=http://media.ebaumsworld.com/2008/01/trouble-leaving-parking-lot.jpg" loop="false" menu="false" quality="high" bgcolor="#ffffff" width="425" height="345" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.ebaumsworld.com/mediaplayer.swf", "file", "http://media.ebaumsworld.com/" + refAtt + ".flv", "displayheight", (height - 24).ToString(), "image", "http://media.ebaumsworld.com/" + refAtt + ".jpg");
						#endregion
					}
					else if (typeAtt == "dailymotion")
					{
						#region dailymotion
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 420;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 331;

						//<div><object width="420" height="331"><param name="movie" value="http://www.dailymotion.com/swf/x3xmzx"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x3xmzx" type="application/x-shockwave-flash" width="420" height="331" allowFullScreen="true" allowScriptAccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x3xmzx_time-attack-evo-crash-knockhill-200_auto">TIME ATTACK EVO CRASH KNOCKHILL 2007</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/TIMEATTACKTV">TIMEATTACKTV</a></i></div>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.dailymotion.com/swf/" + refAtt);
						#endregion
					}
					else if (typeAtt == "veoh")
					{
						return "[Veoh videos disabled]";
						#region veoh
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 450;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 365;

						//<embed src="http://www.veoh.com/videodetails2.swf?player=videodetailsembedded&type=v&permalinkId=v1644215kQ3H8PG2&id=anonymous" allowFullScreen="true" width="540" height="438" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed><br/><a href="http://www.veoh.com/">Online Videos by Veoh.com</a>
						return GetFlash(uniqueId, height, width, nsfw, draw, "http://www.veoh.com/videodetails2.swf?player=videodetailsembedded&type=v&permalinkId=" + refAtt + "&id=anonymous");
						#endregion
					}
					else
					{
						return "[Invalid type attribute]";
					}
					#endregion
				}
				else if (tagName == "dsi:audio")
				{
					#region dsi:audio
					/*
					<dsi:audio 
						type = [mp3]
						src = [mp3-url]
						nsfw = [true | false] (optional)
					/>
					*/
					if (typeAtt == "mp3")
					{
						#region mp3
						string mp3Url = attributes.ContainsKey("src") ? attributes["src"] : null;
						int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 290;
						int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 24;

						string audioPlayerSwfPath = Storage.Path(new Guid("7abb3119-f8ad-43ff-be01-764b2ae111fc"), "swf", Storage.Stores.Pix);

						return GetFlash(uniqueId, height, width, false, "load", audioPlayerSwfPath, "soundFile", mp3Url, "autoStart", "no") +
								@"<a href=""" + mp3Url + @"""><img src=""/gfx/download-button2.png"" width=""73"" height=""16"" border=""0"" /></a>";
						#endregion
					}
					else
					{
						return "[Invalid type attribute]";
					}
					#endregion
				}
				else if (tagName == "dsi:flash")
				{
					#region dsi:flash
					/*
					<dsi:flash 
						src = [swf-url]
						width = [width] 
						height = [height]
						nsfw = [true | false] (optional)
						play = [true | false] (optional)
						loop = [true | false] (optional)
						menu = [true | false] (optional)
						quality = [low | autolow | autohigh | medium | high | best] (optional)
						scale = [default | noorder | exactfit] (optional)
						align = [l | t | r | b] (optional)
						salign = [l | t | r | b | tl | tr | bl | br] (optional)
						wmode = [window | opaque | transparent] (optional)
						bgcolor = [colour] (optional)
						base = [base-url] (optional)
						flashvars = [flashvars] (optional)
						/>
					*/
					string swfUrl = attributes.ContainsKey("src") ? attributes["src"] : null;
					return getFlashAttributesFromSgml(uniqueId, swfUrl, attributes);
					#endregion
				}
				else if (tagName == "dsi:quote")
				{
					#region dsi:quote
					Usr u = null;
					try
					{
						u = new Usr(int.Parse(refAtt));
					}
					catch { }

					if (u != null)
					{
						StringBuilder sb = new StringBuilder();
						sb.Append("<div class=\"QuoteName\">");
						sb.Append(u.Link());
						sb.Append(" said:");
						sb.Append("</div>");
						sb.Append("<div class=\"QuoteBody\">");
						return sb.ToString();
					}
					else
					{
						return "<div class=\"QuoteBody\">";
					}
					#endregion
				}
				else if (tagName == "dsi:object" || tagName == "dsi:link")
				{
					#region dsi:object, dsi:link
					/*
					<dsi:object
						type = [usr | event | venue | place | group | brand | photo | misc]
						ref = [object-k]
						style = [
							content: {text* | icon | text-under-icon};   // for type=usr, event, venue, place, group, brand
							details: {none* | venue | place | country};  // for type=event, venue, place
							date: {false* | true};                       // for type=event
							snip: {number};                              // for type=event
							rollover: {true* | false}                    // for type=usr, photo
							photo: {icon* | thumb | web}                 // for type=photo
							link: {true* | false}
						]
					/>
					*/

					string app = attributes.ContainsKey("app") ? (attributes["app"] == "home" ? null : attributes["app"]) : null;
					string date = attributes.ContainsKey("date") ? attributes["date"].Replace('-', '/') : null;
					string jump = attributes.ContainsKey("jump") ? "#" + attributes["jump"] : "";
					string parStr = attributes.ContainsKey("par") ? attributes["par"] : null;
					#region Decode par array
					string[] par = null;
					if (parStr != null)
					{
						List<string> parList = new List<string>();
						foreach (string s in parStr.Split('&'))
						{
							if (s.Contains("="))
							{
								parList.Add(System.Web.HttpUtility.UrlDecode(s.Split('=')[0]));
								parList.Add(System.Web.HttpUtility.UrlDecode(s.Split('=')[1]));
							}
							else
							{
								parList.Add(System.Web.HttpUtility.UrlDecode(s));
								parList.Add("");
							}
						}
						par = parList.ToArray();
					}
					#endregion

					string styleContent = style.ContainsKey("content") ? style["content"] : "text";
					string styleDetails = style.ContainsKey("details") ? style["details"] : "none";
					bool styleDate = style.ContainsKey("date") ? bool.Parse(style["date"]) : false;
					int styleSnip = style.ContainsKey("snip") ? int.Parse(style["snip"]) : 0;
					bool styleRollover = style.ContainsKey("rollover") ? bool.Parse(style["rollover"]) : true;
					string stylePhoto = style.ContainsKey("photo") ? style["photo"] : "icon";
					bool styleLink = style.ContainsKey("link") ? bool.Parse(style["link"]) : true;

					string extraHtmlAttributes = "";
					string extraStyleAttribute = "";
					string extraStyleElements = "";
					string extraClassAttribute = "";
					string extraClassElements = "";
					foreach (string k in attributes.Keys)
					{
						if (k != "href" && k != "src" && k != "type" && k != "ref" && k != "style" && k != "app" && k != "date" && k != "par" && k != "class")
						{
							extraHtmlAttributes += " " + k + "=\"" + attributes[k] + "\"";
						}
					}

					foreach (string s in style.Keys)
					{
						if (s != "content" && s != "details" && s != "date" && s != "snip" && s != "rollover" && s != "photo" && s != "link")
						{
							extraStyleElements += s + ":" + style[s] + ";";
						}
					}
					if (extraStyleElements.Length > 0)
					{
						extraStyleAttribute = " style=\"" + extraStyleElements + "\"";
					}

					foreach (string s in classes)
					{
						extraClassElements += " " + s;
					}
					if (extraClassElements.Length > 0)
					{
						extraClassAttribute = " class=\"" + extraClassElements + "\"";
					}

					if (typeAtt == "usr")
					{
						#region Usr
						Usr u = new Usr(int.Parse(refAtt));
						string url = getObectPageUrl(u, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						string rolloverHtml = styleRollover ? ((styleContent == "icon" || styleContent == "text-under-icon") ? u.RolloverNoPic : u.Rollover) : "";

						if (styleContent == "icon" || styleContent == "text-under-icon")
						{
							#region Pic
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(rolloverHtml);
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							sb.Append("<img src=\"");
							sb.Append(u.AnyPicPath);
							sb.Append("\"");
							if (styleContent == "icon" && !styleLink)
							{
								//Just image with no link around the image... lets apply any extra html to the image tag.
								if (!attributes.ContainsKey("width"))
									sb.Append(" width=\"100\"");

								if (!attributes.ContainsKey("height"))
									sb.Append(" height=\"100\"");

								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
								sb.Append(" />");
							}
							else
								sb.Append(" width=\"100\" height=\"100\" class=\"BorderBlack All\" />");
							if (styleLink)
								sb.Append("</a>");
							if (styleContent == "text-under-icon")
								sb.Append("<br />");
							#endregion
						}
						if (styleContent == "text" || styleContent == "text-under-icon")
						{
							#region Nickname
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(rolloverHtml);
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							sb.Append(getObjectName(u.NickNameDisplay, app, styleSnip));
							if (styleLink)
								sb.Append("</a>");
							#endregion
						}
						return sb.ToString();
						#endregion
					}
					else if (typeAtt == "event")
					{
						#region Event
						Event e = new Event(int.Parse(refAtt));
						string url = getObectPageUrl(e, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0) && (styleDate || styleDetails == "venue" || styleDetails == "place" || styleDetails == "country"))
						{
							sb.Append("<span");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						#endregion

						if (styleContent == "icon" || styleContent == "text-under-icon")
						{
							#region Pic
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							sb.Append("<img src=\"");
							sb.Append(e.AnyPicPath);
							sb.Append("\"");
							if (styleContent == "icon" && !styleLink)
							{
								//Just image with no link around the image... lets apply any extra html to the image tag.
								if (!attributes.ContainsKey("width"))
									sb.Append(" width=\"100\"");

								if (!attributes.ContainsKey("height"))
									sb.Append(" height=\"100\"");

								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
								sb.Append(" />");
							}
							else
								sb.Append(" width=\"100\" height=\"100\" class=\"BorderBlack All\" />");

							if (styleLink)
								sb.Append("</a>");

							if (styleContent == "text-under-icon")
								sb.Append("<br />");

							#endregion
						}
						if (styleContent == "text" || styleContent == "text-under-icon")
						{
							#region Event link
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}

							sb.Append(getObjectName(e.Name, app, styleSnip));

							if (styleLink)
								sb.Append("</a>");
							#endregion

							#region Venue link
							if (styleDetails == "venue" || styleDetails == "place" || styleDetails == "country")
							{
								sb.Append(" @ ");
								if (styleLink)
								{
									sb.Append("<a href=\"");
									sb.Append(e.Venue.Url());
									sb.Append("\"");
									sb.Append(extraHtmlAttributes);
									sb.Append(extraStyleAttribute);
									sb.Append(extraClassAttribute);
									sb.Append(">");
								}
								sb.Append(Cambro.Misc.Utility.Snip(e.Venue.Name, styleSnip));
								if (styleLink)
									sb.Append("</a>");
							}
							#endregion

							#region Place link
							if (styleDetails == "place" || styleDetails == "country")
							{
								sb.Append(" in ");
								if (styleLink)
								{
									sb.Append("<a href=\"");
									sb.Append(e.Venue.Place.Url());
									sb.Append("\"");
									sb.Append(extraHtmlAttributes);
									sb.Append(extraStyleAttribute);
									sb.Append(extraClassAttribute);
									sb.Append(">");
								}
								if (styleDetails == "country")
								{
									sb.Append(Cambro.Misc.Utility.Snip(e.Venue.Place.Name, styleSnip));
								}
								else
								{
									sb.Append(Cambro.Misc.Utility.Snip(e.Venue.Place.NamePlain, styleSnip));
								}
								if (styleLink)
									sb.Append("</a>");

							}
							#endregion

							#region Date
							if (styleDate)
							{
								sb.Append(", ");
								sb.Append(e.FriendlyDate(false));
							}
							#endregion
						}

						#region End container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0) && (styleDetails == "venue" || styleDetails == "place" || styleDetails == "country"))
						{
							sb.Append("</span>");
						}
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "venue")
					{
						#region Venue
						Venue v = new Venue(int.Parse(refAtt));
						string url = getObectPageUrl(v, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0) && (styleDetails == "place" || styleDetails == "country"))
						{
							sb.Append("<span");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						#endregion

						if (styleContent == "icon" || styleContent == "text-under-icon")
						{
							#region Pic
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							sb.Append("<img src=\"");
							sb.Append(v.AnyPicPath);
							sb.Append("\"");
							if (styleContent == "icon" && !styleLink)
							{
								//Just image with no link around the image... lets apply any extra html to the image tag.
								if (!attributes.ContainsKey("width"))
									sb.Append(" width=\"100\"");

								if (!attributes.ContainsKey("height"))
									sb.Append(" height=\"100\"");

								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
								sb.Append(" />");
							}
							else
								sb.Append(" width=\"100\" height=\"100\" class=\"BorderBlack All\" />");
							if (styleLink)
								sb.Append("</a>");

							if (styleContent == "text-under-icon")
								sb.Append("<br />");
							#endregion
						}

						if (styleContent == "text" || styleContent == "text-under-icon")
						{
							#region Venue link
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}

							sb.Append(getObjectName(v.Name, app, styleSnip));

							if (styleLink)
								sb.Append("</a>");
							#endregion

							#region Place link
							if (styleDetails == "place" || styleDetails == "country")
							{
								sb.Append(" in ");
								if (styleLink)
								{
									sb.Append("<a href=\"");
									sb.Append(v.Place.Url());
									sb.Append("\"");
									sb.Append(extraHtmlAttributes);
									sb.Append(extraStyleAttribute);
									sb.Append(extraClassAttribute);
									sb.Append(">");
								}
								if (styleDetails == "country")
								{
									sb.Append(Cambro.Misc.Utility.Snip(v.Place.Name, styleSnip));
								}
								else
								{
									sb.Append(Cambro.Misc.Utility.Snip(v.Place.NamePlain, styleSnip));
								}
								if (styleLink)
									sb.Append("</a>");
							}
							#endregion
						}

						#region End container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0) && (styleDetails == "place" || styleDetails == "country"))
						{
							sb.Append("</span>");
						}
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "place")
					{
						#region Place
						Place p = new Place(int.Parse(refAtt));
						string url = getObectPageUrl(p, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0))
						{
							sb.Append("<span");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						#endregion

						if (styleContent == "icon" || styleContent == "text-under-icon")
						{
							#region Pic
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							sb.Append("<img src=\"");
							sb.Append(p.AnyPicPath);
							sb.Append("\"");
							if (styleContent == "icon" && !styleLink)
							{
								//Just image with no link around the image... lets apply any extra html to the image tag.
								if (!attributes.ContainsKey("width"))
									sb.Append(" width=\"100\"");

								if (!attributes.ContainsKey("height"))
									sb.Append(" height=\"100\"");

								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								if (style.ContainsKey("border"))
								{
									sb.Append(extraClassAttribute);
								}
								else
								{
									sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
								}
								
								sb.Append(" />");
							}
							else
								sb.Append(" width=\"100\" height=\"100\" class=\"BorderBlack All\" />");
							if (styleLink)
								sb.Append("</a>");
							if (styleContent == "text-under-icon")
								sb.Append("<br />");
							#endregion
						}

						if (styleContent == "text" || styleContent == "text-under-icon")
						{
							#region Place link
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							if (styleDetails == "country")
							{
								sb.Append(getObjectName(p.Name, app, styleSnip));
							}
							else
							{
								sb.Append(getObjectName(p.NamePlain, app, styleSnip));
							}
							if (styleLink)
								sb.Append("</a>");
							#endregion
						}

						#region End container span
						if ((styleContent == "text" || styleContent == "text-under-icon") && !styleLink && (extraHtmlAttributes.Length > 0 || extraStyleAttribute.Length > 0 || extraClassAttribute.Length > 0))
						{
							sb.Append("</span>");
						}
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "group")
					{
						#region Group
						Group g = new Group(int.Parse(refAtt));
						string url = getObectPageUrl(g, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Group link
						if (styleLink)
						{
							sb.Append("<a href=\"");
							sb.Append(url);
							sb.Append("\"");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						sb.Append(getObjectName(g.FriendlyName, app, styleSnip));
						if (styleLink)
							sb.Append("</a>");
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "brand")
					{
						#region Brand
						Brand b = new Brand(int.Parse(refAtt));
						string url = getObectPageUrl(b, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Brand link
						if (styleLink)
						{
							sb.Append("<a href=\"");
							sb.Append(url);
							sb.Append("\"");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						sb.Append(getObjectName(b.FriendlyName, app, styleSnip));
						if (styleLink)
							sb.Append("</a>");
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "photo")
					{
						#region Photo
						Photo p = new Photo(int.Parse(refAtt));
						string url = getObectPageUrl(p, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Link
						if (styleLink)
						{
							sb.Append("<a href=\"");
							sb.Append(url);
							sb.Append("\"");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						#endregion

						if (app != null && app == "chat")
						{
							#region For chat app, just show the name of the parent...
							sb.Append(Cambro.Misc.Utility.Snip(((IName)p.ParentObject).Name, styleSnip) + " (chat)");
							#endregion
						}
						else
						{
							#region Image tag
							sb.Append("<img");

							#region Src attribute
							sb.Append(" src=\"");
							if (stylePhoto == "thumb")
								sb.Append(p.ThumbPath);
							else if (stylePhoto == "icon")
								sb.Append(p.IconPath);
							else if (stylePhoto == "web")
								sb.Append(p.WebPath);
							sb.Append("\"");
							#endregion

							#region Width attribute
							if (styleLink || !attributes.ContainsKey("width"))
							{
								sb.Append(" width=\"");
								if (stylePhoto == "thumb")
									sb.Append(p.ThumbWidth);
								else if (stylePhoto == "icon")
									sb.Append("100");
								else if (stylePhoto == "web")
									sb.Append(p.WebWidth);
								sb.Append("\"");
							}
							#endregion

							#region Height attribute
							if (styleLink || !attributes.ContainsKey("height"))
							{
								sb.Append(" height=\"");
								if (stylePhoto == "thumb")
									sb.Append(p.ThumbHeight);
								else if (stylePhoto == "icon")
									sb.Append("100");
								else if (stylePhoto == "web")
									sb.Append(p.WebHeight);
								sb.Append("\"");
							}
							#endregion

							#region Extra html attributes
							if (!styleLink)
							{
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
							}
							#endregion

							#region Style attribute
							if (styleLink)
							{
								
								sb.Append(" class=\"BorderBlack All\"");
							}
							else if (style.ContainsKey("border"))
							{
								sb.Append(extraClassAttribute);
							}
							else
							{
								sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
							}
							#endregion

							#region Rollover
							if (styleRollover && stylePhoto != "web")
							{
								sb.Append(" onmouseover=\"stm('<img src=" + p.WebPath + " width=" + p.WebWidth + " height=" + p.WebHeight + " class=Block />');\" onmouseout=\"htm();\"");
							}
							#endregion

							sb.Append(" />");
							#endregion
						}

						#region End link
						if (styleLink)
							sb.Append("</a>");
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "misc")
					{
						#region Misc
						Misc mi = new Misc(int.Parse(refAtt));

						if (tagName == "dsi:link")
							return "<a href=\"" + mi.Url() + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						if (mi.Extention.ToLower() == "jpg" || mi.Extention.ToLower() == "jpeg" || mi.Extention.ToLower() == "gif" || mi.Extention.ToLower() == "png")
						{
							StringBuilder sb = new StringBuilder();

							#region Width and height
							int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : mi.Width;
							int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : mi.Height;
							#endregion

							#region Image tag
							sb.Append("<img src=\"");
							sb.Append(mi.Url());
							sb.Append("\" width=\"");
							sb.Append(width);
							sb.Append("\" height=\"");
							sb.Append(height);
							sb.Append("\" border=\"0\"");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(" />");
							#endregion

							return sb.ToString();

						}
						else if (mi.Extention.ToLower() == "swf")
						{
							#region Swf
							return getFlashAttributesFromSgml(uniqueId, mi.Url(), attributes);
							#endregion
						}
						#endregion
					}
					else if (typeAtt == "article")
					{
						#region Article
						Article a = new Article(int.Parse(refAtt));
						string url = getObectPageUrl(a, app, date, par) + jump;

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						#region Article link
						if (styleLink)
						{
							sb.Append("<a href=\"");
							sb.Append(url);
							sb.Append("\"");
							sb.Append(extraHtmlAttributes);
							sb.Append(extraStyleAttribute);
							sb.Append(extraClassAttribute);
							sb.Append(">");
						}
						sb.Append(getObjectName(a.FriendlyName, app, styleSnip));
						if (styleLink)
							sb.Append("</a>");
						#endregion

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "url") //if (attributes.ContainsKey("href"))
					{
						#region Url
						string url = attributes.ContainsKey("href") ? attributes["href"] : "";
						#region Get name
						string name = url;
						string path = url;
						string domain = url;
						string targetAttribute = "";
						try
						{
							if (UrlRegex.IsMatch(url))
							{
								Match urlMatch = UrlRegex.Match(url);
								if (urlMatch.Groups[3].Value.StartsWith("www."))
									name = urlMatch.Groups[3].Value.Substring(4);
								else
									name = urlMatch.Groups[3].Value;

								domain = urlMatch.Groups[3].Value;
								path = urlMatch.Groups[4].Value;
								if (!domain.ToLower().EndsWith(".dontstayin.com") && !attributes.ContainsKey("target"))
									targetAttribute = " target=\"_blank\"";

							}
						}
						catch
						{ }
						#endregion

						if (tagName == "dsi:link")
							return "<a href=\"" + url + "\"" + targetAttribute + extraHtmlAttributes + extraStyleAttribute + extraClassAttribute + ">";

						StringBuilder sb = new StringBuilder();

						if (path.ToLower().EndsWith(".jpg") || path.ToLower().EndsWith(".jpeg") || path.ToLower().EndsWith(".gif") || path.ToLower().EndsWith(".png"))
						{
							#region Image tag
							sb.Append("<img");

							#region Src attribute
							sb.Append(" src=\"");
							sb.Append(url);
							sb.Append("\"");
							#endregion

							sb.Append(extraHtmlAttributes);

							#region Style attribute
							if (domain.EndsWith(".dontstayin.com") && !style.ContainsKey("border"))
							{
								sb.Append(" class=\"BorderBlack All" + extraClassElements + "\"");
							}
							else
							{
								sb.Append(extraClassAttribute);
							}
							#endregion

							sb.Append(extraStyleAttribute);

							sb.Append(" />");
							#endregion
						}
						else if (path.ToLower().EndsWith(".mp3") || path.ToLower().EndsWith(".wav"))
						{
							#region Audio
							int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 290;
							int height = attributes.ContainsKey("height") ? int.Parse(attributes["height"]) : 24;
							string audioPlayerSwfPath = Storage.Path(new Guid("7abb3119-f8ad-43ff-be01-764b2ae111fc"), "swf", Storage.Stores.Pix);
							return GetFlash(uniqueId, height, width, false, "load", audioPlayerSwfPath, "soundFile", url, "autoStart", "no") +
								@"<a href=""" + url + @"""><img src=""/gfx/download-button2.png"" width=""73"" height=""16"" border=""0"" /></a>";
							#endregion
						}
						else if (path.ToLower().EndsWith(".swf"))
						{
							#region Swf
							return getFlashAttributesFromSgml(uniqueId, path, attributes);
							#endregion
						}
						else if (path.ToLower().EndsWith(".flv"))
						{
							#region Flv
							int width = attributes.ContainsKey("width") ? int.Parse(attributes["width"]) : 450;
							int height = attributes.ContainsKey("height") ? (int.Parse(attributes["height"]) + 20) : 357;
							bool nsfw = attributes.ContainsKey("nsfw") ? bool.Parse(attributes["nsfw"].ToLower()) : false;
							string draw = attributes.ContainsKey("draw") ? attributes["draw"].ToLower() : "auto";
							return GetFlash(uniqueId, height, width, nsfw, draw, "/misc/flvplayer.swf", "file", url, "autoStart", "0");
							#endregion
						}
						else
						{
							#region Link
							if (styleLink)
							{
								sb.Append("<a href=\"");
								sb.Append(url);
								sb.Append("\"");
								sb.Append(targetAttribute);
								sb.Append(extraHtmlAttributes);
								sb.Append(extraStyleAttribute);
								sb.Append(extraClassAttribute);
								sb.Append(">");
							}
							#endregion
							#region Name
							sb.Append(name);
							#endregion
							#region End link
							if (styleLink)
								sb.Append("</a>");
							#endregion
						}

						return sb.ToString();

						#endregion
					}
					else if (typeAtt == "room")
					{
						#region Chat room
						Guid guid = refAtt.UnPackGuid();
						Chat.RoomSpec room = Chat.RoomSpec.FromGuid(guid);

						if (room == null)
							return "[Room not found]";
						
						StringBuilder sb = new StringBuilder();
						
						if (tagName == "dsi:link")
							room.LinkHtmlAppendJustStartOfAnchorTag(sb, "selected-onyellow", extraHtmlAttributes, extraStyleAttribute, extraClassAttribute);
						else
							room.LinkHtmlAppend(sb, "selected-onyellow", extraHtmlAttributes, extraStyleAttribute, extraClassAttribute);

						return sb.ToString();

						#endregion
					}
					#endregion
				}
				return "[Invalid tag " + tagName + "]";
			}
			catch (Exception ex)
			{
				if (Vars.DevEnv)
					throw ex;

				return "[Error in " + tagName + " tag]";
			}
		}
Esempio n. 26
0
		protected void Page_Load(object sender, EventArgs e)
		{
			HttpContext.Current.Items["VisitPhotos"] = 1;
			Response.ContentType="text/xml";
			string photoKString = "0";
			bool currentUsrInPhoto = false;
			bool currentUsrFavourite = false;
			string message = null;
			string exceptionMessage = null;
			try
			{
				XmlDocument requestXml = new XmlDocument();
				requestXml.Load(Request.InputStream);
				photoKString = requestXml.DocumentElement.Attributes["k"].Value;
				Photo currentPhoto = new Photo(int.Parse(photoKString));
				currentPhoto.IncrementViews();

				try
				{
					if (currentPhoto.Overlay.Equals(Photo.Overlays.DsiLogoBottomRightThinkBottomLeft) || currentPhoto.Overlay.Equals(Photo.Overlays.DsiLogoBottomRightThinkTextBottomLeft))
					{
						//int bannerK, Banner.Positions position, DateTime date, int hits, int uniqueHits, int clicks
						Bobs.BannerStat.Log(currentPhoto.Overlay.Equals(Photo.Overlays.DsiLogoBottomRightThinkBottomLeft) ? 9295 : 9296, Banner.Positions.Hotbox, DateTime.Now, 1, 0, 0);
					}
				}
				catch { }

				if (Usr.Current != null)
				{
					try
					{
						UsrPhotoMe upm = new UsrPhotoMe(Usr.Current.K, currentPhoto.K);
						currentUsrInPhoto = true;
					}
					catch { }
					try
					{
						UsrPhotoFavourite upf = new UsrPhotoFavourite(Usr.Current.K, currentPhoto.K);
						currentUsrFavourite = true;
					}
					catch { }
				}
				message = currentPhoto.UsrHtml;
			}
			catch(Exception ex)
			{
				currentUsrInPhoto = false;
				currentUsrFavourite = false;
				exceptionMessage = ex.Message;
				message = "Error!";
			}


			XmlTextWriter x = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
			try
			{
				x.WriteStartElement("doc");
				x.WriteAttributeString("k", photoKString);
				x.WriteAttributeString("me", currentUsrInPhoto ? "1" : "0");
				x.WriteAttributeString("fav", currentUsrFavourite ? "1" : "0");
				if (exceptionMessage != null) { x.WriteAttributeString("ex", exceptionMessage); }
				x.WriteString(message);
			}
			finally
			{
				x.WriteEndElement();//doc
				x.Close();
			}
		}
Esempio n. 27
0
		public void DeleteSelected(object o, System.EventArgs e)
		{
		//	DeleteSelectedOutput.InnerHtml = "";
			int deleted = 0;
			foreach (string str in Request.Form.Keys)
			{
				if (str.StartsWith("ucEditGalleryPhotoSelectK") && Request.Form[str].Equals("1"))
				{
					deleted++;
					string str1 = str.Substring(25);
		//			DeleteSelectedOutput.InnerHtml += "Deleting photo " + str1 + "...";
					try
					{
						int photoK = int.Parse(str1);
						Photo p = new Photo(photoK);
						if (p.GalleryK == CurrentGallery.K)
						{
							Delete.DeleteAll(p);
		//					DeleteSelectedOutput.InnerHtml += " Done.";
						}
						else
						{
		//					DeleteSelectedOutput.InnerHtml += " <b>FAILED</b> - photo is not in current gallery. Please contact admin with details.";
						}
					}
					catch
					{
		//				DeleteSelectedOutput.InnerHtml += " <b>FAILED</b> - exception while deleting photo. Maybe a photo moderator already deleted it.";
					}
		//			DeleteSelectedOutput.InnerHtml += "<br>";
				}
			}

		//	if (deleted == 0)
		//		DeleteSelectedOutput.InnerHtml += "<b>NO PHOTOS DELETED</b> - You didn't select any photos.";

		//	DeleteSelectedOutput.Visible = true;

			bindNow();
		}
Esempio n. 28
0
		public void Action_Click(object o, System.EventArgs e)
		{
			if (Mode.Equals(Modes.Abuse))
			{
				if (Page.IsValid)
				{
					if (CurrentAbuse.Status.Equals(Abuse.StatusEnum.Done))
						throw new DsiUserFriendlyException("Oops - this abuse report has already been resolved - maybe someone beat you to it...");

					if (!(OverturnRadio.Checked || NoAbuseRadio.Checked || NoAbuseDeleteRadio.Checked || AbuseDeleteRadio.Checked || AbuseDeleteWatchRadio.Checked || AbuseDeleteBanRadio.Checked || AbuseDeleteBanModerateRadio.Checked))
					{
						throw new DsiUserFriendlyException("You must choose an option!");
					}

					if (OverturnRadio.Checked)
					{
						CurrentAbuse.ResolveDateTime = DateTime.Now;
						CurrentAbuse.Status = Abuse.StatusEnum.Done;
						CurrentAbuse.ResolveStatus = Abuse.ResolveStatusEnum.Overturned;
						CurrentAbuse.ResolveDescription = ResolveDescriptionTextBox.Text;
						CurrentAbuse.ResolveUsrK = Usr.Current.K;
						CurrentAbuse.Update();

						Photo p = null;
						try
						{
							p = new Photo(CurrentAbuse.ObjectK);
						}
						catch { }

						Mailer m = new Mailer();
						m.Subject = "Your abuse report has been resolved";
						m.Body = "<p>You recently filed an abuse report about a photo</p>";
						m.Body += "<p>Our moderators have reviewed the photo, and found no abuse. Please only report photos when there is a clear abuse of the photo rules. If you mis-use this abuse report service, you will not be able to make further reports.</p>";
						m.Body += "<p>Our moderator included the following note:</p>";
						m.Body += "<p><i>" + CurrentAbuse.ResolveDescription + "</i></p>";
						if (p != null)
							m.RedirectUrl = p.Url();
						m.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
						m.UsrRecipient = CurrentAbuse.ReportUsr;
						m.Send();

						CurrentAbuse.ReportUsr.UpdateAbuseTrackers();
						CurrentAbuse.AbuseUsr.UpdateAbuseTrackers();
						Bobs.Global.UpdatePhotoAbuseReports();

					}
					else if (NoAbuseRadio.Checked || NoAbuseDeleteRadio.Checked)
					{
						CurrentAbuse.ResolveDateTime = DateTime.Now;
						CurrentAbuse.Status = Abuse.StatusEnum.Done;
						CurrentAbuse.ResolveStatus = Abuse.ResolveStatusEnum.NoAbuse;
						CurrentAbuse.ResolveDescription = ResolveDescriptionTextBox.Text;
						CurrentAbuse.ResolveUsrK = Usr.Current.K;
						CurrentAbuse.Update();

						Photo p = null;
						try
						{
							p = new Photo(CurrentAbuse.ObjectK);
							if (NoAbuseDeleteRadio.Checked)
								p.DeleteAll(null);
						}
						catch { }

						Mailer m = new Mailer();
						m.Subject = "Your abuse report has been resolved";
						m.Body = "<p>You recently filed an abuse report about a photo</p>";
						m.Body += "<p>Our moderators have reviewed the photo, and found no abuse. Your report was helpful however.</p>";
						m.Body += "<p>Our moderator included the following note:</p>";
						m.Body += "<p><i>" + CurrentAbuse.ResolveDescription + "</i></p>";
						if (p != null)
							m.RedirectUrl = p.Url();
						m.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
						m.UsrRecipient = CurrentAbuse.ReportUsr;
						m.Send();

						CurrentAbuse.ReportUsr.UpdateAbuseTrackers();
						CurrentAbuse.AbuseUsr.UpdateAbuseTrackers();
						Bobs.Global.UpdatePhotoAbuseReports();
					}
					else if (AbuseDeleteRadio.Checked || AbuseDeleteWatchRadio.Checked || AbuseDeleteBanRadio.Checked || AbuseDeleteBanModerateRadio.Checked)
					{
						try
						{
							Photo ph = new Photo(CurrentAbuse.ObjectK);
							ph.DeleteAll(null);
						}
						catch { }

						if (AbuseDeleteWatchRadio.Checked)
						{
							try
							{
								CurrentAbuse.AbuseUsr.ModeratePhotos = true;
								CurrentAbuse.AbuseUsr.Update();
							}
							catch { }
						}

						if (AbuseDeleteBanRadio.Checked)
						{
							try
							{
								CurrentAbuse.AbuseUsr.Banned = true;
								CurrentAbuse.AbuseUsr.BannedByUsrK = Usr.Current.K;
								CurrentAbuse.AbuseUsr.BannedDateTime = DateTime.Now;
								CurrentAbuse.AbuseUsr.BannedReason = ResolveDescriptionTextBox.Text;
								CurrentAbuse.AbuseUsr.Update();

								Mailer sm = new Mailer();
								sm.Body = "<p>Banned user: <a href=\"[LOGIN(" + CurrentAbuse.AbuseUsr.Url() + ")]\">" + CurrentAbuse.AbuseUsr.NickName + "</a> (" + CurrentAbuse.AbuseUsr.K + " - " + CurrentAbuse.AbuseUsr.Email + ")</p>";
								sm.Body += "<p>They were banned by: <a href=\"[LOGIN(" + Usr.Current.Url() + ")]\">" + Usr.Current.NickName + "</a> (" + Usr.Current.K + " - " + Usr.Current.Email + ")</p>";
								sm.Body += "<p>DateTime: " + DateTime.Now.ToString() + "</p>";
								sm.Body += "<p>Reason: " + ResolveDescriptionTextBox.Text + "</p>";
								sm.TemplateType = Mailer.TemplateTypes.AdminNote;
								sm.Subject = "New banned user - " + CurrentAbuse.AbuseUsr.NickName + " was banned by " + Usr.Current.NickName;
								sm.To = "*****@*****.**";
								sm.Send();

							}
							catch { }
						}

						if (AbuseDeleteBanModerateRadio.Checked)
						{
							Query q = new Query();
							q.QueryCondition = new Q(Gallery.Columns.OwnerUsrK, CurrentAbuse.AbuseUsrK);
							GallerySet gs = new GallerySet(q);
							foreach (Gallery g in gs)
							{
								Query qP = new Query();
								qP.QueryCondition = new Q(Photo.Columns.GalleryK, g.K);
								PhotoSet ps = new PhotoSet(qP);
								foreach (Photo ph in ps)
								{
									ph.Status = Photo.StatusEnum.Moderate;
									ph.Update();
								}

								g.UpdateStats(null, true);
								g.UpdatePhotoOrder(null);

								if (g.Event != null)
									g.Event.UpdateTotalPhotos(null);
							}
						}

						CurrentAbuse.ResolveDateTime = DateTime.Now;
						CurrentAbuse.Status = Abuse.StatusEnum.Done;
						CurrentAbuse.ResolveStatus = Abuse.ResolveStatusEnum.Abuse;
						CurrentAbuse.ResolveDescription = ResolveDescriptionTextBox.Text;
						CurrentAbuse.ResolveUsrK = Usr.Current.K;
						CurrentAbuse.Update();

						Mailer m = new Mailer();
						m.Subject = "Your abuse report has been resolved";
						m.Body = "<p>You recently filed an abuse report about a photo</p>";
						m.Body += "<p>Our moderators have reviewed the photo, and found it breaks our rules. It has been deleted.</p>";
						m.Body += "<p>Our moderator included the following note:</p>";
						m.Body += "<p><i>" + CurrentAbuse.ResolveDescription + "</i></p>";
						m.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
						m.UsrRecipient = CurrentAbuse.ReportUsr;
						m.Send();

						CurrentAbuse.ReportUsr.UpdateAbuseTrackers();
						CurrentAbuse.AbuseUsr.UpdateAbuseTrackers();
						Bobs.Global.UpdatePhotoAbuseReports();
					}
					PanelAbuse_Load(null, null);
				}
			}
		}
Esempio n. 29
0
		void BuildUsrPhotoMeList(Photo currentPhoto)
		{
			if (currentPhoto.UsrCount == 0)
			{
				PanelThreadSubjectPhotoMePanel.Visible = false;
			}
			else
			{
				PanelThreadSubjectPhotoMePanel.Visible = true;
				PanelThreadSubjectPhotoMePh.Controls.Clear();
				PanelThreadSubjectPhotoMePh.Controls.Add(new LiteralControl(currentPhoto.UsrHtml));
			}
		}
Esempio n. 30
0
		private void PanelAbuse_Load(object sender, System.EventArgs e)
		{
			if (Mode.Equals(Modes.Abuse))
			{
				ChangePanel(PanelAbuse);
				PhotoKLabel.Text = CurrentAbuse.ObjectK.ToString();
				PhotoStringLabel.Text = CurrentAbuse.ObjectString;
				Photo p = null;
				try
				{
					p = new Photo(CurrentAbuse.ObjectK);
				}
				catch { }

				if (p != null)
				{
					ThisGalleryP.InnerHtml = "<a href=\"" + p.Gallery.PagedUrl() + "\" target=\"_blank\">" + p.Gallery.UrlNoSkip() + "</a> - <a href=\"" + p.Gallery.UrlApp("edit") + "\" target=\"_blank\">[edit]</a> - (" + p.Gallery.TotalPhotos + " photos, " + p.Gallery.LivePhotos + " live)<br>";

					PhotoAnchor.HRef = p.Url();
					PhotoImg.Src = p.WebPath;
					PhotoImg.Height = p.WebHeight;
					PhotoImg.Width = p.WebWidth;
					PhotoPanel.Visible = true;
					NoPhotoPanel.Visible = false;
				}
				else
				{
					ThisGalleryPanel.Visible = false;
					PhotoPanel.Visible = false;
					NoPhotoPanel.Visible = true;
				}

				AbuseByP.InnerHtml = CurrentAbuse.AbuseUsr.LinkNewWindow() + "<br>";
				AbuseByP.InnerHtml += "Pending abuse accusations: " + CurrentAbuse.AbuseUsr.AbuseAccusationsPending + "<br>";
				AbuseByP.InnerHtml += "Abuse in the past: " + CurrentAbuse.AbuseUsr.AbuseAccusationsAbuse + "<br>";
				AbuseByP.InnerHtml += "Accusations with no abuse: " + CurrentAbuse.AbuseUsr.AbuseAccusationsNoAbuse;

				ReportByP.InnerHtml = CurrentAbuse.ReportUsr.LinkNewWindow() + "<br>";
				ReportByP.InnerHtml += "Pending abuse reports: " + CurrentAbuse.ReportUsr.AbuseReportsPending + "<br>";
				ReportByP.InnerHtml += "Successful abuse reports: " + CurrentAbuse.ReportUsr.AbuseReportsUseful + "<br>";
				ReportByP.InnerHtml += "Overturned abuse reports: " + CurrentAbuse.ReportUsr.AbuseReportsOverturned;

				ReportDescriptionP.InnerText = CurrentAbuse.ReportDescription;



				Query q = new Query();
				q.QueryCondition = new Q(Gallery.Columns.OwnerUsrK, CurrentAbuse.AbuseUsrK);
				q.TopRecords = 20;
				q.OrderBy = new OrderBy(Gallery.Columns.LastLiveDateTime, OrderBy.OrderDirection.Descending);
				GallerySet gs = new GallerySet(q);
				GalleriesP.InnerHtml = "";
				foreach (Gallery g in gs)
				{
					GalleriesP.InnerHtml += "<a href=\"" + g.PagedUrl() + "\" target=\"_blank\">" + g.UrlNoSkip() + "</a> - <a href=\"" + g.UrlApp("edit") + "\" target=\"_blank\">[edit]</a> - (" + g.TotalPhotos + " photos, " + g.LivePhotos + " live)<br>";
				}

				if (CurrentAbuse.Status.Equals(Abuse.StatusEnum.Done))
				{
					ActionsPanel.Visible = false;
					ResolvedPanel.Visible = true;
					if (CurrentAbuse.ResolveStatus.Equals(Abuse.ResolveStatusEnum.Abuse))
						ResolvedLabel.Text = "There was abuse.";
					else if (CurrentAbuse.ResolveStatus.Equals(Abuse.ResolveStatusEnum.NoAbuse))
						ResolvedLabel.Text = "There was no abuse, but the report was helpful.";
					else if (CurrentAbuse.ResolveStatus.Equals(Abuse.ResolveStatusEnum.Overturned))
						ResolvedLabel.Text = "There was no abuse, the report was overturned.";

					ResolvedLabel.Text += " Resolved by " + CurrentAbuse.ResolveUsr.Link() + ", " + Cambro.Misc.Utility.FriendlyTime(CurrentAbuse.ResolveDateTime);
					ResolveDescriptionP.InnerText = CurrentAbuse.ResolveDescription;

				}
				else
				{
					ActionsPanel.Visible = true;
					ResolvedPanel.Visible = false;
				}
			}
		}