summaryrefslogtreecommitdiff
path: root/0.8/src/data
diff options
context:
space:
mode:
Diffstat (limited to '0.8/src/data')
-rw-r--r--0.8/src/data/README4
-rw-r--r--0.8/src/data/con.cpp68
-rw-r--r--0.8/src/data/con.h46
-rw-r--r--0.8/src/data/con_base.cpp43
-rw-r--r--0.8/src/data/con_base.h43
-rw-r--r--0.8/src/data/data.cpp227
-rw-r--r--0.8/src/data/data.h53
-rw-r--r--0.8/src/data/data_base.cpp203
-rw-r--r--0.8/src/data/data_base.h66
9 files changed, 0 insertions, 753 deletions
diff --git a/0.8/src/data/README b/0.8/src/data/README
deleted file mode 100644
index 6a993bb..0000000
--- a/0.8/src/data/README
+++ /dev/null
@@ -1,4 +0,0 @@
- - ./data.*
- The database wrapper
-
-
diff --git a/0.8/src/data/con.cpp b/0.8/src/data/con.cpp
deleted file mode 100644
index c60cd66..0000000
--- a/0.8/src/data/con.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*:*
- *: File: ./src/data/con.cpp
- *:
- *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *: Copyright (C) 2006, 2007 Paul C. Buetow
- *:
- *: 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.
- *:*/
-#include "con.h"
-
-using namespace std;
-
-#ifdef DATABASE
-#ifndef CON_CPP
-#define CON_CPP
-
-con::con()
-{
- p_mysql = mysql_init(NULL);
-
- while ( !p_mysql )
- {
- wrap::system_message( MYSQLE1 );
- usleep( 30000000 );
- mysql_init(p_mysql);
- }
-
- while ( mysql_real_connect(
- p_mysql,
- (const char*)wrap::CONF->get_elem("chat.database.serverhost").c_str(),
- (const char*)wrap::CONF->get_elem("chat.database.user").c_str(),
- (const char*)wrap::CONF->get_elem("chat.database.password").c_str(),
- (const char*)wrap::CONF->get_elem("chat.database.dbname").c_str(),
- tool::string2int(wrap::CONF->get_elem("chat.database.port")),
- NULL, 0 ) == NULL )
- {
- wrap::system_message( MYSQLQU + string( mysql_error(p_mysql) ) );
- usleep( 30000000 );
- }
-}
-
-con::~con()
-{
- if ( p_mysql )
- {
- if (mysql_ping( p_mysql ) != 0)
- mysql_close( p_mysql );
- }
-}
-
-#endif
-#endif
diff --git a/0.8/src/data/con.h b/0.8/src/data/con.h
deleted file mode 100644
index ca09626..0000000
--- a/0.8/src/data/con.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*:*
- *: File: ./src/data/con.h
- *:
- *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *: Copyright (C) 2006, 2007 Paul C. Buetow
- *:
- *: 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.
- *:*/
-#include "../incl.h"
-#ifdef DATABASE
-
-#ifndef CON_H
-#define CON_H
-
-#include <mysql/mysql.h>
-#include <iostream>
-#include "con_base.h"
-
-using namespace std;
-
-class con : public con_base
-{
-public:
- MYSQL* p_mysql;
- con( );
- ~con( );
-};
-
-#endif
-#endif
diff --git a/0.8/src/data/con_base.cpp b/0.8/src/data/con_base.cpp
deleted file mode 100644
index 98baab9..0000000
--- a/0.8/src/data/con_base.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*:*
- *: File: ./src/data/con_base.cpp
- *:
- *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *: Copyright (C) 2006, 2007 Paul C. Buetow
- *:
- *: 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.
- *:*/
-#include "con_base.h"
-
-#ifdef DATABASE
-#ifndef CON_BASE_CPP
-#define CON_BASE_CPP
-
-using namespace std;
-
-con_base::con_base()
-{
- renew_timeout( );
-}
-
-con_base::~con_base()
-{}
-
-
-#endif
-#endif
diff --git a/0.8/src/data/con_base.h b/0.8/src/data/con_base.h
deleted file mode 100644
index 35853b2..0000000
--- a/0.8/src/data/con_base.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*:*
- *: File: ./src/data/con_base.h
- *:
- *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *: Copyright (C) 2006, 2007 Paul C. Buetow
- *:
- *: 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.
- *:*/
-#include "../incl.h"
-#ifdef DATABASE
-
-#ifndef CON_BASE_H
-#define CON_BASE_H
-
-#include "../time/timo.h"
-
-using namespace std;
-
-class con_base : public timo
-{
-public:
- con_base( );
- ~con_base( );
-};
-
-#endif
-#endif
diff --git a/0.8/src/data/data.cpp b/0.8/src/data/data.cpp
deleted file mode 100644
index a401dab..0000000
--- a/0.8/src/data/data.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/*:*
- *: File: ./src/data/data.cpp
- *:
- *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *: Copyright (C) 2006, 2007 Paul C. Buetow
- *:
- *: 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.
- *:*/
-#include "data.h"
-
-#ifdef DATABASE
-#ifndef DATA_CPP
-#define DATA_CPP
-
-using namespace std;
-
-data::data()
-{}
-
-data::~data()
-{}
-
-hashmap<string>
-data::select_user_data( string s_user, string s_query)
-{
- string s_where_rule = " WHERE nick = \"" + s_user + "\"";
- vector<string> vec_elements;
- MYSQL_RES* p_result = select_query( s_query, s_where_rule, vec_elements );
- return parse_result( p_result, vec_elements );
-}
-
-MYSQL_RES*
-data::select_query( string s_query, string s_where_rule, vector<string>& vec_elements )
-{
- con* p_con = get_con();
-
- vec_elements = map_queries[s_query];
- string s_mysql_query = "SELECT ";
- vector<string>::iterator iter = vec_elements.begin();
-
- string s_table = *iter;
- iter++;
-
- while ( iter != vec_elements.end() )
- {
- s_mysql_query.append( secure_query(*iter) );
- if ( ++iter != vec_elements.end() )
- s_mysql_query.append( ", " );
- }
-
- s_mysql_query.append(" FROM " + s_table + s_where_rule );
- print_query( MYSQLQU + s_mysql_query );
-
- MYSQL_RES* p_result = NULL;
-
- if ( 0 == mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
- {
- p_result = mysql_store_result( p_con->p_mysql );
- push_con( p_con );
- }
- else
- {
- wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
- if (p_con != NULL)
- delete p_con;
- }
-
- return p_result;
-}
-
-hashmap<string>
-data::parse_result( MYSQL_RES* p_result, vector<string>& vec_elements )
-{
- hashmap<string> map_ret;
- if ( p_result != NULL )
- {
- MYSQL_ROW row;
- vector<string>::iterator vec_iter = vec_elements.begin();
- vec_iter++;
-
- while ( (row = mysql_fetch_row(p_result)) )
- for ( int i=0; i < mysql_num_fields(p_result); i++, vec_iter++ )
- map_ret[*vec_iter] = string(row[i]);
-
- mysql_free_result( p_result );
- }
- return map_ret;
-}
-
-void
-data::insert_user_data( string s_user, string s_query, map<string,string> insert_map )
-{
- insert_query( s_query, insert_map );
-}
-
-void
-data::insert_query( string s_query, map<string,string> map_insert )
-{
- vector<string> vec_elements = map_queries[s_query];
- vector<string>::iterator iter = vec_elements.begin();
-
- string s_table = *iter;
- iter++;
- string s_mysql_query = "INSERT INTO " + s_table + " (";
-
- while ( iter != vec_elements.end() )
- {
- s_mysql_query.append( *iter );
-
- if ( ++iter != vec_elements.end() )
- s_mysql_query.append( ", " );
- else
- s_mysql_query.append( ") VALUES(" );
- }
-
- iter = vec_elements.begin();
- iter++;
-
- while ( iter != vec_elements.end() )
- {
- s_mysql_query.append( "\"" + secure_query(map_insert[*iter]) + "\"" );
- if ( ++iter != vec_elements.end() )
- s_mysql_query.append( ", " );
- else
- s_mysql_query.append( ")" );
- }
-
- print_query( MYSQLQU + s_mysql_query );
-
- con* p_con = get_con();
-
- if ( 0 != mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
- wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
-
- push_con( p_con );
-
- return;
-}
-
-void
-data::update_user_data( string s_user, string s_query, hashmap<string> update_map )
-{
- vector<string> vec_elements = map_queries[s_query];
-
- if ( vec_elements.size() == 0 )
- return;
-
- vector<string>::iterator iter = vec_elements.begin();
- vector<string>::iterator iter_second = vec_elements.begin();
- iter_second++;
-
- string s_table = *iter;
- iter++;
- string s_mysql_query = "UPDATE " + s_table + " SET ";
- bool b_flag = 0;
-
- while ( iter != vec_elements.end() )
- {
- if ( update_map[*iter] == "" ) // Dont update data if it has not been changed / if its empty!
- {
- iter++;
- continue;
- }
-
- if ( iter != iter_second && b_flag )
- s_mysql_query.append( ", " );
-
- s_mysql_query.append( *iter + "=\"" + secure_query(update_map[*iter]) + "\"" );
- b_flag = 1;
- iter++;
- }
-
- if ( b_flag )
- {
- s_mysql_query.append( " WHERE nick=\"" + tool::to_lower(s_user) + "\"" );
-
- con* p_con = get_con();
- print_query( MYSQLQU + s_mysql_query );
-
- if ( 0 != mysql_query( p_con->p_mysql, (const char*)s_mysql_query.c_str() ) )
- wrap::system_message( MYSQLQU + string( mysql_error(p_con->p_mysql) ) );
-
- push_con( p_con );
- }
-}
-
-string
-data::secure_query( string s_mysql_query )
-{
- // Prevent from MySQL injection attacks (escaping " and \)
- unsigned i_pos = s_mysql_query.find("\\");
-
- while ( i_pos != string::npos )
- {
- s_mysql_query.replace( i_pos, 1, "/" );
- i_pos = s_mysql_query.find("\\");
- }
-
- i_pos = s_mysql_query.find("\"");
-
- while ( i_pos != string::npos )
- {
- s_mysql_query.replace( i_pos, 1, "'" );
- i_pos = s_mysql_query.find("\"");
- }
-
- return s_mysql_query;
-}
-
-#endif
-#endif
diff --git a/0.8/src/data/data.h b/0.8/src/data/data.h
deleted file mode 100644
index e0281db..0000000
--- a/0.8/src/data/data.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*:*
- *: File: ./src/data/data.h
- *:
- *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *: Copyright (C) 2006, 2007 Paul C. Buetow
- *:
- *: 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.
- *:*/
-#include "../incl.h"
-#ifdef DATABASE
-
-#ifndef DATA_H
-#define DATA_H
-
-#include "data_base.h"
-#include <mysql/mysql.h>
-
-using namespace std;
-
-class data : public data_base // data implementation used in data.h
-{
-private:
- MYSQL_RES* select_query( string s_query, string s_where_rule, vector<string>& vec_elements );
- hashmap<string> parse_result( MYSQL_RES* p_result, vector<string>& vec_elements );
- void insert_query( string s_query, map<string,string> map_insert );
- string secure_query( string s_mysql_query );
-public:
- data( );
- ~data( );
-
- hashmap<string> select_user_data( string s_user, string s_query );
- void insert_user_data( string s_user, string s_query, map<string,string> insert_map );
- void update_user_data( string s_user, string s_query, hashmap<string> update_map );
-};
-
-#endif
-#endif
diff --git a/0.8/src/data/data_base.cpp b/0.8/src/data/data_base.cpp
deleted file mode 100644
index 57705e0..0000000
--- a/0.8/src/data/data_base.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/*:*
- *: File: ./src/data/data_base.cpp
- *:
- *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *: Copyright (C) 2006, 2007 Paul C. Buetow
- *:
- *: 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.
- *:*/
-#include "data_base.h"
-
-#ifdef DATABASE
-#ifndef DATA_BASE_CPP
-#define DATA_BASE_CPP
-
-using namespace std;
-
-data_base::data_base( )
-{
-
- vector<string> vec_keys = *wrap::CONF->get_key_vector();
- vector<string>::iterator iter;
-
- // Reads all DATA_ elements of conf.txt!
- for ( iter = vec_keys.begin(); iter != vec_keys.end(); iter++ )
- {
- if ( iter->length() > 20
- && iter->compare(0, 19, "chat.database.mysql") == 0
- && iter->find(".descr") == string::npos )
- {
- vector<string> vec_tokens;
- string s_element = wrap::CONF->get_elem(*iter);
- unsigned i_pos = 0;
-
- for ( bool b_find = 1; b_find; )
- {
- i_pos = s_element.find_first_of( " ", 0 );
-
- if ( i_pos != string::npos )
- {
- vec_tokens.push_back( s_element.substr(0, i_pos) );
- s_element = s_element.substr( i_pos+1 );
- }
- else
- {
- vec_tokens.push_back( s_element );
- b_find = 0;
- }
- }
-
- string s_mysqlquery = iter->substr(20);
- wrap::system_message(MYSQLQ2 + s_mysqlquery);
- map_queries[s_mysqlquery] = vec_tokens;
- }
- }
-}
-
-void data_base::init_connections()
-{
- int i_min_con = tool::string2int( wrap::CONF->get_elem("chat.database.mincon") ),
- i_max_con = tool::string2int( wrap::CONF->get_elem("chat.database.maxcon") );
-
- wrap::system_message(DATAIN0 + tool::int2string(i_max_con));
- wrap::system_message(DATAIN1 + tool::int2string(i_min_con));
-
- for ( int i = 0; i < i_min_con && i < i_max_con; i++ )
- push_back( new con() );
-}
-
-data_base::~data_base()
-{}
-
-hashmap<string>
-data_base::select_user_data( string s_user, string s_query)
-{
- print_query( DATAQUE + s_query );
- hashmap<string> map_ret;
- return map_ret;
-}
-
-void
-data_base::insert_user_data( string s_user, string s_query, hashmap<string> insert_map )
-{
- print_query( DATAQUE + s_query );
-}
-
-
-void
-data_base::update_user_data( string s_user, string s_query, hashmap<string> update_map )
-{
- print_query( DATAQUE + s_query );
-}
-
-void
-data_base::print_query( string s_query )
-{
-#ifdef DATA_PRINT_QUERIES
- print_query_( s_query );
-#endif
-}
-
-#ifdef DATA_PRINT_QUERIES
-void
-data_base::print_query_( string s_query )
-{
- wrap::system_message( s_query );
-}
-#endif
-
-con*
-data_base::get_con()
-{
-
- if ( empty() )
- {
- wrap::system_message( DATANEW + string("(") + tool::int2string(size()+1) + ")" );
- return new con;
- }
- else if ( size() > i_max_con-1 )
- {
- wrap::system_message( DATAMAX + string("(") + tool::int2string(i_max_con) + ")" );
- usleep( 5000000 );
- return get_con();
- }
-
-
- con* p_con = *begin();
- pop_front();
-
- wrap::system_message( DATAGET );
-
- p_con->renew_timeout();
- return p_con;
-}
-
-void
-data_base::push_con( con* p_con )
-{
- push_front( p_con );
-
- wrap::system_message( DATAADD );
-}
-
-void
-data_base::disconnect_all_connections()
-{
- wrap::system_message( DATADIS );
-
- while ( !empty() )
- {
- con* p_con = *begin();
- pop_front();
- delete p_con;
- }
-
-}
-
-void
-data_base::check_data_con_timeout()
-{
- int i_timeout_time = tool::string2int(wrap::CONF->get_elem("chat.database.contimeout"));
- int i_last_activity;
-
-
- list< list<con*>::iterator > erase_list;
- for ( list<con*>::iterator iter = begin();
- iter != end(); iter++ )
- {
- i_last_activity = (int) (*iter)->get_last_activity();
- if ( i_timeout_time <= i_last_activity )
- {
- con* p_con = *iter;
- erase_list.push_back(iter);
- delete p_con;
- wrap::system_message(DATADI2 + tool::int2string(size()-erase_list.size()+1) + ","
- + tool::int2string(i_timeout_time) + ","
- + tool::int2string(i_last_activity) + ")");
- }
- }
- for ( list< list<con*>::iterator >::iterator erase_iter = erase_list.begin();
- erase_iter != erase_list.end(); erase_iter++ )
- erase( *erase_iter );
-
-}
-
-
-#endif
-#endif
diff --git a/0.8/src/data/data_base.h b/0.8/src/data/data_base.h
deleted file mode 100644
index 834aea3..0000000
--- a/0.8/src/data/data_base.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*:*
- *: File: ./src/data/data_base.h
- *:
- *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT
- *:
- *: Copyright (C) 2003 Paul C. Buetow, Volker Richter
- *: Copyright (C) 2004 Paul C. Buetow
- *: Copyright (C) 2005 EXA Digital Solutions GbR
- *: Copyright (C) 2006, 2007 Paul C. Buetow
- *:
- *: 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.
- *:*/
-#include "../incl.h"
-#ifdef DATABASE
-
-#ifndef DATA_BASE_H
-#define DATA_BASE_H
-
-#include <vector>
-#include <list>
-#include "con.h"
-
-using namespace std;
-
-class data_base : protected list<con*>
-{
-private:
- int i_max_con;
-
-protected:
- hashmap< vector<string> > map_queries;
- void print_query( string s_query );
-#ifdef DATA_PRINT_QUERIES
-
- virtual void print_query_( string s_query );
-#endif
-
- con* get_con();
- void push_con( con* p_con );
-
-public:
- data_base();
- ~data_base();
-
- void init_connections();
- virtual hashmap<string> select_user_data( string s_user, string s_query );
- virtual void insert_user_data( string s_user, string s_query, hashmap<string> insert_map );
- virtual void update_user_data( string s_user, string s_query, hashmap<string> update_map );
- void disconnect_all_connections();
- void check_data_con_timeout();
-};
-
-#endif
-#endif