All pastes #38020 Raw Edit

Unnamed

public text v1 · immutable
#38020 ·published 2006-01-22 16:05 UTC
rendered paste body
/* 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 and expier the user from the user database
				   by Dabba */
				$userdb = &$config['captiveportal']['user'];
				if (is_array($userdb)) {
					$moddb = false;
					for ($i = 0; $i < count($userdb); $i++) {
						if ($userdb[$i]['name'] == $user) {
							$userdb[$i]['expirationdate'] = "-2 day";
							$moddb = true;
						}
					}
					if ($moddb)
						write_config()