Raised This Month: $ Target: $400
 0% 

SMF forum and CS


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hasta
Senior Member
Join Date: Aug 2004
Location: Ukraine, Kyiv
Old 06-12-2007 , 09:19   SMF forum and CS
Reply With Quote #1

plugin checks a login and the password of the user from base of a forum, it is a correct code?
forum: _www.simplemachines.org/

Code:
#include <amxmodx>
#include <amxmisc>
#include <dbi>
#include <regex>

new Sql:sql
new Result:Res
//new users = 0



//drew проверка логина и пароля
access_user(id,username[32]){
	new userip[32],userauthid[32],password[32],passfield[32]
	get_user_ip(id,userip,31)
	get_user_authid(id,userauthid,31)
	//get_cvar_string("users_password_field",passfield,31)
	get_cvar_string("users_password_field",passfield,31)
	//get_cvar_string("amx_password_field", tmppass, 31)

	get_user_info(id,passfield,password,31)
	//new result = get_access(id,username,userauthid,userip,password)

	server_print("====== LOGIN ===============================================")
	server_print("USER %s",username)
	server_print("ENTER PASSWORD %s",password)

	// drew get_cvar_string("amx_password_field", tmppass, 31)
	//Res=dbi_query(sql,"SELECT memberName, passwd,md5('%s') as mypass FROM smf_members where UPPER(memberName)=UPPER('%s')",password,username)
	Res=dbi_query(sql,"SELECT memberName, passwd,sha1(CONCAT(lower('%s'),'%s')) as mypass FROM smf_members where UPPER(memberName)=UPPER('%s')",username,password,username)
	
	if (Res > RESULT_NONE)
	{
	 while (dbi_nextrow(Res) > 0)
	 {                            
		new user[32],pass1[32],pass2[32]

		//dbi_field(Res,1,user,31)
		//dbi_field(Res,2,pass1,31)
		//dbi_field(Res,3,pass2,31)
		dbi_result(Res, "memberName", user, 31)
		dbi_result(Res, "passwd", pass1, 31)
		dbi_result(Res, "mypass", pass2, 31)

		server_print("SELECT memberName, passwd,sha1(CONCAT(lower('%s'),'%s')) as mypass FROM smf_members where UPPER(memberName)=UPPER('%s')",username,password,username)
		server_print("HASH ENTER PASSWORD %s",pass2)
		server_print("HASH BASES PASSWORD %s",pass1)


		if (!equali(pass1,pass2)) 
		{
			server_cmd("kick #%d ^"Neverniy parol' dlya %s (setinfo  _pw-hotpoint)^"", get_user_userid(id),username)
			return PLUGIN_CONTINUE
		}
	 }
	}
	else
	{
	server_print("USER not base, connect ok.")
	}
	server_print("====== END LOGIN ===========================================")	


	return PLUGIN_CONTINUE
}

public client_infochanged(id){
	if (get_cvar_num("users_mode")==0)
		return PLUGIN_CONTINUE
	new newname[32], oldname[32]
	get_user_name(id,oldname,31)
	get_user_info(id,"name",newname,31)
	if (is_user_connected(id)&&!equal(newname,oldname)){
		access_user(id,newname)
	}
	return PLUGIN_CONTINUE
}


public plugin_init(){
	register_plugin("UserDB","2.2","Loki[HP]&Wfx[HP]&ZeroX")
	new configsDir[64]
	get_configsdir(configsDir, 63)
	register_cvar("users_mode","0")
	register_cvar("users_password_field","_pw-hotpoint")
	register_cvar("users_sql_host","127.0.0.1")
	register_cvar("users_sql_user","root-users")
	register_cvar("users_sql_pass","")
	register_cvar("users_sql_db","amx")
	register_cvar("users_srv_id","")

	server_cmd("exec %s/userdb.cfg", configsDir)

	new host[64],user[32],pass[32],db[32],error[128],srvid[9]
	get_cvar_string("users_sql_host",host,63)
	get_cvar_string("users_sql_user",user,31)
	get_cvar_string("users_sql_pass",pass,31)
	get_cvar_string("users_sql_db",db,31)
	get_cvar_string("users_srv_id",srvid,8)
	
	server_print("[UserDB2] connect dsn=%s:%s@%s/%s",user,pass,host,db)
	sql=dbi_connect(host,user,pass,db,error,127)
	if(sql <= SQL_FAILED){
   		dbi_error(sql,error,127)
		log_amx("can't connect: '%s'",error)
		server_print("[UserDB2] CONNECT MySQL error") 
		return 0
	}

  	return PLUGIN_CONTINUE
}


public client_connect(id){
	if (get_cvar_num("users_mode")==0)
		return PLUGIN_CONTINUE
	new name[32]
	get_user_name(id,name,31)
	return access_user(id,name)
}

public client_disconnect(id){
        new amx_pw[32]
        get_cvar_string("users_password_field",amx_pw,31)
        client_cmd(id,"setinfo %s ^"^"",amx_pw)
        return PLUGIN_CONTINUE
}
hasta is offline
Send a message via ICQ to hasta
Old 06-14-2007, 12:01
hasta
This message has been deleted by Brad. Reason: don't bump your posts
sysop666
Member
Join Date: Mar 2008
Location: Argentina
Old 09-19-2008 , 03:12   Re: SMF forum and CS
Reply With Quote #2

I need plugin "check registred users" for my SMF 1.1.x forum
Thanks!
__________________
FRAT.com.ar - CS 1.6 PRO SERVERS
Fast Download
- 190.2.45.10:27015 - ZOMBIE PLAGUE 1. 32 SLOTS
- 190.2.45.10:27016 - ZOMBIE PLAGUE 2. 32 SLOTS
- 190.2.45.10:27017 - GUN GAME 1. 32 SLOTS
- 190.2.45.10:27017 - GUN GAME 2. 32 SLOTS
sysop666 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode