MyBB Registeration

[release]
Screw an intro, you should know what this is, if you don’t know what MyBB is, then click here.
[/release]

[release]
Screen shots
In-Game

http://img543.imageshack.us/img543/6932/gamevk.jpg[/media]
phpMyAdmin
[media]http://img26.imageshack.us/img26/9210/sqlp.png[/media]
Forums
[media]http://img715.imageshack.us/img715/3491/forumsw.png

[/release]

[release]
Release
Download
[/release]

[release]
:siren::siren:Requirements.:siren::siren:
tmysql
libmysql
cryptopp

You have to alter your mybb_users table or this will not work.
Here is code you can paste right in your query box to do it for you.



ALTER TABLE `mybb_users` ADD `steamid` TEXT NOT NULL AFTER `usernotes`


[/release]

[release]
MISC
Request a feature by posting or personal messaging me.

Like to thank frostschutz, on mybb forums for his/her help.

Oh also post bugs or problems you run into.
[/release]

Nice! Might test this soon.

Convert to mysqloo please!

Fuck that, mysqloo is a piece of shit, keep tmysql.

Also why not make an extra field in users and call it SteamID? and just insert the players steamid in there so you can track em :slight_smile:

Whats wrong with mysqloo compared to tmysql then? :s

It’s because it crashes a little more than tmysql, but tmysql can’t handle more than 1 database connection at time.

[editline]17th March 2011[/editline]

Also, I wold suggest you to do checks if the email adress is actually an email adress and so on.

Right, now i see…

And yeah, i used to use mybb all the time, opens a LOT of pathways towards proper server/webserver integration. Thanks!

Woot, yay :D! Epic Aide!

Read the OP. I’ve stated you have to alter your mybb_users table. You need to have a field called steamid or this won’t work off the bat.



ALTER TABLE `mybb_users` ADD `steamid` TEXT NOT NULL AFTER `usernotes`


Hmm, any possibility to convert this to SMF2? As this is really a great feature! :slight_smile:

Edit:
As I see, the SMF2 members table is very similar to MyBB… If I’m correct, its just to change these lines:
[lua]DB = “mybb”

tmysql.query(“INSERT INTO mybb_users (username, password, email, usergroup, allownotices, hideemail, invisible, receivepms, showsigs, showavatars, showquickreply, regdate, regip, lastip, steamid) VALUES (’” … tmysql.escape(user) … “’, '” … tmysql.escape(string.lower(crypto.md5(pass))) … “’,’” … tmysql.escape(email) … “’, '”… group … “’, '” … 1 … “’, '” … 0 … “’, '” … 0 … “’, '” … 1 … “’, '” … 1 … “’, '” … 1 … “’, '” … 1 … “’, '” … regdate … “’, '” … self:IPAddress() … “’, '” … self:IPAddress() … “’, '” … tmysql.escape(self:SteamID()) … “’ )” , SQLHandle )

tmysql.query( “SELECT usergroup FROM mybb_users WHERE steamid= '” … id … “’”, function ( Args )

tmysql.query( “SELECT steamid FROM mybb_users WHERE steamid= '” … id … “’”, function ( Args )
[/lua]
to match the SMF2 members layout? Right? I got some lua knowlegde, but absolutly no MySQL xD.

Edit2:
Just a question, I don’t have to fill out all the fields? They can be empty if they are no important? Or do I got to set each value in the right order? Thanks :slight_smile:

I can create one for smf2 if that’s what you’d like. The field you have to fill out are defined by the function only three arguments can be left empty.

( uid, user, pass, email, group, regdate )

Only ones that need to be set are,
( user, pass, email )

As the function will automatically pick them up.

Ok, this is all the fields I can fill out:



id_member, member_name, date_registered, posts, id_group, lngfile, last_login, real_name, instant_messages, 
unread_messages, new_pm, buddy_list, pm_ignore_list, pm_prefs, mod_prefs, message_labels, passwd, 
openid_uri, email_address, personal_text, gender, birthdate, website_title, website_url, location, icq, aim, yim, 
msn, hide_email, show_online, time_format, signature, time_offset, avatar, pm_email_notify, karma_bad, 
karma_good, usertitle, notify_announcements, notify_regularity, notify_send_body, notify_types, member_ip,
 member_ip2, secret_question, secret_answer, id_theme, is_activated, validation_code, id_msg_last_visit, 
additional_groups, smiley_set, id_post_group, total_time_logged_in, password_salt, ignore_boards, warning, 
passwd_flood, pm_receive_from 

What you are saying is that I don’t need to define values in all them? I can just define the ones which are important right (member_name, date_reg, id_group, last_login, email, passwd, is_activated) ?
And I don’t want to “steal” your time, but if you just want to give me a pointer or bit of help that would be great :slight_smile: All credits to you ofcourse :slight_smile:

Thanks :slight_smile:

Edit:
Okay, this is odd, but I cannot run the tmysql module for some reason…

This happens when I got the module, in the right folder, and with the right filename (as seen in the error):


 lua_openscript_cl SMFv1.lua
Running script SMFv1.lua...
error loading module 'tmysql' from file 's:\steam\steamapps\anderen2\garrysmod\garrysmod\lua\includes\modules\gm_tmysql.dll':
	The specified module could not be found.


This happens if I remove/change name on it:



lua_openscript_cl SMFv1.lua
Running script SMFv1.lua...
ERROR! Module 'tmysql' not found!
[lua\smfv1.lua:12] attempt to index global 'tmysql' (a nil value)


To obtain the password salt you should look inside the registration/login code of SMF.

It means you’re missing libmysql.dll.

Downloaded it via: http://gmodmodules.googlecode.com/svn/trunk/gm_tmysql2/libmysql.dll and put it next to your srcds.exe and if it still doesnt work also copy it to your garrysmod/garrysmod/ directory.

[editline]19th March 2011[/editline]

Also I didn’t notice that bit, my apology.

I would love a SMF2 version since most of the time I use SMF anyways

We all make mistakes.

Working on expanding this a bit more to allow more interaction between garry’s mod and website.
[lua]
// Creates a thread as if he/she was on the forums.
function Player:CreateThread( fid, sub, mes ) end

// Creates a private message as if he/she was on the forums.
function Player:PrivateMessage( pmid, sub, mes ) end
[/lua]

Also will be working on SMF2 and SMF1. I already got started on SMF2 but got stuck when I looked at there salt forumla.

If you want a sneak peak at SMF2 look below it’s almost a solid copy of this.

sv_smf2.lua
[lua]
require(“tmysql”)
require(“cryptopp”)

Host = “localhost” // Host(IP/Hostname)
User = “root” // Username
Pass = “” // Password
DB = “smf” // Databse to select
Port = 3306 // Port, By default it’s 3306.
Group = 0 // This is the default group they will be placed into. By default 0 is registered. Must be a number!
WEBURL = “http://www.Changeme.com” // This is your website url.

tmysql.initialize( Host, User, Pass, DB, Port, 2, 2 )

local Player = _R.Player

function SQLHandle( result, _, error )
if error and error != 0 then
print( "SQL ERROR: " … error )
end
end

// This creates a user as if he/she was registering on the forums.
function Player:RegisterUser( uid, user, pass, email, group, regdate )
if !user or !pass or !email then self:ChatPrint( “[SMF2] Failed to create new user, one of the fields were nil.” ) return end
if !group then group = Group or 0 end
if !uid then uid = self:SteamID() end
if !regdate then regdate = os.time() end
tmysql.query(“INSERT INTO smf_members (member_name, passwd, date_registered, id_group, real_name, email_address, member_ip, member_ip2, steamid) VALUES (’” … tmysql.escape(user) … “’, '” … tmysql.escape(string.lower(crypto.sha1(user … pass))) … “’, '” … regdate … “’, '” … group … “’, '” … tmysql.escape(user) … “’, '” … email … “’, '” … self:IPAddress() … “’, '” … self:IPAddress() … “’, '” … tmysql.escape(uid) … “’ )” , SQLHandle )
self:ChatPrint( "[SMF2] Successfully registered user, " … user )
self.Register = true
end

// We can use this for a custom admin mod. Or use this to set admins. You could have your admins be controled via the forums.
function Player:GetUsersGroup( id )
if !id then self:ChatPrint( “[SMF2] Failed to get user, got a nil value in argument.” ) return end
tmysql.query( “SELECT id_group FROM smf_members WHERE steamid= '” … id … “’”, function ( Args )
if (Args && Args[1]) then
self:ChatPrint( "[SMF2] User is a part of group number " … Args[1] )
// Place some code here to make them an admin. This is of course if you want your admins to be controled by there forum user group.
else
self:ChatPrint( “[SMF2] Failed to get user’s group.” )
end
end)
end

// We use this to see if he/she is registered.
function Player:GetUsersID( id )
if !id then self:ChatPrint( “[SMF2] Failed to get user, got a nil value in argument.” ) return end
tmysql.query( “SELECT steamid FROM smf_members WHERE steamid= '” … id … “’”, function ( Args )
if (Args && Args[1]) then
self.Register = true
self:ChatPrint( "[SMF2] Welcome back " … self:Nick() … ", Remember to visit our forums @ " … WEBURL )
else
self.Register = false
self:ChatPrint( "[SMF2] Hello " … self:Nick() … “, starting registration process.” )
// Place some code here to make them register. (Console Command, Datastream, or User Message)
end
end)
end

hook.Add(“PlayerInitialSpawn”, “FirstSpawn”, function( pl )
pl.Register = false
pl:GetUsersID( pl:SteamID() )
end)

concommand.Add(“smf2_register”, function( pl, cmd, args )
pl.Register = false
if !args[1] or !args[2] then pl:ChatPrint( “[SMF2] Failed to create new user, one of the fields were nil.” ) return end
if pl.Register then pl:ChatPrint( “[SMF2] Your already registered.” ) return end
pl:RegisterUser(pl:SteamID(), pl:Nick(), args[1], args[2])
end)
[/lua]
This is not full working because of SMF2’s salt forumla.

As I’ve read you can leave the salt field empty, SMF2 will fill it out automaticly at first login if its missing :wink:

Edit: Yeah, just tried myself, added a new user in phpmyadmin, with only data in username, realname and password. The rest filled itself out, and I could login sucessfuly :slight_smile:

I tried it yesterday when I slightly modded it and was unable to login so thought that password_salt had to be generated.

http://www.garrysmod.org/img/?t=dll&id=119302
Good enough?

At this:
[lua]tmysql.escape(string.lower(crypto.sha1(user … pass))[/lua]
Why are you encrypting username+password with sha1? Removed user and it worked fine :wink:
And also, making it all lowcase(string.lower) may not be a good idea as the SMF2 forums are case sensitive :wink: