changed Makefile; build all commands as an own file
[NeonServV5.git] / cmd_neonserv_oplog.c
index 7b724839d02dd549f63c16560124ad5199063cc9..a69c449651d0271205536ebc2eccf9f28504ee93 100644 (file)
@@ -1,19 +1,22 @@
 
+#include "cmd_neonserv.h"
+
 /*
 * argv[0]     time
 * argv[1-*]   match
 */
 
-static CMD_BIND(neonserv_cmd_oplog) {
+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_channel`, `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));
+    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));
     res = mysql_use();
     int skip = mysql_num_rows(res) - 100;
     int count = 0;
@@ -27,7 +30,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);