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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.