Anope MySQL Support
-------------------

IMPLEMENTATION STEPS:

PHASE 1:Anope will be able to save all it's databases
        to MySQL. It will happen in conjuction with
        the current FFF databases. This first step is 
        nothing more than a MySQL dump of the databases 
        (i.e. read-only), since Anope will not (for now) 
        read from Mysql. (COMPLETED)

PHASE 2:The next step is load the databases from mysql, 
        being able to replace the FFF completely as an 
        archive method (since all changes to the mysql 
        db would be lost on the next Services save). All,
        while keeping FFF intact. This is still not the 
        final goal, but it's a milestone.

PHASE 3:The next step, and most convoluted of all (since 
        we'll need to modify pretty much all the source) is 
        to load/save (SELECT/INSERT) data in realtime. That 
        way the mysql db could be modified externaly (web?).
        Again, the FFF will be kept intact.

REQUIREMENTS

1. MySQL server version 3.23.32 or greater
2. A MySQL user account
3. A MySQL database

ALPHA INSTALLATION

1. Create a mysql user and database (you can use mkanope.sql) (not done yet)
2. Edit services.conf add changes noted in Changes.conf
3. Change the above values to your mysql user and database
4. Run ./configure and choose the MySQL option
5. make ; make install
6. Create the tables with tables.sql

SECURITY

   To add a layer of security you have the option of encrypting or encoding
   all passwords for nicks and chans. Use the "MysqlSecure" directive on your
   services.conf file to enable it. The availabe storage methos are:

   #MysqlSecure "" or MysqlSecure ""

      Disables security. All passwords will be saved on the MySQL database
      as clear text, with no encryption or encoding. FASTEST

   MysqlSecure "des"

      Encrypts all passwords using a unix DES encription. This is a one way
      encryption algorithm. You can only validate it agains another DES
      encrypted string, using the same "salt" (the first two characters of
      the encrypted string). FAST

   MysqlSecure "md5"

      Calculates an MD5 128-bit checksum for the password. The value is 
      returned as a 32-digit hex number that may be used as a hash key.
      SLOW

   MysqlSecure "sha"

      Calculates an SHA 160-bit checksum for the password. The value is 
      returned as a 40-digit hex number. SLOWEST

   MysqlSecure "mykey"

      Encodes the passwords using "mykey" as the encryption password. It
      produces a binary string and can be decoded using the MySQL builtit
      function DECODE(crypt_str,mykey). VARIABLE

   Caveat: Keep in mind that this if you use any method other than clear
   text, services will need to encrypt/encode every single password on
   every database save. On large networks, it may impact responsiveness
   during the saves.

NOTES (things to fix)

* We need a more robust sql_query function. (DONE)
* ./configure does not look for, or check for MySQL libs. (DONE)
* ./configure uses hardcoded lib paths for MySQL. (DONE)
* mysql4 is #include <mysql.h> need a cpp clause. (DONE)

NOTES IN SPANISH (also need fixing)
1. en ./configure script. Supuestamente deberia tratar de decetectar donde estan las libs de mysql.  Ahora esta' hardcoded a /usr/lib/mysql.o (algo asi). Eso necesita ser dinamico, como los autoconf. (DONE)
2. en todo el mysql.c uso arrays fijos, onda char *query[2048], lo cual puede producir un overflow si es que se pasa de eso (DONE)
3. la funcion db_mysql_query() debe ser mas inteligente. Detecar timeouts, y hacer retries. Y deberia tener una forma mejor de salirse de errores (DONE)
4. las tablas. Necesitan ser optimizadas. Usar ENUM donde corresponda, y ver bien los lenghts de los fields. Quizas hacer un index, no se.
5. ver todas las funciones del save (dump) y confirmar que son consistentes, o sea, que hacemos la misma cosa para todos. (DONE)
6. poner un layer entre services y mysql, onda rdb.c que en vez de llamar db_mysql_save_ns_core, por ejemplo llame db_save_ns_core y que de ahi llame a la funcion especifica de mysql (para futuramente poder implementar msql, pgsql, etc) (DONE)
7. poner las directivas en el services.conf onda UseMysql, MysqlDump, MysqlRead, MysqlRealtime (DONE)

