[ previous ] [ next ] [ threads ]
 
 From:  "David Davies" <ebayer at dnj dot nu>
 To:  <m0n0wall at lists dot m0n0 dot ch>
 Subject:  Captive Portal Modification
 Date:  Tue, 17 Jan 2006 09:40:32 -0000
Hi all,

I am looking to modify the captive portal, currently if ticked it wont allow
concurrent logins.
And the behaviour disconnects any existing session, is there a simple way to
modify this so as it disconnects
the existing session and wont allow the username to be used again.
Im thinking like a modification to these piece's of code to delete the user
from the db

Sadly im not a php person, paypal standing by!

d

/* Ensure that only one username is used by one client at a time
 * by Paul Taylor
 */
function kick_concurrent_logins($user) {

	captiveportal_lock();

	/* read database */
	$cpdb = captiveportal_read_db();

	captiveportal_unlock();

	if (isset($cpdb)) {
		/* find duplicate entry */
		for ($i = 0; $i < count($cpdb); $i++) {
			if ($cpdb[$i][4] == $user) {
				/* This user was already logged in */
				disconnect_client($cpdb[$i][5],"CONCURRENT
LOGIN - TERMINATING OLD SESSION",13);


	/* find an existing entry and delete it */
	for ($i = 0; $i < count($cpdb); $i++) {
		if(!strcasecmp($cpdb[$i][2],$clientip)) {
			if(isset($config['captiveportal']['radacct_enable'])
&& isset($radiusservers[0])) {
				RADIUS_ACCOUNTING_STOP($cpdb[$i][1], //
ruleno
	
$cpdb[$i][4], // username
	
$cpdb[$i][5], // sessionid
	
$cpdb[$i][0], // start time
	
$radiusservers[0]['ipaddr'],
	
$radiusservers[0]['acctport'],
	
$radiusservers[0]['key'],
	
$cpdb[$i][2], // clientip
	
$cpdb[$i][3], // clientmac
	
13); // Port Preempted
			}
			mwexec("/sbin/ipfw delete " . $cpdb[$i][1] . " " .
($cpdb[$i][1]+10000));
			unset($cpdb[$i]);
			break;
		}
	}