コード例 #1
0
ファイル: client.c プロジェクト: Gaoyuan0710/MyFtp
void user_find(int conn_fd, char * local_path)
{

	char server_path[SIZE];
	char  filename[SIZE];
	char file_path[SIZE];
	char len[SIZE];
	struct dirent * ptr;
	struct stat buf;
	DIR  * dir;
	int fd;
	int zan;

	system("clear");
	stat (local_path, &buf);
	if (S_ISREG(buf.st_mode))
	{
		if ((fd = open(local_path, O_RDONLY)) == -1)
		{
			my_err("open", __LINE__);
		}
		send_data(conn_fd, "q\n");
		sprintf(len, "%ld", (long)buf.st_size);
		user_upload(conn_fd, fd, len);
		close(fd);

	}
	chdir(local_path);
	getcwd(file_path, sizeof(file_path));
	file_path[strlen(file_path)] = '/';
	file_path[strlen(file_path) + 1] = '\0';
	dir = opendir(file_path);
	printf("\n\n\t\t.\n\n\t\t..");
	while ((ptr = readdir(dir)) != NULL)
	{
		if (strcmp(ptr->d_name, ".") && strcmp(ptr->d_name, ".."))
		{
			printf("\n\n\t\t%s", ptr->d_name);
		}
	}
	printf("\n");
	printf("请选择要上传的文件\n..返回上层目录\n");
	scanf("%s", filename);
	if (strncmp(filename, "..", 2) == 0)
	{
		user_find(conn_fd, "..");
	}
	else
	{
		user_find(conn_fd, filename);
	}
}
コード例 #2
0
ファイル: asuka.c プロジェクト: wodim/irc-hispano
int denora_event_topic(char *source, int ac, char **av)
{
    User *u;
    Server *s;
    char *newav[5];

    if (denora->protocoldebug)
        protocol_debug(source, ac, av);

    if (ac < 4)
        return MOD_CONT;

    u = user_find(source);
    if (!u)
        s = server_find(source);

    newav[0] = av[0];

    if (u)
        newav[1] = u->nick;
    else if (s)
        newav[1] = s->name;
    else
        newav[1] = source;

    newav[2] = av[ac - 2];
    newav[3] = av[ac - 1];
    newav[4] = '\0';

    do_topic(4, newav);
    return MOD_CONT;
}
コード例 #3
0
ファイル: nefarious13.c プロジェクト: danopia/denora
int denora_event_spamfilter(char *source, int ac, char **av)
{
	User * u;
	char setby[BUFSIZE];
	char setat[10];

    if (denora->protocoldebug) {
        protocol_debug(source, ac, av);
    }

    u = user_find(av[0]);

    if (!stricmp(av[1], "+") && u) {
    	/* (char *target, char *action, char *setby, char *expires, char *setat,
            char *duration, char *reason, char *regex) */
    	ircsnprintf(setby, BUFSIZE, "%s!%s@%s", u->nick, u->username, u->vhost ? u->vhost : u->host);
    	ircsnprintf(setat, 10, "%ld", (long int) time(NULL));
        sql_do_server_spam_add(av[2], av[3], setby, "0", setat, av[4], av[ac-2], av[ac-1]);
    } else if (!stricmp(av[1], "-")) {
    	/* (char *target, char *action, char *regex) */
        sql_do_server_spam_remove(av[2], av[3], av[ac-1]);
    }

    return MOD_CONT;
}
コード例 #4
0
ファイル: command.c プロジェクト: qcho/SO2C2011TP2
int chown_cmd(int argc, char **argv) {
    if (argc == 2) {
        TTY* tty = tty_getCurrentTTY();
        u32int currentiNode = tty->currDirectory;
        fs_node_t current;
        fs_getFsNode(&current, currentiNode);
        fs_node_t* file = finddir_fs(&current, argv[1]);
        if (file == NULL) {
            printf("chown: No such file or directory %s.\n", argv[1]);
            kfree(file);
            return -1;
        }
        if (!permission_file_isOwner(file)) {
            printf("chown: You are not the owner of %s.\n", argv[1]);
            kfree(file);
            return -2;
        }
        errno = OK;
        int uid = user_find(argv[0]);
        if (uid == NO_USER) {
            printf("chown: User %s does not exist.\n", argv[0]);
            kfree(file);
            return -2;
        } else {
            fs_setFileUid(file->inode, uid);
            if (errno != OK) {
                printf ("ERROR %d", errno);
            }
        }
        kfree(file);
    } else {
        printf("Usage: chmod OCTALMODE FILE");
    }
    return 0;
}
コード例 #5
0
ファイル: db.c プロジェクト: wodim/irc-hispano
/* nick should be db_escape'd before call */
int db_getnick(char *nick)
{
    User *u;
    int res = 0;
#ifdef USE_MYSQL
    MYSQL_RES *mysql_res;
#endif

    u = user_find(nick);
    if (u && u->sqlid) {
        return u->sqlid;
    }

    if (!denora->do_sql) {
        return 0;
    }
    SET_SEGV_LOCATION();

    rdb_query(QUERY_HIGH, "SELECT nickid FROM %s WHERE nick=\'%s\'",
              UserTable, nick);
#ifdef USE_MYSQL
    mysql_res = mysql_store_result(mysql);
    if (mysql_res) {
        if (mysql_num_rows(mysql_res)) {
            mysql_row = mysql_fetch_row(mysql_res);
            res = strtol(mysql_row[0], NULL, 10);
        } else {
            alog(LOG_NONEXISTANT, "nickname not found ! %s", nick);
        }
        mysql_free_result(mysql_res);
    }
#endif
    return res;
}
コード例 #6
0
ファイル: MainDlg.cpp プロジェクト: huairen/JMsg
void MainDlg::OnRecvMsg()
{
	char buff[1024] = {0};
	uint32_t user_id;
	struct msg_packet msg;

	while(1)
	{
		msg_recv(&msg);
		user_id = process_msg(&msg);

		switch (GET_MODE(msg.command))
		{
		case IPMSG_SENDMSG:
			break;

		case IPMSG_ANSENTRY:
		case IPMSG_BR_ENTRY:
			OnFriendOnline(user_find(user_id));
			break;

		case IPMSG_BR_EXIT:
			break;
		}
	}
}
コード例 #7
0
ファイル: usr.c プロジェクト: michaelfoster/yak
struct user *user_get(char *prefix)
{
	struct user *user;

	user = user_find(prefix);
	return user ? user : user_new(prefix);
}
コード例 #8
0
ファイル: messages.c プロジェクト: danopia/denora
/**
 * Handle AWAY messages
 *
 * @param source is the nick of the person whom is now away
 * @param msg is the text of the away message
 *
 * @return always returns MOD_CONT
 */
int m_away(char *source, char *msg)
{
    User *u;

    if (!source) {
        return MOD_CONT;
    }
    u = user_find(source);
    if (!u) {
        return MOD_CONT;
    }

    SET_SEGV_LOCATION();

    if (msg) {
        stats->away++;
        u->isaway = 1;
        u->awaymsg = sstrdup(msg);
    } else {
        stats->away--;
        u->isaway = 0;
        u->awaymsg = NULL;
    }
    if (denora->do_sql) {
        rdb_query
            (QUERY_LOW,
             "UPDATE %s SET away=\'%s\', awaymsg=\'%s\' WHERE nickid=%d",
             UserTable, (u->isaway ? (char *) "Y" : (char *) "N"),
             rdb_escape(u->awaymsg), db_getnick(u->sqlnick));
    }
    return MOD_CONT;
}
コード例 #9
0
ファイル: whois.c プロジェクト: cmouse/hbs
void user_command_whois (CONSOLE * console, const char *cmd,
			 const char **args, int argc)
{
  size_t i;
  USER *victim;
  if (argc < 1)
    {
      console_write (console, "Usage: %s user\r\n", cmd);
      return;
    }
  if (!(victim = user_find (args[0])))
    {
      console_write (console, "No such user %s\r\n", args[0]);
      return;
    }
  // Oki
  console_write (console, "%-15s %s %s\r\n", victim->user,
		 (*victim->pass ? "(has password)" : "(has no password)"),
		 (victim->admin ? "(is admin)" : "(is not admin)"));
  console_write (console, " %-20s %s\r\n", "Channel", "Role");
  for (i = 0; i < victim->nchannels; i++)
    console_write (console, "  %-20s %s\r\n",
		   victim->channels[i].channel->channel,
		   user_mode_to_level (victim->channels[i].modes));
  console_write (console, "End of record\r\n");
}
コード例 #10
0
ファイル: session.c プロジェクト: ocelot-inc/tarantool
/** Session user id. */
static int
lbox_session_su(struct lua_State *L)
{
	int top = lua_gettop(L);
	if (top < 1)
		luaL_error(L, "session.su(): bad arguments");
	struct session *session = current_session();
	if (session == NULL)
		luaL_error(L, "session.su(): session does not exist");
	struct user *user;
	if (lua_type(L, 1) == LUA_TSTRING) {
		size_t len;
		const char *name = lua_tolstring(L, 1, &len);
		user = user_find_by_name(name, len);
	} else {
		user = user_find(lua_tointeger(L, 1));
	}
	if (user == NULL)
		lbox_error(L);
	struct credentials orig_cr;
	credentials_copy(&orig_cr, &session->credentials);
	credentials_init(&session->credentials, user);
	if (top == 1)
		return 0; /* su */

	/* sudo */
	int error = lua_pcall(L, top - 2, LUA_MULTRET, 0);
	credentials_copy(&session->credentials, &orig_cr);
	if (error)
		lbox_error(L);
	return lua_gettop(L) - 1;
}
コード例 #11
0
ファイル: plexus.c プロジェクト: danopia/atheme
static void m_uid(sourceinfo_t *si, int parc, char *parv[])
{
	server_t *s;
	user_t *u;

	/* got the right number of args for an introduction? */
	if (parc == 11)
	{
		s = si->s;
		slog(LG_DEBUG, "m_uid(): new user on `%s': %s", s->name, parv[0]);

		u = user_add(parv[0], parv[4], parv[5], parv[9], parv[6], parv[7], parv[10], s, atoi(parv[2]));
		if (u == NULL)
			return;

		user_mode(u, parv[3]);

		/* If server is not yet EOB we will do this later.
		 * This avoids useless "please identify" -- jilles
		 */
		if (s->flags & SF_EOB)
			handle_nickchange(user_find(parv[0]));
	}
	else
	{
		int i;
		slog(LG_DEBUG, "m_uid(): got UID with wrong number of params");

		for (i = 0; i < parc; i++)
			slog(LG_DEBUG, "m_uid():   parv[%d] = %s", i, parv[i]);
	}
}
コード例 #12
0
ファイル: user.c プロジェクト: angelachan64/final
// TODO make directories
user *user_create(char *name, char *passwd) {  
  user *u;

  // Return if user already exists
  if ( (u = user_find(name)) ) {
    // Don't free u->name
    free(u->passwd);
    free(u);
    
    errno = EEXIST;
    return NULL;
  }

  // Add user to flat file
  char *ufname = server_dir("users.csv");
  FILE *uf = fopen(ufname, "r");
  fseek(uf, 0, SEEK_END);
  int status = fprintf(uf, "%s,%s\n", name, passwd);

  // Clean up
  fclose(uf);
  free(ufname);

  // Check if fprintf worked
  if (status > 0) {
    u = malloc(sizeof(user));
    u->name = name;
    u->passwd = passwd;
    return u;
  }
  else {
    return NULL;
  }
}
コード例 #13
0
ファイル: plexus3.c プロジェクト: denora/protocol-legacy
/* :42XAAAAAB TOPIC #testchan :test test test */
int denora_event_topic(char *source, int ac, char **av)
{
	char *newav[5];
	User *u;

	if (denora->protocoldebug)
	{
		protocol_debug(source, ac, av);
	}
	if (ac == 2)
	{
		u = user_find(source);
		if (u)
		{
			newav[0] = sstrdup(av[0]);
			newav[1] = sstrdup(u->nick);
			newav[2] = itostr(time(NULL));
			newav[3] = sstrdup(av[1]);
			do_topic(4, newav);
			free(newav[0]);
			free(newav[1]);
			free(newav[3]);
		}

	}
	else
	{
		do_topic(ac, av);
	}
	return MOD_CONT;
}
コード例 #14
0
int do_newnick(int ac, char **av)
{
	User *u;

	SET_SEGV_LOCATION();

	if (!ConnectServConnected) {
		return 1;
    }

	u = user_find(av[0]);
	
	
	if (!u) {
		return MOD_CONT;
    }

	if (!stricmp(u->nick, s_ConnectServ)) {
		return MOD_CONT;
	}

	/* Print Connection Notice */
	if (SignOnMessage) {
        if (!UseColorfulMessages) {
            alog(LOG_NORMAL, "\2SIGNON\2 %s (%s@%s - %s) has signed on at %s", u->nick, u->username, u->host, u->realname, u->server->name);
        } else {
            alog(LOG_NORMAL, "\2\0034SIGNED ON\2 user: \2%s\2 (%s@%s - %s) at: \2%s\2\003", u->nick, u->username, u->host, u->realname, u->server->name);
        }   
	}
	return MOD_CONT;
}
コード例 #15
0
/* 
 * Echo nick changes
 */
int cs_user_nick(int ac, char **av)
{
	User *u;

	SET_SEGV_LOCATION();

	if (!ConnectServConnected) {
		return MOD_CONT;
    }

	u = user_find(av[1]);
	if (!u) {
		return MOD_CONT;
    }

	if (!stricmp(u->nick, s_ConnectServ)) {
		return MOD_CONT;
	}
	if (NickChangeMessage) {
        if (!UseColorfulMessages) {
            alog(LOG_NORMAL, "\2NICK\2 %s (%s@%s) changed their nick to %s", av[0], u->username, u->host, av[1]);
        } else {
            alog(LOG_NORMAL, "\2\0037Nick Change\2 user: \2%s\2 (%s@%s) Changed their nick to \2%s\2\003", av[0], u->username, u->host, av[1]);
        }   
	}
	return 1;
}
コード例 #16
0
ファイル: usr.c プロジェクト: michaelfoster/yak
struct user *user_get2(char *prefix, bool *existed)
{
	struct user *user;

	user = user_find(prefix);
	*existed = user != NULL;
	return user ? user : user_new(prefix);
}
コード例 #17
0
ファイル: test.c プロジェクト: Gaoyuan0710/MyFtp
void user_find(int conn_fd, char * local_path)
{

	char server_path[SIZE];
	char  filename[SIZE];
	char file_path[SIZE];
	struct dirent * ptr;
	struct stat buf;
	DIR  * dir;
	int fd;

	stat (local_path, &buf);
	if (S_ISREG(buf.st_mode))
	{
		printf("进入上传页面\n");
		while (1)
		  ;
	}
	chdir(local_path);
	getcwd(file_path, sizeof(file_path));
	file_path[strlen(file_path)] = '/';
	file_path[strlen(file_path) + 1] = '\0';
	dir = opendir(file_path);
	printf("\n\n\t\t.\n\n\t\t.");
		while ((ptr = readdir(dir)) != NULL)
		{
			if (strcmp(ptr->d_name, ".") && strcmp(ptr->d_name, ".."))
			{
				printf("\n\n\t\t%s", ptr->d_name);
			}
		}
		printf("\n");
		printf("请选择要上传的文件\n..返回上层目录\n");
		scanf("%s", filename);
		if (strncmp(filename, "..", 2) == 0)
		{
			user_find(conn_fd, "..");
		}
		else
		{
			user_find(conn_fd, filename);
		}

}
コード例 #18
0
ファイル: test.c プロジェクト: Gaoyuan0710/MyFtp
int main ()
{
	char file_path[SIZE];

	chdir("/home/");
	getcwd(file_path, sizeof(file_path));

user_find(1, file_path);

}
コード例 #19
0
ファイル: scarynet.c プロジェクト: danopia/denora
int denora_event_notice(char *source, int ac, char **av)
{
    User *user_s = NULL;
    User *user_r = NULL;

    if (denora->protocoldebug)
        protocol_debug(source, ac, av);

    if (ac != 2 || *av[0] == '$' || strlen(source) == 2)
        return MOD_CONT;

    user_s = user_find(source);
    if (*av[0] == '#' && user_s) {
        m_notice(user_s->nick, av[0], av[1]);
    } else if (user_s) {
        user_r = user_find(av[0]);
        if (user_r) {
            m_notice(user_s->nick, user_r->nick, av[1]);
        }
    }
    return MOD_CONT;
}
コード例 #20
0
ファイル: nefarious.c プロジェクト: danopia/denora
int denora_event_fakehost(char *source, int ac, char **av)
{
    User *ud;
    char *parv[2];

    ud = user_find(av[0]);

    if (ud) {
        parv[0] = (char *) ud->nick;
        parv[1] = (char *) "+f";
        do_umode(ud->nick, 2, parv);
    }

    change_user_host(ud->nick, av[1]);
    return MOD_CONT;
}
コード例 #21
0
ファイル: nefarious.c プロジェクト: danopia/denora
int denora_event_mark(char *source, int ac, char **av)
{
    User *u;

    if (denora->protocoldebug) {
        protocol_debug(source, ac, av);
    }

    u = user_find(av[0]);
    if (!u)
        return 1;

    if (!strcmp(av[1], "CVERSION") && strlen(av[2])) {
        handle_ctcp_version(u->nick, av[2]);
    }

    return MOD_CONT;
}
コード例 #22
0
ファイル: messages.c プロジェクト: danopia/denora
/**
 * Handle PRIVMSG commands
 *
 * @param source is the nick of the person whom sent the privmsg
 * @param receiver is the nick whom it was sent to
 * @param msg is the message that was sent
 *
 * @return always returns MOD_CONT
 */
int m_privmsg(char *source, char *receiver, char *msg)
{
    char *s;
    User *u;
    PrivMsg *p;

    if (BadPtr(source) || BadPtr(receiver) || BadPtr(msg)) {
        return MOD_CONT;
    }

    u = user_find(source);

    if (!u) {
        alog(LOG_NONEXISTANT, "%s: user record for %s not found", msg,
             source);
        denora_cmd_notice(receiver, source,
                          getstring(NULL, USER_RECORD_NOT_FOUND));
        return MOD_CONT;
    }

    if (*receiver == '#') {
        if (denora->do_sql && !LargeNet) {
            if (stricmp(u->nick, s_StatServ)
                || stricmp(u->nick, s_StatServ_alias)) {
                do_cstats(u, receiver, msg);
            }
        }
    } else {
        /* If a server is specified (nick@server format), make sure it matches
         * us, and strip it off. */
        s = strchr(receiver, '@');
        if (s) {
            *s++ = 0;
            if (stricmp(s, ServerName) != 0)
                return MOD_CONT;
        }
        p = findPrivMsg(receiver);
        if (p) {
            p->handler(u, msg);
            SET_SEGV_LOCATION();
        }
    }
    return MOD_CONT;
}
コード例 #23
0
ファイル: scarynet.c プロジェクト: danopia/denora
/* ABAAA M #ircops +v ABAAB */
int denora_event_mode(char *source, int ac, char **av)
{
    User *u;
    User *v;
    Server *s;
    char *sender;
    char hhostbuf[255];

    if (denora->protocoldebug)
        protocol_debug(source, ac, av);

    if (ac < 2)
        return MOD_CONT;

    u = find_byuid(source);

    if (!u) {
        sender = source;
    } else {
        sender = u->nick;
    }

    if (*av[0] == '#' || *av[0] == '&') {
        do_cmode(source, ac, av);
    } else {
        s = server_find(source);
        if (s)
            sender = av[0];
        do_umode(sender, ac, av);
        if (strcmp(av[1], "x") != -1) {
            v = user_find(av[0]);
            if (v->account) {
                ircsnprintf(hhostbuf,
                            sizeof(v->account) + sizeof(hhostbuf) + 2,
                            "%s%s%s", HiddenPrefix, v->account,
                            HiddenSuffix);
                change_user_host(v->nick, hhostbuf);
            }
        }
    }
    return MOD_CONT;
}
コード例 #24
0
ファイル: client.c プロジェクト: Gaoyuan0710/MyFtp
void user_choose(int conn_fd)
{
	int flag;
	char path[SIZE];
	char filename[SIZE];
	char tmp[SIZE];

	sleep(1);
	system("clear");

	printf("\n\n\t\t1.浏览资源\n");
	printf("\t\t2.上传资源\n");
	printf("\t\t3.查找资源\n");

	scanf("%d", &flag);

	switch(flag)
	{
		case 1:
			user_browse(conn_fd);
			break;
		case 2:
			chdir("/home/");
			getcwd(path, sizeof(path));
			user_find(conn_fd, path);
			break;
		case 3:
			send_data(conn_fd, "d\n");
			printf("请输入文件名称:");
			memset(filename, '\0', sizeof(filename));
			scanf("%s", filename);
			dir_recur(conn_fd, filename);
			getchar();
			getch();
			user_choose(conn_fd);

	}
}
コード例 #25
0
int cs_global_kill(int ac, char **av)
{
	User *u;

	SET_SEGV_LOCATION();

	if (!ConnectServConnected)
		return 1;

	u = user_find(av[1]);
	if (!u) /* User not found */
		return 1;

	if (!stricmp(u->nick, s_ConnectServ)) {
		return MOD_CONT;
	}
    if (UseColorfulMessages) {
            alog(LOG_DEBUG,  "\2\00312GLOBAL KILL\2 user: \2%s\2 (%s@%s) was Killed by \2%s\2 - Reason sighted: \2%s\2\003", u->nick, u->username, u->host, av[0], av[2]);
    } else {
            alog(LOG_DEBUG, "\2GLOBAL KILL\2 %s (%s@%s) was killed by %s - Reason sighted: \2%s\2", u->nick, u->username, u->host, av[0], av[2]);
    }   
	return MOD_CONT;
}
コード例 #26
0
int cs_server_kill(int ac, char **av)
{
	User *u;

	SET_SEGV_LOCATION();

	if (!ConnectServConnected)
		return 1;

	u = user_find(av[1]);
	if (!u) /* User not found */
		return 1;

	if (!stricmp(u->nick, s_ConnectServ)) {
		return MOD_CONT;
	}
    if (UseColorfulMessages) {
            alog(LOG_NORMAL, "\2SERVER KILL\2 user: \2%s\2 (%s@%s) was Killed by the Server \2%s\2 - Reason sighted: \2%s\2", u->nick, u->username, u->host, av[0], av[2]);
    } else {
            alog(LOG_NORMAL, "\2SERVER KILL\2 %s (%s@%s) was killed by the server %s - Reason sighted: \2%s\2", u->nick, u->username, u->host, av[0], av[2]);
    }   
	return 1;
}
コード例 #27
0
ファイル: nefarious.c プロジェクト: danopia/denora
int denora_event_account(char *source, int ac, char **av)
{
    Server *s;
    User *u;

    if ((ac < 2) || !source || !(s = server_find(source)))
        return 0;               /* source must be server. */

    u = user_find(av[0]);
    if (!u)
        return 1;               /* A QUIT probably passed the ACCOUNT. */

    if (!strcmp(av[1], "R"))    /* Set */
        do_p10account(u, av[2], 0);
    else if (!strcmp(av[1], "M"))       /* Rename */
        do_p10account(u, av[2], 2);
    else if (!strcmp(av[1], "U"))       /* Remove */
        do_p10account(u, NULL, 1);
    else
        do_p10account(u, av[1], 0);     /* For backward compatability */

    return MOD_CONT;
}
コード例 #28
0
ファイル: messages.c プロジェクト: danopia/denora
/**
 * Handle KILL messages
 *
 * @param source is the server or nick that send the message
 * @param nick is the user name that was killed
 * @param msg is the text of the kill message
 *
 * @return void - no returend value
 */
void m_kill(char *source, char *nick, char *msg)
{
    User *u;
    ServStats *s;
    int id;

    if ((u = user_find(source))) {
        if ((s = findserverstats(u->server->name))) {
            s->ircopskills++;
        }
        send_event(EVENT_GLOBAL_KILL, 3, source, nick, msg);
    } else if ((s = findserverstats(source))) {
        s->serverkills++;
        send_event(EVENT_SERVER_KILL, 3, source, nick, msg);
    }
    do_kill(nick, msg);
    if (denora->do_sql) {
        nick = rdb_escape(nick);
        db_removenick(nick, msg);
        if (UserCacheTime) {
            db_cleanuser();
        }
        free(nick);
    }
    if (s && denora->do_sql) {
        id = db_getserver(s->name);
        if (id) {
            rdb_query
                (QUERY_LOW,
                 "UPDATE %s SET ircopskills=%d, serverkills=%ld WHERE servid=%d",
                 ServerTable, s->ircopskills, s->serverkills, id);
        }
    }
    if (nickIsServices(nick)) {
        introduce_user(nick);
    }
}
コード例 #29
0
int cs_user_logoff(int ac, char **av)
{
	User *u;

	SET_SEGV_LOCATION();

	if (!ConnectServConnected) {
        return MOD_CONT;
    }

    if (ac <= 1) {
        return MOD_CONT;
    }

	u = user_find(av[0]);
	if (!u) {
		return MOD_CONT;
    }

	if (!stricmp(u->nick, s_ConnectServ)) {
		return MOD_CONT;
	}

	if (SignOffMessage) {
        if (UseColorfulMessages) {
  		  alog(LOG_NORMAL,"\2\0033Signed Off\2 user: %s (%s@%s - %s) at: %s - %s\003",
			  u->nick, u->username, u->host, u->realname,
			  u->server->name, av[1]);
        } else {
  		  alog(LOG_NORMAL,"\2SIGNOFF\2 %s (%s@%s - %s) has signed off at %s - %s",
			  u->nick, u->username, u->host, u->realname,
			  u->server->name, av[1]);
        }
	}
	return MOD_CONT;
}
コード例 #30
0
ファイル: db.c プロジェクト: wodim/irc-hispano
/* nick should be db_escape'd before call */
int db_getnick_unsure(char *nick)
{
    User *u;
    int res = 0;
#ifdef USE_MYSQL
    MYSQL_RES *mysql_res;
#endif

    SET_SEGV_LOCATION();

    u = user_find(nick);
    if (u && u->sqlid) {
        return u->sqlid;
    }

    if (!denora->do_sql) {
        return -1;
    }

    rdb_query(QUERY_HIGH, "SELECT nickid FROM %s WHERE nick=\'%s\'",
              UserTable, nick);
#ifdef USE_MYSQL
    mysql_res = mysql_store_result(mysql);
    if (mysql_res) {
        if (mysql_num_rows(mysql_res)) {
            mysql_row = mysql_fetch_row(mysql_res);
            res = strtol(mysql_row[0], NULL, 10);
        } else {
            res = -1;
        }
        SET_SEGV_LOCATION();
        mysql_free_result(mysql_res);
    }
#endif
    return res;
}