API — Web Programming

Block IP on Cloudflare

Integrates Cloudflare to block IPs. Compatible with classic ASP and PHP via the extension's COM object.

Classic ASP PHP XML / JSON

By adding 2 extra lines of code you can connect to Cloudflare. CloudFlareLogin and CloudflareDomain

Function BlockIp(IP,Rulename)

From your web page — in your index.asp, index.php, or any section of your application — you can call this function to block an IP address through Firewall Manager. It requires valid credentials.

1 Required parameters


Parameter Type Required Description
Username String Required System user.
Password String Required User password.
FormatOutput String Optional Response format: xml (default) or json.
IP String Required IPv4 or IPv6 address to be blocked.
CloudFlareLogin String Required Cloudflare email and token key
CloudflareDomain String Required Domain integrated with Cloudflare
json/xml return values
result
(true or false) Status of the block request.
app
Site where it was blocked: Windows, MailEnable, Cloudflare
desc
If the result is negative, it will show information about the reason.

Important: Use this function on pages protected with your own authentication. Exposing the call without protection allows any user to block arbitrary IPs.

2 Classic ASP example


Instantiate the FlexFirewallManager.Admin COM object, set the credentials, and call UnlockIP(). The response is parsed as XML.

' Create COM object instance Set App = CreateObject("FlexFirewallManager.Admin") App.FormatOutput = "xml" App.Username = "System User" App.Password = "User Password" App.CloudFlareLogin("Cloudflare Email" , "Cloudflare Token") App.CloudflareDomain = "Domain Name" ' IP to block Dim strIP : strIP = "123.123.123.123" Dim returnstring : returnstring = App.BlockIp(strIP)

You can use FormatOutput = "json" if you prefer to parse the response with JSON.parse instead of XML. JSON format is recommended for modern applications.

3 PHP example


In PHP, instantiate the COM object with new COM(). Use json format to parse the response directly with json_decode().

// Create COM object instance $app = new COM("FlexFirewallManager.Admin"); $app->FormatOutput = "json"; $app->Username = "System User"; $app->Password = "User Password"; // IP to unblock $strIP = "123.123.123.123"; $app->CloudFlareLogin("Cloudflare Email","Cloudflare Token"); $app->CloudflareDomain = "Domain Name"; // Method 2 $returnstring = $app->BlockIp($strIP); // Parse JSON response $appjson = json_decode($returnstring); if ($appjson->result) { echo "IP Blocked " . $strIP; }

Tip: You can combine this function with an internal administration form so your users can self-manage blocking their own IP without needing access to the administrator.

4 Implementation notes


Keep the following in mind when integrating this function into your application:

Prior authentication Always protect the page that calls BlockIp() with an authenticated user session.
Windows Server only The FlexFirewallManager.Admin COM object requires Windows Server with the extension installed.
Secure credentials Never include the username and password in publicly accessible source code. Use environment variables or external configuration files.
Cloudflare synchronization With the Cloudflare integration parameters enabled, blocking will only be applied to the rules of the selected domain.