how many people are connected to me in a network?

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

saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

how many people are connected to me in a network?

Post by saumya »

hi guys,
i am new to php,so please bear with me if it is a stupid question.
is it possible to know how many people are connected to me in my network?Ok let me explain.WE all are working in one office and we have got one server to which everybody gets connected.Well I wan to know whether it is possible to know how many people are connected to it at any given time.I mean if some body logs on to his/her pc then i should be able to see him in my html/php page.once he/she turns off the pc then it should be noticed too.
thanks
saumya
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

not a stupid question, but a hard one to understand...

see, i don't know if you mean if you can tell if someone is logged onto your network, or onto your page?

either way, yes, you can definately find out how many people are connected to you and what their ip's are (among other things based on what OS you are using...)
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

You should hmake some kinda login/logout script for them and then at any given time calculate the online ones. simple enough.
saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

Post by saumya »

thank guys.well with a login screen its simple.but I do not want that.rather it should be autometically detect from my pc,how many people are there in my network.if they are turned on their pc then the screen should say "the particular use is on table.".can it be done?
thats like invisibly keeping an eye on them.I do not have access to myserver either.whatever I have to do is to do with my own pc.I am under a server and so as others.its actually should check how many people are currently loged in to to the main server.
thanks again for your help
saumya
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I think you can do something with sessions.... Can't quite remember what... there's a post by jason in the tutorial board on this I believe. :wink:

viewtopic.php?t=29342
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

So you want to find out how many people are on the LAN.. I'm assuming this is a Windows network, as I wouldn't know for a unix set up, but it should be similar..

The following should display all computers attached to the group/domain associated with the machine it is run on.

Code: Select all

<?php

var_export(shell_exec('net view'));

?>
saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

Post by saumya »

hi friend,my browser said NULL to your code.I think you got it right.I want to know no of people on the lan,but I am also a part of that LAN,not the server.
thank you
saumya
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you may be on the LAN but is your computer in the same domain or workgroup? That's the requirement for 'net view' to work.. There are other utilities out there that can display more detailed network information than what is availble "by default" with the OS.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

kick tcpdump/windump into action and filter out all unique mac/ip addresses..

then display those results in a page...
saumya
Forum Contributor
Posts: 193
Joined: Sun Jan 30, 2005 10:21 pm

Post by saumya »

ya i am in aworkgroup but still its NULL.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Yesterday, I thought of the same answer but forgot to post it afterwards.
Why does it return NULL ?
Fire up the command prompt and type 'net view' and see what that returns.
If that returns an error or does not display anything, contact LAN Admin.
Feyd's above code works real fine for me.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

i tried feyd's code above and it returned me this error
Warning: shell_exec(): Unable to execute 'net view' in c:\inetpub\wwwroot\mysample\TMP1zj0ydhjnf.php on line 3
false
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

care to post the code cuz it sounds like you must have mistyped it...

edit: what version of windows are you using?
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

Code: Select all

<?php
 
var_export(shell_exec('net view'));
 
?>
im using windows xp
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

n00b Saibot wrote:Yesterday, I thought of the same answer but forgot to post it afterwards.
Fire up the command prompt and type 'net view' and see what that returns.

did you try that and see if it actually displayed anything for you? Because there is no reason why it should not work if you have windows xp (unless you don't have high enough privelages to run the command...)
Post Reply