customizable table name

This commit is contained in:
Felix Geyer 2004-08-08 11:05:59 +00:00
parent 70a1afe05e
commit 175c5767f1

View File

@ -50,8 +50,7 @@ new g_aAccess[MAX_ADMINS]
new g_aNum = 0 new g_aNum = 0
new g_cmdLoopback[16] new g_cmdLoopback[16]
public plugin_init() public plugin_init() {
{
#if defined USING_SQL #if defined USING_SQL
register_plugin("Admin Base (SQL)",AMXX_VERSION_STR,"AMXX Dev Team") register_plugin("Admin Base (SQL)",AMXX_VERSION_STR,"AMXX Dev Team")
#else #else
@ -81,6 +80,7 @@ public plugin_init()
register_cvar("amx_sql_user","root") register_cvar("amx_sql_user","root")
register_cvar("amx_sql_pass","") register_cvar("amx_sql_pass","")
register_cvar("amx_sql_db","amx") register_cvar("amx_sql_db","amx")
register_cvar("amx_sql_table","admins")
#endif #endif
register_concmd("amx_reloadadmins","cmdReload",ADMIN_ADMIN) register_concmd("amx_reloadadmins","cmdReload",ADMIN_ADMIN)
@ -146,11 +146,12 @@ loadSettings(szFilename[])
#if defined USING_SQL #if defined USING_SQL
public adminSql() { public adminSql() {
new host[64],user[32],pass[32],db[32],error[128] new host[64],user[32],pass[32],db[32],table[32],error[128]
get_cvar_string("amx_sql_host",host,63) get_cvar_string("amx_sql_host",host,63)
get_cvar_string("amx_sql_user",user,31) get_cvar_string("amx_sql_user",user,31)
get_cvar_string("amx_sql_pass",pass,31) get_cvar_string("amx_sql_pass",pass,31)
get_cvar_string("amx_sql_db",db,31) get_cvar_string("amx_sql_db",db,31)
get_cvar_string("amx_sql_table",table,31)
new Sql:sql = dbi_connect(host,user,pass,db,error,127) new Sql:sql = dbi_connect(host,user,pass,db,error,127)
if (sql <= SQL_FAILED) { if (sql <= SQL_FAILED) {
@ -158,9 +159,9 @@ public adminSql() {
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
dbi_query(sql,"CREATE TABLE IF NOT EXISTS admins ( auth varchar(32) NOT NULL default '', password varchar(32) NOT NULL default '', access varchar(32) NOT NULL default '', flags varchar(32) NOT NULL default '' )") dbi_query(sql,"CREATE TABLE IF NOT EXISTS `%s` ( `auth` VARCHAR( 32 ) NOT NULL, `password` VARCHAR( 32 ) NOT NULL, `access` VARCHAR( 32 ) NOT NULL, `flags` VARCHAR( 32 ) NOT NULL ) COMMENT = 'AMX Mod X Admins'",table);
new Result:Res = dbi_query(sql,"SELECT auth,password,access,flags FROM admins") new Result:Res = dbi_query(sql,"SELECT `auth`,`password`,`access`,`flags` FROM `%s`",table)
if (Res == RESULT_FAILED) { if (Res == RESULT_FAILED) {
dbi_error(sql,error,127) dbi_error(sql,error,127)
@ -178,8 +179,7 @@ public adminSql() {
new szFlags[32],szAccess[32] new szFlags[32],szAccess[32]
g_aNum = 0 g_aNum = 0
while( dbi_nextrow(Res) > 0 ) while( dbi_nextrow(Res) > 0 ) {
{
dbi_result(Res, "auth", g_aName[g_aNum], 31) dbi_result(Res, "auth", g_aName[g_aNum], 31)
dbi_result(Res, "password", g_aPassword[g_aNum], 31) dbi_result(Res, "password", g_aPassword[g_aNum], 31)
dbi_result(Res, "access", szAccess, 31) dbi_result(Res, "access", szAccess, 31)
@ -201,8 +201,7 @@ public adminSql() {
} }
#endif #endif
public cmdReload(id,level,cid) public cmdReload(id,level,cid) {
{
if (!cmd_access(id,level,cid,1)) if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED return PLUGIN_HANDLED
@ -220,8 +219,7 @@ public cmdReload(id,level,cid)
return PLUGIN_HANDLED return PLUGIN_HANDLED
} }
getAccess(id,name[],authid[],ip[], password[]) getAccess(id,name[],authid[],ip[], password[]) {
{
new index = -1 new index = -1
new result = 0 new result = 0
for(new i = 0; i < g_aNum; ++i) { for(new i = 0; i < g_aNum; ++i) {
@ -301,8 +299,7 @@ getAccess(id,name[],authid[],ip[], password[])
return result return result
} }
accessUser( id, name[] = "" ) accessUser( id, name[] = "" ) {
{
remove_user_flags(id) remove_user_flags(id)
new userip[32],userauthid[32],password[32],passfield[32],username[32] new userip[32],userauthid[32],password[32],passfield[32],username[32]
get_user_ip(id,userip,31,1) get_user_ip(id,userip,31,1)
@ -322,8 +319,7 @@ accessUser( id, name[] = "" )
return PLUGIN_CONTINUE return PLUGIN_CONTINUE
} }
public client_infochanged(id) public client_infochanged(id) {
{
if ( !is_user_connected(id) || !get_cvar_num("amx_mode") ) if ( !is_user_connected(id) || !get_cvar_num("amx_mode") )
return PLUGIN_CONTINUE return PLUGIN_CONTINUE