Badchip Posted June 19, 2018 Share Posted June 19, 2018 I'm trying to protect a php file to prevent it from being used frequently outside of my web. My idea is to rename it with a 4-digit pin using the code: $pin = mt_rand (1000, 9999); ... but I don't know how to rename the old file/pin with the new one: rename ("old", "new"); ??? Any help will be welcome. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 19, 2018 Share Posted June 19, 2018 You're not protecting anything by doing that, but if it makes you feel better you can rename the file if you want. http://php.net/manual/en/function.rename.php Link to comment Share on other sites More sharing options...
Badchip Posted June 20, 2018 Author Share Posted June 20, 2018 (edited) It's to avoid that the PHP path can be used by anyone. What I want to do is change the PHP name often automatically. I want it to change every time I run PHP. Edited June 20, 2018 by Badchip Link to comment Share on other sites More sharing options...
justsomeguy Posted June 20, 2018 Share Posted June 20, 2018 Yeah, security by obscurity is not security. The solution is to make that file harmless if someone unauthorized accesses it, not try to hide an insecure file that someone can exploit if they find it. Link to comment Share on other sites More sharing options...
Badchip Posted June 23, 2018 Author Share Posted June 23, 2018 (edited) Then I just need to change the PHP name periodically & automatically. Edited June 23, 2018 by Badchip Link to comment Share on other sites More sharing options...
justsomeguy Posted June 25, 2018 Share Posted June 25, 2018 That's security by obscurity, and it doesn't work. You should be able to post the URL of that file online and not worry about what will happen when people access it, because the code in the file will stop people from abusing it. If you don't have any security in your actual code, and you're counting on people just not knowing the URL of the file, that's a problem. Link to comment Share on other sites More sharing options...
davej Posted June 25, 2018 Share Posted June 25, 2018 Are you saying that you don't want to allow external links to the file? What about bookmarking? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now