local DB = require"db" local Escapes = require"html" local BigGlobe = require"bigglobe" local Rand = require"openssl.rand" assert(Rand.ready()) local DB = require"db" local function sendeml(raw) --[[local fn = "/tmp/ikibooru" .. DB.b256toreadable(Rand.bytes(16)) .. ".eml" local f = io.open(fn, "wb") f:write(raw) f:close() -- Send e-mail. Yes, this is crude. io.popen("{ sendmail -t < " .. fn .. "; rm " .. fn .. "; } &", "r")]] end return { sendauthinfo = function(user) local url = BigGlobe.cfg.domain .."/verif?q=" .. Escapes.urlescape(DB.userauth(user)) -- print(url) if BigGlobe.cfg.anarchy == "ANARCHY" then return url else sendeml(string.format([[To: %s Subject: %s sign-in via e-mail Content-Type: text/html; charset=UTF-8 MIME-Version: 1.0

Welcome back to %s. Click on the below link to access your account.

If you had not initiated a sign-in request, consider whether your e-mail account has been compromised.

Sign-in
]], user.email, BigGlobe.cfg.sitename, BigGlobe.cfg.sitename, url)) return true end end, sendregisterinfo = function(user) local url = BigGlobe.cfg.domain .."/reg?q=" .. Escapes.urlescape(DB.userregcode(user)) print(url) if BigGlobe.cfg.anarchy == "ANARCHY" then return url else sendeml(string.format([[To: %s Subject: %s registration via e-mail Content-Type: text/html; charset=UTF-8 MIME-Version: 1.0

You have either registered or been invited to register at %s. Click on the below link to complete your registration.

If you have no idea what this is, consider whether your e-mail account has been compromised.

Complete
]], user.email, BigGlobe.cfg.sitename, BigGlobe.cfg.sitename, url)) return true end end }