Created
September 11, 2012 21:04
-
-
Save Protozoid/3702049 to your computer and use it in GitHub Desktop.
LG module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env lua | |
-------------------------------------------------------------- | |
-- @Description: Module for LogicalGamers auxiliary functions | |
-- @Author: Forget Me Not (The Unintelligible) | |
-- @Contact: xxprotozoid@live.com | |
-- @Version: v0.1 | |
-- @License: GNU General Public License v2 (GPLv2) - http://www.gnu.org/copyleft/gpl.html | |
-------------------------------------------------------------- | |
---------------------------------------------- | |
--- Initialization | |
---------------------------------------------- | |
local md5 = require("md5") | |
local http = require("socket.http") | |
--local ltn12 = require("ltn12") | |
local string = require("string") | |
local print = print | |
module("LG") | |
---------------------------------------------- | |
--- Internal Methods | |
---------------------------------------------- | |
local function string.between(s, leader, trailer) | |
local end_trailer = string.find(s, leader) + #leader | |
local start_trailer = string.find(s, trailer, end_leader) | |
return string.sub(s, end_trailer, start_trailer - 1) | |
end | |
---------------------------------------------- | |
--- Public Methods | |
---------------------------------------------- | |
--- Function for validating LogicalGamers users | |
-- @param user string in which the user to authenticate is specified | |
-- @param pass string in which the corresponding password to the user is specified | |
-- @usage LG.login(user, pass [, body]) | |
-- @return boolean value indicating if user is valid or otherwise authenticated | |
function login(user, pass) | |
-- Hash our password for the VBulletin standard login procedure | |
local pass = md5.sumhexa(pass) | |
local reqbody = ("vb_login_username=" .. user .."&vb_login_password=&vb_login_password_hint=Password" .. | |
"&s=&securitytoken=guest&do=login&vb_login_md5password=" .. pass .. "&vb_login_md5password_utf=" .. pass) | |
local r = http.request("http://forum.logicalgamers.com/login.php?do=login", reqbody) | |
return string.find(r, "Thank you for logging in") ~= nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment