Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 12th, 2005, 2:08 AM   #1
yip_kw_trowa
Newbie
 
Join Date: Feb 2005
Posts: 8
Rep Power: 0 yip_kw_trowa is on a distinguished road
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..
yip_kw_trowa is offline   Reply With Quote
Old Apr 12th, 2005, 2:26 AM   #2
codetaino
Programmer
 
codetaino's Avatar
 
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4 codetaino is on a distinguished road
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" :)
codetaino is offline   Reply With Quote
Old Apr 12th, 2005, 3:32 AM   #3
yip_kw_trowa
Newbie
 
Join Date: Feb 2005
Posts: 8
Rep Power: 0 yip_kw_trowa is on a distinguished road
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
yip_kw_trowa is offline   Reply With Quote
Old Apr 12th, 2005, 8:27 AM   #4
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Apr 13th, 2005, 10:57 PM   #5
yip_kw_trowa
Newbie
 
Join Date: Feb 2005
Posts: 8
Rep Power: 0 yip_kw_trowa is on a distinguished road
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
yip_kw_trowa is offline   Reply With Quote
Old Apr 14th, 2005, 7:16 AM   #6
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
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]
__________________

tempest is offline   Reply With Quote
Old Apr 14th, 2005, 11:27 PM   #7
yip_kw_trowa
Newbie
 
Join Date: Feb 2005
Posts: 8
Rep Power: 0 yip_kw_trowa is on a distinguished road
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..
yip_kw_trowa is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:00 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC