Beispiel #1
0
static int
m_cycle(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    char *p, *name;
    char *s = LOCAL_COPY(parv[1]);
    struct Channel *chptr;
    struct membership *msptr;

    name = rb_strtok_r(s, ",", &p);

    /* Finish the flood grace period... */
    if(MyClient(source_p) && !IsFloodDone(source_p))
        flood_endgrace(source_p);

    while(name) {
        if((chptr = find_channel(name)) == NULL) {
            sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
            return 0;
        }

        msptr = find_channel_membership(chptr, source_p);
        if(msptr == NULL) {
            sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name);
            return 0;
        }

        if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p))
            check_spambot_warning(source_p, NULL);

        if((is_any_op(msptr) || !MyConnect(source_p) ||
            ((can_send(chptr, source_p, msptr) > 0 &&
              (source_p->localClient->firsttime +
               ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time())))) {
            sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
                          ":%s PART %s :Cycling", use_id(source_p), chptr->chname);
            sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :Cycling",
                                 source_p->name, source_p->username,
                                 source_p->host, chptr->chname);
        } else {
            sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
                          ":%s PART %s", use_id(source_p), chptr->chname);
            sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s",
                                 source_p->name, source_p->username,
                                 source_p->host, chptr->chname);
        }

        remove_user_from_channel(msptr);

        chptr = NULL;
        msptr = NULL;

        name = rb_strtok_r(NULL, ",", &p);
    }

    user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL);

    return 0;
}
int cgiParser() {
	    //request call=status
	    if(!memscmp(query,"status") && uid > 0){
	        id=status();
		if(id < 0) { 
			return FALSE;
		} 

		len=snprintf(query,BLOCK-1,"<check><place>%d</place></check>",id);
		if ( id == 0 ) place_list();
	        cgiWrite(query,len); 

	    //request call=list
	    } else if(!memscmp(query,"getplace") && uid > 0){
		place_list();
	    //request call=getuser
	    } else if(!memscmp(query,"getuser") && uid > 0){
		get_user();
	    //request call=getmsg
	    } else if(!memscmp(query,"getmsg") && uid > 0){
		place_get_message();
	    //request call=fresh
	    } else if(!memscmp(query,"fresh") && uid > 0){
		get_user();
		if(uid>0) place_get_message();
	    //request call=addmsg
	    } else if(!memscmp(query,"addmsg") && !cgiFormString ("msg",query,150) && uid > 0){
		if(!memcmp(query,"/MSG ",5)) {
			place_add_private(query+5);
		} else {
			place_add_message(query);
		}
	    //request call=join
	    } else if(!memscmp(query,"join")  && !cgiFormString ("place",query,3) && uid > 0){
		id=atoi(query);
	        user_join(id);
                cgiWriteStr("<action>join</action>");
		cgiprintf("<place_id>%s</place_id>",query); 
	    //request call=logout
	    } else if(!memscmp(query,"logout") ){
		LOGOUT
		return FALSE;	
	    //request call=login
            } else if(!memscmp(query,"login")  && !cgiFormString ("login",REG_LOGIN,REG_LOGIN_SIZE)  && !cgiFormString ("password",REG_PASS,REG_PASS_SIZE)){
Beispiel #3
0
Datei: RT1.C Projekt: g8bpq/BPQ32
static void chkctl(CIRCUIT *ckt_from)
{
	NODE    *node, *ln;
	CIRCUIT *ckt_to;
	USER    *user, *su;
	char    *ncall, *ucall, *f1, *f2, *buf;

	if (ckt_from->buf[FORMAT_O] != FORMAT) return; // Not a control message.
	buf = strdup(ckt_from->buf + DATA_O);

// FORMAT and TYPE bytes are followed by node and user callsigns.

	ncall = buf;
	ucall = strlop(buf, ' ');
	if (!ucall) { free(buf); return; } // Not a control message.

// There may be at least one field after the node and user callsigns.
// Node leave (id_unlink) has no F1.

	f1 = strlop(ucall, ' ');

// If the frame came from an unknown node ignore it.
// If the frame came from us ignore it (loop breaking).

	node = node_find(ncall);
	if (!node || matchi(ncall, Node->calls)) { free(buf); return; }

	switch(ckt_from->buf[TYPE_O])
	{
// Data from user ucall at node ncall.

		case id_data :
			user = user_find(ucall);
			if (!user) break;
			text_tellu(user, f1, NULL, o_topic);

			for (ckt_to = circuit_hd; ckt_to; ckt_to = ckt_to->next)
				if ((ckt_to->flags & p_linked) &&
					   ckt_to->refcnt &&
					   !cn_find(ckt_to, node) &&
					   ct_find(ckt_to, user->topic)) nprintf(ckt_to->s, "%s\n", ckt_from->buf);
			break;

// User ucall at node ncall changed their Name/QTH info.

		case id_user :
			echo(ckt_from, node);  // Relay to other nodes.
			user = user_find(ucall);
			if (!user) break;
			f2 = strlop(f1, ' ');
			if (!f2) break;
			strnew(&user->name, f1);
			strnew(&user->qth,  f2);
			upduser(user);
			break;

// User ucall logged into node ncall.

		case id_join :
			echo(ckt_from, node);  // Relay to other nodes.
			f2 = strlop(f1, ' ');
			if (!f2) break;
			user = user_join(ckt_from, ucall, ncall, NULL);
			if (!user) break;
			ckt_from->refcnt++;
			text_tellu(user, rtjoin, NULL, o_all);
			strnew(&user->name, f1);
			strnew(&user->qth,  f2);
			upduser(user);
			break;

// User ucall logged out of node ncall.

		case id_leave :
			echo(ckt_from, node);  // Relay to other nodes.
			user = user_find(ucall);
			if (!user) break;
			f2 = strlop(f1, ' ');
			if (!f2) break;
			text_tellu(user, rtleave, NULL, o_all);
			ckt_from->refcnt--;
			cn_dec(ckt_from, node);
			strnew(&user->name, f1);
			strnew(&user->qth,  f2);
			upduser(user);
			user_leave(user);
			break;

// Node ncall lost its link to node ucall, alias f1.

		case id_unlink :
			echo(ckt_from, node);  // Relay to other nodes.
			ln = node_find(ucall);
			if (ln)	cn_dec(ckt_from, ln);
			break;

// Node ncall acquired a link to node ucall, alias f1.
// If we are not linked, is no problem, don't link.
// If we are linked, is a loop, do what?

		case id_link :
			echo(ckt_from, node);  // Relay to other nodes.
			ln = node_find(ucall);
			if (!ln && !matchi(ncall, Node->calls)) cn_inc(ckt_from, ucall, f1);
			break;

// User ucall at node ncall sent f2 to user f1.

		case id_send :
			user = user_find(ucall);
			if (!user) break;
			f2 = strlop(f1, ' ');
			if (!f2) break;
			su = user_find(f1);
			if (!su) break;

			if (su->circuit->flags & p_user)
				text_tellu(user, f2, f1, o_one);
			else
				echo(ckt_from, node);  // Relay to other nodes.
			break;

// User ucall at node ncall changed topic.

		case id_topic :
			echo(ckt_from, node);  //  Relay to other nodes.
			user = user_find(ucall);
			if (user) topic_chg(user, f1);
			break;

		default :  break;
	}

	free(buf);
}
Beispiel #4
0
Datei: RT1.C Projekt: g8bpq/BPQ32
int rtloginu ()
{
	CIRCUIT *c, *circuit;
	USER    *user;

// Is this user already logged in to RT somewhere else?

	if (user_find(CurProc->user))
	{
		tputs("*** Already connected at another node.\n");
		return cmd_exit;
	}

	if (log_rt) tlogp("RT Login");

// Create a circuit for this user.

	circuit = circuit_new(p_user, CurProc->output);
	if (!circuit) return cmd_exit;

// Create the user entry.

	user = user_join(circuit, CurProc->user, Node->calls, Node->aliass);
	circuit->u.user = user;
	tputs("RoundTable Server.\nType /h for command summary.\nBringing up links to other nodes.\n");
	tputs("This may take a minute or two.\nThe /p command shows what nodes are linked.\n");
	text_tellu(user, rtjoin, NULL, o_all);
	user_tell(user, id_join);
	show_users();
	makelinks();

// Run in circles, scream and shout.

	for (;;) if (getinp(circuit))
	{
		if (circuit->buf[0] is '/')
		{
			if (!rt_cmd(circuit))
			{
				tputs("Returned to node.\n");
				logout(circuit);
				return cmd_ok;
			}
		}
		else
		{
			text_tellu(user, circuit->buf, NULL, o_topic); // To local users.

// To remote users.

			for (c = circuit_hd; c; c = c->next)
			if ((c->flags & p_linked) && c->refcnt && ct_find(c, user->topic))
				nprintf(c->s, "%c%c%s %s %s\n",
				FORMAT, id_data, Node->calls, user->call, circuit->buf);
		}
	}
	else
	{
		logout(circuit);
		return cmd_exit;
	}
}