Created
October 10, 2019 14:12
-
-
Save jcchikikomori/7f9cc9600b5330aa19d8b6427517df34 to your computer and use it in GitHub Desktop.
NinjaFirewall config for Bedrock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
+=====================================================================+ | |
| NinjaFirewall optional configuration file | | |
| | | |
| See: https://nintechnet.com/ninjafirewall/wp-edition/help/?htninja | | |
| | | |
+=====================================================================+ | |
| | | |
| BEDROCK SUPPORT | | |
| | | |
+=====================================================================+ | |
*/ | |
require_once dirname(__DIR__) . '/vendor/autoload.php'; | |
require_once dirname(__DIR__) . '/config/application.php'; | |
$ninja_db_port = 3306; | |
if (env('DATABASE_URL')) { | |
$dsn = (object) parse_url(env('DATABASE_URL')); | |
$ninja_db_port = $dsn->port; | |
} | |
// Connect to the DB and store the link into "$GLOBALS['nfw_mysqli']": | |
$GLOBALS['nfw_mysqli'] = new mysqli( env('DB_HOST') ?: 'localhost', env('DB_USER'), env('DB_PASSWORD'), env('DB_NAME'), $ninja_db_port); | |
// We need the table prefix too: | |
$GLOBALS['nfw_table_prefix'] = env('DB_PREFIX') ?: 'wp_'; | |
$nfw_['DB_NAME'] = env('DB_NAME'); | |
$nfw_['DB_USER'] = env('DB_USER'); | |
$nfw_['DB_PASSWORD'] = env('DB_PASSWORD'); | |
$nfw_['DB_HOST'] = env('DB_HOST'); | |
$nfw_['table_prefix'] = $GLOBALS['nfw_table_prefix']; | |
$nfw_['port'] = $ninja_db_port; | |
// Users of Cloudflare CDN: | |
if (! empty($_SERVER["HTTP_CF_CONNECTING_IP"]) && | |
filter_var($_SERVER["HTTP_CF_CONNECTING_IP"],FILTER_VALIDATE_IP)) { | |
$_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_CF_CONNECTING_IP"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment