added new multi log system
[NeonServV5.git] / src / modules / global.mod / cmd_global_setaccess.c
index 8d1ffe20225da4e6ee8daccce6dd3b3d47ec88c1..8753cc30ac74442275e9b83c7a6daa4dfc057de0 100644 (file)
@@ -1,4 +1,4 @@
-/* cmd_global_setaccess.c - NeonServ v5.3
+/* cmd_global_setaccess.c - NeonServ v5.6
  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
@@ -39,13 +39,13 @@ CMD_BIND(global_cmd_setaccess) {
     MYSQL_ROW row;
     caccess = atoi(argv[1]);
     if(caccess < 0 || caccess > 1000) {
-        reply(getTextBot(), user, "NS_INVALID_ACCESS", caccess);
+        reply(textclient, user, "NS_INVALID_ACCESS", caccess);
         return;
     }
     printf_mysql_query("SELECT `user_access` FROM `users` WHERE `user_user` = '%s'", escape_string(user->auth));
     res = mysql_use();
     if ((row = mysql_fetch_row(res)) == NULL || atoi(row[0]) < caccess) {
-        reply(getTextBot(), user, "NS_ACCESS_OUTRANKED");
+        reply(textclient, user, "NS_ACCESS_OUTRANKED");
         return;
     }
     if(argv[0][0] == '*') {
@@ -54,17 +54,17 @@ CMD_BIND(global_cmd_setaccess) {
         printf_mysql_query("SELECT `user_user` FROM `users` WHERE `user_user` = '%s'", escape_string(argv[0]));
         res = mysql_use();
         if ((row = mysql_fetch_row(res)) != NULL) {
-            global_cmd_setaccess_async1(client, getTextBot(), user, event, argv[0], row[0], caccess);
+            global_cmd_setaccess_async1(client, textclient, user, event, argv[0], row[0], caccess);
         } else {
             //we need to create a new user...
             //but first lookup the auth to check if it really exists
             struct global_cmd_setaccess_cache *cache = malloc(sizeof(*cache));
             if (!cache) {
-                perror("malloc() failed");
+                printf_log("global", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__);
                 return;
             }
             cache->client = client;
-            cache->textclient = getTextBot();
+            cache->textclient = textclient;
             cache->user = user;
             cache->event = event;
             cache->access = caccess;
@@ -76,21 +76,21 @@ CMD_BIND(global_cmd_setaccess) {
         if(!cuser) {
             cuser = createTempUser(argv[0]);
                        if(!cuser) {
-                reply(getTextBot(), user, "NS_USER_UNKNOWN", argv[0]);
+                reply(textclient, user, "NS_USER_UNKNOWN", argv[0]);
                 return;
             }
             cuser->flags |= USERFLAG_ISTMPUSER;
         }
         if(cuser->flags & USERFLAG_ISAUTHED) {
-            global_cmd_setaccess_async1(client, getTextBot(), user, event, argv[0], cuser->auth, caccess);
+            global_cmd_setaccess_async1(client, textclient, user, event, argv[0], cuser->auth, caccess);
         } else {
             struct global_cmd_setaccess_cache *cache = malloc(sizeof(*cache));
             if (!cache) {
-                perror("malloc() failed");
+                printf_log("global", LOG_ERROR, "%s:%d malloc() failed", __FILE__, __LINE__);
                 return;
             }
             cache->client = client;
-            cache->textclient = getTextBot();
+            cache->textclient = textclient;
             cache->user = user;
             cache->event = event;
             cache->access = caccess;