Jump to content

Direct file accessing


markspec87

Recommended Posts

Ive seen on CMS' like PHPnuke when you access certain files that simply process data or just arent meant to be accessed, it says "you cannot access this file directly".

How do you go about doing that?

I want to protect some of my admin files that add database information but would prefer not to go through making them admin only. Id rather have nobody be able to use them unless theyve been referred from one of the CMS forms etc.

any ideas?
Link to comment
https://forums.phpfreaks.com/topic/28304-direct-file-accessing/
Share on other sites

chmoding your files with a custom errorpage would do this although it can have adverse effects and make scripts stop working because you must always remember that the script isn't goign to access the file as an owner it will be a guest , or at best with a bit of fancy coding a user

alwasy be carefull and take notes when chmoding yoru web dir just so if anythign stops workign you can jsut roll it back








Link to comment
https://forums.phpfreaks.com/topic/28304-direct-file-accessing/#findComment-129441
Share on other sites

Normally you would do that with .htaccess files, assuming you are using Apache as the webserver.

Alternatively, you could put code at the top of each sensitive script which checks if it was included from the CMS or being called directly.  The CMS can set a variable which the sensitive code can check before executing.  If the variable is set, it runs as usual.  If it's not set, then it displays an error message.

Or to be truly paranoid, you can combine both methods :)
Link to comment
https://forums.phpfreaks.com/topic/28304-direct-file-accessing/#findComment-129443
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.