diff --git a/code/__HELPERS/bandetect.dm b/code/__HELPERS/bandetect.dm new file mode 100644 index 000000000000..ee15f67a6025 --- /dev/null +++ b/code/__HELPERS/bandetect.dm @@ -0,0 +1,34 @@ +#define YOUNG 4 + + +/client/proc/join_date_check(y,m,d) + var/DBQuery/query = dbcon.NewQuery("SELECT DATEDIFF(Now(),'[y]-[m]-[d]')") + + if(!query.Execute()) + world.log << "SQL ERROR doing datediff. Error : \[[query.ErrorMsg()]\]\n" + return + + if(query.NextRow()) + var/diff = text2num(query.item[1]) + if(diff < YOUNG) + var/msg = "(IP: [address], ID: [computer_id]) is a new BYOND account made on [y]-[m]-[d]." + if(diff < 0) + msg += " They are also apparently from the future." + message_admins("[key_name_admin(src)] [msg]") +#undef YOUNG + + +/client/proc/findJoinDate() + var/http[] = world.Export("http://byond.com/members/[src.ckey]?format=text") + if(!http) + world.log << "Failed to connect to byond age check for [src.ckey]" + + var/F = file2text(http["CONTENT"]) + if(F) + var/regex/R = regex("joined = \"(\\d{4})-(\\d{2})-(\\d{2})\"") + if(!R.Find(F)) + CRASH("Age check regex failed") + var/y = R.group[1] + var/m = R.group[2] + var/d = R.group[3] + join_date_check(y,m,d) \ No newline at end of file diff --git a/code/__HELPERS/time.dm b/code/__HELPERS/time.dm index e5e190a09ba9..eefb3693cf62 100644 --- a/code/__HELPERS/time.dm +++ b/code/__HELPERS/time.dm @@ -22,4 +22,4 @@ //returns timestamp in a sql and ISO 8601 friendly format /proc/SQLtime() - return time2text(world.realtime, "YYYY-MM-DD hh:mm:ss") + return time2text(world.realtime, "YYYY-MM-DD hh:mm:ss") \ No newline at end of file diff --git a/code/_globalvars/misc.dm b/code/_globalvars/misc.dm index 36ef28c7c056..810e20feac7f 100644 --- a/code/_globalvars/misc.dm +++ b/code/_globalvars/misc.dm @@ -19,4 +19,4 @@ var/map_ready = 0 Therefore, we'd need to use spawn() inside New() to wait for the surrounding turf contents to be instanced However, using lots of spawn() has a severe performance impact, and often results in spaghetti-code map_ready will be set to 1 when world/New() is called (which happens just after the map is instanced) -*/ +*/ \ No newline at end of file diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index c0241ba6b748..bb3889ced3ed 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -25,7 +25,6 @@ /////////////// var/ambience_playing= null var/played = 0 - //////////// //SECURITY// //////////// diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index f30e26edfee5..6c4d4bb2fcec 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -185,6 +185,8 @@ var/next_external_rsc = 0 else if (isnum(player_age) && player_age < config.notify_new_player_age) message_admins("New user: [key_name_admin(src)] just connected with an age of [player_age] day[(player_age==1?"":"s")]") + findJoinDate() + sync_client_with_db() send_resources() diff --git a/tgstation.dme b/tgstation.dme index a60e10a9f00e..df343a221c87 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -50,6 +50,7 @@ #include "code\__HELPERS\510.dm" #include "code\__HELPERS\_logging.dm" #include "code\__HELPERS\_string_lists.dm" +#include "code\__HELPERS\bandetect.dm" #include "code\__HELPERS\cmp.dm" #include "code\__HELPERS\files.dm" #include "code\__HELPERS\game.dm"