Allowing one user at a time to access a particular PHP Page

Please support our PHP advertiser: 50% off 6 Months Dedicated Server Hosting from 1&1!
Reply

Join Date: Jul 2005
Posts: 73
Reputation: LiBOC is an unknown quantity at this point 
Solved Threads: 0
LiBOC's Avatar
LiBOC LiBOC is offline Offline
Junior Poster in Training

Allowing one user at a time to access a particular PHP Page

 
0
  #1
Jul 28th, 2008
Dear Forum,

Thanks for taking time reading this post.

I checked out on sessions and cookies but I guess they are more towards the client side?

Is there a way to achieve this:

The PHP program I am doing is to reverse Telnet (Terminal Server and it accessing through CONSOLE port) into a router from a selection of a dropdown list box. Once this user had successfully logged into the router, other users(different computer) will NOT be able to even see this same logged on router as a selection to log in again.

I hope you can understand my question.

Thanks alot people!
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,086
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 179
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Veteran Poster

Re: Allowing one user at a time to access a particular PHP Page

 
0
  #2
Jul 29th, 2008
Well, if you put your routers into a mysql table, then once selected you could flag a column (as being in use).
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 68
Reputation: lordspace is an unknown quantity at this point 
Solved Threads: 5
lordspace's Avatar
lordspace lordspace is offline Offline
Junior Poster in Training

Re: Allowing one user at a time to access a particular PHP Page

 
1
  #3
Jul 29th, 2008
One solution could be:

create a temp file called lock.txt.
The file will be created only after a successful login. The file will be deleted after logout.
Before login you check if the file exists and if it does the script stops.

Note:
if for some reason the temp file cannot be deleted. It is a good idea before login to check for last modification time if it is more than 24hours delete the file.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 73
Reputation: LiBOC is an unknown quantity at this point 
Solved Threads: 0
LiBOC's Avatar
LiBOC LiBOC is offline Offline
Junior Poster in Training

Re: Allowing one user at a time to access a particular PHP Page

 
0
  #4
Aug 6th, 2008
I will try that... thanks so much, even for replying!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 73
Reputation: LiBOC is an unknown quantity at this point 
Solved Threads: 0
LiBOC's Avatar
LiBOC LiBOC is offline Offline
Junior Poster in Training

Re: Allowing one user at a time to access a particular PHP Page

 
0
  #5
Aug 7th, 2008
Hi,

I tried with the lock.txt. It worked pretty well.

But do you know the coding to check if a file exist or not? I am very new to PHP. Thanks!

Dav

Originally Posted by lordspace View Post
One solution could be:

create a temp file called lock.txt.
The file will be created only after a successful login. The file will be deleted after logout.
Before login you check if the file exists and if it does the script stops.

Note:
if for some reason the temp file cannot be deleted. It is a good idea before login to check for last modification time if it is more than 24hours delete the file.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 573
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: Allowing one user at a time to access a particular PHP Page

 
0
  #6
Aug 7th, 2008
use file_exists function

  1.  
  2. $filename = '/path/to/foo.txt';
  3.  
  4. if (file_exists($filename)) {
  5. echo "The file $filename exists";
  6. } else {
  7. echo "The file $filename does not exist";
  8. }
PHP,Javascript and AJAX tutorials.
I am currently accepting CodeIgniter,JQuery,WordPress ,PSD->XHTML jobs.Contact Me.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 73
Reputation: LiBOC is an unknown quantity at this point 
Solved Threads: 0
LiBOC's Avatar
LiBOC LiBOC is offline Offline
Junior Poster in Training

Re: Allowing one user at a time to access a particular PHP Page

 
0
  #7
Aug 7th, 2008
Oh Hi,

Sorry. I done that detection of existing file already. Thanks,

Originally Posted by lordspace View Post
One solution could be:

create a temp file called lock.txt.
The file will be created only after a successful login. The file will be deleted after logout.
Before login you check if the file exists and if it does the script stops.

Note:
if for some reason the temp file cannot be deleted. It is a good idea before login to check for last modification time if it is more than 24hours delete the file.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 73
Reputation: LiBOC is an unknown quantity at this point 
Solved Threads: 0
LiBOC's Avatar
LiBOC LiBOC is offline Offline
Junior Poster in Training

Re: Allowing one user at a time to access a particular PHP Page

 
0
  #8
Aug 7th, 2008
Hey hi!

Thanks for replying. Do you know how to pop u an alert window message in PHP?
Thanks,

Dav

Originally Posted by ryan_vietnow View Post
use file_exists function

  1.  
  2. $filename = '/path/to/foo.txt';
  3.  
  4. if (file_exists($filename)) {
  5. echo "The file $filename exists";
  6. } else {
  7. echo "The file $filename does not exist";
  8. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 573
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: Allowing one user at a time to access a particular PHP Page

 
0
  #9
Aug 7th, 2008
I think that's not possible,Use javascript instead for popup boxes
PHP,Javascript and AJAX tutorials.
I am currently accepting CodeIgniter,JQuery,WordPress ,PSD->XHTML jobs.Contact Me.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 573
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: Allowing one user at a time to access a particular PHP Page

 
0
  #10
Aug 7th, 2008
something like:

  1. echo '<script type="text/javascript">
  2. alert("hello");
  3. </script>';

but this is not recommended..
Last edited by ryan_vietnow; Aug 7th, 2008 at 1:42 am.
PHP,Javascript and AJAX tutorials.
I am currently accepting CodeIgniter,JQuery,WordPress ,PSD->XHTML jobs.Contact Me.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 925 | Replies: 9
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC