{"NS_USER_UNKNOWN", "User with nick \002%s\002 does not exist."},
{"NS_AUTH_UNKNOWN", "Account \002%s\002 has not been registered."},
{"NS_USER_NEED_AUTH", "%s must first authenticate with \002AuthServ\002."},
+ {"NS_INVALID_ACCESS", "\002%d\002 is an invalid access level."},
{NULL, NULL}
};
check_mysql();
//check acccess
caccess = atoi(argv[1]);
+ if(caccess <= 0 || caccess > 500) {
+ reply(getTextBot(), user, "NS_INVALID_ACCESS", caccess);
+ return;
+ }
+ //check own access
if(argv[0][0] == '*') {
//we've got an auth
argv[0]++;
static void neonserv_cmd_adduser_async1(struct ClientSocket *client, struct ClientSocket *textclient, struct UserNode *user, struct ChanNode *chan, char *nick, char *auth, int caccess) {
//we've got a valid auth now...
- putsock(client, "PRIVMSG %s :%s: %s %d", chan->name, nick, auth, caccess);
+ int userid;
+ printf_mysql_query("SELECT `user_id` FROM `users` WHERE `user_user` = '%s'", escape_string(auth));
+ res = mysql_use();
+ if ((row = mysql_fetch_row(res)) != NULL) {
+ userid = atoi(res[0]);
+ } else {
+ printf_mysql_query("INSERT INTO `users` (`user_user`) VALUES ('%s')", escape_string(auth));
+ userid = (int) mysql_insert_id(mysql_conn);
+ }
+ putsock(client, "PRIVMSG %s :%s: [%d] %s %d", chan->name, nick, userid, auth, caccess);
}