fixed cmd_events & cmd_oplog parameter handling
authorpk910 <philipp@zoelle1.de>
Sat, 24 Sep 2011 01:00:56 +0000 (03:00 +0200)
committerpk910 <philipp@zoelle1.de>
Sat, 24 Sep 2011 14:42:31 +0000 (16:42 +0200)
cmd_neonserv_events.c
cmd_neonserv_oplog.c

index 30cc68ef46beaf7249c27820fc039f912b077c50..586fdac1c7213e8cdb2ed796f560b984ce59cdb2 100644 (file)
@@ -6,11 +6,12 @@
 
 static CMD_BIND(neonserv_cmd_events) {
     char *str_match;
-    int duration = (argc ? strToTime(user, argv[0]) : (60*60*24));
-    if(argc)
+    int duration = (argc ? strToTime(user, argv[0]) : 0);
+    if(argc > (duration ? 1 : 0))
         str_match = merge_argv(argv, (duration ? 1 : 0), argc);
     else
-        str_match = "*";
+        str_match = "";
+    if(!duration) duration = (60*60*24);
     MYSQL_RES *res;
     MYSQL_ROW row;
     printf_mysql_query("SELECT `time`, `auth`, `nick`, `command` FROM `events` WHERE `cid` = '%d' AND `time` > '%lu' ORDER BY `time` ASC", chan->channel_id, ((unsigned long) time(0) - duration));
@@ -27,7 +28,7 @@ static CMD_BIND(neonserv_cmd_events) {
             skip--;
             continue;
         }
-        if(match(str_match, row[3])) continue;
+        if(*str_match && match(str_match, row[3])) continue;
         count++;
         event_time = (time_t) atol(row[0]);
         timeinfo = localtime(&event_time);
index bf33f4f088a4dab6ac9630f74e464194f1712444..0bf8689962a2eb61c44fa35423417b31f12aa391 100644 (file)
@@ -6,11 +6,12 @@
 
 static CMD_BIND(neonserv_cmd_oplog) {
     char *str_match;
-    int duration = (argc ? strToTime(user, argv[0]) : (60*60*24));
-    if(argc)
+    int duration = (argc ? strToTime(user, argv[0]) : 0);
+    if(argc > (duration ? 1 : 0))
         str_match = merge_argv(argv, (duration ? 1 : 0), argc);
     else
-        str_match = "*";
+        str_match = "";
+    if(!duration) duration = (60*60*24);
     MYSQL_RES *res;
     MYSQL_ROW row;
     printf_mysql_query("SELECT `godlog_time`, `user_user`, `channel_name`, `godlog_cmd` FROM `godlog` LEFT JOIN `channels` ON `godlog_cid` = `channel_id` LEFT JOIN `users` ON `godlog_uid` = `user_id` WHERE `godlog_time` > '%lu' ORDER BY `godlog_time` ASC", ((unsigned long) time(0) - duration));
@@ -27,7 +28,7 @@ static CMD_BIND(neonserv_cmd_oplog) {
             skip--;
             continue;
         }
-        if(match(str_match, row[3])) continue;
+        if(*str_match && match(str_match, row[3])) continue;
         count++;
         event_time = (time_t) atol(row[0]);
         timeinfo = localtime(&event_time);