Link to home
Start Free TrialLog in
Avatar of AXISHK
AXISHK

asked on

use php to lock a directory / files access on LInux

Is it possible to write a small code to lock the file / directory on Linux with PHP ? Tks
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Why not use htaccess for this?
Avatar of AXISHK
AXISHK

ASKER

It is a part of a function on a PHP applications system....
What do you mean by "lock"? Please give more details.  Do you want to lock the file from other users locally on the server? or to prevent being accessed from the Internet? or something else?
Avatar of AXISHK

ASKER

some html pages should be locked temporarily for multi-user access. Need to ensure those copies will not be overrided,... for any reason.

Tks
Are you writing a CMS?  If that is the case, you can force a check in / check out.  If somebody wants a page, they click a button or link to get it. You mark a flag in the db that it is being edited and your php code prevents others from seeing any type of edit box.  Once the user "checks out" then others can edit.  I would put in some type of timer after x minutes to pop up and ask the user if they are still editing though.  If no response, release by updating the edit flag in the db.
Avatar of AXISHK

ASKER

Yes, but the files may be accessed through FTP, not such the PHP application... Tks
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AXISHK

ASKER

tks