*** VERSION 5.5.0 ***
[NeonServV5.git] / src / main.c
index fa8aee1f8bb24135776721aba6394c41705627b5..2e0e5f3da2d8d5b34bda5b7d629f05efcdfa39de 100644 (file)
@@ -1,4 +1,4 @@
-/* main.c - NeonServ v5.4
+/* main.c - NeonServ v5.5
  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
@@ -40,6 +40,7 @@
 #include "version.h"
 #include "modules.h"
 #include "module_commands.h"
+#include "ModuleFunctions.h"
 
 time_t start_time;
 static int running, hard_restart;
@@ -216,6 +217,12 @@ int main(int argc, char *argv[]) {
         exit(0);
     }
     check_firstrun();
+    char **modulelist = get_all_fieldnames("modules");
+    if(!modulelist || !modulelist[0]) {
+        fprintf(stderr, "no modules loaded... Please update your configuration!\n");
+        exit(0);
+    }
+    free(modulelist);
     if (run_as_daemon) {
         #ifndef WIN32
         /* Attempt to fork into the background if daemon mode is on. */
@@ -289,6 +296,7 @@ main:
     register_module_commands();
     init_handleinfohandler();
     init_tools();
+    init_modulefunctions();
     loadModules();
     init_bots();
     init_DBHelper();
@@ -423,15 +431,24 @@ static AUTHLOOKUP_CALLBACK(main_checkauths_callback) {
     printf_mysql_query("SELECT `user_id`, `user_registered` FROM `users` WHERE `user_user` = '%s'", escape_string(auth));
     res = mysql_use();
     if ((row = mysql_fetch_row(res)) != NULL) {
-        if(!exists || (strcmp(row[1], "0") && registered != atoi(row[1]))) {
+        int diff = registered - atoi(row[1]);
+        if(diff < 0)
+            diff *= -1;
+        if(!exists || (strcmp(row[1], "0") && diff > 86400)) {
             //User is no longer valid! Delete it...
             deleteUser(atoi(row[0]));
             char *alertchan = get_string_field("General.CheckAuths.alertchan");
             if(alertchan) {
+                char reason[MAXLEN];
+                if(!exists) {
+                    strcpy(reason, "USER_NOT_EXISTS");
+                } else {
+                    sprintf(reason, "USER_REGISTERED_MISSMATCH: %lu, expected %d (diff: %d)", (unsigned long) registered, atoi(row[1]), diff);
+                }
                 struct ChanNode *alertchan_chan = getChanByName(alertchan);
                 struct ClientSocket *alertclient;
                 if(alertchan_chan && (alertclient = getChannelBot(alertchan_chan, 0)) != NULL) {
-                    putsock(alertclient, "PRIVMSG %s :Deleted User %s", alertchan_chan->name, auth);
+                    putsock(alertclient, "PRIVMSG %s :Deleted User %s (%s)", alertchan_chan->name, auth, reason);
                 }
             }
         } else if(exists && !strcmp(row[1], "0")) {