mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-26 10:03:45 +00:00
Merge pull request #22 from Tastyfish/master
Merged tg's and bay12's paper code, and closed a possible exploit.
This commit is contained in:
@@ -163,6 +163,7 @@ var
|
||||
|
||||
//Don't set this very much higher then 1024 unless you like inviting people in to dos your server with message spam
|
||||
const/MAX_MESSAGE_LEN = 1024
|
||||
const/MAX_PAPER_MESSAGE_LEN = 3072
|
||||
|
||||
const/shuttle_time_in_station = 1800 // 3 minutes in the station
|
||||
const/shuttle_time_to_arrive = 6000 // 10 minutes to arrive
|
||||
|
||||
@@ -14,7 +14,6 @@ CLIPBOARDS
|
||||
// PAPER
|
||||
|
||||
/obj/item/weapon/paper/New()
|
||||
|
||||
..()
|
||||
src.pixel_y = rand(-8, 8)
|
||||
src.pixel_x = rand(-9, 9)
|
||||
@@ -22,160 +21,35 @@ CLIPBOARDS
|
||||
src.overlays += "paper_words"
|
||||
return
|
||||
|
||||
|
||||
/obj/item/weapon/paper/examine()
|
||||
set src in view()
|
||||
|
||||
..()
|
||||
if (!( istype(usr, /mob/living/carbon/human) || istype(usr, /mob/dead/observer) || istype(usr, /mob/living/silicon) ))
|
||||
usr << browse(text("<HTML><HEAD><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", src.name, stars(src.info)), text("window=[]", src.name))
|
||||
// actually strip formatting, so stars doesn't screw up
|
||||
var/t = dd_replacetext(src.info, "\n", "")
|
||||
t = dd_replacetext(t, "\[b\]", "")
|
||||
t = dd_replacetext(t, "\[/b\]", "")
|
||||
t = dd_replacetext(t, "\[i\]", "")
|
||||
t = dd_replacetext(t, "\[/i\]", "")
|
||||
t = dd_replacetext(t, "\[u\]", "")
|
||||
t = dd_replacetext(t, "\[/u\]", "")
|
||||
usr << browse(text("<HTML><HEAD><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", src.name, stars(t)), text("window=[]", src.name))
|
||||
onclose(usr, "[src.name]")
|
||||
else
|
||||
usr << browse(text("<HTML><HEAD><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", src.name, src.info), text("window=[]", src.name))
|
||||
// if people want lazy bb-code
|
||||
var/t = dd_replacetext(src.info, "\n", "<BR>")
|
||||
t = dd_replacetext(t, "\[b\]", "<B>")
|
||||
t = dd_replacetext(t, "\[/b\]", "</B>")
|
||||
t = dd_replacetext(t, "\[i\]", "<I>")
|
||||
t = dd_replacetext(t, "\[/i\]", "</I>")
|
||||
t = dd_replacetext(t, "\[u\]", "<U>")
|
||||
t = dd_replacetext(t, "\[/u\]", "</U>")
|
||||
t = text("<font face=calligrapher>[]</font>", t)
|
||||
usr << browse(text("<HTML><HEAD><TITLE>[]</TITLE></HEAD><BODY><TT>[]</TT></BODY></HTML>", src.name, t), text("window=[]", src.name))
|
||||
onclose(usr, "[src.name]")
|
||||
return
|
||||
|
||||
/obj/item/weapon/pen/proc/formatText(var/s)
|
||||
if (text_size < 2 || text_size > 7)
|
||||
text_size = 3
|
||||
if (!(text_color))
|
||||
text_color = "#000000"
|
||||
|
||||
var/textToAddHeader = ""
|
||||
var/textToAddFooter = ""
|
||||
|
||||
if (text_color && text_size)
|
||||
textToAddHeader = "<font size=[text_size] color=[text_color]>"
|
||||
textToAddFooter = "</font>"
|
||||
|
||||
if (text_bold == 1)
|
||||
textToAddHeader = "[textToAddHeader]<b>"
|
||||
textToAddFooter = "</b>[textToAddFooter]"
|
||||
|
||||
if (text_underline == 1)
|
||||
textToAddHeader = "[textToAddHeader]<u>"
|
||||
textToAddFooter = "</u>[textToAddFooter]"
|
||||
|
||||
if (text_italic == 1)
|
||||
textToAddHeader = "[textToAddHeader]<i>"
|
||||
textToAddFooter = "</i>[textToAddFooter]"
|
||||
|
||||
if (text_break == 1)
|
||||
textToAddFooter = "[textToAddFooter]<br>"
|
||||
|
||||
var/r = "[textToAddHeader][s][textToAddFooter]"
|
||||
return r
|
||||
|
||||
/obj/item/weapon/pen/attack_self(mob/user as mob)
|
||||
var/dat
|
||||
|
||||
dat = text("How would you like to write?<br>")
|
||||
|
||||
dat = text("[formatText("example")]<br>")
|
||||
|
||||
dat += text("<b>size:</b><br>")
|
||||
dat += text("<A href='?src=\ref[src];size=2'><font size=2>2</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];size=3'><font size=3>3</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];size=4'><font size=4>4</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];size=5'><font size=5>5</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];size=6'><font size=6>6</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];size=7'><font size=7>7<font></A><br><br>")
|
||||
|
||||
dat += text("<b>Color:</b><br>")
|
||||
dat += text("<A href='?src=\ref[src];color=["000000"]'><font color=black>black:</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["222222"]'><font color=#222222>1</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["444444"]'><font color=#444444>2</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["666666"]'><font color=#666666>3</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["888888"]'><font color=#888888>4</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["AAAAAA"]'><font color=#AAAAAA>5</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["CCCCCC"]'><font color=#CCCCCC>6</font></A><br>")
|
||||
|
||||
dat += text("<A href='?src=\ref[src];color=["FF0000"]'><font color=#FF0000>Red:</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["440000"]'><font color=#440000>1</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["880000"]'><font color=#880000>2</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["CC0000"]'><font color=#CC0000>3</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["FF2222"]'><font color=#FF2222>4</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["FF6666"]'><font color=#FF6666>5</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["FFBBBB"]'><font color=#FFBBBB>6</font></A><br>")
|
||||
|
||||
dat += text("<A href='?src=\ref[src];color=["FFFF00"]'><font color=#FFFF00>Yellow:</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["444400"]'><font color=#444400>1</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["888800"]'><font color=#888800>2</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["CCCC00"]'><font color=#CCCC00>3</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["FFFF22"]'><font color=#FFFF22>4</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["FFFF66"]'><font color=#FFFF66>5</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["FFFFBB"]'><font color=#FFFFBB>6</font></A><br>")
|
||||
|
||||
dat += text("<A href='?src=\ref[src];color=["00FF00"]'><font color=#00FF00>Green:</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["004400"]'><font color=#004400>1</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["008800"]'><font color=#008800>2</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["00CC00"]'><font color=#00CC00>3</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["22FF22"]'><font color=#22FF22>4</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["66FF66"]'><font color=#66FF66>5</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["BBFFBB"]'><font color=#BBFFBB>6</font></A><br>")
|
||||
|
||||
dat += text("<A href='?src=\ref[src];color=["00FFFF"]'><font color=#00FFFF>Cyan:</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["004444"]'><font color=#004444>1</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["008888"]'><font color=#008888>2</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["00CCCC"]'><font color=#00CCCC>3</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["22FFFF"]'><font color=#22FFFF>4</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["66FFFF"]'><font color=#66FFFF>5</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["BBFFFF"]'><font color=#BBFFFF>6</font></A><br>")
|
||||
|
||||
dat += text("<A href='?src=\ref[src];color=["0000FF"]'><font color=#0000FF>Blue:</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["000044"]'><font color=#000044>1</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["000088"]'><font color=#000088>2</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["0000CC"]'><font color=#0000CC>3</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["2222FF"]'><font color=#2222FF>4</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["6666FF"]'><font color=#6666FF>5</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["BBBBFF"]'><font color=#BBBBFF>6</font></A><br>")
|
||||
|
||||
dat += text("<A href='?src=\ref[src];color=["000000"]'><font color=#FF00FF>Purple:</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["440044"]'><font color=#440044>1</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["880088"]'><font color=#880088>2</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["CC00CC"]'><font color=#CC00CC>3</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["FF22FF"]'><font color=#FF22FF>4</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["FF66FF"]'><font color=#FF66FF>5</font></A> ")
|
||||
dat += text("<A href='?src=\ref[src];color=["FFBBFF"]'><font color=#FFBBFF>6</font></A><br><br>")
|
||||
|
||||
if (text_bold)
|
||||
dat += text("<b>Bold:</b> yes / <A href='?src=\ref[src];bold=[0]'>no</A><br>")
|
||||
else
|
||||
dat += text("<b>Bold: <A href='?src=\ref[src];bold=[1]'>yes</A> / no<br>")
|
||||
|
||||
if (text_italic)
|
||||
dat += text("<b>Italic:</b> yes / <A href='?src=\ref[src];italic=[0]'>no</A><br>")
|
||||
else
|
||||
dat += text("<b>Italic: <A href='?src=\ref[src];italic=[1]'>yes</A> / no<br>")
|
||||
|
||||
if (text_underline)
|
||||
dat += text("<b>Underline:</b> yes / <A href='?src=\ref[src];underline=[0]'>no</A><br>")
|
||||
else
|
||||
dat += text("<b>Underline:</b> <A href='?src=\ref[src];underline=[1]'>yes</A> / no<br>")
|
||||
|
||||
if (text_break)
|
||||
dat += text("<b>Jump into a new line at the end?</b> yes / <A href='?src=\ref[src];break=[0]'>no</A><br>")
|
||||
else
|
||||
dat += text("<b>Jump into a new line at the end?</b> <A href='?src=\ref[src];break=[1]'>yes</A> / no<br>")
|
||||
user << browse("[dat]", "window=pen")
|
||||
|
||||
/obj/item/weapon/pen/Topic(href, href_list)
|
||||
usr.machine = src
|
||||
if(href_list["color"])
|
||||
src.text_color = "#"
|
||||
src.text_color += href_list["color"]
|
||||
if(href_list["size"])
|
||||
src.text_size = text2num(href_list["size"])
|
||||
if(href_list["bold"])
|
||||
src.text_bold = text2num(href_list["bold"])
|
||||
if(href_list["underline"])
|
||||
src.text_underline = text2num(href_list["underline"])
|
||||
if(href_list["italic"])
|
||||
src.text_italic = text2num(href_list["italic"])
|
||||
if(href_list["break"])
|
||||
src.text_break = text2num(href_list["break"])
|
||||
attack_self(usr)
|
||||
return
|
||||
|
||||
/obj/item/weapon/paper/verb/rename()
|
||||
set name = "Rename paper"
|
||||
@@ -217,30 +91,35 @@ CLIPBOARDS
|
||||
clown = 1
|
||||
|
||||
if (istype(P, /obj/item/weapon/pen))
|
||||
var/obj/item/weapon/pen/PEN = P
|
||||
if(src.stamped != null && src.stamped.len > 0)
|
||||
user << "\blue This paper has been stamped and can no longer be edited."
|
||||
return
|
||||
|
||||
var/t = "[src.info]"
|
||||
do
|
||||
t = input(user, "What text do you wish to add?", text("[]", src.name), t) as message
|
||||
if ((!in_range(src, usr) && src.loc != user && !( istype(src.loc, /obj/item/weapon/clipboard) ) && src.loc.loc != user && user.equipped() != P))
|
||||
return
|
||||
|
||||
if(lentext(t) >= MAX_PAPER_MESSAGE_LEN)
|
||||
var/cont = input(user, "Your message is too long! Would you like to continue editing it?", "", "yes") in list("yes", "no")
|
||||
if(cont == "no")
|
||||
break
|
||||
while(lentext(t) > MAX_PAPER_MESSAGE_LEN)
|
||||
|
||||
var/t = strip_html(input(user, "What text do you wish to add?", text("[]", src.name), null),8192) as message
|
||||
t = text("[PEN.formatText(t)]")
|
||||
|
||||
if ((!in_range(src, usr) && src.loc != user && !( istype(src.loc, /obj/item/weapon/clipboard) ) && src.loc.loc != user && user.equipped() != P))
|
||||
return
|
||||
/*
|
||||
t = copytext(sanitize(t),1,MAX_MESSAGE_LEN)
|
||||
t = dd_replacetext(t, "\n", "<BR>")
|
||||
t = dd_replacetext(t, "\[b\]", "<B>")
|
||||
t = dd_replacetext(t, "\[/b\]", "</B>")
|
||||
t = dd_replacetext(t, "\[i\]", "<I>")
|
||||
t = dd_replacetext(t, "\[/i\]", "</I>")
|
||||
t = dd_replacetext(t, "\[u\]", "<U>")
|
||||
t = dd_replacetext(t, "\[/u\]", "</U>")
|
||||
t = dd_replacetext(t, "\[sign\]", text("<font face=vivaldi>[]</font>", user.real_name))
|
||||
*/
|
||||
t = text("<font face=calligrapher>[]</font>", t)
|
||||
|
||||
// check for exploits
|
||||
if(findtext(t, "<script") != 0 || findtext(t, "<frame") != 0 || findtext(t, "<iframe") != 0 || findtext(t, "<input") != 0 || findtext(t, "<button") != 0 || findtext(t, "<a") != 0)
|
||||
user << "\blue You think to yourself, \"Hm.. this is only paper...\""
|
||||
return
|
||||
|
||||
if(!overlays.Find("paper_words"))
|
||||
src.overlays += "paper_words"
|
||||
src.info += t
|
||||
|
||||
src.info = t
|
||||
else
|
||||
if(istype(P, /obj/item/weapon/stamp))
|
||||
if ((!in_range(src, usr) && src.loc != user && !( istype(src.loc, /obj/item/weapon/clipboard) ) && src.loc.loc != user && user.equipped() != P))
|
||||
|
||||
Reference in New Issue
Block a user