I have a file called backup.php that creates a backup .sql file of my db and saves it to my folder "backups"
I have set up my backups folders file permission to: 700. So now, the backup files files cannot be accessed by a web browser, and I have to get them via ftp. Which is good.
I also tried setting my backup.php to the file permission: 700, but I can still run the script by going to the page.
So, my question is, how can I restrict people from running my script and only allow a cron job from my server to run the script?
Just need to check if the IP trying to access the file is the server, otherwise stop it.
if($_SERVER['REMOTE_ADDR'] !== '127.0.0.1'){
die('no access');
}
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