FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » file access permission?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: file access permission? [message #170080 is a reply to message #170074] Fri, 08 October 2010 21:31 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 10/7/2010 2:50 PM, Amit Prakash Pawar wrote:
> I want to create simple file program.
>
> Suppose i have 10 users. and file xyz.txt
>
> When 1st user access file he has authority to read and write.
> but if at the same time 2nd user try to access this file.
> i have to give only read access or put message like wait 1st users
> writing some operation.
>
> How to create such program in PHP.
>
> Please tell me which concept i want to use or any reference tutorial?

Check out http://us3.php.net/manual/en/function.flock.php.

But please note - this is ADVISORY LOCKING only - which means it only
works if you consistently use flock() before every request. And even
then it isn't real clean, because you need to open the file before you
can lock it.

However, if you look in the user notes, you can see examples of using
another file for locking, then access the file. Still not real clean,
but more workable.

But the real question here is - why are you attempting to do it this
way? It's the hardest way to get right, and very prone to errors. A
database would be a much better solution; it's made to lock data. And
if your data is something like a list, you don't even have to lock the
entire file - just the item you are changing.

A version control system, as Micah pointed out, would also be a good
solution, and maybe better if the file is more of a text document than a
list. But it would be a bit harder to implement than a simple database.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Can anyone recommend a good debugger & IDE for PHP?
Next Topic: Send .csv file to browser
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 10:00:10 GMT 2024

Total time taken to generate the page: 0.04041 seconds