thelolcat
thelolcat

Reputation: 11615

How to make sure a directory is safe from modifications

so let' say I have a list of directories and files on the server:

/stuff/
/other_stuff/
  index.php
/important_stuff/
  index.php
  script.php

From within the script.php script, how can I make sure the files within the important_stuff directory (__DIR__) cannot be modified by any other script?

Upvotes: 0

Views: 90

Answers (2)

gaRex
gaRex

Reputation: 4225

Right answer is about ownership/permissions. Also if you are under linux, then google for "chattr immutable".

But if you want to check if something changed, then use md file function

Upvotes: 1

greg0ire
greg0ire

Reputation: 23255

Let's assume you're using linux and that you are able to change file ownership and permissions.

php is run by the webserver user (often named apache or www-data). Make sure this user has no right to write in your important_stuff folder. This can be achieved by giving this files to another user, but making them readable by members of the www-data (or apache or whatever) group.

Upvotes: 2

Related Questions