Allowing ONLY one user to access a particular PHP Page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
LeeDavis
Forum Newbie
Posts: 3
Joined: Sun Jul 27, 2008 11:51 pm
Location: Singapore

Allowing ONLY one user to access a particular PHP Page

Post by LeeDavis »

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? :banghead:

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! :bow:
Last edited by LeeDavis on Mon Jul 28, 2008 12:50 am, edited 1 time in total.
SomeoneE1se
Forum Newbie
Posts: 20
Joined: Sat May 31, 2008 2:53 am

Re: Allowing ONLY one user to access a particular PHP Page

Post by SomeoneE1se »

is the TELNET 'client' embeded in the page or is the php handling everything?

and are you using ajax
User avatar
LeeDavis
Forum Newbie
Posts: 3
Joined: Sun Jul 27, 2008 11:51 pm
Location: Singapore

Re: Allowing ONLY one user to access a particular PHP Page

Post by LeeDavis »

Hi SomeoneE1se,

I wrote wrongly, it is via console ports but through a Terminal Server.

The console connection handling and stuff is done by the PHP program codes. I did not use AJAX.

Some codes:

<?php
session_start();

$info = $_SESSION['manual']; //Associate Array?
$lala = explode("|", $info); //passing arguments to explode() function?
?>

<?php
$host = "172.16.221.".$lala[2]; //terminal server's ip address
$port = "23"; //terminal server port number
$con1 = TRUE;
$hostname = $_POST['devicename'];
set_time_limit(180); //changed from 300 to 180 on 11:34 AM 21/7/2008

$fp = fsockopen($host,$port,$errno,$errstr);

if(!$fp)
{
$results = "Error: could not open socket connection";
}
else
{
fputs ($fp, "12345\n"); //telnet password
fputs ($fp, "en\n");
fputs ($fp, "c12345\n"); //enable password
fgets ($fp, 1024);

..................

Dav
SomeoneE1se
Forum Newbie
Posts: 20
Joined: Sat May 31, 2008 2:53 am

Re: Allowing ONLY one user to access a particular PHP Page

Post by SomeoneE1se »

whats the reason you want only one user at a time?
User avatar
LeeDavis
Forum Newbie
Posts: 3
Joined: Sun Jul 27, 2008 11:51 pm
Location: Singapore

Re: Allowing ONLY one user to access a particular PHP Page

Post by LeeDavis »

If one is configuring the router, no second or third party should come in and configure. For consistency sake...

Dav
SomeoneE1se
Forum Newbie
Posts: 20
Joined: Sat May 31, 2008 2:53 am

Re: Allowing ONLY one user to access a particular PHP Page

Post by SomeoneE1se »

write to a file the epoch and check it to see if someone is currently using it? about 2-3 mins later should mean they're done.
Post Reply