- putsock(client, "PRIVMSG %s :[BOT JOIN] Users on this Channel:", chan->name);
- for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
- putsock(client, "PRIVMSG %s : %s!%s@%s [%s] rights: %d", chan->name, chanuser->user->nick, chanuser->user->ident, chanuser->user->host, ((chanuser->user->flags & USERFLAG_ISAUTHED) ? chanuser->user->auth : "*"), chanuser->flags);
+ printf_mysql_query("SELECT `chanuser_access`, `user_user`, `chanuser_seen`, `chanuser_flags` FROM `chanusers` LEFT JOIN `users` ON `chanuser_uid` = `user_id` WHERE `chanuser_cid` = '%d' ORDER BY `chanuser_access` DESC, `user_user` ASC", chan->channel_id);
+ res = mysql_use();
+ table = table_init(4, mysql_num_rows(res) + 1, 0);
+ if(usermask)
+ reply(textclient, user, "NS_USERS_HEADER_MATCH", chan->name, min_access, max_access, usermask);
+ else
+ reply(textclient, user, "NS_USERS_HEADER", chan->name, min_access, max_access);
+ char *content[4];
+ content[0] = get_language_string(user, "NS_USERS_HEADER_ACCESS");
+ content[1] = get_language_string(user, "NS_USERS_HEADER_ACCOUNT");
+ content[2] = get_language_string(user, "NS_USERS_HEADER_SEEN");
+ content[3] = get_language_string(user, "NS_USERS_HEADER_STATE");
+ table_add(table, content);
+ while ((row = mysql_fetch_row(res)) != NULL) {
+ caccess = atoi(row[0]);
+ if((!usermask || !match(usermask, row[1])) && caccess >= min_access && caccess <= max_access) {
+ content[0] = row[0];
+ content[1] = row[1];
+ is_here = 0;
+ for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
+ if((chanuser->user->flags & USERFLAG_ISAUTHED) && !strcmp(chanuser->user->auth, row[1])) {
+ if((chanuser->flags & CHANUSERFLAG_INVISIBLE))
+ is_here = 2;
+ else {
+ is_here = 1;
+ break;
+ }
+ }
+ }
+ if(is_here) {
+ content[2] = get_language_string(user, (is_here == 2 ? "NS_USERS_SEEN_INVISIBLE" : "NS_USERS_SEEN_HERE"));
+ } else if(!strcmp(row[2], "0")) {
+ content[2] = get_language_string(user, "NS_USERS_SEEN_NEVER");
+ } else {
+ timeToStr(user, (time(0) - atoi(row[2])), 2, seenstr);
+ content[2] = seenstr; //generate time
+ }
+ cflags = atoi(row[3]);
+ if(cflags & DB_CHANUSER_SUSPENDED)
+ content[3] = get_language_string(user, "NS_USERS_STATE_SUSPENDED");
+ else
+ content[3] = get_language_string(user, "NS_USERS_STATE_NORMAL");
+ content_count++;
+ table_add(table, content);
+ }
+ }
+ //send the table
+ char **table_lines = table_end(table);
+ for(i = 0; i < table->entrys; i++) {
+ reply(textclient, user, table_lines[i]);