![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 8
Rep Power: 0
![]() |
Enquiry about my PHP project
Hello...
Now, i create the file management system to our company. But i face some problem that is i dont know how to check whether this file is already open by other people or not. Becasue each file just can access by one user, if other user want to access the same file, it might be blocked by system. So, what can i do? wait for your reply as soon as possible. Thanks.. |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4
![]() |
To be able to answer your question you have to provide more information about your problem... how you store your info... in a dbms in a file.. and a more specific description...
-codetaino
__________________
"God bless u all" :) |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Feb 2005
Posts: 8
Rep Power: 0
![]() |
Hello,
Sorry that i didn't describe it properly. All files are stored in the folder. For example, all the files are saved in htdoc folder. So, the system will display all the fields with their details which are contained inside this folder. I have finished this part but the main problem that i faced is don't know how to block user from opening the file if that file is still open by other user. For instance, firstly is User A open 123.txt and then access it. After the moment, user B also want to open 123.txt. But 123.txt is still accessed by user A. So ,the system will not allow user B to open this 123.txt. Hope u can help me... thanks |
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
have either a table or a flat file to store the "file status" as either open or closed.
have php code (checkStatus.php) to "poll" this file or database table to see if the file has already been opened or if it is closed. Use the include function to bring in checkStatus.php to each of the files in question. MAIN SYSTEM -> STATUS CHECK -> FILE ACCESS
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Feb 2005
Posts: 8
Rep Power: 0
![]() |
Oic... i try to do it.
Which command should i use? is it use chmod command to change the file status? I m sorry coz i just a newbie in this php.. So, can give some example and let me refer? Hope u can help me... thanks |
|
|
|
|
|
#6 |
|
Programming Guru
![]() |
Try the is_readable() function... ex:
[php] $file = "/home/user/file_they_want"; if(is_readable($file)) { // Show file... } else { echo "This file is currently in use by another user or application. Please try again later"; } [/php]
__________________
|
|
|
|
|
|
#7 |
|
Newbie
Join Date: Feb 2005
Posts: 8
Rep Power: 0
![]() |
I try follow your way to modift my coding. But the result is same, the sys cant block user from opening the file if that file is still open by other user.
Can somebody help me checking my coding.? Here is my coding... ------------------- ... for ($i = 1; $i <= $filecounter; $i++) { $file = $dir.$files[$i]['name']; $fileprint.="<tr>"; $fileprint.='<td>'.get_icon($dir, $files[$i]['name']).'</td>'; //Get the icon of type file if(is_readable($file)) { $fileprint.='<td><a target="_blank" href="'.$www_root.$shortdir.$files[$i]['name'].'">'.$files[$i]['name'].'</td>'; } else { $fileprint.='<td>'.$files[$i]['name'].'</td>'; } $fileprint.='<td width="75">'.$files[$i]['size'].'</td>'; $fileprint.='<td width="180">'.$files[$i]['datetime'].'</td>'; $fileprint.='</font></td></tr>'; } ..... Hope somebody can help me. Thanks.. ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|