コード例 #1
0
bool XLineManager::AddLine(XLine* line, User* user)
{
	ServerInstance->BanCache->RemoveEntries(line->type, false); // XXX perhaps remove ELines here?

	if (line->duration && ServerInstance->Time() > line->expiry)
		return false; // Don't apply expired XLines.

	/* Don't apply duplicate xlines */
	ContainerIter x = lookup_lines.find(line->type);
	if (x != lookup_lines.end())
	{
		LookupIter i = x->second.find(line->Displayable());
		if (i != x->second.end())
		{
			return false;
		}
	}

	/*ELine* item = new ELine(ServerInstance, ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str());*/
	XLineFactory* xlf = GetFactory(line->type);
	if (!xlf)
		return false;

	if (xlf->AutoApplyToUserList(line))
		pending_lines.push_back(line);

	lookup_lines[line->type][line->Displayable()] = line;
	line->OnAdd();

	FOREACH_MOD(I_OnAddLine,OnAddLine(user, line));

	return true;
}
コード例 #2
0
ファイル: xline.cpp プロジェクト: H7-25/inspircd
bool XLineManager::AddLine(XLine* line, User* user)
{
    if (line->duration && ServerInstance->Time() > line->expiry)
        return false; // Don't apply expired XLines.

    /* Don't apply duplicate xlines */
    ContainerIter x = lookup_lines.find(line->type);
    if (x != lookup_lines.end())
    {
        LookupIter i = x->second.find(line->Displayable());
        if (i != x->second.end())
        {
            // XLine propagation bug was here, if the line to be added already exists and
            // it's expired then expire it and add the new one instead of returning false
            if ((!i->second->duration) || (ServerInstance->Time() < i->second->expiry))
                return false;

            ExpireLine(x, i);
        }
    }

    /*ELine* item = new ELine(ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str());*/
    XLineFactory* xlf = GetFactory(line->type);
    if (!xlf)
        return false;

    ServerInstance->BanCache->RemoveEntries(line->type, false); // XXX perhaps remove ELines here?

    if (xlf->AutoApplyToUserList(line))
        pending_lines.push_back(line);

    lookup_lines[line->type][line->Displayable()] = line;
    line->OnAdd();

    FOREACH_MOD(I_OnAddLine,OnAddLine(user, line));

    return true;
}