public static void HeaderChange(NetState state, PacketReader pvSrc) { Mobile from = state.Mobile; BaseBook book = World.FindItem(pvSrc.ReadInt32()) as BaseBook; if (book == null || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from)) { return; } pvSrc.Seek(4, SeekOrigin.Current); // Skip flags and page count int titleLength = pvSrc.ReadUInt16(); if (titleLength > 60) { return; } string title = pvSrc.ReadUTF8StringSafe(titleLength); int authorLength = pvSrc.ReadUInt16(); if (authorLength > 30) { return; } string author = pvSrc.ReadUTF8StringSafe(authorLength); title = Utility.FixHtml(title); author = Utility.FixHtml(author); #region AntiAdverts if (!String.IsNullOrWhiteSpace(title)) { int exit = 100; string detected; while (AntiAdverts.Detect(title, out detected) && !String.IsNullOrWhiteSpace(detected) && --exit >= 0) { title = title.Replace(detected, new String('*', detected.Length)); } } if (!String.IsNullOrWhiteSpace(author)) { int exit = 100; string detected; while (AntiAdverts.Detect(author, out detected) && !String.IsNullOrWhiteSpace(detected) && --exit >= 0) { author = author.Replace(detected, new String('*', detected.Length)); } } #endregion book.Title = title; book.Author = author; }
protected NameResultMessage VerifyName(PlayerMobile m, string name, bool message) { if (m == null || m.Deleted) { return(NameResultMessage.NotAllowed); } if (String.IsNullOrWhiteSpace(name)) { if (message) { m.SendMessage("The name you chose is too short."); } return(NameResultMessage.TooFewCharacters); } string kw; if (AntiAdverts.Detect(name, out kw)) { if (message) { m.SendMessage("The name you chose is not allowed."); } return(NameResultMessage.NotAllowed); } NameResultMessage res = NameVerification.ValidatePlayerName( name, 1, 16, true, false, true, 0, NameVerification.Empty, NameVerification.DisallowedWords, NameVerification.StartDisallowed, NameVerification.DisallowedAnywhere); switch (res) { case NameResultMessage.InvalidCharacter: { if (message) { m.SendMessage("The name you chose contains invalid characters."); } } return(res); case NameResultMessage.NotAllowed: { if (message) { m.SendMessage("The name you chose is not allowed."); } } return(res); case NameResultMessage.TooFewCharacters: { if (message) { m.SendMessage("The name you chose is too short."); } } return(res); case NameResultMessage.TooManyCharacters: { if (message) { m.SendMessage("The name you chose is too long."); } } return(res); } if (ProfanityProtection.DisallowedWords.Any(t => name.IndexOf(t, StringComparison.OrdinalIgnoreCase) != -1)) { // That name isn't very polite. m.SendLocalizedMessage(1072622); return(NameResultMessage.NotAllowed); } return(NameResultMessage.Allowed); }
public static void ContentChange(NetState state, PacketReader pvSrc) { Mobile from = state.Mobile; BaseBook book = World.FindItem(pvSrc.ReadInt32()) as BaseBook; if (book == null || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from)) { return; } int pageCount = pvSrc.ReadUInt16(); if (pageCount > book.PagesCount) { return; } for (int i = 0; i < pageCount; ++i) { int index = pvSrc.ReadUInt16(); if (index >= 1 && index <= book.PagesCount) { --index; int lineCount = pvSrc.ReadUInt16(); if (lineCount <= 8) { string[] lines = new string[lineCount]; lines.SetAll( j => { string line = pvSrc.ReadUTF8StringSafe(); if (!String.IsNullOrWhiteSpace(line)) { if (line.Length > 80) { line = line.Substring(0, 80); } #region AntiAdverts int exit = 100; string detected; while (AntiAdverts.Detect(line, out detected) && !String.IsNullOrWhiteSpace(detected) && --exit >= 0) { line = line.Replace(detected, new String('*', detected.Length)); } #endregion } return(line); }); book.Pages[index].Lines = lines; } else { return; } } else { return; } } }