PHP code example of cleantalk / firewall

1. Go to this page and download the library: Download cleantalk/firewall library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cleantalk / firewall example snippets




namespace Cleantalk\Common\Firewall;

$api_key = 'API_KEY_HERE';
$fw_logs_table_name = 'TBL_FIREWALL_LOG';
$fw_data_table_name = 'TBL_FIREWALL_DATA';

try {
    $firewall = new Firewall($api_key, $fw_logs_table_name);

    $firewall->loadFwModule(
        new SFW($fw_logs_table_name, $fw_data_table_name)
    );
    
    $firewall->run();
} catch (\Exception $e) {
    error_log('CleanTalk Firewall is not loaded: ' . $e->getMessage());
}




namespace Cleantalk\Common\Firewall;

$api_key = 'API_KEY_HERE';
$fw_logs_table_name = 'TBL_FIREWALL_LOG';

$firewall = new Firewall($api_key, $fw_logs_table_name);

$fw_updater = $firewall->getUpdater();
if ( defined('APBCT_SFW_DIRECT_UPDATE') && APBCT_SFW_DIRECT_UPDATE ) {
    return $fw_updater->directUpdate();
}
return $fw_updater->update();




namespace Cleantalk\Common\Firewall;

$api_key = 'API_KEY_HERE';
$fw_logs_table_name = 'TBL_FIREWALL_LOG';

$firewall = new Firewall($api_key, $fw_logs_table_name);
return $firewall->sendLogs();