I'm trying to build an authentication script and i'm trying to get this one method together.
I want to know if the user has logged into their account from another computer on their network.
For instance if Sally logged in from computer 192.168.0.101 then Bob logs in from his computer on 192.168.0.103 i want Sally to be logged off.
I can already check to see if a user has logged in from another computer by matching their system specs against stored system specs. For instance, checkin开发者_C百科g operating system, os version, etc.
but this will be easy to trick if there were 2 identical computers on the same network. My script would not know the difference.
Is there a way to detect either MAC address or Private IP's or something to that effect via PHP?
Well, if the clients are running windows you can use java-script together with activex to get the computer name. This is unique across a domain. Make sure that it can run due to security.
<HTML>
<HEAD>
<SCRIPT>
function PROCRun() {
var shell = new ActiveXObject("WScript.Shell");
var user= shell.ExpandEnvironmentStrings("%UserName%");
var comp= shell.ExpandEnvironmentStrings("%ComputerName%")
document.getElementById('userInfo').innerHTML = ('user: ' + user + ' comp: ' + comp);
}
</SCRIPT>
</HEAD>
<BODY ONLOAD='PROCRun();'>
<div id=userInfo>
</div>
</BODY>
</HTML>
i think you can't detect either MAC address or Private IP's in PHP
but you can make a table in the database that contain's the currently logged in user
each time a user login check if it's exist in the online table .
hope this may help you
In case your users don't block cookie, there is a solution at hand.
Put all users in one group you don't want to be logged in at the same time, e.g. "network". After a successful login, clear all authentication data of previous logins assigned to the group and auth the new user.
Scenario: Sally logs in, assigned to the group "network". After a while, Bob logs in, in group "network", too. But wait, there already are active users in the network group. Kill there session/auth data before
精彩评论