Added md5 hash for sql, removed old sql stuff

This commit is contained in:
Walter Julius Hennecke 2011-12-16 11:14:13 +01:00
parent 63cf3982f2
commit 1b7a1afe07
5 changed files with 58 additions and 209 deletions

View file

@ -85,7 +85,8 @@ OBJ = \
lua_weapons.o \ lua_weapons.o \
lua_trace.o \ lua_trace.o \
lua_cvar.o \ lua_cvar.o \
sqlite3.o sqlite3.o \
md5.o
# game object for syscalls to the engine # game object for syscalls to the engine
SOOBJ = \ SOOBJ = \
@ -196,6 +197,7 @@ lua_weapons.o: lua_weapons.c; $(DO_CC)
lua_trace.o: lua_trace.c; $(DO_CC) lua_trace.o: lua_trace.c; $(DO_CC)
lua_cvar.o: lua_cvar.c; $(DO_CC) lua_cvar.o: lua_cvar.c; $(DO_CC)
sqlite3.o: sqlite3.c; $(DO_CC) sqlite3.o: sqlite3.c; $(DO_CC)
md5.o: md5.c; $(DO_CC)
# game syscalls # game syscalls
g_syscalls.o : g_syscalls.c; $(DO_CC) g_syscalls.o : g_syscalls.c; $(DO_CC)

View file

@ -4538,13 +4538,7 @@ void Cmd_UnDrag_f( gentity_t *ent)
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "drag"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
clientNum = ent->client->ps.clientNum; clientNum = ent->client->ps.clientNum;
@ -4742,13 +4736,7 @@ void Cmd_disarm_f( gentity_t *ent)
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "disarm"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
trap_Argv( 1, arg, sizeof( arg ) ); trap_Argv( 1, arg, sizeof( arg ) );
@ -5282,13 +5270,7 @@ void Cmd_ForceRank_f( gentity_t *ent)
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "forceRank"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if(!ent || !ent->client) if(!ent || !ent->client)
@ -5772,13 +5754,7 @@ void Cmd_Revive_f( gentity_t *ent)
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "revive"))) { // ToDo
if(!IsAdmin( ent ) || !rpg_medicsrevive.integer)
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if(!ent || !ent->client) if(!ent || !ent->client)
@ -5939,13 +5915,7 @@ void Cmd_n00b_f( gentity_t *ent)
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "n00b"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if ( !ent || !ent->client ) { if ( !ent || !ent->client ) {
@ -6005,13 +5975,7 @@ static void Cmd_admin_message( gentity_t *ent)
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "msg"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if ( !ent || !ent->client ) { if ( !ent || !ent->client ) {
@ -6072,13 +6036,7 @@ static void Cmd_ForceModel_f( gentity_t *ent ) {
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "forcemodel"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
//get the first arg //get the first arg
@ -6147,13 +6105,7 @@ static void Cmd_PlayMusic_f( gentity_t *ent )
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "play"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if(!ent || !ent->client) if(!ent || !ent->client)
@ -6187,13 +6139,7 @@ static void Cmd_StopMusic_f( gentity_t *ent )
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "stopmusic"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if(!ent || !ent->client) if(!ent || !ent->client)
@ -6218,13 +6164,7 @@ static void Cmd_PlaySound_f( gentity_t *ent )
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "sound"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if(!ent || !ent->client) if(!ent || !ent->client)
@ -6323,13 +6263,7 @@ static void Cmd_UseEnt_f ( gentity_t *ent ) {
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "useEnt"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
trap_Argv( 1, entArg, sizeof( entArg ) ); trap_Argv( 1, entArg, sizeof( entArg ) );
@ -6411,13 +6345,7 @@ void Cmd_EntList_f ( gentity_t *ent ) {
return; return;
} }
#else #else
if(sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "admin")) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
//initialise the data holders //initialise the data holders
@ -6674,13 +6602,7 @@ void Cmd_BeamToLoc_f( gentity_t *ent ) {
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "beam"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
trap_Argv( 1, argStr, sizeof( argStr ) ); trap_Argv( 1, argStr, sizeof( argStr ) );
@ -6851,13 +6773,7 @@ void Cmd_ForcePlayer_f ( gentity_t *ent ) {
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "forceplayer"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
// find the player // find the player
@ -6960,13 +6876,7 @@ void Cmd_BeamToPlayer_f( gentity_t *ent ) {
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "beam"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
trap_Argv( 1, argStr, sizeof( argStr ) ); trap_Argv( 1, argStr, sizeof( argStr ) );
@ -7433,13 +7343,7 @@ void Cmd_fxGun_f ( gentity_t *ent ) {
if ( !IsAdmin( ent ) ) if ( !IsAdmin( ent ) )
return; return;
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "fx"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
trap_Argv( 1, arg, sizeof( arg ) ); trap_Argv( 1, arg, sizeof( arg ) );
@ -7672,13 +7576,7 @@ void Cmd_flushFX_f( gentity_t *ent ) {
if ( !IsAdmin( ent ) ) if ( !IsAdmin( ent ) )
return; return;
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "flushfx"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
trap_SendServerCommand( -1, "cg_flushFX" ); trap_SendServerCommand( -1, "cg_flushFX" );
@ -7697,13 +7595,7 @@ void Cmd_spawnChar_f( gentity_t *ent ) {
if ( !IsAdmin( ent ) ) if ( !IsAdmin( ent ) )
return; return;
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "spawnchar"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if ( !PlaceDecoy(ent) ) if ( !PlaceDecoy(ent) )
@ -7733,13 +7625,7 @@ void Cmd_fluchChars_f( gentity_t *ent ) //GSIO01: fluch Chars ehhh? you know flu
if ( !IsAdmin( ent ) ) if ( !IsAdmin( ent ) )
return; return;
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "flushchars"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
trap_Argv( 1, arg, sizeof(arg) ); trap_Argv( 1, arg, sizeof(arg) );
@ -7815,13 +7701,7 @@ static void Cmd_Kick2_f( gentity_t *ent ) {
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "kick2"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if(!ent || !ent->client) if(!ent || !ent->client)
@ -7918,13 +7798,7 @@ static void Cmd_ClampInfo_f( gentity_t* ent ) {
if ( !IsAdmin( ent ) ) if ( !IsAdmin( ent ) )
return; return;
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "clamp"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if ( !ent->client ) if ( !ent->client )
@ -8280,13 +8154,7 @@ static void Cmd_lockDoor_f(gentity_t *ent) {
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "lock"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
trap_Argv( 1, entArg, sizeof( entArg ) ); trap_Argv( 1, entArg, sizeof( entArg ) );
@ -8367,13 +8235,7 @@ static void Cmd_ffColor_f(gentity_t *ent) {
if(!IsAdmin(ent)) if(!IsAdmin(ent))
return; return;
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "ffcolor"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
trap_Argv(1, arg, sizeof(arg)); trap_Argv(1, arg, sizeof(arg));
@ -8451,13 +8313,7 @@ static void Cmd_unlockAll_f(gentity_t *ent) {
if(!IsAdmin(ent)) if(!IsAdmin(ent))
return; return;
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "unlockall"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
for(i = g_maxclients.integer; i < MAX_GENTITIES ; i++) { for(i = g_maxclients.integer; i < MAX_GENTITIES ; i++) {
@ -8505,13 +8361,7 @@ static void Cmd_lockAll_f(gentity_t *ent) {
if(!IsAdmin(ent)) if(!IsAdmin(ent))
return; return;
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "lockall"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
for(i = g_maxclients.integer; i < MAX_GENTITIES; i++) { for(i = g_maxclients.integer; i < MAX_GENTITIES; i++) {
@ -8576,13 +8426,7 @@ static void Cmd_alert_f(gentity_t *ent) {
if(!IsAdmin(ent)) if(!IsAdmin(ent))
return; return;
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "alert"))) { // ToDo
if(!IsAdmin(ent));
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
alertEnt = G_Find(NULL, FOFS(classname), "target_alert"); alertEnt = G_Find(NULL, FOFS(classname), "target_alert");
@ -8660,13 +8504,7 @@ static void Cmd_admin_centerprint_f(gentity_t *ent) {
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "msg2"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if ( !ent || !ent->client ) { if ( !ent || !ent->client ) {
@ -8915,15 +8753,7 @@ static void Cmd_flushTentities_f(gentity_t *ent) {
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "tess"))) { // ToDo
if(!IsAdmin(ent)) {
G_PrintfClient(ent, "You're not logged in as admin or/and don't have the needed rights to use TESS.\n");
return;
}
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if(!trap_Argc()) { if(!trap_Argc()) {
@ -8986,13 +8816,7 @@ static void Cmd_spawnTentity_f(gentity_t *ent) {
return; return;
} }
#else #else
if((sql_use.integer && !trap_SQL_UserCheckRight(sql_dbName.string, ent->client->uid, "tess"))) { // ToDo
if(!IsAdmin(ent))
return;
} else {
if(!IsAdmin(ent))
return;
}
#endif #endif
if(!numArgs) { if(!numArgs) {
@ -9700,7 +9524,7 @@ static void UI_DEBUG(gentity_t *ent) {
G_Printf(S_COLOR_GREEN "%s\n", arg); G_Printf(S_COLOR_GREEN "%s\n", arg);
} }
#ifdef SQL #ifdef OLDSQL // SQL
/* /*
================= =================
Cmd_SqlLogin_f Cmd_SqlLogin_f
@ -10197,7 +10021,7 @@ void ClientCommand( int clientNum )
Cmd_UiHolodeck_f(ent); Cmd_UiHolodeck_f(ent);
else if (Q_stricmp(cmd, "ui_debug") == 0) else if (Q_stricmp(cmd, "ui_debug") == 0)
UI_DEBUG(ent); UI_DEBUG(ent);
#ifdef SQL #ifdef OLDSQL // SQL
else if (Q_stricmp(cmd, "userlogin") == 0) else if (Q_stricmp(cmd, "userlogin") == 0)
Cmd_SqlLogin_f(ent); Cmd_SqlLogin_f(ent);
else if (Q_stricmp(cmd, "sql_setup") == 0) else if (Q_stricmp(cmd, "sql_setup") == 0)

View file

@ -541,7 +541,7 @@ char *G_NewString( const char *string ) {
l = strlen(string) + 1; l = strlen(string) + 1;
newb = G_Alloc( l ); newb = (char *)G_Alloc( l );
new_p = newb; new_p = newb;

View file

@ -9,6 +9,7 @@
//#include "q_shared.h" //#include "q_shared.h"
#include "g_sql.h" #include "g_sql.h"
#include "g_local.h" #include "g_local.h"
#include "md5.h"
extern vmCvar_t sql_dbName; extern vmCvar_t sql_dbName;
extern vmCvar_t sql_use; extern vmCvar_t sql_use;
@ -22,6 +23,28 @@ extern void QDECL G_PrintfClient( gentity_t *ent, const char *fmt, ...);
sqlite3 *user_db; sqlite3 *user_db;
char *G_Sql_Md5(char *s) {
char *res;
unsigned char sig[16];
struct MD5Context md5c;
MD5Init(&md5c);
MD5Update(&md5c, s, strlen(s));
MD5Final(sig, &md5c);
res = (char *)malloc(sizeof(char)*MAX_QPATH);
if(!res) {
G_Printf(S_COLOR_RED "SQL ERROR: was unable to allocate %u byte\n", sizeof(char)*(strlen(s)+1));
return NULL;
}
sprintf(res, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
sig[0], sig[1], sig[2], sig[3], sig[4], sig[5], sig[6], sig[7],
sig[8], sig[9], sig[10], sig[11], sig[12], sig[13], sig[14], sig[15] );
return res;
}
/* /*
=============== ===============
G_SqlInit G_SqlInit

Binary file not shown.