I'm using a simple pre-made authorisation tool to secure my site. The tool requires this line of code to be applied to the top of every .php page. Auth.php lives on the root level.
<?php ${(require_once('Auth.php'))}->protectme(); ?>
I need to be able to add this line of code to every file, including files in sub-folders. But I'm unsure of how to apply the method as shown in require_once in php to ensure it always is linked absolutely, alongside the protectme(); function.
Any enlightenment is appreciated.
Cheers.
Set a variable to the absolute path. $_SERVER['DOCUMENT_ROOT'] is a PHP global variable that stores the servers, root path. You just need to insert the rest of the path information to the script. For instance if your website exists on /var/www/ and your script exists at /var/www/scripts you would do the following.
$path = $_SERVER['DOCUMENT_ROOT'] . '/scripts/Auth.php';
require_once($path);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With