Changeset 1434

Show
Ignore:
Timestamp:
12/09/09 14:06:04 (2 years ago)
Author:
gbastien
Message:

* New code for node groups
* Login and signup and logout script now can do something with the mac address

Location:
branches/gbastien/wifidog
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branches/gbastien/wifidog/classes/Dependency.php

    r1416 r1434  
    128128       'mandatory' => true, 
    129129       "type" => "localLib", 
    130        "detectFiles" => "lib/PHPMailer_v2.0.0/class.phpmailer.php", 
     130       "detectFiles" => "lib/PHPMailer_v5.1/class.phpmailer.php", 
    131131       'description' => "Required for sending mail", 
    132132       'website' => "http://phpmailer.codeworxtech.com/", 
    133        'installSourceUrl' => "http://superb-west.dl.sourceforge.net/sourceforge/phpmailer/PHPMailer_v2.0.0.tar.gz", 
     133       'installSourceUrl' => "http://iweb.dl.sourceforge.net/sourceforge/phpmailer/PHPMailer_v5.1.tar.gz", 
    134134       'installMethod' => "tarball", 
    135135       'installDestination' => "/" 
  • branches/gbastien/wifidog/classes/MainUI.php

    r1419 r1434  
    467467        $_gwAddress = null; 
    468468        $_gwPort = null; 
     469        $_mac = null; 
    469470        $_selected = ""; 
    470471        $_languageChooser = array (); 
     
    499500            $_gwAddress = $session->get(SESS_GW_ADDRESS_VAR); 
    500501            $_gwPort = $session->get(SESS_GW_PORT_VAR); 
     502            $_mac = $session->get(SESS_USER_MAC_VAR); 
    501503 
    502504            // If gateway information could be detected tell them to Smarty 
    503505            if ($_gwId && $_gwAddress && $_gwPort) { 
    504                 $this->smarty->assign('logoutParameters', "&gw_id=" . $_gwId . "&gw_address=" . $_gwAddress . "&gw_port=" . $_gwPort); 
     506                $this->smarty->assign('logoutParameters', "&gw_id=" . $_gwId . "&gw_address=" . $_gwAddress . "&gw_port=" . $_gwPort . ($_mac? "&mac=".$_mac:"")); 
    505507            } 
    506508        } else { 
  • branches/gbastien/wifidog/classes/Session.php

    r1421 r1434  
    4545define('SESS_USERNAME_VAR', 'SESS_USERNAME'); 
    4646define('SESS_USER_ID_VAR', 'SESS_USER_ID'); 
     47define('SESS_USER_MAC_VAR', 'SESS_USER_MAC'); 
    4748define('SESS_PASSWORD_HASH_VAR', 'SESS_PASSWORD_HASH'); 
    4849define('SESS_ORIGINAL_URL_VAR', 'SESS_ORIGINAL_URL'); 
  • branches/gbastien/wifidog/classes/User.php

    r1428 r1434  
    639639    @return true on success, false on failure 
    640640    */ 
    641     function generateConnectionToken() { 
     641    function generateConnectionToken($mac = null) { 
    642642        if ($this->isUserValid()) { 
    643643            $db = AbstractDb::getObject(); 
     
    648648                $node_ip = $db->escapeString($_SERVER['REMOTE_ADDR']); 
    649649            } 
     650             
    650651            if ($session && $node_ip && $session->get(SESS_NODE_ID_VAR)) { 
    651652                //echo "$session && $node_ip && {$session->get(SESS_NODE_ID_VAR)}"; 
    652653                $node_id = $db->escapeString($session->get(SESS_NODE_ID_VAR)); 
    653                 $abuseControlFault = User::isAbuseControlViolated($this, null, Node::getObject($node_id)); 
     654                $abuseControlFault = User::isAbuseControlViolated($this, $mac, Node::getObject($node_id)); 
    654655                if($abuseControlFault) { 
    655656                    throw new Exception ($abuseControlFault); 
    656657                } 
     658                $mac = (is_null($mac)?'': $db->escapeString($mac)); 
    657659                /* 
    658660                 * Delete all unused tokens for this user, so we don't fill the database 
     
    663665 
    664666                $sql .= "INSERT INTO tokens (token_owner, token_issuer, token_id, token_status) VALUES ('" . $this->getId() . "', '" . $this->getId() . "', '$token', '" . TOKEN_UNUSED . "');\n"; 
    665                 $sql .= "INSERT INTO connections (user_id, token_id, timestamp_in, node_id, node_ip, last_updated) VALUES ('" . $this->getId() . "', '$token', CURRENT_TIMESTAMP, '$node_id', '$node_ip', CURRENT_TIMESTAMP)"; 
     667                $sql .= "INSERT INTO connections (user_id, token_id, timestamp_in, node_id, node_ip, last_updated, user_mac) VALUES ('" . $this->getId() . "', '$token', CURRENT_TIMESTAMP, '$node_id', '$node_ip', CURRENT_TIMESTAMP, '$mac')"; 
    666668                $db->execSqlUpdate($sql, false); 
    667669                $retval = $token; 
  • branches/gbastien/wifidog/login/index.php

    r1419 r1434  
    8888$gw_port = null; 
    8989$gw_id = null; 
     90$mac = null; 
    9091$logout = null; 
    9192 
     
    118119    exit; 
    119120} 
     121 
     122if (isset($_REQUEST["mac"])) { 
     123    $session->set(SESS_USER_MAC_VAR, $_REQUEST['mac']); 
     124    $mac = $_REQUEST['mac']; 
     125} 
     126 
    120127 
    121128/* 
     
    182189        // Login from a gateway, redirect to the gateway to activate the token 
    183190        $user = $network->getSplashOnlyUser(); 
    184         $token = $user->generateConnectionToken(); 
     191        $token = $user->generateConnectionToken($mac); 
    185192        User::setCurrentUser($user); 
    186193        header("Location: http://" . $gw_address . ":" . $gw_port . "/wifidog/auth?token=" . $token); 
     
    206213        if (!empty($gw_address) && !empty($gw_port)) { 
    207214            // Login from a gateway, redirect to the gateway to activate the token 
    208             $token = $user->generateConnectionToken(); 
     215            $token = $user->generateConnectionToken($mac); 
    209216            if(!$token) 
    210217            { 
     
    245252$smarty->assign('gw_port', $gw_port); 
    246253$smarty->assign('gw_id', $gw_id); 
     254$smarty->assign('mac', $mac); 
    247255 
    248256// Get the login form 
     
    256264if ($gw_id != null) 
    257265$html .= "<input type='hidden' name='gw_id' value='{$gw_id}'>\n"; 
     266if ($mac != null) 
     267$html .= "<input type='hidden' name='mac' value='{$mac}'>\n"; 
    258268$html .= Authenticator::getLoginUI(); 
    259269$html .= "</form>\n"; 
  • branches/gbastien/wifidog/signup.php

    r1421 r1434  
    228228        $gw_address = $session->get(SESS_GW_ADDRESS_VAR); 
    229229        $gw_port = $session->get(SESS_GW_PORT_VAR); 
     230        $mac = $session->get(SESS_USER_MAC_VAR); 
    230231 
    231232        if ($gw_id && $gw_address && $gw_port) { 
    232233            // Make sure the user IDs match 
    233234            if(($created_user->getId() == $authenticated_user->getId())) { 
    234                 $token = $created_user->generateConnectionToken(); 
     235                $token = $created_user->generateConnectionToken($mac); 
    235236 
    236237                $redirURL = "http://" . $gw_address . ":" . $gw_port . "/wifidog/auth?token=" . $token;