Adds detecting newly made byond accounts (#16269)

* Adds age checking for byond accounts.

* WIP. moved to regex.

* Actually works now.

* local vars

* Changes to use sql.

* Fixes

* Removes unused var
This commit is contained in:
Shadowlight213
2016-04-14 18:04:52 -07:00
committed by Jordie
parent c2feeacaee
commit ab25f840e9
6 changed files with 39 additions and 3 deletions

View File

@@ -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)

View File

@@ -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")

View File

@@ -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)
*/
*/

View File

@@ -25,7 +25,6 @@
///////////////
var/ambience_playing= null
var/played = 0
////////////
//SECURITY//
////////////

View File

@@ -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()

View File

@@ -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"