Merge branch 'master' into goonchatv3

This commit is contained in:
Cyberboss
2017-05-05 19:18:25 -04:00
committed by GitHub
177 changed files with 1506 additions and 898 deletions
+5 -2
View File
@@ -39,9 +39,11 @@
////////////////////////////////////
//things that require the database//
////////////////////////////////////
var/player_age = "Requires database" //So admins know why it isn't working - Used to determine how old the account is - in days.
var/player_age = -1 //Used to determine how old the account is - in days.
var/related_accounts_ip = "Requires database" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this ip
var/related_accounts_cid = "Requires database" //So admins know why it isn't working - Used to determine what other accounts previously logged in from this computer id
var/account_join_date = null //Date of byond account creation in ISO 8601 format
var/account_age = -1 //Age of byond account in days
preload_rsc = PRELOAD_RSC
@@ -64,4 +66,5 @@
var/inprefs = FALSE
var/list/topiclimiter
var/datum/chatOutput/chatOutput
var/datum/chatOutput/chatOutput
+68 -54
View File
@@ -274,17 +274,11 @@ GLOBAL_LIST(external_rsc_urls)
if((global.comms_key == "default_pwd" || length(global.comms_key) <= 6) && global.comms_allowed) //It's the default value or less than 6 characters long, but it somehow didn't disable comms.
to_chat(src, "<span class='danger'>The server's API key is either too short or is the default value! Consider changing it immediately!</span>")
add_verbs_from_config()
add_verbs_from_config(tdata)
set_client_age_from_db()
var/cached_player_age = player_age //we have to cache this because other shit may change it and we need it's current value now down below.
if (isnum(cached_player_age) && cached_player_age == -1) //first connection
player_age = 0
if(!IsGuestKey(key) && SSdbcore.IsConnected())
findJoinDate()
sync_client_with_db(tdata)
if (isnum(cached_player_age) && cached_player_age == -1) //first connection
if (config.panic_bunker && !holder && !(ckey in GLOB.deadmins))
log_access("Failed Login: [key] - New account attempting to connect during panic bunker")
@@ -303,7 +297,14 @@ GLOBAL_LIST(external_rsc_urls)
send2irc_adminless_only("New-user", "[key_name(src)] is connecting for the first time!")
else if (isnum(cached_player_age) && cached_player_age < config.notify_new_player_age)
message_admins("New user: [key_name_admin(src)] just connected with an age of [cached_player_age] day[(player_age==1?"":"s")]")
if(config.use_account_age_for_jobs && account_age >= 0)
player_age = account_age
if(account_age >= 0 && account_age < config.notify_new_player_account_age)
message_admins("[key_name_admin(src)] (IP: [address], ID: [computer_id]) is a new BYOND account day[(account_age==1?"":"s")] old, created on [account_join_date].")
if (config.irc_first_connection_alert)
send2irc_adminless_only("new_byond_user", "[key_name(src)] (IP: [address], ID: [computer_id]) is a new BYOND account day[(account_age==1?"":"s")] old, created on [account_join_date].")
else //We failed to get an age for this user, let admins know they need to keep an eye on them
message_admins("Failed to get BYOND account age for [key_name_admin(src)]")
get_message_output("watchlist entry", ckey)
check_ip_intel()
@@ -348,7 +349,6 @@ GLOBAL_LIST(external_rsc_urls)
adminGreet(1)
holder.owner = null
GLOB.admins -= src
if (!GLOB.admins.len && SSticker.IsRoundInProgress()) //Only report this stuff if we are currently playing.
if(!GLOB.admins.len) //Apparently the admin logging out is no longer an admin at this point, so we have to check this towards 0 and not towards 1. Awell.
var/cheesy_message = pick(
@@ -379,70 +379,84 @@ GLOBAL_LIST(external_rsc_urls)
/client/Destroy()
return QDEL_HINT_HARDDEL_NOW
/client/proc/set_client_age_from_db()
/client/proc/set_client_age_from_db(connectiontopic)
if (IsGuestKey(src.key))
return
if(!SSdbcore.Connect())
return
var/sql_ckey = sanitizeSQL(src.ckey)
var/datum/DBQuery/query_get_client_age = SSdbcore.NewQuery("SELECT id, datediff(Now(),firstseen) as age FROM [format_table_name("player")] WHERE ckey = '[sql_ckey]'")
if(!query_get_client_age.Execute())
return
while(query_get_client_age.NextRow())
player_age = text2num(query_get_client_age.item[2])
return
//no match mark it as a first connection for use in client/New()
player_age = -1
/client/proc/sync_client_with_db(connectiontopic)
if (IsGuestKey(src.key))
return
if (!SSdbcore.Connect())
return
var/sql_ckey = sanitizeSQL(ckey)
var/datum/DBQuery/query_get_ip = SSdbcore.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE ip = INET_ATON('[address]') AND ckey != '[sql_ckey]'")
query_get_ip.Execute()
var/datum/DBQuery/query_get_related_ip = SSdbcore.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE ip = INET_ATON('[address]') AND ckey != '[sql_ckey]'")
query_get_related_ip.Execute()
related_accounts_ip = ""
while(query_get_ip.NextRow())
related_accounts_ip += "[query_get_ip.item[1]], "
var/datum/DBQuery/query_get_cid = SSdbcore.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE computerid = '[computer_id]' AND ckey != '[sql_ckey]'")
if(!query_get_cid.Execute())
while(query_get_related_ip.NextRow())
related_accounts_ip += "[query_get_related_ip.item[1]], "
var/datum/DBQuery/query_get_related_cid = SSdbcore.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE computerid = '[computer_id]' AND ckey != '[sql_ckey]'")
if(!query_get_related_cid.Execute())
return
related_accounts_cid = ""
while (query_get_cid.NextRow())
related_accounts_cid += "[query_get_cid.item[1]], "
while (query_get_related_cid.NextRow())
related_accounts_cid += "[query_get_related_cid.item[1]], "
var/admin_rank = "Player"
if (src.holder && src.holder.rank)
admin_rank = src.holder.rank.name
else
if (check_randomizer(connectiontopic))
return
var/sql_ip = sanitizeSQL(src.address)
var/sql_computerid = sanitizeSQL(src.computer_id)
var/sql_ip = sanitizeSQL(address)
var/sql_computerid = sanitizeSQL(computer_id)
var/sql_admin_rank = sanitizeSQL(admin_rank)
var/datum/DBQuery/query_log_player = SSdbcore.NewQuery("INSERT INTO [format_table_name("player")] (id, ckey, firstseen, lastseen, ip, computerid, lastadminrank) VALUES (null, '[sql_ckey]', Now(), Now(), INET_ATON('[sql_ip]'), '[sql_computerid]', '[sql_admin_rank]') ON DUPLICATE KEY UPDATE lastseen = VALUES(lastseen), ip = VALUES(ip), computerid = VALUES(computerid), lastadminrank = VALUES(lastadminrank)")
if(!query_log_player.Execute())
var/new_player
var/datum/DBQuery/query_client_in_db = SSdbcore.NewQuery("SELECT 1 FROM [format_table_name("player")] WHERE ckey = '[sql_ckey]'")
if(!query_client_in_db.Execute())
return
//Logging player access
if(!query_client_in_db.NextRow())
new_player = 1
account_join_date = sanitizeSQL(findJoinDate())
var/datum/DBQuery/query_add_player = SSdbcore.NewQuery("INSERT INTO [format_table_name("player")] VALUES ('[sql_ckey]', Now(), Now(), INET_ATON('[sql_ip]'), '[sql_computerid]', '[sql_admin_rank]', [account_join_date ? "'[account_join_date]'" : "NULL"])")
if(!query_add_player.Execute())
return
if(!account_join_date)
account_join_date = "Error"
account_age = -1
var/datum/DBQuery/query_get_client_age = SSdbcore.NewQuery("SELECT DATEDIFF(Now(),firstseen), DATEDIFF(Now(),accountjoindate) FROM [format_table_name("player")] WHERE ckey = '[sql_ckey]'")
if(!query_get_client_age.Execute())
return
if(query_get_client_age.NextRow())
player_age = text2num(query_get_client_age.item[1])
if(!account_join_date)
account_age = query_get_client_age.item[2]
if(!account_age)
account_join_date = sanitizeSQL(findJoinDate())
if(!account_join_date)
account_age = -1
else
var/datum/DBQuery/query_datediff = SSdbcore.NewQuery("SELECT DATEDIFF(Now(),[account_join_date])")
if(!query_datediff.Execute())
return
if(query_datediff.NextRow())
account_age = text2num(query_datediff.item[1])
if(!new_player)
var/datum/DBQuery/query_log_player = SSdbcore.NewQuery("UPDATE [format_table_name("player")] SET lastseen = Now(), ip = INET_ATON('[sql_ip]'), computerid = '[sql_computerid]', lastadminrank = '[sql_admin_rank]', accountjoindate = [account_join_date ? "'[account_join_date]'" : "NULL"] WHERE ckey = '[sql_ckey]'")
if(!query_log_player.Execute())
return
if(!account_join_date)
account_join_date = "Error"
var/datum/DBQuery/query_log_connection = SSdbcore.NewQuery("INSERT INTO `[format_table_name("connection_log")]` (`id`,`datetime`,`server_ip`,`server_port`,`ckey`,`ip`,`computerid`) VALUES(null,Now(),INET_ATON('[world.internet_address]'),'[world.port]','[sql_ckey]',INET_ATON('[sql_ip]'),'[sql_computerid]')")
query_log_connection.Execute()
/client/proc/findJoinDate()
var/list/http = world.Export("http://byond.com/members/[ckey]?format=text")
if(!http)
log_world("Failed to connect to byond age check for [ckey]")
return
var/F = file2text(http["CONTENT"])
if(F)
var/regex/R = regex("joined = \"(\\d{4}-\\d{2}-\\d{2})\"")
if(R.Find(F))
. = R.group[1]
else
CRASH("Age check regex failed for [src.ckey]")
/client/proc/check_randomizer(topic)
. = FALSE
if (connection != "seeker")
+3 -2
View File
@@ -265,9 +265,10 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
if(config.mutant_races && species_id && (species_id in GLOB.roundstart_species))
var/newtype = GLOB.roundstart_species[species_id]
pref_species = new newtype()
else
else if (config.roundstart_races.len)
var/rando_race = pick(config.roundstart_races)
pref_species = new rando_race()
if (rando_race)
pref_species = new rando_race()
if(!S["features["mcolor"]"] || S["features["mcolor"]"] == "#000")
S["features["mcolor"]"] << "#FFF"
+1 -1
View File
@@ -12,7 +12,7 @@
return
if(confirm == "Yes")
suiciding = 1
log_game("[key_name(src)] (job: [job ? "[job]" : "None"]) commited suicide at [get_area(src)].")
log_game("[key_name(src)] (job: [job ? "[job]" : "None"]) committed suicide at [get_area(src)].")
var/obj/item/held_item = get_active_held_item()
if(held_item)
var/damagetype = held_item.suicide_act(src)