DatabaseStuff.h 981 B

123456789101112131415161718192021222324
  1. #ifndef __DATABASE_STUFF_H
  2. #define __DATABASE_STUFF_H
  3. #include "mysqli.h"
  4. #include "mysqli_bind.h"
  5. //#include "Node.h"
  6. #include "Tree.h"
  7. #include "IPAddress.h"
  8. class DatabaseStuff
  9. {
  10. public:
  11. static void GetIPsToBan(Tree<IPAddress> &tree,const char *server); // Get the list of IPs to ban from the database.
  12. static void GetLastBannedTime(const char *server,char *output,unsigned long maxLength); // Returns the last time an IP was banned.
  13. private:
  14. static void OpenDatabase(mysqli &db,const char *server); // Opens a database connection.
  15. static void rot13(const char *original,char *output); // A simple cipher that's good enough to beat someone with a hex editor.
  16. static void PrepareGetNewBannedQuery(mysqli &db,mysqli_stmt &stmt); // Prepares the query to get new banned IPs.
  17. static void PrepareGetLastBannedTimeQuery(mysqli &db,mysqli_stmt &stmt); // prepares the query to get the last time something was banned.
  18. static bool IsServerAUrl(const char *server);
  19. };
  20. #endif