Page 1 of 1

Allowing ONLY one user to access a particular PHP Page

Posted: Mon Jul 28, 2008 12:27 am
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:

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

Posted: Mon Jul 28, 2008 12:30 am
by SomeoneE1se
is the TELNET 'client' embeded in the page or is the php handling everything?

and are you using ajax

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

Posted: Mon Jul 28, 2008 12:54 am
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

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

Posted: Mon Jul 28, 2008 1:25 am
by SomeoneE1se
whats the reason you want only one user at a time?

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

Posted: Mon Jul 28, 2008 3:32 am
by LeeDavis
If one is configuring the router, no second or third party should come in and configure. For consistency sake...

Dav

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

Posted: Thu Jul 31, 2008 1:18 pm
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.