diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index 4c6abbd7d0b..082af09f3f1 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -431,7 +431,7 @@ proc/checkhtml(var/t) text = copytext(text, 1, index) + repl_chars[char] + copytext(text, index+keylength) index = findtext(text, char) return text - + //Checks if any of a given list of needles is in the haystack /proc/text_in_list(haystack, list/needle_list, start=1, end=0) for(var/needle in needle_list) @@ -445,3 +445,98 @@ proc/checkhtml(var/t) if(findtextEx(haystack, needle, start, end)) return 1 return 0 + + +// Pencode +/proc/pencode_to_html(text, mob/user, var/obj/item/weapon/pen/P = null, deffont = "Verdana", signfont = "Times New Roman", crayonfont = "Comic Sans MS") + text = replacetext(text, "\n", "
") + text = replacetext(text, "\[center\]", "
") + text = replacetext(text, "\[/center\]", "
") + text = replacetext(text, "\[br\]", "
") + text = replacetext(text, "\[b\]", "") + text = replacetext(text, "\[/b\]", "") + text = replacetext(text, "\[i\]", "") + text = replacetext(text, "\[/i\]", "") + text = replacetext(text, "\[u\]", "") + text = replacetext(text, "\[/u\]", "") + text = replacetext(text, "\[large\]", "") + text = replacetext(text, "\[/large\]", "") + text = replacetext(text, "\[sign\]", "[user ? user.real_name : "Anonymous"]") + text = replacetext(text, "\[field\]", "") + + text = replacetext(text, "\[h1\]", "

") + text = replacetext(text, "\[/h1\]", "

") + text = replacetext(text, "\[h2\]", "

") + text = replacetext(text, "\[/h2\]", "

") + text = replacetext(text, "\[h3\]", "

") + text = replacetext(text, "\[/h3\]", "

") + + if(istype(P, /obj/item/weapon/pen)) + text = replacetext(text, "\[*\]", "
  • ") + text = replacetext(text, "\[hr\]", "
    ") + text = replacetext(text, "\[small\]", "") + text = replacetext(text, "\[/small\]", "") + text = replacetext(text, "\[list\]", "") + text = replacetext(text, "\[table\]", "") + text = replacetext(text, "\[/table\]", "
    ") + text = replacetext(text, "\[grid\]", "") + text = replacetext(text, "\[/grid\]", "
    ") + text = replacetext(text, "\[row\]", "") + text = replacetext(text, "\[cell\]", "") + text = replacetext(text, "\[logo\]", "") + + text = "[text]" + else // If it is a crayon, and he still tries to use these, make them empty! + text = replacetext(text, "\[*\]", "") + text = replacetext(text, "\[hr\]", "") + text = replacetext(text, "\[small\]", "") + text = replacetext(text, "\[/small\]", "") + text = replacetext(text, "\[list\]", "") + text = replacetext(text, "\[/list\]", "") + text = replacetext(text, "\[table\]", "") + text = replacetext(text, "\[/table\]", "") + text = replacetext(text, "\[row\]", "") + text = replacetext(text, "\[cell\]", "") + text = replacetext(text, "\[logo\]", "") + + text = "[text]" + + text = copytext(text, 1, MAX_PAPER_MESSAGE_LEN) + return text + +/proc/html_to_pencode(text) + text = replacetext(text, "
    ", "\n") + text = replacetext(text, "
    ", "\[center\]") + text = replacetext(text, "
    ", "\[/center\]") + text = replacetext(text, "
    ", "\[br\]") + text = replacetext(text, "", "\[b\]") + text = replacetext(text, "", "\[/b\]") + text = replacetext(text, "", "\[i\]") + text = replacetext(text, "", "\[/i\]") + text = replacetext(text, "", "\[u\]") + text = replacetext(text, "", "\[/u\]") + text = replacetext(text, "", "\[large\]") + text = replacetext(text, "", "\[field\]") + + text = replacetext(text, "

    ", "\[h1\]") + text = replacetext(text, "

    ", "\[/h1\]") + text = replacetext(text, "

    ", "\[h2\]") + text = replacetext(text, "

    ", "\[/h2\]") + text = replacetext(text, "

    ", "\[h3\]") + text = replacetext(text, "

    ", "\[/h3\]") + + text = replacetext(text, "
  • ", "\[*\]") + text = replacetext(text, "
    ", "\[hr\]") + text = replacetext(text, "", "\[small\]") + text = replacetext(text, "
      ", "\[list\]") + text = replacetext(text, "
    ", "\[/list\]") + text = replacetext(text, "", "\[table\]") + text = replacetext(text, "
    ", "\[/table\]") + text = replacetext(text, "", "\[grid\]") + text = replacetext(text, "
    ", "\[/grid\]") + text = replacetext(text, "", "\[row\]") + text = replacetext(text, "", "\[cell\]") + text = replacetext(text, "", "\[logo\]") + return text + diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index fde15986d0b..d61400c9fa1 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -3137,6 +3137,59 @@ ticker.mode.station_goals += G modify_goals() + // Library stuff + else if(href_list["library_book_id"]) + var/isbn = sanitizeSQL(href_list["library_book_id"]) + + if(href_list["view_library_book"]) + var/DBQuery/query_view_book = dbcon.NewQuery("SELECT content, title FROM [format_table_name("library")] WHERE id=[isbn]") + if(!query_view_book.Execute()) + var/err = query_view_book.ErrorMsg() + log_game("SQL ERROR viewing book. Error : \[[err]\]\n") + return + + var/content = "" + var/title = "" + while(query_view_book.NextRow()) + content = query_view_book.item[1] + title = html_encode(query_view_book.item[2]) + + var/dat = "
    "
    +			dat += "[html_encode(html_to_pencode(content))]"
    +			dat += "
    " + + var/datum/browser/popup = new(usr, "admin_view_book", "[title]", 700, 400) + popup.set_content(dat) + popup.open(0) + + log_admin("[key_name(usr)] has viewed the book [isbn].") + message_admins("[key_name_admin(usr)] has viewed the book [isbn].") + return + + else if(href_list["unflag_library_book"]) + var/DBQuery/query_unflag_book = dbcon.NewQuery("UPDATE [format_table_name("library")] SET flagged = 0 WHERE id=[isbn]") + if(!query_unflag_book.Execute()) + var/err = query_unflag_book.ErrorMsg() + log_game("SQL ERROR unflagging book. Error : \[[err]\]\n") + return + + log_admin("[key_name(usr)] has unflagged the book [isbn].") + message_admins("[key_name_admin(usr)] has unflagged the book [isbn].") + + else if(href_list["delete_library_book"]) + var/DBQuery/query_delbook = dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[isbn]") + if(!query_delbook.Execute()) + var/err = query_delbook.ErrorMsg() + log_game("SQL ERROR deleting book. Error : \[[err]\]\n") + return + + log_admin("[key_name(usr)] has deleted the book [isbn].") + message_admins("[key_name_admin(usr)] has deleted the book [isbn].") + + // Refresh the page + src.view_flagged_books() + + /proc/admin_jump_link(var/atom/target) if(!target) return // The way admin jump links handle their src is weirdly inconsistent... diff --git a/code/modules/library/admin.dm b/code/modules/library/admin.dm index 7e3abd91db9..83268c5eecb 100644 --- a/code/modules/library/admin.dm +++ b/code/modules/library/admin.dm @@ -29,13 +29,36 @@ to_chat(src, "Only administrators may use this command.") return + holder.view_flagged_books() + +/datum/admins/proc/view_flagged_books() + if(!usr.client.holder) + return + + var/dat = "" + var/DBQuery/query = dbcon.NewQuery("SELECT id, title, flagged FROM [format_table_name("library")] WHERE flagged > 0 ORDER BY flagged DESC") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR getting flagged books. Error : \[[err]\]\n") return - var/i - for(i = 0, query.NextRow(), i++) - to_chat(usr, "[add_zero(query.item[1], 4)] ([query.item[2]]) - flagged [query.item[3]] times.") - to_chat(usr, "[i] flagged books total.") \ No newline at end of file + var/books = 0 + while(query.NextRow()) + books++ + var/isbn = query.item[1] + dat += "" + + dat += "
    ISBNTitleTotal FlagsOptions
    [add_zero(isbn, 4)][query.item[2]][query.item[3]]" + dat += "View Content" + dat += "Unflag" + dat += "Delete" + dat += "
    " + + if(!books) + dat = "

    No flagged books! :)

    " + + var/datum/browser/popup = new(usr, "admin_view_flagged_books", "Flagged Books", 700, 400) + popup.set_content(dat) + popup.open(0) + diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index 7e5f847419f..a5f04461551 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -199,62 +199,8 @@ update_icon() -/obj/item/weapon/paper/proc/parsepencode(var/t, var/obj/item/weapon/pen/P, mob/user as mob, var/iscrayon = 0) -// t = sanitize(copytext(t),1,MAX_MESSAGE_LEN) - - t = replacetext(t, "\[center\]", "
    ") - t = replacetext(t, "\[/center\]", "
    ") - t = replacetext(t, "\[br\]", "
    ") - t = replacetext(t, "\[b\]", "") - t = replacetext(t, "\[/b\]", "") - t = replacetext(t, "\[i\]", "") - t = replacetext(t, "\[/i\]", "") - t = replacetext(t, "\[u\]", "") - t = replacetext(t, "\[/u\]", "") - t = replacetext(t, "\[large\]", "") - t = replacetext(t, "\[/large\]", "") - t = replacetext(t, "\[sign\]", "[user ? user.real_name : "Anonymous"]") - t = replacetext(t, "\[field\]", "") - - t = replacetext(t, "\[h1\]", "

    ") - t = replacetext(t, "\[/h1\]", "

    ") - t = replacetext(t, "\[h2\]", "

    ") - t = replacetext(t, "\[/h2\]", "

    ") - t = replacetext(t, "\[h3\]", "

    ") - t = replacetext(t, "\[/h3\]", "

    ") - - if(!iscrayon) - t = replacetext(t, "\[*\]", "
  • ") - t = replacetext(t, "\[hr\]", "
    ") - t = replacetext(t, "\[small\]", "") - t = replacetext(t, "\[/small\]", "") - t = replacetext(t, "\[list\]", "
      ") - t = replacetext(t, "\[/list\]", "
    ") - t = replacetext(t, "\[table\]", "") - t = replacetext(t, "\[/table\]", "
    ") - t = replacetext(t, "\[grid\]", "") - t = replacetext(t, "\[/grid\]", "
    ") - t = replacetext(t, "\[row\]", "") - t = replacetext(t, "\[cell\]", "") - t = replacetext(t, "\[logo\]", "") - - t = "[t]" - else // If it is a crayon, and he still tries to use these, make them empty! - t = replacetext(t, "\[*\]", "") - t = replacetext(t, "\[hr\]", "") - t = replacetext(t, "\[small\]", "") - t = replacetext(t, "\[/small\]", "") - t = replacetext(t, "\[list\]", "") - t = replacetext(t, "\[/list\]", "") - t = replacetext(t, "\[table\]", "") - t = replacetext(t, "\[/table\]", "") - t = replacetext(t, "\[row\]", "") - t = replacetext(t, "\[cell\]", "") - t = replacetext(t, "\[logo\]", "") - - t = "[t]" - - t = copytext(t, 1, MAX_PAPER_MESSAGE_LEN) +/obj/item/weapon/paper/proc/parsepencode(var/t, var/obj/item/weapon/pen/P, mob/user as mob) + t = pencode_to_html(t, usr, P, deffont, signfont, crayonfont) //Count the fields var/laststart = 1 @@ -303,12 +249,10 @@ //var/t = strip_html_simple(input("Enter what you want to write:", "Write", null, null) as message, MAX_MESSAGE_LEN) var/t = input("Enter what you want to write:", "Write", null, null) as message var/obj/item/i = usr.get_active_hand() // Check to see if he still got that darn pen, also check if he's using a crayon or pen. - var/iscrayon = 0 add_hiddenprint(usr) // No more forging nasty documents as someone else, you jerks if(!istype(i, /obj/item/weapon/pen)) if(!istype(i, /obj/item/toy/crayon)) return - iscrayon = 1 // if paper is not in usr, then it must be near them, or in a clipboard or folder, which must be in or near usr @@ -326,8 +270,7 @@ return */ t = html_encode(t) - t = replacetext(t, "\n", "
    ") - t = parsepencode(t, i, usr, iscrayon) // Encode everything from pencode to html + t = parsepencode(t, i, usr) // Encode everything from pencode to html if(id!="end") addtofield(text2num(id), t) // He wants to edit a field, let him.