Exemplo n.º 1
0
CBan* CBanManager::AddSerialBan ( const char* szSerial, CClient* pBanner, const char* szReason, time_t tTimeOfUnban )
{
    if ( /*IsValidSerial ( szSerial ) &&*/ !IsSerialBanned ( szSerial ) )
	{
		CBan* pBan = AddBan ( pBanner, szReason, tTimeOfUnban );
        pBan->SetSerial ( szSerial );
        SaveBanList ();

        return pBan;
    }

    return NULL;
}
Exemplo n.º 2
0
bool CBanManager::Add( const char * szSerial, const char * szBanner, unsigned long ulBanTime, unsigned long ulUnbanTime, const char * szReason, bool bNewNode )
{
	// Is this serial already banned?
	if( IsSerialBanned( szSerial ) )
	{
		CLogFile::Print( "Failed to add ban to file. (Serial is already banned!)" );
		return false;
	}

	// Should we create a new node?
	if( bNewNode )
	{
		// Do we not have the root node?
		if( !m_pRootNode )
			m_pRootNode = m_pBanFile->GetRootNode();

		// Create a new node
		CXMLNode * pBanNode = m_pRootNode->CreateSubNode( "ban" );
		pBanNode->SetAttribute( "banner", szBanner );
		pBanNode->SetAttribute( "time", String( "%i", ulBanTime ).Get() );
		pBanNode->SetAttribute( "unban", String( "%i", ulUnbanTime ).Get() );
		pBanNode->SetAttribute( "reason", szReason );
		pBanNode->SetValue( szSerial );

		// Save the ban XML file
		m_pBanFile->Save();
	}

	// Create the ban instance
	SServerBan * pServerBan = new SServerBan;
	pServerBan->szSerial = szSerial;
	pServerBan->szBanner = szBanner;
	pServerBan->ulBanTime = ulBanTime;
	pServerBan->ulUnbanTime = ulUnbanTime;
	pServerBan->szReason = szReason;

	// Add the ban into the banlist
	m_banList.push_back( pServerBan );

	// Get the player from the serial
	CNetworkPlayer * pPlayer = pCore->GetPlayerManager()->GetPlayerFromSerial( szSerial );

	// Ensure the player is valid
	if( pPlayer )
	{
		// Kick the player from the server
		pPlayer->Kick();
	}

	return true;
}
Exemplo n.º 3
0
CBan* CBanManager::AddSerialBan ( CPlayer* pPlayer, CClient* pBanner, const char* szReason, time_t tTimeOfUnban )
{
    if ( pPlayer )
    {
        if ( !pPlayer->GetSerial ().empty() && !IsSerialBanned ( pPlayer->GetSerial ().c_str () ) )
	    {
		    CBan* pBan = AddBan ( pBanner, szReason, tTimeOfUnban );
            pBan->SetNick ( pPlayer->GetNick() );
            pBan->SetSerial ( pPlayer->GetSerial () );
            SaveBanList ();

            return pBan;
        }
    }

    return NULL;
}