mirror of
https://git.zx2c4.com/cgit
synced 2024-11-26 02:18:42 +00:00
26 lines
736 B
Lua
26 lines
736 B
Lua
local digest = require("openssl.digest")
|
|
|
|
function md5_hex(input)
|
|
local b = digest.new("md5"):final(input)
|
|
local x = ""
|
|
for i = 1, #b do
|
|
x = x .. string.format("%.2x", string.byte(b, i))
|
|
end
|
|
return x
|
|
end
|
|
|
|
function filter_open(email, page)
|
|
buffer = ""
|
|
hexdigest = md5_hex(email:sub(2, -2):lower())
|
|
end
|
|
|
|
function filter_close()
|
|
baseurl = os.getenv("HTTPS") and "https://seccdn.libravatar.org/" or "http://cdn.libravatar.org/"
|
|
html("<span class='libravatar'><img class='inline' src='" .. baseurl .. "avatar/" .. hexdigest .. "?s=13&d=retro' /><img class='onhover' src='" .. baseurl .. "avatar/" .. hexdigest .. "?s=128&d=retro' /></span>" .. buffer)
|
|
return 0
|
|
end
|
|
|
|
function filter_write(str)
|
|
buffer = buffer .. str
|
|
end
|