diff --git a/dlls/pgsql/Makefile b/dlls/pgsql/Makefile new file mode 100755 index 00000000..2e8314c1 --- /dev/null +++ b/dlls/pgsql/Makefile @@ -0,0 +1,104 @@ +MODNAME = fun_amx +SRCFILES = fun.cpp + +EXTRA_LIBS_LINUX = +EXTRA_LIBS_WIN32 = +EXTRA_LIBDIRS_LINUX = -Lextra/lib_linux +EXTRA_LIBDIRS_WIN32 = -Lextra/lib_win32 + +EXTRA_INCLUDEDIRS = -Iextra/include -I../amxmodx + +EXTRA_FLAGS = -Dstrcmpi=strcasecmp + +AMXDIR=../amxmodx +SDKTOP=../hlsdk +METADIR=../metamodx + + +SDKSRC=$(SDKTOP)/SourceCode +OBJDIR_LINUX=obj.linux +OBJDIR_WIN32=obj.win32 +SRCDIR=. + +ifdef windir + OS=WIN32 +else + OS=LINUX +endif + +CC_LINUX=gcc-2.95 +ifeq "$(OS)" "WIN32" + CC_WIN32=gcc + LD_WINDLL=dllwrap + DEFAULT=win32 + CLEAN=clean_win32 +else + CC_WIN32=/usr/local/cross-tools/i386-mingw32msvc/bin/gcc + LD_WINDLL=/usr/local/cross-tools/bin/i386-mingw32msvc-dllwrap + DEFAULT=linux win32 + CLEAN=clean_both +endif + + + +LIBFILE_LINUX = $(MODNAME)_i386.so +LIBFILE_WIN32 = $(MODNAME).dll +TARGET_LINUX = $(OBJDIR_LINUX)/$(LIBFILE_LINUX) +TARGET_WIN32 = $(OBJDIR_WIN32)/$(LIBFILE_WIN32) + +FILES_ALL = *.cpp *.h [A-Z]* *.rc +ifeq "$(OS)" "LINUX" + ASRCFILES := $(shell ls -t $(SRCFILES)) +else + ASRCFILES := $(shell dir /b) +endif +OBJ_LINUX := $(SRCFILES:%.cpp=$(OBJDIR_LINUX)/%.o) +OBJ_WIN32 := $(SRCFILES:%.cpp=$(OBJDIR_WIN32)/%.o) + +CCOPT = -march=i586 -O6 -ffast-math -funroll-loops \ + -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \ + -malign-jumps=2 -malign-functions=2 -s -DNDEBUG + +INCLUDEDIRS=-I../curl/include -I$(SRCDIR) -I$(AMXDIR) -I$(METADIR) -I$(SDKSRC)/engine -I$(SDKSRC)/common -I$(SDKSRC)/pm_shared -I$(SDKSRC)/dlls -I$(SDKSRC) $(EXTRA_INCLUDEDIRS) +CFLAGS=-Wall -Wno-unknown-pragmas +ODEF = -DOPT_TYPE=\"optimized\" +CFLAGS:=$(CCOPT) $(CFLAGS) $(ODEF) $(EXTRA_FLAGS) + +DO_CC_LINUX=$(CC_LINUX) $(CFLAGS) -fPIC $(INCLUDEDIRS) -o $@ -c $< +DO_CC_WIN32=$(CC_WIN32) $(CFLAGS) $(INCLUDEDIRS) -o $@ -c $< +LINK_LINUX=$(CC_LINUX) $(CFLAGS) -shared -ldl -lm $(OBJ_LINUX) $(EXTRA_LIBDIRS_LINUX) $(EXTRA_LIBS_LINUX) -o $@ +LINK_WIN32=$(LD_WINDLL) -mwindows --def $(MODNAME).def --add-stdcall-alias $(OBJ_WIN32) $(EXTRA_LIBDIRS_WIN32) $(EXTRA_LIBS_WIN32) -o $@ + +$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.cpp + $(DO_CC_LINUX) + +$(OBJDIR_WIN32)/%.o: $(SRCDIR)/%.cpp + $(DO_CC_WIN32) + +default: $(DEFAULT) + +$(TARGET_LINUX): $(OBJDIR_LINUX) $(OBJ_LINUX) + $(LINK_LINUX) + +$(TARGET_WIN32): $(OBJDIR_WIN32) $(OBJ_WIN32) + $(LINK_WIN32) + +$(OBJDIR_LINUX): + mkdir $@ + +$(OBJDIR_WIN32): + mkdir $@ + +win32: $(TARGET_WIN32) + +linux: $(TARGET_LINUX) + +clean: $(CLEAN) + +clean_both: + -rm -f $(OBJDIR_LINUX)/* + -rm -f $(OBJDIR_WIN32)/* + +clean_win32: + del /q $(OBJDIR_WIN32) + diff --git a/dlls/pgsql/admin_pgsql.sma b/dlls/pgsql/admin_pgsql.sma new file mode 100755 index 00000000..c6963db3 --- /dev/null +++ b/dlls/pgsql/admin_pgsql.sma @@ -0,0 +1,274 @@ +/* AMX Mod X +* Admin Base for PgSQL Plugin +* +* by the David "BAILOPAN" Anderson +* +* This file for AMX Mod X. +* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +*/ + +#include +#include +#include + +#define MAX_ADMINS 64 + +new g_aPassword[MAX_ADMINS][32] +new g_aName[MAX_ADMINS][32] +new g_aFlags[MAX_ADMINS] +new g_aAccess[MAX_ADMINS] +new g_aNum = 0 +#if !defined NO_STEAM +new g_cmdLoopback[16] +#endif + +public plugin_init() +{ + register_plugin("Admin Base for PgSQL","0.16","BAILOPAN") + + register_cvar("amx_mode","2.0") + register_cvar("amx_password_field","_pw") + register_cvar("amx_default_access","") + register_srvcmd("amx_sqladmins","adminSql") + register_cvar("amx_pgsql_host","127.0.0.1") + register_cvar("amx_pgsql_user","root") + register_cvar("amx_pgsql_pass","") + register_cvar("amx_pgsql_db","amx") + + register_cvar("amx_vote_ratio","0.02") + register_cvar("amx_votekick_ratio","0.40") + register_cvar("amx_voteban_ratio","0.40") + register_cvar("amx_votemap_ratio","0.40") + register_cvar("amx_vote_time","10") + register_cvar("amx_vote_answers","1") + register_cvar("amx_vote_delay","60") + register_cvar("amx_last_voting","0") + register_cvar("amx_show_activity","2") + set_cvar_float("amx_last_voting",0.0) + + register_concmd("amx_reloadadmins","cmdReload",ADMIN_ADMIN) + +#if !defined NO_STEAM + format( g_cmdLoopback, 15, "amxauth%c%c%c%c" , + random_num('A','Z') , random_num('A','Z') ,random_num('A','Z'),random_num('A','Z') ) + register_clcmd( g_cmdLoopback, "ackSignal" ) +#endif + + remove_user_flags(0,read_flags("z")) // remove 'user' flag from server rights + + new configsDir[128] + get_configsdir(configsDir, 127) + server_cmd("exec %s/amxx.cfg", configsDir) // Execute main configuration file + server_cmd("exec %s/pgsql.cfg;amx_sqladmins", configsDir) +} + +public adminSql() { + new host[64],user[32],pass[32],db[32],error[128] + get_cvar_string("amx_pgsql_host",host,63) + get_cvar_string("amx_pgsql_user",user,31) + get_cvar_string("amx_pgsql_pass",pass,31) + get_cvar_string("amx_pgsql_db",db,31) + + new pgsql = pgsql_connect(host,user,pass,db) + if(pgsql < 1){ + pgsql_error(pgsql, error, 128) + server_print("[AMXX] PgSQL error: can't connect: '%s'",error) + return PLUGIN_HANDLED + } + + pgsql_query(pgsql,"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 '' ) TYPE=MyISAM") + + if(pgsql_query(pgsql,"SELECT auth,password,access,flags FROM admins") < 1) { + pgsql_error(pgsql,error,127) + server_print("[AMXX] PgSQL error: can't load admins: '%s'",error) + return PLUGIN_HANDLED + } + + new szFlags[32],szAccess[32],iAccess + while( pgsql_nextrow(pgsql) > 0 ) + { + pgsql_getfield(pgsql, 1, g_aName[ g_aNum ] ,31) + pgsql_getfield(pgsql, 2, g_aPassword[ g_aNum ] ,31) + pgsql_getfield(pgsql, 3, szAccess,31) + pgsql_getfield(pgsql, 4, szFlags,31) + + iAccess = read_flags(szAccess) + if (!(iAccess & ADMIN_USER) && !(iAccess & ADMIN_ADMIN)) { + iAccess |= ADMIN_ADMIN + } + + g_aAccess[ g_aNum ] = iAccess + g_aFlags[ g_aNum ] = read_flags( szFlags ) + ++g_aNum + } + + server_print("[AMXX] Loaded %d admin%s from database",g_aNum, (g_aNum == 1) ? "" : "s" ) + pgsql_close(pgsql) + return PLUGIN_HANDLED +} + +public cmdReload(id,level,cid) +{ + if (!cmd_access(id,level,cid,1)) + return PLUGIN_HANDLED + + g_aNum = 0 + adminSql() // Re-Load admins accounts + + return PLUGIN_HANDLED +} + +getAccess(id,name[],authid[],ip[], password[]){ + new index = -1 + new result = 0 + for(new i = 0; i < g_aNum; ++i) { + if (g_aFlags[i] & FLAG_AUTHID) { + if (equal(authid,g_aName[i])) { + index = i + break + } + } + else if (g_aFlags[i] & FLAG_IP) { + new c = strlen( g_aName[i] ) + if ( g_aName[i][ c - 1 ] == '.' ) { /* check if this is not a xxx.xxx. format */ + if ( equal( g_aName[i] , ip , c ) ) { + index = i + break + } + } /* in other case an IP must just match */ + else if ( equal(ip,g_aName[i]) ){ + index = i + break + } + } + else { + if (g_aFlags[i] & FLAG_TAG) { + if (contain(name,g_aName[i])!=-1){ + index = i + break + } + } + else if (equal(name,g_aName[i])) { + index = i + break + } + } + } + if (index != -1) { + if (g_aFlags[index] & FLAG_NOPASS){ + result |= 8 + new sflags[32] + get_flags(g_aAccess[index],sflags,31) + set_user_flags(id,g_aAccess[index]) + log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", + name,get_user_userid(id),authid,g_aName[index] ,sflags,ip) + } + else if (equal(password,g_aPassword[index])) { + result |= 12 + set_user_flags(id,g_aAccess[index]) + new sflags[32] + get_flags(g_aAccess[index],sflags,31) + log_amx("Login: ^"%s<%d><%s><>^" became an admin (account ^"%s^") (access ^"%s^") (address ^"%s^")", + name,get_user_userid(id),authid,g_aName[index] ,sflags,ip) + } + else { + result |= 1 + if (g_aFlags[index] & FLAG_KICK){ + result |= 2 + log_amx("Login: ^"%s<%d><%s><>^" kicked due to invalid password (account ^"%s^") (address ^"%s^")", + name,get_user_userid(id),authid,g_aName[index],ip) + } + } + } + else if (get_cvar_float("amx_mode")==2.0) { + result |= 2 + } + else { + new defaccess[32] + get_cvar_string("amx_default_access",defaccess,31) + if (!defaccess[0]) + defaccess[0] = 'z' + new idefaccess = read_flags(defaccess) + if (idefaccess){ + result |= 8 + set_user_flags(id,idefaccess) + } + } + + return result +} + +accessUser( id, name[]="" ) +{ + remove_user_flags(id) + new userip[32],userauthid[32],password[32],passfield[32],username[32] + get_user_ip(id,userip,31,1) + get_user_authid(id,userauthid,31) + if ( name[0] ) copy( username , 31, name) + else get_user_name(id,username,31 ) + get_cvar_string("amx_password_field",passfield,31) + get_user_info(id,passfield,password,31) + new result = getAccess(id,username,userauthid,userip,password) + if (result & 1) client_cmd(id,"echo ^"* Invalid Password!^"") + if (result & 2) { +#if !defined NO_STEAM + client_cmd(id,g_cmdLoopback) +#else + client_cmd(id,"echo ^"* You have no entry to the server...^";disconnect") +#endif + return PLUGIN_HANDLED + } + if (result & 4) client_cmd(id,"echo ^"* Password accepted^"") + if (result & 8) client_cmd(id,"echo ^"* Privileges set^"") + return PLUGIN_CONTINUE +} + +public client_infochanged(id) +{ + if ( !is_user_connected(id) || !get_cvar_num("amx_mode") ) + return PLUGIN_CONTINUE + + new newname[32], oldname[32] + get_user_name(id,oldname,31) + get_user_info(id,"name",newname,31) + + if ( !equal(newname,oldname) ) + accessUser( id , newname ) + + return PLUGIN_CONTINUE +} + +#if !defined NO_STEAM + +public ackSignal(id) + server_cmd("kick #%d ^"You have no entry to the server...^"", get_user_userid(id) ) + +public client_authorized(id) +#else +public client_connect(id) +#endif + return get_cvar_num( "amx_mode" ) ? accessUser( id ) : PLUGIN_CONTINUE diff --git a/dlls/pgsql/libpq.lib b/dlls/pgsql/libpq.lib new file mode 100755 index 00000000..4458ed28 Binary files /dev/null and b/dlls/pgsql/libpq.lib differ diff --git a/dlls/pgsql/pgsql.inc b/dlls/pgsql/pgsql.inc new file mode 100755 index 00000000..1341fa11 --- /dev/null +++ b/dlls/pgsql/pgsql.inc @@ -0,0 +1,32 @@ +/* PostgreSQL functions +* +* by David "BAILOPAN" Anderson +* Under the GNU General Public License, version 2 +*/ + +#if defined _pgsql_included + #endinput +#endif +#define _pgsql_included + +/* Opens connection. If already such exists then that will be used. +* Function returns sql id to use with other sql natives. +* Host can be plain ip or hostname, ports are not yet allowed. */ +native pgsql_connect(host[],user[],pass[],dbname[]); + +/* Uses an existing connection (sql) to perform a new query (query) (might close previous query if any). + Will return the number of rows found. + */ +native pgsql_query(sql,query[], {Float,_}:...); + +/* Advances to the next row in the query set. */ +native pgsql_nextrow(sql); + +/* Stores specified column (fieldnum) of current query (sql) in (dest) with (maxlength) characters maximum. */ +native pgsql_getfield(sql,fieldnum,dest[],maxlength); + +/* Clears query (sql) and closes connection (if any other plugin doesn't use it). */ +native pgsql_close(sql); + +/* Stores last error of current query/connection (sql) in (dest) with (maxlength) characters maximum. */ +native pgsql_error(sql,dest[],maxlength); \ No newline at end of file diff --git a/dlls/pgsql/pgsql_amx.cpp b/dlls/pgsql/pgsql_amx.cpp new file mode 100755 index 00000000..1af1f553 --- /dev/null +++ b/dlls/pgsql/pgsql_amx.cpp @@ -0,0 +1,219 @@ +/* AMX Mod X +* PostgreSQL Module +* +* by David "BAILOPAN" Anderson +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +*/ + +#include "pgsql_amx.h" + +pgs *cns = NULL; + +bool is_ipaddr(const char *IP) +{ + do { + if ((int)(*(IP++)) > 0x37) { + return false; + } + } while (*IP); + + return true; +} + + +char *make_connstring(const char *host, const char *user, const char *pass, const char *name) +{ + int len = 46 + strlen(host) + strlen(user) + strlen(pass) + strlen(name) + 2; + char *c_info = new char[len]; + + if (is_ipaddr(host)) { + sprintf(c_info, "hostaddr = '%s' user = '%s' pass = '%s' name = '%s'", host, user, pass, name); + } else { + sprintf(c_info, "host = '%s' user = '%s' pass = '%s' name = '%s'", host, user, pass, name); + } + + return c_info; +} + +PGconn* make_connection(const char *h, const char *u, const char *ps, const char *n) +{ + pgs *p = cns; + int last = 0; + + while (p) { + last = p->ii(); + if (p->v.host==h && p->v.user==u && p->v.pass==ps && p->v.name==n) { + return p->v.cn; + } + } + char *c_info = make_connstring(h, u, ps, n); + if (cns == NULL) { + cns = new pgs; + PGconn *cn = PQconnectdb(c_info); + cns->set(h, u, ps, n, 1); + cns->scn(cn); + return cn; + } else { + p = new pgs(h, u, ps, n, last+1); + cns->sln(p); + PGconn *cn = PQconnectdb(c_info); + cns->scn(cn); + return cn; + } +} + +pgs* get_conn_i(int n=1) +{ + pgs *p = cns; + int i=0; + while (p) { + if (++i==n) { + return p; + } else { + p = p->link(); + } + } + + return NULL; +} + +static cell AMX_NATIVE_CALL pgsql_connect(AMX *amx, cell *params) +{ + int i; + const char *host = GET_AMXSTRING(amx,params[1],0,i); + const char *user = GET_AMXSTRING(amx,params[2],1,i); + const char *pass = GET_AMXSTRING(amx,params[3],2,i); + const char *name = GET_AMXSTRING(amx,params[4],3,i); + + PGconn *cn = make_connection(host, user, pass, name); + + if (PQstatus(cn) != CONNECTION_OK) { + return 0; + } + + return 1; +} + +static cell AMX_NATIVE_CALL pgsql_error(AMX *amx, cell *params) +{ + int c = params[1]; + pgs *p = get_conn_i(c); + char *error = PQerrorMessage(p->v.cn); + SET_AMXSTRING(amx, params[2], (error==NULL?"":error), params[3]); + return 1; +} + +static cell AMX_NATIVE_CALL pgsql_query(AMX *amx, cell *params) +{ + pgs *p = get_conn_i(params[1]); + if (p == NULL) { + return 0; + } + + if (p->v.res) { + p->reset(); + } + + int i; + const char *query = FORMAT_AMXSTRING(amx, params, 2, i); + + p->v.res = PQexec(p->v.cn, query); + + if (PQresultStatus(p->v.res) != PGRES_COMMAND_OK) { + return -1; + } + + return PQntuples(p->v.res); +} + +static cell AMX_NATIVE_CALL pgsql_nextrow(AMX *amx, cell *params) +{ + pgs *p = get_conn_i(params[1]); + if (p == NULL) { + return 0; + } + + if (p->v.row > PQntuples(p->v.res)) { + return 0; + } + + p->v.row++; + + return 1; +} + +static cell AMX_NATIVE_CALL pgsql_getfield(AMX *amx, cell *params) +{ + pgs *p = get_conn_i(params[1]); + int col = params[2] + 1; + if (p == NULL) { + return 0; + } + if (col-1 > PQnfields(p->v.res)) { + return 0; + } + + char *field = PQgetvalue(p->v.res, p->v.row, col); + return SET_AMXSTRING(amx, params[3], field?field:"", params[4]); +} + +static cell AMX_NATIVE_CALL pgsql_close(AMX *amx, cell *params) +{ + pgs *p = get_conn_i(params[1]); + + p->close(); + + return 1; +} + +AMX_NATIVE_INFO pgsql_exports[] = { + {"pgsql_connect", pgsql_connect}, + {"pgsql_error", pgsql_error}, + {"pgsql_query", pgsql_query}, + {"pgsql_nextrow", pgsql_nextrow}, + {"pgsql_close", pgsql_close}, + + {NULL, NULL}, +}; + +C_DLLEXPORT int AMX_Query(module_info_s** info) { + *info = &module_info; + return 1; +} + +C_DLLEXPORT int AMX_Attach(pfnamx_engine_g* amxeng,pfnmodule_engine_g* meng) { + g_engAmxFunc = amxeng; + g_engModuleFunc = meng; + + ADD_AMXNATIVES(&module_info, pgsql_exports); + + return(1); +} + +C_DLLEXPORT int AMX_Detach() { + delete cns; + return(1); +} diff --git a/dlls/pgsql/pgsql_amx.def b/dlls/pgsql/pgsql_amx.def new file mode 100755 index 00000000..283974b1 --- /dev/null +++ b/dlls/pgsql/pgsql_amx.def @@ -0,0 +1,6 @@ +LIBRARY fun_amx +EXPORTS + AMX_Attach @1 + AMX_Detach @3 +SECTIONS + .data READ WRITE diff --git a/dlls/pgsql/pgsql_amx.h b/dlls/pgsql/pgsql_amx.h new file mode 100755 index 00000000..0f799996 --- /dev/null +++ b/dlls/pgsql/pgsql_amx.h @@ -0,0 +1,134 @@ +/* AMX Mod X +* PostgreSQL Module +* +* by David "BAILOPAN" Anderson +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +*/ +#include +#include +#include +#include +#include + +#define destroy(x) if(x){delete(x);x=0;} +#define destarr(x) if(x){delete[]x;x=0;} + +pfnamx_engine_g* g_engAmxFunc; +pfnmodule_engine_g* g_engModuleFunc; + +#define NAME "PgSQL" +#define AUTHOR "BAILOPAN" +#define VERSION "1.00" +#define URL "http://www.bailopan.com/" +#define LOGTAG "PGSQL" +#define DATE __DATE__ + +module_info_s module_info = { + NAME, + AUTHOR, + VERSION, + AMX_INTERFACE_VERSION, + RELOAD_MODULE, +}; + +class pgs +{ +public: + pgs() + { + } + + pgs(const char *h, const char *u, const char *p, const char *n, int i=1) + { + set(h, u, p, n, i); + } + + void set(const char *h, const char *u, const char *p, const char *n, int i=1) + { + v.host = h; + v.user = u; + v.pass = p; + v.name = n; + v.cn = NULL; + v.row = 0; + next = NULL; + id = i; + } + + pgs* link() + { + return next; + } + + int ii() + { + return id; + } + + void scn(PGconn *cn) + { + v.cn = cn; + } + + void sln(pgs *p) + { + next = p; + } + + void reset() + { + PQclear(v.res); + v.row = 0; + } + + void close() + { + PQfinish(v.cn); + destroy(v.host); + destroy(v.user); + destroy(v.pass); + destroy(v.name); + } + + struct pgsql { + const char *host; + const char *user; + const char *pass; + const char *name; + PGconn *cn; + PGresult *res; + int row; + } v; + + ~pgs() + { + close(); + } + +private: + pgs *next; + int id; +}; \ No newline at end of file diff --git a/dlls/pgsql/pgsql_amx.vcproj b/dlls/pgsql/pgsql_amx.vcproj new file mode 100755 index 00000000..0633c919 --- /dev/null +++ b/dlls/pgsql/pgsql_amx.vcproj @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dlls/pgsql/readme.txt b/dlls/pgsql/readme.txt new file mode 100755 index 00000000..5ee59e6b --- /dev/null +++ b/dlls/pgsql/readme.txt @@ -0,0 +1,32 @@ +PgSQL Module for AMX Mod X +by David "BAILOPAN" Anderson +---------------------------- + +Installation +------------ + +1] Place the pgsql.cfg file in your addons/amxx/configs dir. + + +2] Place the module in the right place: +Linux: + +Place geoip_amx_i386.so into addons/amxx/modules/ +(If you want a glibc2.3 optimized binary, use geoip_amx_i686.so) +Add this line to addons/amxx/modules.ini : +geoip_amx_i386.so + + +Windows: + +Place geoip_amx.dll into addons/ammx/modules/ +Add this line to addons/amxx/modules.ini : +geoip_amx.dll + + +3] Scripters: Place "pgsql.inc" in addons/amxx/scripting/include + +4] If you are using pgsql to store admins: +Place admin_pgsql.amx in addons/amxx/plugins/ +And add this line to addons/amxx/plugins.ini: +admin_pgsql.amx \ No newline at end of file