mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-21 03:55:05 +01:00
This commit is contained in:
@@ -53,7 +53,7 @@
|
||||
var/isadmin = 0
|
||||
if(src.client && src.client.holder)
|
||||
isadmin = 1
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT id FROM erro_poll_question WHERE [(isadmin ? "" : "adminonly = false AND")] Now() BETWEEN starttime AND endtime AND id NOT IN (SELECT pollid FROM erro_poll_vote WHERE ckey = \"[ckey]\")")
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT id FROM erro_poll_question WHERE [(isadmin ? "" : "adminonly = false AND")] Now() BETWEEN starttime AND endtime AND id NOT IN (SELECT pollid FROM erro_poll_vote WHERE ckey = \"[ckey]\") AND id NOT IN (SELECT pollid FROM erro_poll_textreply WHERE ckey = \"[ckey]\")")
|
||||
query.Execute()
|
||||
var/newpoll = 0
|
||||
while(query.NextRow())
|
||||
@@ -83,24 +83,33 @@
|
||||
break
|
||||
|
||||
//shh ;)
|
||||
var/music = ticker.login_music
|
||||
if(ckey == "cajoes")
|
||||
music = 'sound/music/dangerzone.ogg'
|
||||
else if(ckey == "duntada")
|
||||
music = 'sound/music/you_are_likely_to_be_eaten.ogg'
|
||||
else if(ckey == "misterbook")
|
||||
music = 'sound/music/dinosaur.ogg'
|
||||
else if(ckey == "chinsky")
|
||||
music = 'sound/music/soviet_anthem.ogg'
|
||||
else if(ckey == "abi79")
|
||||
music = 'sound/music/spinmeround.ogg'
|
||||
else if(ckey == "mloc")
|
||||
music = 'sound/music/cantina1_short.ogg'
|
||||
else if(ckey == "applemaster")
|
||||
music = 'sound/music/elektronik_supersonik.ogg'
|
||||
else if(ckey == "wrongnumber")
|
||||
music = 'sound/music/greenthumb.ogg'
|
||||
src << sound(music, repeat = 0, wait = 0, volume = 85, channel = 1) //MAD JAMZ
|
||||
switch(src.key)
|
||||
if("caelaislinn")
|
||||
src << sound('sound/music/drive_me_closer.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("daneesh")
|
||||
src << sound('sound/music/ill_make_a_man_out_of_you.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("doughnuts")
|
||||
src << sound('sound/music/ultimate_showdown.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("themij")
|
||||
src << sound('sound/music/pegasus.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("searif")
|
||||
src << sound('sound/music/pegasus.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("danny220")
|
||||
src << sound('sound/music/dirty_hands.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("sparklysheep")
|
||||
src << sound('sound/music/dirty_hands.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("pobiega")
|
||||
src << sound('sound/music/the_gabber_robots.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("chinsky")
|
||||
src << sound('sound/music/cotton_eye_joe.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("russkisam")
|
||||
src << sound('sound/music/elektronik_supersonik.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("duntadaman")
|
||||
src << sound('sound/music/spinmeround.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
if("misterbook")
|
||||
src << sound('sound/music/down_with_the_sickness.ogg', repeat = 0, wait = 0, volume = 85, channel = 1)
|
||||
else
|
||||
src << sound(ticker.login_music, repeat = 0, wait = 0, volume = 85, channel = 1) // MAD JAMS
|
||||
|
||||
proc/Stopmusic()
|
||||
src << sound(null, repeat = 0, wait = 0, volume = 85, channel = 1) // stop the jamsz
|
||||
@@ -313,6 +322,25 @@
|
||||
if("TEXT")
|
||||
var/replytext = href_list["replytext"]
|
||||
log_text_poll_reply(pollid, replytext)
|
||||
if("NUMVAL")
|
||||
var/id_min = text2num(href_list["minid"])
|
||||
var/id_max = text2num(href_list["maxid"])
|
||||
|
||||
if( (id_max - id_min) > 100 ) //Basic exploit prevention
|
||||
usr << "The option ID difference is too big. Please contact administration or the database admin."
|
||||
return
|
||||
|
||||
for(var/optionid = id_min; optionid<= id_max; optionid++)
|
||||
if(!isnull(href_list["o[optionid]"])) //Test if this optionid was replied to
|
||||
var/rating
|
||||
if(href_list["o[optionid]"] == "abstain")
|
||||
rating = null
|
||||
else
|
||||
rating = text2num(href_list["o[optionid]"])
|
||||
if(!isnum(rating))
|
||||
return
|
||||
|
||||
vote_on_numval_poll(pollid, optionid, rating)
|
||||
|
||||
proc/IsJobAvailable(rank)
|
||||
var/datum/job/job = job_master.GetJob(rank)
|
||||
|
||||
@@ -229,6 +229,77 @@
|
||||
output += "[vote_text]"
|
||||
|
||||
src << browse(output,"window=playerpoll;size=500x500")
|
||||
|
||||
//Polls with a text input
|
||||
if("NUMVAL")
|
||||
var/DBQuery/voted_query = dbcon.NewQuery("SELECT o.text, v.rating FROM erro_poll_option o, erro_poll_vote v WHERE o.pollid = [pollid] AND v.ckey = '[usr.ckey]' AND o.id = v.optionid")
|
||||
voted_query.Execute()
|
||||
|
||||
var/output = "<div align='center'><B>Player poll</B>"
|
||||
output +="<hr>"
|
||||
output += "<b>Question: [pollquestion]</b><br>"
|
||||
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
|
||||
|
||||
var/voted = 0
|
||||
while(voted_query.NextRow())
|
||||
voted = 1
|
||||
|
||||
var/optiontext = voted_query.item[1]
|
||||
var/rating = voted_query.item[2]
|
||||
|
||||
output += "<br><b>[optiontext] - [rating]</b>"
|
||||
|
||||
if(!voted) //Only make this a form if we have not voted yet
|
||||
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
|
||||
output += "<input type='hidden' name='src' value='\ref[src]'>"
|
||||
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
|
||||
output += "<input type='hidden' name='votetype' value='NUMVAL'>"
|
||||
|
||||
var/minid = 999999
|
||||
var/maxid = 0
|
||||
|
||||
var/DBQuery/option_query = dbcon.NewQuery("SELECT id, text, minval, maxval, descmin, descmid, descmax FROM erro_poll_option WHERE pollid = [pollid]")
|
||||
option_query.Execute()
|
||||
while(option_query.NextRow())
|
||||
var/optionid = text2num(option_query.item[1])
|
||||
var/optiontext = option_query.item[2]
|
||||
var/minvalue = text2num(option_query.item[3])
|
||||
var/maxvalue = text2num(option_query.item[4])
|
||||
var/descmin = option_query.item[5]
|
||||
var/descmid = option_query.item[6]
|
||||
var/descmax = option_query.item[7]
|
||||
|
||||
if(optionid < minid)
|
||||
minid = optionid
|
||||
if(optionid > maxid)
|
||||
maxid = optionid
|
||||
|
||||
var/midvalue = round( (maxvalue + minvalue) / 2)
|
||||
|
||||
if(isnull(minvalue) || isnull(maxvalue) || (minvalue == maxvalue))
|
||||
continue
|
||||
|
||||
output += "<br>[optiontext]: <select name='o[optionid]'>"
|
||||
output += "<option value='abstain'>abstain</option>"
|
||||
for (var/j = minvalue; j <= maxvalue; j++)
|
||||
if(j == minvalue && descmin)
|
||||
output += "<option value='[j]'>[j] ([descmin])</option>"
|
||||
else if (j == midvalue && descmid)
|
||||
output += "<option value='[j]'>[j] ([descmid])</option>"
|
||||
else if (j == maxvalue && descmax)
|
||||
output += "<option value='[j]'>[j] ([descmax])</option>"
|
||||
else
|
||||
output += "<option value='[j]'>[j]</option>"
|
||||
|
||||
output += "</select>"
|
||||
|
||||
output += "<input type='hidden' name='minid' value='[minid]'>"
|
||||
output += "<input type='hidden' name='maxid' value='[maxid]'>"
|
||||
|
||||
output += "<p><input type='submit' value='Submit'>"
|
||||
output += "</form>"
|
||||
|
||||
src << browse(output,"window=playerpoll;size=500x500")
|
||||
return
|
||||
|
||||
/mob/new_player/proc/vote_on_poll(var/pollid = -1, var/optionid = -1)
|
||||
@@ -364,4 +435,74 @@
|
||||
insert_query.Execute()
|
||||
|
||||
usr << "\blue Feedback logging successful."
|
||||
usr << browse(null,"window=playerpoll")
|
||||
|
||||
|
||||
/mob/new_player/proc/vote_on_numval_poll(var/pollid = -1, var/optionid = -1, var/rating = null)
|
||||
if(pollid == -1 || optionid == -1)
|
||||
return
|
||||
|
||||
if(!isnum(pollid) || !isnum(optionid))
|
||||
return
|
||||
|
||||
var/user = sqlfdbklogin
|
||||
var/pass = sqlfdbkpass
|
||||
var/db = sqlfdbkdb
|
||||
var/address = sqladdress
|
||||
var/port = sqlport
|
||||
|
||||
var/DBConnection/dbcon = new()
|
||||
dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]")
|
||||
if(dbcon.IsConnected())
|
||||
|
||||
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime")
|
||||
select_query.Execute()
|
||||
|
||||
var/validpoll = 0
|
||||
|
||||
while(select_query.NextRow())
|
||||
if(select_query.item[4] != "NUMVAL")
|
||||
return
|
||||
validpoll = 1
|
||||
break
|
||||
|
||||
if(!validpoll)
|
||||
usr << "\red Poll is not valid."
|
||||
return
|
||||
|
||||
var/DBQuery/select_query2 = dbcon.NewQuery("SELECT id FROM erro_poll_option WHERE id = [optionid] AND pollid = [pollid]")
|
||||
select_query2.Execute()
|
||||
|
||||
var/validoption = 0
|
||||
|
||||
while(select_query2.NextRow())
|
||||
validoption = 1
|
||||
break
|
||||
|
||||
if(!validoption)
|
||||
usr << "\red Poll option is not valid."
|
||||
return
|
||||
|
||||
var/alreadyvoted = 0
|
||||
|
||||
var/DBQuery/voted_query = dbcon.NewQuery("SELECT id FROM erro_poll_vote WHERE optionid = [optionid] AND ckey = '[usr.ckey]'")
|
||||
voted_query.Execute()
|
||||
|
||||
while(voted_query.NextRow())
|
||||
alreadyvoted = 1
|
||||
break
|
||||
|
||||
if(alreadyvoted)
|
||||
usr << "\red You already voted in this poll."
|
||||
return
|
||||
|
||||
var/adminrank = "Player"
|
||||
if(usr && usr.client && usr.client.holder)
|
||||
adminrank = usr.client.holder.rank
|
||||
|
||||
|
||||
var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO erro_poll_vote (id ,datetime ,pollid ,optionid ,ckey ,ip ,adminrank, rating) VALUES (null, Now(), [pollid], [optionid], '[usr.ckey]', '[usr.client.address]', '[adminrank]', [(isnull(rating)) ? "null" : rating])")
|
||||
insert_query.Execute()
|
||||
|
||||
usr << "\blue Vote successful."
|
||||
usr << browse(null,"window=playerpoll")
|
||||
Reference in New Issue
Block a user