Raised This Month: $ Target: $400
 0% 

Help with compile...


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
AtomicServers
Junior Member
Join Date: Jul 2013
Location: Sofia, Bulgaria
Old 08-08-2013 , 10:41   Help with compile...
Reply With Quote #1

Hello guys I need help to compile this plugin:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>

#define PLUGIN "Chat"
#define VERSION "1.3"
#define AUTHOR "Alka"

#define USE_COLORCHAT

#define MAX_WARNINGS 3
#define MAX_LOGS 50

#define BYPASS_FLAG ADMIN_RCON

#define IsValidBlock(%0) (0 <= str_to_num(%0) <= 255)

enum (<<=1) {
    
    
ADV_BLOCK 1,
    
ADV_WARN,
    
ADV_KICK,
    
ADV_LOG,
    
ADV_BYPASS
};

enum {
    
    
ADDR_VALID 1,
    
ADDR_NOT_FOUND = -1
};

new 
g_pCvarMode;

new 
Trie:g_tCharsTrie:g_tBlocks;
new Array:
g_aDomains, Array:g_aWhitelist;

new 
g_iWarnings[33];

new 
g_szLogsFile[64];

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd("say""clcmd_HandleChat");
    
register_clcmd("say_team""clcmd_HandleChat");
    
    
g_pCvarMode register_cvar("amx_advblock""abd");
    
    
g_tChars TrieCreate();
    
g_tBlocks TrieCreate();
    
    
g_aDomains ArrayCreate(6);
    
g_aWhitelist ArrayCreate(32);
}

public 
plugin_cfg()
{
    
get_basedir(g_szLogsFilecharsmax(g_szLogsFile));
    
add(g_szLogsFilecharsmax(g_szLogsFile), "/logs/advblock_logs.log");
    
    if(
file_size(g_szLogsFile1) / MAX_LOGS)
        
fclose(fopen(g_szLogsFile"w"));
    else
        
fclose(fopen(g_szLogsFile"a"));
    
    
LoadConfigs();
}

public 
plugin_end()
{
    
TrieDestroy(g_tChars);
    
TrieDestroy(g_tBlocks);
    
ArrayDestroy(g_aDomains);
    
ArrayDestroy(g_aWhitelist);
}

public 
client_disconnect(id)
{
    if(
g_iWarnings[id] > 0)
        
g_iWarnings[id] = 0;
}

public 
clcmd_HandleChat(id)
{
    if((
GetModFlags() & ADV_BYPASS) && get_user_flags(id) & BYPASS_FLAG)
        return 
PLUGIN_CONTINUE;
    
    new 
szText[191];
    
read_args(szTextcharsmax(szText));
    
remove_quotes(szText);
    
    if(
strlen(szText) < 4)
        return 
PLUGIN_CONTINUE;
    
    
TrieClear(g_tBlocks);
    
    new 
szBlock[4], iLen;
    new 
iNumSeqiNumBlocksiDel;
    new 
iLastBlock;
    new 
bool:bDuplicate;
    
    for(new 
sizeof szText i++)
    {
        if(
isdigit(szText[i]) && (sizeof szText))
        {
            
iLen += formatex(szBlock[iLen], charsmax(szBlock) - iLen"%c"szText[i]);
            
            if(
isdigit(szText[1]))
                
iNumSeq++;
            else
            {
                if(
IsValidBlock(szBlock))
                {
                    if(!
TrieKeyExists(g_tBlocksszBlock))
                    {
                        
TrieSetCell(g_tBlocksszBlock1);
                        
                        new 
iTo strlen(szBlock) == : (strlen(szBlock) == i);
                        if(
FindDiffChars(szTextcharsmax(szText), iLastBlockiTo) < 8)
                            
iNumBlocks++;
                        
                        
iLastBlock i;
                    }
                    else if(
TrieKeyExists(g_tBlocksszBlock) && !bDuplicate)
                    {
                        new 
iTo strlen(szBlock) == : (strlen(szBlock) == i);
                        if(
FindDiffChars(szTextcharsmax(szText), iLastBlockiTo) < 8)
                            
iNumBlocks++;
                        
                        
iLastBlock i;
                        
bDuplicate true;
                    }
                }
                
iLen 0;
            }
        }
        else
        {
            if(
szText[i] != 0)
            {
                
iDel++;
            }
        }
    }
    
    if((
iNumSeq && iNumBlocks 3) || (iNumBlocks && iDel 5) || CheckAddr(szTextcharsmax(szText)) != ADDR_NOT_FOUND)
    {
        new 
iFlags GetModFlags();
        
        if(
iFlags ADV_WARN)
        {
            if(
iFlags ADV_KICK)
            {
                
g_iWarnings[id]++;
                
#if !defined USE_COLORCHAT
                    
client_print(idprint_chat"Warning!!! Possible IP / Website advertising! [%d/%d] - Kick"g_iWarnings[id], MAX_WARNINGS);
                
#else
                    
client_print_color(idRED"^3[^4ChatGuardian^3] ^1Detected ^4[^3IP^4] ^1or ^4[^3Website^4] ^1advertising! ^4[^3%d^4/^3%d^4]"g_iWarnings[id], MAX_WARNINGS);
                
#endif
                
                
if(g_iWarnings[id] == 3)
                {
                    
server_cmd("kick #%d ^"Advertising!^""get_user_userid(id));
                    
g_iWarnings[id] = 0;
                }
            }
            else
            {
                
#if !defined USE_COLORCHAT
                    
client_print(idprint_chat"Warning!!! Possible IP / Website advertising!");
                
#else
                    
client_print_color(idRED"^4[^3ChatGuardian^4] ^1Detected ^3[^4IP^3] ^1or ^3[^4Website^3] ^1advertising!");
                
#endif
            
}
        }
        if(
iFlags ADV_LOG)
        {
            new 
szName[32];
            
get_user_name(idszNamecharsmax(szName));
            
            new 
iFile fopen(g_szLogsFile"a");
            
fprintf(iFile"Name: %s ^nChat: %s^n---------------------------------------^n"szNameszText);
            
fclose(iFile);
        }
        if(
iFlags ADV_BLOCK)
            return 
PLUGIN_HANDLED;
        else
            return 
PLUGIN_CONTINUE;
    }
    return 
PLUGIN_CONTINUE;
}

stock FindDiffChars(szString[], iLeniFromiTo)
{
    
TrieClear(g_tChars);
    
    new 
iChars;
    for(new 
iLen i++)
    {
        if(
iFrom iTo)
        {
            new 
szChar[2];
            
formatex(szCharcharsmax(szChar), "%c"szString[i]);
            
            if(!
TrieKeyExists(g_tCharsszChar))
            {
                
TrieSetCell(g_tCharsszChar1);
                
iChars++;
            }
        }
    }
    return 
iChars;
}

stock CheckAddr(szString[], iLen)
{
    new 
szText[128], iLen2;
    new 
i;
    for(
iLen i++)
    {
        if(!
isalpha(szString[i]) && !ValidAddrSeparator(szString[i]))
            continue;
        
        
iLen2 += formatex(szText[iLen2], charsmax(szText) - iLen2"%c"szString[i]);
    }
    
    new 
szTemp[6], szTemp1[32];
    for(
ArraySize(g_aWhitelist) ; i++)
    {
        
ArrayGetString(g_aWhitelistiszTemp1charsmax(szTemp1));
        if(
containi(szTextszTemp1) != -1)
        {
            
replace(szTextcharsmax(szText), szTemp1"");
            
i--;
        }
    }
    for(
ArraySize(g_aDomains) ; i++)
    {
        
ArrayGetString(g_aDomainsiszTempcharsmax(szTemp));
        
        if(
containi(szTextszTemp) > 0)
            return 
ADDR_VALID;
    }    
    return 
ADDR_NOT_FOUND;
}

stock bool:ValidAddrSeparator(iChar)
{
    new 
iChars[] = { ':''/''.' };
    for(new 
sizeof iChars i++)
    {
        if(
iChar == iChars[i])
            return 
true;
    }
    return 
false;
}

stock GetModFlags()
{
    new 
szVal[6];
    
get_pcvar_string(g_pCvarModeszValcharsmax(szVal));
    
    return 
read_flags(szVal);
}

stock LoadConfigs()
{
    new 
szFile[64];
    
get_configsdir(szFilecharsmax(szFile));
    
add(szFilecharsmax(szFile), "/advblock_config.ini");
    
    new 
iFile fopen(szFile"r");
    if(!
iFile)
        
set_fail_state("Error loading configuration file!");
    
    new 
szBuffer[32];
    new 
iConfig;
    while(!
feof(iFile))
    {
        
fgets(iFileszBuffercharsmax(szBuffer));
        
trim(szBuffer);
        
        if(!
szBuffer[0] || szBuffer[0] == ';')
            continue;
        
        if(
equal(szBuffer"#domains"))
        {
            
iConfig 1;
            continue;
        }
        else if(
equal(szBuffer"#whitelist"))
        {
            
iConfig 2;
            continue;
        }
        else
        {
            if(
szBuffer[0] != '{' || szBuffer[0] != '}')
            {
                switch(
iConfig)
                {
                    case 
1ArrayPushString(g_aDomainsszBuffer);
                    case 
2ArrayPushString(g_aWhitelistszBuffer);
                }
            }
        }
    }
    
fclose(iFile);

Can someone compile it and give it to me please?

Last edited by AtomicServers; 08-08-2013 at 10:42.
AtomicServers is offline
Send a message via Skype™ to AtomicServers
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode