简体   繁体   中英

How to prevent execution of a PHP file?

I want to prevent the running of x.php but I can't see how to do it in cPanel. I also can't see how to do it the .htaccess . How can I do this?

My suggestion would be to modify the file with a run key that only you know.

<?php
if (!isset($_GET['runkey']) || ($_GET['runkey'] != my-secret-value)) {
   die("You do not have permission to run this script");
}

Then when you wanted to run the script, you'd call it with

https://my-site.com/my_script.php?runkey=my-secret-value

Change the file's permissions so it is not executable. You can do this from either cPanel, FTP (right-click the file and change permissions) or from the command line (chmod).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM