Changeset 708

Show
Ignore:
Timestamp:
09/02/05 03:16:02 (8 years ago)
Author:
benoitg
Message:

2005-09-01 Benoit Gr�goire <bock@…>

WARNING: DO NOT use the CVS auth server in production until further notice.
Massive internal changes are underway.
Use the release tagged 1.0m1 in production.

  • Network abstraction mostly complete, including UI. All that is missing is new network creation, network stakeholder UI and testing.
  • Cleanup the config file of all the now unneeded constants. Note that the install script is currently broken. There can now be multiple networks on the server. The install script will have to make sure that there is at least one, with one super-admin
Location:
trunk/wifidog-auth
Files:
28 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/ChangeLog

    r706 r708  
     12005-09-01 Benoit Grégoire  <bock@step.polymtl.ca> 
     2        WARNING:  DO NOT use the CVS auth server in production until further notice.   
     3        Massive internal changes are underway.   
     4        Use the release tagged 1.0m1 in production. 
     5        * Network abstraction mostly complete, including UI.   
     6        All that is missing is new network creation, network stakeholder UI and testing.   
     7        * Cleanup the config file of all the now unneeded constants.  
     8         Note that the install script is currently broken.   
     9        There can now be multiple networks on the server.   
     10        The install script will have to make sure that there is at least one, with one super-admin 
     11 
    1122005-08-31 Francois Proulx <francois.proulx@gmail.com> 
    213        * Fixed bug where node ID containing periods, whitespaces or underscores would confuse PHP 
    314        * MD5 hash is used to make sur the http vars are unique 
    415        * This is only valid for Node administration 
    5          
     16 
     17NOTE:  the 1.0m1 release was tagged here 
     18                 
    6192005-08-31 Benoit Grégoire  <bock@step.polymtl.ca> 
    720        * Node.php:  Fix node creation 
  • trunk/wifidog-auth/INSTALL

    r692 r708  
    5959***************************************** 
    6060 
     61***************************************** 
     62Backup and restore 
     63***************************************** 
     64 
     65To backup: 
     66        pg_dump wifidog --blobs --file=wifidog_backup.sql --format=c --ignore-version --no-owner -v --compress=3 -U wifidog 
     67 
     68To restore from a backup: 
     69        dropdb wifidog 
     70        createdb wifidog --encoding=UTF-8 --owner=wifidog 
     71        pg_restore -U wifidog -d wifidog -v wifidog_backup.sql 
    6172 
    6273Enjoy! 
  • trunk/wifidog-auth/wifidog/admin/incoming_outgoing_swap.php

    r401 r708  
    2626require_once 'admin_common.php'; 
    2727 
    28 echo "<div id='head'><h1>". HOTSPOT_NETWORK_NAME ._(' cumulative user statistics')."</h1></div>\n";     
     28echo "<div id='head'><h1>incoming_outgoing_swap</h1></div>\n";     
    2929echo "<div id='navLeft'>\n"; 
    3030//echo get_user_management_menu(); 
  • trunk/wifidog-auth/wifidog/auth/index.php

    r638 r708  
    3232$auth_message = ''; 
    3333 
     34$token = null; 
     35if(!empty($_REQUEST['token'])) 
     36{ 
    3437$token = $db->EscapeString($_REQUEST['token']); 
    35 $db->ExecSqlUniqueRes("SELECT NOW(), *, CASE WHEN ((NOW() - reg_date) > interval '".VALIDATION_GRACE_TIME." minutes') THEN true ELSE false END AS validation_grace_time_expired FROM users,connections WHERE users.user_id=connections.user_id AND connections.token='$token'", $info, false); 
     38} 
     39 
     40$db->ExecSqlUniqueRes("SELECT NOW(), *, CASE WHEN ((NOW() - reg_date) > networks.validation_grace_time) THEN true ELSE false END AS validation_grace_time_expired FROM connections JOIN users ON (users.user_id=connections.user_id) JOIN networks ON (users.account_origin = networks.network_id) WHERE connections.token='$token'", $info, false); 
    3641if ($info != null) 
    3742{ 
    3843        // Retrieve the associated authenticator 
    39         $authenticator = $AUTH_SOURCE_ARRAY[$info['account_origin']]['authenticator']; 
    40  
    41         if ($_REQUEST['stage'] == STAGE_LOGIN) 
     44        $authenticator = Network::getObject($info['account_origin'])->getAuthenticator(); 
     45if(!$authenticator) 
     46{ 
     47                        $auth_message .= "| Error: Unable to instanciate authenticator. "; 
     48                        $auth_response = ACCOUNT_STATUS_ERROR; 
     49} 
     50else 
     51{ 
     52if ($_REQUEST['stage'] == STAGE_LOGIN) 
    4253        { 
    4354                if ($info['token_status'] == TOKEN_UNUSED) 
     
    123134                } 
    124135} 
     136} 
    125137else 
    126138{ 
  • trunk/wifidog-auth/wifidog/change_password.php

    r579 r708  
    2626define('BASEPATH','./'); 
    2727require_once BASEPATH.'include/common.php'; 
     28require_once BASEPATH.'classes/MainUI.php'; 
    2829require_once BASEPATH.'include/common_interface.php'; 
    2930require_once BASEPATH.'classes/User.php'; 
    30 require_once BASEPATH.'classes/MainUI.php'; 
    3131 
    3232isset($_REQUEST["username"]) && $smarty->assign("username", $_REQUEST["username"]); 
     
    3434if (isset($_REQUEST["submit"])) { 
    3535    try { 
    36         // If the source is present and that it's in our AUTH_SOURCE_ARRAY, save it to a var for later use 
    37                 $_REQUEST['auth_source'] && in_array($_REQUEST['auth_source'], array_keys($AUTH_SOURCE_ARRAY)) && $account_origin = $_REQUEST['auth_source']; 
     36        // If the source is present and that it's in our, save it to a var for later use 
     37                $account_origin = Networt::getObject($_REQUEST['auth_source']); 
    3838                 
    3939        if (!$account_origin || !$_REQUEST["username"] || !$_REQUEST["oldpassword"] || !$_REQUEST["newpassword"] || !$_REQUEST["newpassword_again"]) 
     
    7373$sources = array (); 
    7474// Preserve keys 
    75 foreach (array_keys($AUTH_SOURCE_ARRAY) as $auth_source_key) 
    76         if ($AUTH_SOURCE_ARRAY[$auth_source_key]['authenticator']->isRegistrationPermitted()) 
    77                 $sources[$auth_source_key] = $AUTH_SOURCE_ARRAY[$auth_source_key]; 
     75$network_array=Network::getAllNetworks(); 
     76foreach ($network_array as $network) 
     77        if ($network->getAuthenticator()->isRegistrationPermitted()) 
     78                $sources[$network->getId()] = $network->getName(); 
    7879                 
    7980isset ($sources) && $smarty->assign('auth_sources', $sources); 
  • trunk/wifidog-auth/wifidog/classes/AbstractDbPostgres.php

    r619 r708  
    271271         @param $sql requête SELECT à exécuter 
    272272         @param $debug Si TRUE, affiche la requête brute 
     273         @return false on failure, true otherwise 
    273274         */ 
    274275        function ExecSqlUpdate($sql, $debug=false) 
  • trunk/wifidog-auth/wifidog/classes/Authenticator.php

    r609 r708  
    2323 * Technologies Coeus inc. 
    2424 */ 
     25require_once 'AuthenticatorLocalUser.php'; 
     26require_once 'AuthenticatorRadius.php'; 
    2527 
    2628/** Abstract class to represent an authentication source */ 
  • trunk/wifidog-auth/wifidog/classes/AuthenticatorLocalUser.php

    r553 r708  
    4747        { 
    4848                return get_class($account_origin['authenticator']) == "AuthenticatorLocalUser"; 
    49         } 
    50  
    51         /** 
    52          * Returns in array containing only Local User account origins 
    53          * @return array 
    54          */ 
    55         public static function getAllLocalUserAccountOrigins() 
    56         { 
    57                 global $AUTH_SOURCE_ARRAY; 
    58                 return array_filter($AUTH_SOURCE_ARRAY, array("self", "isLocalUserAccountOrigin")); 
    5949        } 
    6050 
  • trunk/wifidog-auth/wifidog/classes/AuthenticatorRadius.php

    r544 r708  
    4646        /** 
    4747         * AuthenticatorRadius constructor 
     48         * Example:  new AuthenticatorRadius(IDRC_ACCOUNT_ORIGIN, "192.168.0.11", 
     49         * 1812, 1813, "secret_key", "CHAP_MD5"); 
    4850         * @param $account_orgin : The origin of the account 
    4951         * @param $host : hostname of the RADIUS server 
  • trunk/wifidog-auth/wifidog/classes/Content.php

    r694 r708  
    233233        public static function getSelectContentUI($user_prefix, $sql_additional_where = null) 
    234234        { 
    235                 global $AUTH_SOURCE_ARRAY; 
    236235                $html = ''; 
    237236                $name = "{$user_prefix}"; 
  • trunk/wifidog-auth/wifidog/classes/Content/ContentGroup.php

    r686 r708  
    315315 
    316316                /* content_ordering_mode */ 
    317                 global $AUTH_SOURCE_ARRAY; 
    318317                $html .= "<div class='admin_section_container'>\n"; 
    319318                $html .= "<div class='admin_section_title'>"._("In what order should the content displayed?").": </div>\n"; 
  • trunk/wifidog-auth/wifidog/classes/MainUI.php

    r695 r708  
    2525 */ 
    2626require_once BASEPATH.'include/common.php'; 
     27        /** @note We put a call to validate_schema() here so it systematically called 
     28 * from any UI page, but not from any machine readable pages  
     29 */  
     30                require_once BASEPATH.'include/schema_validate.php'; 
     31                validate_schema(); 
     32                 
    2733require_once BASEPATH.'include/common_interface.php'; 
    2834 
     
    3945        private $footer_scripts = array (); 
    4046 
    41          
    42         /** @note We put a call to validate_schema() here so it systematically called 
    43  * from any UI page, but not from any machine readable pages  
    44  */  
    4547        function __construct() 
    4648        { 
    47                 require_once BASEPATH.'include/schema_validate.php'; 
    48                 validate_schema(); 
    49  
    5049                $this->smarty = new SmartyWifidog(); 
    5150                $this->title = Network :: getCurrentNetwork()->getName().' '._("authentication server"); //Default title 
     
    357356        { 
    358357                $html = "<p>$errmsg</p>\n"; 
    359                 $html .= "<p>"._("Please get in touch with ")."<a href='{TECH_SUPPORT_EMAIL}'>{TECH_SUPPORT_EMAIL}</a></p>"; 
     358                $email = Network::getCurrentNetwork()->getTechSupportEmail(); 
     359                if(!empty($email)) 
     360                { 
     361                $html .= "<p>"._("Please get in touch with ")."<a href='{$email}'>{$email}</a></p>"; 
     362                } 
    360363                $this->setMainContent($html); 
    361364                $this->display(); 
  • trunk/wifidog-auth/wifidog/classes/Network.php

    r705 r708  
    11<?php 
     2 
    23/********************************************************************\ 
    34 * This program is free software; you can redistribute it and/or    * 
     
    3132{ 
    3233        private $id; /**< The network id */ 
     34        private $mRow; 
    3335 
    3436        /** Get an instance of the object 
     
    4244        } 
    4345 
     46        /** Get all the Networks configured on this server 
     47         * @return an array of Network objects.  The default network is returned 
     48         * first 
     49         */ 
     50        static function getAllNetworks() 
     51        { 
     52                $retval = array (); 
     53                global $db; 
     54                $sql = "SELECT network_id FROM networks ORDER BY is_default_network DESC"; 
     55                $network_rows = null; 
     56                $db->ExecSql($sql, $network_rows, false); 
     57                if ($network_rows == null) 
     58                { 
     59                        throw new Exception(_("Network::getAllNetworks:  Fatal error: No networks in the database!")); 
     60                } 
     61                foreach ($network_rows as $network_row) 
     62                { 
     63                        $retval[] = new self($network_row['network_id']); 
     64                } 
     65                return $retval; 
     66        } 
     67 
     68        /** Get the default network 
     69         * @return a Network object, NEVER returns null. 
     70         */ 
     71        static function getDefaultNetwork($real_network_only = false) 
     72        { 
     73                $retval = null; 
     74                        global $db; 
     75                        $sql = "SELECT network_id FROM networks WHERE is_default_network=TRUE ORDER BY creation_date LIMIT 1"; 
     76                        $network_row = null; 
     77                        $db->ExecSqlUniqueRes($sql, $network_row, false); 
     78                        if ($network_row == null) 
     79                        { 
     80                                throw new Exception(_("Network::getDefaultNetwork:  Fatal error: Unable to find the default network!")); 
     81                        } 
     82                        $retval = new self($network_row['network_id']); 
     83                return $retval; 
     84        } 
     85         
    4486        /** Get the current network for which the portal is displayed or to which a user is physically connected. 
    45          * @param $real_network_only true or false.  If true, the real physical network where the user is connected is returned, and the node set by setCurrentNode is ignored. 
    46          * @return a Node object, or null if it can't be found. 
     87         * @param $real_network_only NOT IMPLEMENTED YET true or false.  If true, 
     88         * the real physical network where the user is connected is returned, and 
     89         * the node set by setCurrentNode is ignored. 
     90         * @return a Network object, NEVER returns null. 
    4791         */ 
    4892        static function getCurrentNetwork($real_network_only = false) 
    4993        { 
    50                 global $AUTH_SOURCE_ARRAY; 
    51                 $keys = array_keys($AUTH_SOURCE_ARRAY); 
    52  
    53                 return new self($keys[0]); 
     94                $retval = null; 
     95                $current_node = Node :: getCurrentNode(); 
     96                if ($current_node != null) 
     97                { 
     98                        $retval = $current_node->getNetwork(); 
     99                } 
     100                else 
     101                { 
     102                        $retval = Network::getDefaultNetwork(); 
     103                } 
     104                return $retval; 
    54105        } 
    55106 
     
    69120        public static function getSelectNetworkUI($user_prefix) 
    70121        { 
    71                 global $AUTH_SOURCE_ARRAY; 
    72122                $html = ''; 
    73123                $name = $user_prefix; 
    74124                $html .= _("Network:")." \n"; 
    75                 $number_of_networks = count($AUTH_SOURCE_ARRAY); 
     125 
     126                global $db; 
     127                $sql = "SELECT network_id, name FROM networks ORDER BY is_default_network DESC"; 
     128                $network_rows = null; 
     129                $db->ExecSql($sql, $network_rows, false); 
     130                if ($network_rows == null) 
     131                { 
     132                        throw new Exception(_("Network::getAllNetworks:  Fatal error: No networks in the database!")); 
     133                } 
     134 
     135                $network_array = self :: getAllNetworks(); 
     136                $number_of_networks = count($network_rows); 
    76137                if ($number_of_networks > 1) 
    77138                { 
    78139                        $i = 0; 
    79                         foreach ($AUTH_SOURCE_ARRAY as $network_id => $network_info) 
     140                        foreach ($network_rows as $network_row) 
    80141                        { 
    81                                 $tab[$i][0] = $network_id; 
    82                                 $tab[$i][1] = $network_info['name']; 
     142                                $tab[$i][0] = $network_row['network_id']; 
     143                                $tab[$i][1] = $network_row['name']; 
    83144                                $i ++; 
    84145                        } 
     
    88149                else 
    89150                { 
    90                         foreach ($AUTH_SOURCE_ARRAY as $network_id => $network_info) //iterates only once... 
     151                        foreach ($network_rows as $network_row) //iterates only once... 
    91152                        { 
    92                                 $html .= " $network_info[name] "; 
    93                                 $html .= "<input type='hidden' name='$name' value='$network_id'>"; 
     153                                $html .= " $network_row[name] "; 
     154                                $html .= "<input type='hidden' name='$name' value='$network_row[network_id]'>"; 
    94155                        } 
    95156                } 
     
    105166                $object = null; 
    106167                $name = "{$user_prefix}"; 
    107                 if(!empty($_REQUEST[$name])) 
     168                if (!empty ($_REQUEST[$name])) 
    108169                        return new self($_REQUEST[$name]); 
    109170                else 
     
    113174        private function __construct($p_network_id) 
    114175        { 
    115                 global $AUTH_SOURCE_ARRAY; 
    116                 $found = false; 
    117                 foreach ($AUTH_SOURCE_ARRAY as $network_id => $network_info) 
    118                 { 
    119                         if ($p_network_id == $network_id) 
    120                         { 
    121                                 $found = true; 
    122                         } 
    123                 } 
    124                 if (!$found) 
    125                 { 
    126                         throw new Exception(_("The specified network doesn't exist: ").$p_network_id); 
    127                 } 
    128                 $this->id = $p_network_id; 
     176                global $db; 
     177 
     178                $network_id_str = $db->EscapeString($p_network_id); 
     179                $sql = "SELECT *, EXTRACT(EPOCH FROM validation_grace_time) as validation_grace_time_seconds FROM networks WHERE network_id='$network_id_str'"; 
     180                $row = null; 
     181                $db->ExecSqlUniqueRes($sql, $row, false); 
     182                if ($row == null) 
     183                { 
     184                        throw new Exception("The network with id $network_id_str could not be found in the database"); 
     185                } 
     186                $this->mRow = $row; 
     187                $this->id = $db->EscapeString($row['network_id']); 
    129188        } 
    130189 
     
    140199        public function getTechSupportEmail() 
    141200        { 
    142                 return TECH_SUPPORT_EMAIL; 
    143         } 
    144  
     201                return $this->mRow['tech_support_email']; 
     202        } 
     203 
     204        /** Set the network's tech support and information email address 
     205         * @param $value The new value  
     206         * @return true on success, false on failure */ 
     207        function setTechSupportEmail($value) 
     208        { 
     209                $retval = true; 
     210                if ($value != $this->getName()) 
     211                { 
     212                        global $db; 
     213                        $value = $db->EscapeString($value); 
     214                        $retval = $db->ExecSqlUpdate("UPDATE networks SET tech_support_email = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     215                        $this->refresh(); 
     216                } 
     217                return $retval; 
     218        } 
     219         
    145220        /** Retreives the network name  
    146          * @return The id */ 
     221         * @return A string */ 
    147222        public function getName() 
    148223        { 
    149                 return HOTSPOT_NETWORK_NAME; 
     224                return $this->mRow['name']; 
     225        } 
     226 
     227        /** Set the network's name 
     228         * @param $value The new value  
     229         * @return true on success, false on failure */ 
     230        function setName($value) 
     231        { 
     232                $retval = true; 
     233                if ($value != $this->getName()) 
     234                { 
     235                        global $db; 
     236                        $value = $db->EscapeString($value); 
     237                        $retval = $db->ExecSqlUpdate("UPDATE networks SET name = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     238                        $this->refresh(); 
     239                } 
     240                return $retval; 
    150241        } 
    151242 
     
    154245        public function getHomepageURL() 
    155246        { 
    156                 return HOTSPOT_NETWORK_URL; 
    157         } 
     247                return $this->mRow['homepage_url']; 
     248        } 
     249 
     250        /** Set the network's homepage url 
     251         * @param $value The new value  
     252         * @return true on success, false on failure */ 
     253        function setHomepageURL($value) 
     254        { 
     255                $retval = true; 
     256                if ($value != $this->getName()) 
     257                { 
     258                        global $db; 
     259                        $value = $db->EscapeString($value); 
     260                        $retval = $db->ExecSqlUpdate("UPDATE networks SET homepage_url = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     261                        $this->refresh(); 
     262                } 
     263                return $retval; 
     264        } 
     265 
     266        /** Retreives the network's authenticator's class. 
     267         *  @return    A string */ 
     268        public function getAuthenticatorClassName() 
     269        { 
     270                return $this->mRow['network_authenticator_class']; 
     271        } 
     272 
     273        /** Set the network's authenticator's class.  The subclass of Authenticator to be used for user authentication (ex: AuthenticatorRadius) 
     274         * @param $value a string, the class name of a  subclass of Authenticator  
     275         * @return true on success, false on failure */ 
     276        function setAuthenticatorClassName($value) 
     277        { 
     278                $retval = true; 
     279                if ($value != $this->getAuthenticatorClassName()) 
     280                { 
     281                        global $db; 
     282                        $value = $db->EscapeString($value); 
     283                        $retval = $db->ExecSqlUpdate("UPDATE networks SET network_authenticator_class = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     284                        $this->refresh(); 
     285                } 
     286                return $retval; 
     287        } 
     288                 
     289        /** Retreives the authenticator's parameters 
     290         * @return A string */ 
     291        public function getAuthenticatorConstructorParams() 
     292        { 
     293                return $this->mRow['network_authenticator_params']; 
     294        } 
     295 
     296        /** The explicit parameters to be passed to the authenticator's constructor (ex: 'my_network_id', '192.168.0.11', 1812, 1813, 'secret_key', 'CHAP_MD5') 
     297         * @param $value The new value  
     298         * @return true on success, false on failure */ 
     299        function setAuthenticatorConstructorParams($value) 
     300        { 
     301                $retval = true; 
     302                if ($value != $this->getAuthenticatorConstructorParams()) 
     303                { 
     304                        global $db; 
     305                        $value = $db->EscapeString($value); 
     306                        $retval = $db->ExecSqlUpdate("UPDATE networks SET network_authenticator_params = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     307                        $this->refresh(); 
     308                } 
     309                return $retval; 
     310        } 
     311         
     312        /** Get the Authenticator object for this network  
     313         * @return a subclass of Authenticator */ 
     314        public function getAuthenticator() 
     315        { 
     316                require_once BASEPATH.'classes/Authenticator.php'; 
     317                if (strpos($this->mRow['network_authenticator_params'], ';') != false) 
     318                { 
     319                        throw new Exception("Network::getAuthenticator():  Security error:  The parameters passed to the constructor of the authenticator are potentially unsafe"); 
     320                } 
     321                $objstring = 'return new '.$this->mRow['network_authenticator_class'].'('.$this->mRow['network_authenticator_params'].');'; 
     322                return eval ($objstring); 
     323        } 
     324                 
     325        /** Is the network the default network? 
     326         * @return true or false */ 
     327        public function isDefaultNetwork() 
     328        { 
     329                ($this->mRow['is_default_network']=='t')?$retval=true:$retval=false; 
     330                return $retval; 
     331        } 
     332 
     333        /** Set as the default network.  The can only be one default network, so this method will unset is_default_network for all other network  
     334         * @return true on success, false on failure */ 
     335        function setAsDefaultNetwork() 
     336        { 
     337                $retval = true; 
     338                if (!$this->isDefaultNetwork()) 
     339                { 
     340                        global $db; 
     341                        $sql = "UPDATE networks SET is_default_network = FALSE;\n"; 
     342                        $sql .= "UPDATE networks SET is_default_network = TRUE WHERE network_id = '{$this->getId()}';\n"; 
     343                        $retval = $db->ExecSqlUpdate($sql, false); 
     344                        $this->refresh(); 
     345                } 
     346                return $retval; 
     347        } 
     348 
     349        /** Retreives the network's validation grace period 
     350         * @return An integer (seconds) */ 
     351        public function getValidationGraceTime() 
     352        { 
     353                return $this->mRow['validation_grace_time_seconds']; 
     354        } 
     355 
     356        /** Set the network's validation grace period in seconds.  A new user is granted Internet access for this period check his email and validate his account. 
     357         * @param $value The new value  
     358         * @return true on success, false on failure */ 
     359        function setValidationGraceTime($value) 
     360        { 
     361                $retval = true; 
     362                if ($value != $this->getValidationGraceTime()) 
     363                { 
     364                        global $db; 
     365                        $value = $db->EscapeString($value); 
     366                        $retval = $db->ExecSqlUpdate("UPDATE networks SET validation_grace_time = '{$value} seconds' WHERE network_id = '{$this->getId()}'", false); 
     367                        $this->refresh(); 
     368                } 
     369                return $retval; 
     370        } 
     371                         
     372        /** Retreives the FROM adress of the validation email 
     373         * @return A string */ 
     374        public function getValidationEmailFromAddress() 
     375        { 
     376                return $this->mRow['validation_email_from_address']; 
     377        } 
     378 
     379        /** Set the FROM adress of the validation email 
     380         * @param $value The new value  
     381         * @return true on success, false on failure */ 
     382        function setValidationEmailFromAddress($value) 
     383        { 
     384                $retval = true; 
     385                if ($value != $this->getValidationEmailFromAddress()) 
     386                { 
     387                        global $db; 
     388                        $value = $db->EscapeString($value); 
     389                        $retval = $db->ExecSqlUpdate("UPDATE networks SET validation_email_from_address = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     390                        $this->refresh(); 
     391                } 
     392                return $retval; 
     393        } 
     394                 
     395        /** Can an account be connected more than once at the same time? 
     396         * @return true or false */ 
     397        public function getMultipleLoginAllowed() 
     398        { 
     399                ($this->mRow['allow_multiple_login']=='t')?$retval=true:$retval=false; 
     400                return $retval; 
     401        } 
     402 
     403        /** Set if a account be connected more than once at the same time? 
     404         * @param $value The new value, true or false 
     405         * @return true on success, false on failure */ 
     406        function setMultipleLoginAllowed($value) 
     407        { 
     408                $retval = true; 
     409                if ($value != $this->getMultipleLoginAllowed()) 
     410                { 
     411                        global $db; 
     412                        $value?$value='TRUE':$value='FALSE'; 
     413                        $retval = $db->ExecSqlUpdate("UPDATE networks SET allow_multiple_login = {$value} WHERE network_id = '{$this->getId()}'", false); 
     414                        $this->refresh(); 
     415                } 
     416                return $retval; 
     417        } 
     418 
     419        /** Are nodes allowed to be set as splash-only (no login)? 
     420         * @return true or false */ 
     421        public function getSplashOnlyNodesAllowed() 
     422        { 
     423                ($this->mRow['allow_splash_only_nodes']=='t')?$retval=true:$retval=false; 
     424                return $retval; 
     425        } 
     426 
     427        /** Set if nodes are allowed to be set as splash-only (no login) 
     428         * @param $value The new value, true or false 
     429         * @return true on success, false on failure */ 
     430        function setSplashOnlyNodesAllowed($value) 
     431        { 
     432                $retval = true; 
     433                if ($value != $this->getSplashOnlyNodesAllowed()) 
     434                { 
     435                        global $db; 
     436                        $value?$value='TRUE':$value='FALSE'; 
     437                        $retval = $db->ExecSqlUpdate("UPDATE networks SET allow_splash_only_nodes = {$value} WHERE network_id = '{$this->getId()}'", false); 
     438                        $this->refresh(); 
     439                } 
     440                return $retval; 
     441        }                
     442         
     443        /** Are nodes allowed to redirect users to an arbitrary web page instead of the portal? 
     444         * @return true or false */ 
     445        public function getCustomPortalRedirectAllowed() 
     446        { 
     447                ($this->mRow['allow_custom_portal_redirect']=='t')?$retval=true:$retval=false; 
     448                return $retval; 
     449        } 
     450 
     451        /** Set if nodes are allowed to redirect users to an arbitrary web page instead of the portal? 
     452         * @param $value The new value, true or false 
     453         * @return true on success, false on failure */ 
     454        function setCustomPortalRedirectAllowed($value) 
     455        { 
     456                $retval = true; 
     457                if ($value != $this->getCustomPortalRedirectAllowed()) 
     458                { 
     459                        global $db; 
     460                        $value?$value='TRUE':$value='FALSE'; 
     461                        $retval = $db->ExecSqlUpdate("UPDATE networks SET allow_custom_portal_redirect = {$value} WHERE network_id = '{$this->getId()}'", false); 
     462                        $this->refresh(); 
     463                } 
     464                return $retval; 
     465        }                
    158466 
    159467        /**Get an array of all Content linked to the network 
    160468        * @param boolean $exclude_subscribed_content 
    161     * @param User $subscriber The User object used to discriminate the content 
     469        * @param User $subscriber The User object used to discriminate the content 
    162470        * @return an array of Content or an empty arrray */ 
    163471        function getAllContent($exclude_subscribed_content = false, $subscriber = null) 
    164472        { 
    165            global $db; 
     473                global $db; 
    166474                $retval = array (); 
    167         // Get all network, but exclude user subscribed content if asked 
     475                // Get all network, but exclude user subscribed content if asked 
    168476                if ($exclude_subscribed_content == true && $subscriber) 
    169477                        $sql = "SELECT content_id FROM network_has_content WHERE network_id='$this->id' AND content_id NOT IN (SELECT content_id FROM user_has_content WHERE user_id = '{$subscriber->getId()}') ORDER BY subscribe_timestamp DESC"; 
     
    171479                        $sql = "SELECT content_id FROM network_has_content WHERE network_id='$this->id' ORDER BY subscribe_timestamp DESC"; 
    172480                $db->ExecSql($sql, $content_rows, false); 
    173          
     481 
    174482                if ($content_rows != null) 
    175483                { 
     
    185493         * @return The HTML fragment for this interface */ 
    186494 
    187         /** Get the Authenticator object for this network */ 
    188         public function getAuthenticator() 
    189         { 
    190                 global $AUTH_SOURCE_ARRAY; 
    191                 return $AUTH_SOURCE_ARRAY[$this->id]['authenticator']; 
    192         } 
    193  
    194495        public function getAdminUI() 
    195496        { 
     
    199500                $html .= "<div class='admin_class'>Network (".get_class($this)." instance)</div>\n"; 
    200501 
     502                // network_id 
     503                $html .= "<div class='admin_section_container'>\n"; 
     504                $html .= "<div class='admin_section_title'>"._("Network ID")." : </div>\n"; 
     505                $html .= "<div class='admin_section_data'>\n"; 
     506                $name = "network_".$this->getId()."_name"; 
     507                $value = htmlspecialchars($this->getId(), ENT_QUOTES); 
     508                $html .= $value; 
     509                //$html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
     510                $html .= "</div>\n"; 
     511                $html .= "</div>\n"; 
     512                 
     513                // name 
     514                $html .= "<div class='admin_section_container'>\n"; 
     515                $html .= "<div class='admin_section_title'>"._("Network name")." : </div>\n"; 
     516                $html .= "<div class='admin_section_data'>\n"; 
     517                $name = "network_".$this->getId()."_name"; 
     518                $value = htmlspecialchars($this->getName(), ENT_QUOTES); 
     519                $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
     520                $html .= "</div>\n"; 
     521                $html .= "</div>\n"; 
     522 
     523                // homepage_url 
     524                $html .= "<div class='admin_section_container'>\n"; 
     525                $html .= "<div class='admin_section_title'>"._("Network's web site")." : </div>\n"; 
     526                $html .= "<div class='admin_section_data'>\n"; 
     527                $name = "network_".$this->getId()."_homepage_url"; 
     528                $value = htmlspecialchars($this->getHomepageURL(), ENT_QUOTES); 
     529                $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
     530                $html .= "</div>\n"; 
     531                $html .= "</div>\n"; 
     532 
     533                // tech_support_email 
     534                $html .= "<div class='admin_section_container'>\n"; 
     535                $html .= "<div class='admin_section_title'>"._("Technical support email")." : </div>\n"; 
     536                $html .= "<div class='admin_section_data'>\n"; 
     537                $name = "network_".$this->getId()."_tech_support_email"; 
     538                $value = htmlspecialchars($this->getTechSupportEmail(), ENT_QUOTES); 
     539                $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
     540                $html .= "</div>\n"; 
     541                $html .= "</div>\n"; 
     542 
     543 
     544                //  network_authenticator_class 
     545                $html .= "<div class='admin_section_container'>\n"; 
     546                $html .= "<div class='admin_section_title'>"._("Network authenticator class.  The subclass of Authenticator to be used for user authentication (ex: AuthenticatorRadius)")." : </div>\n"; 
     547                $html .= "<div class='admin_section_data'>\n"; 
     548                $name = "network_".$this->getId()."_network_authenticator_class"; 
     549                $value = htmlspecialchars($this->getAuthenticatorClassName(), ENT_QUOTES); 
     550                $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
     551                $html .= "</div>\n"; 
     552                $html .= "</div>\n"; 
     553 
     554                //  network_authenticator_params 
     555                $html .= "<div class='admin_section_container'>\n"; 
     556                $html .= "<div class='admin_section_title'>"._("The explicit parameters to be passed to the authenticator (ex: 'my_network_id', '192.168.0.11', 1812, 1813, 'secret_key', 'CHAP_MD5')")." : </div>\n"; 
     557                $html .= "<div class='admin_section_data'>\n"; 
     558                $name = "network_".$this->getId()."_network_authenticator_params"; 
     559                $value = htmlspecialchars($this->getAuthenticatorConstructorParams(), ENT_QUOTES); 
     560                $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
     561                $html .= "</div>\n"; 
     562                $html .= "</div>\n";             
     563                 
     564                //  is_default_network 
     565                $html .= "<div class='admin_section_container'>\n"; 
     566                $html .= "<div class='admin_section_title'>"._("Is this network the default network?")." : </div>\n"; 
     567                $html .= "<div class='admin_section_data'>\n"; 
     568                $name = "network_".$this->getId()."_is_default_network"; 
     569                $this->isDefaultNetwork()? $checked='CHECKED': $checked=''; 
     570                $html .= "<input type='checkbox' name='$name' $checked>\n"; 
     571                $html .= "</div>\n"; 
     572                $html .= "</div>\n";                     
     573         
     574                //  validation_grace_time 
     575                $html .= "<div class='admin_section_container'>\n"; 
     576                $html .= "<div class='admin_section_title'>"._("The length of the validation grace period in seconds.  A new user is granted Internet access for this period check his email and validate his account.")." : </div>\n"; 
     577                $html .= "<div class='admin_section_data'>\n"; 
     578                $name = "network_".$this->getId()."_validation_grace_time"; 
     579                $value = htmlspecialchars($this->getValidationGraceTime(), ENT_QUOTES); 
     580                $html .= "<input type='text' size ='5' value='$value' name='$name'>\n"; 
     581                $html .= "</div>\n"; 
     582                $html .= "</div>\n"; 
     583                         
     584                //  validation_email_from_address 
     585                $html .= "<div class='admin_section_container'>\n"; 
     586                $html .= "<div class='admin_section_title'>"._("This will be the from adress of the validation email")." : </div>\n"; 
     587                $html .= "<div class='admin_section_data'>\n"; 
     588                $name = "network_".$this->getId()."_validation_email_from_address"; 
     589                $value = htmlspecialchars($this->getValidationEmailFromAddress(), ENT_QUOTES); 
     590                $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
     591                $html .= "</div>\n"; 
     592                $html .= "</div>\n"; 
     593                 
     594                //  allow_multiple_login 
     595                $html .= "<div class='admin_section_container'>\n"; 
     596                $html .= "<div class='admin_section_title'>"._("Can an account be connected more than once at the same time?")." : </div>\n"; 
     597                $html .= "<div class='admin_section_data'>\n"; 
     598                $name = "network_".$this->getId()."_allow_multiple_login"; 
     599                $this->getMultipleLoginAllowed()? $checked='CHECKED': $checked=''; 
     600                $html .= "<input type='checkbox' name='$name' $checked>\n"; 
     601                $html .= "</div>\n"; 
     602                $html .= "</div>\n"; 
     603                 
     604                //  allow_splash_only_nodes 
     605                $html .= "<div class='admin_section_container'>\n"; 
     606                $html .= "<div class='admin_section_title'>"._("Are nodes allowed to be set as splash-only (no login)?")." : </div>\n"; 
     607                $html .= "<div class='admin_section_data'>\n"; 
     608                $name = "network_".$this->getId()."_allow_splash_only_nodes"; 
     609                $this->getSplashOnlyNodesAllowed()? $checked='CHECKED': $checked=''; 
     610                $html .= "<input type='checkbox' name='$name' $checked>\n"; 
     611                $html .= "</div>\n"; 
     612                $html .= "</div>\n"; 
     613                 
     614                //  allow_custom_portal_redirect 
     615                $html .= "<div class='admin_section_container'>\n"; 
     616                $html .= "<div class='admin_section_title'>"._("Are nodes allowed to redirect users to an arbitrary web page instead of the portal?")." : </div>\n"; 
     617                $html .= "<div class='admin_section_data'>\n"; 
     618                $name = "network_".$this->getId()."_allow_custom_portal_redirect"; 
     619                $this->getCustomPortalRedirectAllowed()? $checked='CHECKED': $checked=''; 
     620                $html .= "<input type='checkbox' name='$name' $checked>\n"; 
     621                $html .= "</div>\n"; 
     622                $html .= "</div>\n"; 
     623                 
     624                //      network_stakeholders 
     625                $html .= "<div class='admin_section_container'>\n"; 
     626                $html .= "<div class='admin_section_title'>"._("Network stakeholders")." : </div>\n"; 
     627                $html .= "<div class='admin_section_data'>\n"; 
     628                //$name = "network_".$this->getId()."_allow_custom_portal_redirect"; 
     629                //$this->getCustomPortalRedirectAllowed()? $checked='CHECKED': $checked=''; 
     630                //$html .= "<input type='checkbox' name='$name' $checked>\n"; 
     631                $html .= "WRITEME!"; 
     632                $html .= "</div>\n"; 
     633                $html .= "</div>\n";             
     634                                 
    201635                // Create new nodes 
    202636                $html .= "<div class='admin_section_container'>\n"; 
    203637                $html .= "<div class='admin_section_title'>"._("New node ID")." : </div>\n"; 
    204                  
     638 
    205639                $html .= "<div class='admin_section_data'>\n"; 
    206640                $name = "network_{$this->getId()}_new_node_id"; 
    207641                $html .= "<input type='text' size='10' name='{$name}'>\n"; 
    208                  
     642 
    209643                $html .= "<div class='admin_section_tools'>\n"; 
    210644                $name = "network_{$this->getId()}_create_node"; 
    211645                $html .= "<input type='submit' name='{$name}' value='"._("Create a new node")."'>\n"; 
    212646                $html .= "</div>\n"; 
    213                  
    214                 $html .= "</div>\n"; 
    215                 $html .= "</div>\n"; 
    216                  
     647 
     648                $html .= "</div>\n"; 
     649                $html .= "</div>\n"; 
     650 
    217651                // Content management            
    218652                $html .= "<div class='admin_section_container'>\n"; 
     
    242676                $html .= "</div>\n"; 
    243677                $html .= "</div>\n"; 
    244                  
     678 
    245679                return $html; 
    246680        } 
    247          
     681 
    248682        /** Process admin interface of this object. 
    249683        */ 
    250684        public function processAdminUI() 
    251685        { 
    252         $user = User::getCurrentUser(); 
    253         if (!$user->isSuperAdmin()) 
    254         { 
    255             throw new Exception(_('Access denied!')); 
    256         } 
    257          
    258         // Node creation 
    259         $create_new_node = "network_{$this->getId()}_create_node"; 
    260         $new_node_id = "network_{$this->getId()}_new_node_id"; 
    261         if (!empty ($_REQUEST[$create_new_node])) 
    262                 if(!empty ($_REQUEST[$new_node_id])) 
    263                 { 
    264                                 Node::createNewNode($_REQUEST[$new_node_id], $this); 
    265                                 $url = GENERIC_OBJECT_ADMIN_ABS_HREF."?".http_build_query(array("object_class" => "Node", "action" => "edit", "object_id" => $_REQUEST[$new_node_id])); 
     686                //pretty_print_r($_REQUEST); 
     687                $user = User :: getCurrentUser(); 
     688                if (!$user->isSuperAdmin()) 
     689                { 
     690                        throw new Exception(_('Access denied!')); 
     691                } 
     692 
     693                // name 
     694                $name = "network_".$this->getId()."_name"; 
     695                $this->setName($_REQUEST[$name]); 
     696                 
     697                // homepage_url 
     698                $name = "network_".$this->getId()."_homepage_url"; 
     699                $this->setHomepageURL($_REQUEST[$name]); 
     700 
     701 
     702                // tech_support_email 
     703                $name = "network_".$this->getId()."_tech_support_email"; 
     704                $this->setTechSupportEmail($_REQUEST[$name]); 
     705 
     706                //  network_authenticator_class 
     707                $name = "network_".$this->getId()."_network_authenticator_class"; 
     708                $this->setAuthenticatorClassName($_REQUEST[$name]); 
     709 
     710                //  network_authenticator_params 
     711                $name = "network_".$this->getId()."_network_authenticator_params"; 
     712                $this->setAuthenticatorConstructorParams($_REQUEST[$name]); 
     713                 
     714                //  is_default_network 
     715                $name = "network_".$this->getId()."_is_default_network"; 
     716                if($_REQUEST[$name]=='on') 
     717                        $this->setAsDefaultNetwork(); 
     718         
     719                //  validation_grace_time 
     720                $name = "network_".$this->getId()."_validation_grace_time"; 
     721                $this->setValidationGraceTime($_REQUEST[$name]); 
     722                         
     723                //  validation_email_from_address 
     724                $name = "network_".$this->getId()."_validation_email_from_address"; 
     725                $this->setValidationEmailFromAddress($_REQUEST[$name]);  
     726                 
     727                //  allow_multiple_login 
     728                $name = "network_".$this->getId()."_allow_multiple_login"; 
     729                $this->setMultipleLoginAllowed(empty($_REQUEST[$name])?false:true);      
     730                 
     731                //  allow_splash_only_nodes 
     732                $name = "network_".$this->getId()."_allow_splash_only_nodes"; 
     733                $this->setSplashOnlyNodesAllowed(empty($_REQUEST[$name])?false:true);    
     734 
     735                //  allow_custom_portal_redirect 
     736                $name = "network_".$this->getId()."_allow_custom_portal_redirect"; 
     737                $this->setCustomPortalRedirectAllowed(empty($_REQUEST[$name])?false:true);       
     738                                 
     739                // Node creation 
     740                $create_new_node = "network_{$this->getId()}_create_node"; 
     741                $new_node_id = "network_{$this->getId()}_new_node_id"; 
     742                if (!empty ($_REQUEST[$create_new_node])) 
     743                        if (!empty ($_REQUEST[$new_node_id])) 
     744                        { 
     745                                Node :: createNewNode($_REQUEST[$new_node_id], $this); 
     746                                $url = GENERIC_OBJECT_ADMIN_ABS_HREF."?".http_build_query(array ("object_class" => "Node", "action" => "edit", "object_id" => $_REQUEST[$new_node_id])); 
    266747                                header("Location: {$url}"); 
    267                 } 
     748                        } 
    268749                        else 
    269750                                echo _("You MUST enter a node ID."); 
    270                  
    271         // Content management 
     751 
     752                // Content management 
    272753                foreach ($this->getAllContent() as $content) 
    273754                { 
     
    284765                        $name = "network_{$this->id}_new_content"; 
    285766                        $content = Content :: processSelectContentUI($name); 
    286             if($content) 
    287                 $this->addContent($content); 
     767                        if ($content) 
     768                                $this->addContent($content); 
    288769                } 
    289770        } 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r706 r708  
    3333{ 
    3434        private $mRow; 
     35        private $mdB; /**< An AbstractDb instance */ 
    3536        private $id; 
    3637        private static $current_node_id = null; 
     
    251252 
    252253        /** @param $node_id The id of the node */ 
    253         function __construct($node_id) 
    254         { 
    255                 global $db; 
    256  
     254        private function __construct($node_id) 
     255        { 
     256                global $db; 
     257                $this->mDb = & $db; 
     258                 
    257259                $node_id_str = $db->EscapeString($node_id); 
    258260                $sql = "SELECT * FROM nodes WHERE node_id='$node_id_str'"; 
     
    263265                } 
    264266                $this->mRow = $row; 
    265                 $this->mDb = & $db; 
    266267                $this->id = $row['node_id']; 
    267268        } 
     
    269270        function getId() 
    270271        { 
    271                 return $this->mRow['node_id']; 
     272                return $this->id; 
     273        } 
     274 
     275        /** Gets the Network to which the node belongs  
     276         * @return Network object (never returns null) 
     277         */ 
     278        public function getNetwork() 
     279        { 
     280                        return Network::getObject($this->mRow['network_id']); 
    272281        } 
    273282 
  • trunk/wifidog-auth/wifidog/classes/SmartyWifidog.php

    r700 r708  
    116116        $this->assign('wifidog_logo_url', COMMON_CONTENT_URL.WIFIDOG_LOGO_NAME); 
    117117        $this->assign('wifidog_logo_banner_url',COMMON_CONTENT_URL.WIFIDOG_LOGO_BANNER_NAME); 
    118          
     118        $network = Network::GetCurrentNetwork(); 
    119119/* Usefull stuff from config.php */ 
    120         $this->assign('hotspot_network_name',HOTSPOT_NETWORK_NAME); 
    121         $this->assign('hotspot_network_url',HOTSPOT_NETWORK_URL); 
     120        $this->assign('hotspot_network_name',$network->getName()); 
     121        $this->assign('hotspot_network_url',$network->getHomepageURL()); 
    122122 
    123123     $this->assign('hotspot_logo_url', find_local_content_url(HOTSPOT_LOGO_NAME)); 
  • trunk/wifidog-auth/wifidog/classes/User.php

    r695 r708  
    126126        } 
    127127 
    128         /** 
    129          * Get the list of users associated with a username  
    130          * Since we cannot guarantee the uniqueness of (user, e-mail) key this will 
    131          * return an array. 
    132          *  
    133          * NB : This function will only extract users who authenticate 
    134          * through a LocalUserAuthenticator  
    135          * (see AuthenticatorLocalUser::getAllLocalUserAccountOrigins) 
    136          *  
    137          * @param $username : the username criterion 
    138          * @return array : array of User objects 
    139          */ 
    140         public static function getUsersByUsername($username) 
    141         { 
    142                 $users_list = array (); 
    143  
    144                 // E-mail cannot be empty, will return an empty array. 
    145                 if (!empty ($username)) 
    146                 { 
    147                         // Build SQL query, excluding users who do not authenticate through LocalUserAuth 
    148                         global $db; 
    149                         $username_str = $db->EscapeString($username); 
    150                         $sql = "SELECT user_id FROM users WHERE username = '$username_str'"; 
    151                         $first = true; 
    152                         foreach (array_keys(AuthenticatorLocalUser :: getAllLocalUserAccountOrigins()) as $account_origin) 
    153                         { 
    154                                 if ($first === true) 
    155                                 { 
    156                                         $sql .= " AND (account_origin = '$account_origin'"; 
    157                                         $first = false; 
    158                                 } 
    159                                 else 
    160                                         $sql .= " OR account_origin = '$account_origin'"; 
    161                         } 
    162                         if ($first === false) 
    163                                 $sql .= ")"; 
    164                         $db->ExecSql($sql, $users_rows, false); 
    165  
    166                         // Fill an array with User objects corresponding to those we just got 
    167                         if (!empty ($users_rows)) 
    168                                 foreach ($users_rows as $user_row) 
    169                                         $users_list[] = new User($user_row['user_id']); 
    170                 } 
    171  
    172                 return $users_list; 
    173         } 
    174  
    175         /** 
    176          * Get the list of users associated with an e-mail address 
    177          * Since we cannot guarantee the unicity of (user, e-mail) key 
    178          * this will return an array. 
    179          *  
    180          * NB : This function will only extract users who authenticate 
    181          * through a LocalUserAuthenticator  
    182          * (see AuthenticatorLocalUser::getAllLocalUserAccountOrigins) 
    183          *  
    184          * @param $email : the e-mail criterion 
    185          * @return array : array of User objects 
    186          */ 
    187         public static function getUsersByEmail($email) 
    188         { 
    189                 $users_list = array (); 
    190  
    191                 // E-mail cannot be empty, will return an empty array. 
    192                 if (!empty ($email)) 
    193                 { 
    194                         // Build SQL query, excluding users who do not authenticate through LocalUserAuth 
    195                         global $db; 
    196                         $email_str = $db->EscapeString($email); 
    197                         $sql = "SELECT user_id FROM users WHERE email = '$email_str'"; 
    198                         $first = true; 
    199                         foreach (array_keys(AuthenticatorLocalUser :: getAllLocalUserAccountOrigins()) as $account_origin) 
    200                         { 
    201                                 if ($first === true) 
    202                                 { 
    203                                         $sql .= " AND (account_origin = '$account_origin'"; 
    204                                         $first = false; 
    205                                 } 
    206                                 else 
    207                                         $sql .= " OR account_origin = '$account_origin'"; 
    208                         } 
    209                         if ($first === false) 
    210                                 $sql .= ")"; 
    211                         $db->ExecSql($sql, $users_rows, false); 
    212  
    213                         // Fill an array with User objects corresponding to those we just got 
    214                         if (!empty ($users_rows)) 
    215                                 foreach ($users_rows as $user_row) 
    216                                         $users_list[] = new User($user_row['user_id']); 
    217                 } 
    218  
    219                 return $users_list; 
    220         } 
    221  
    222128        /** Returns the hash of the password suitable for storing or comparing in the database.  This hash is the same one as used in NoCat 
    223129         * @return The 32 character hash. 
     
    275181                return $this->id; 
    276182        } 
     183         
     184        /** Gets the Network to which the user belongs  
     185         * @return Network object (never returns null) 
     186         */ 
     187        public function getNetwork() 
     188        { 
     189                        return Network::getObject($this->mRow['account_origin']); 
     190        } 
     191 
    277192 
    278193        /** Get a user display suitable for a user list.  Will include link to the user profile. */ 
     
    365280                        if ($account_status == ACCOUNT_STATUS_VALIDATION) 
    366281                        { 
    367                                 $sql = "SELECT CASE WHEN ((NOW() - reg_date) > interval '".VALIDATION_GRACE_TIME." minutes') THEN true ELSE false END AS validation_grace_time_expired FROM users WHERE (user_id='{$this->id}')"; 
     282                                $sql = "SELECT CASE WHEN ((NOW() - reg_date) > interval networks.validation_grace_time) THEN true ELSE false END AS validation_grace_time_expired, networks.validation_grace_time FROM users  JOIN networks ON (users.account_origin = networks.network_id) WHERE (user_id='{$this->id}')"; 
    368283                                $db->ExecSqlUniqueRes($sql, $user_info, false); 
    369284 
    370285                                if ($user_info['validation_grace_time_expired'] == 't') 
    371286                                { 
    372                                         $errmsg = _("Sorry, your ").VALIDATION_GRACE_TIME._(" minutes grace period to retrieve your email and validate your account has now expired. You will have to connect to the internet and validate your account from another location or create a new account. For help, please ").'<a href="'.BASEPATH.'faq.php'.'">'._("click here.").'</a>'; 
     287                                        $errmsg = sprintf(_("Sorry, your %s minutes grace period to retrieve your email and validate your account has now expired. You will have to connect to the internet and validate your account from another location or create a new account. For help, please %s click here %s."), $user_info['validation_grace_time_expired'], '<a href="'.BASEPATH.'faq.php'.'">', '</a>'); 
    373288                                        $retval = false; 
    374289                                } 
     
    520435        function sendLostUsername() 
    521436        { 
     437                $network = $this->getNetwork(); 
    522438                $username = $this->getUsername(); 
    523439                $headers = 'MIME-Version: 1.0'."\r\n"; 
    524440                $headers .= 'Content-type: text/plain; charset=UTF-8'."\r\n"; 
    525                 $headers .= "From: ".VALIDATION_EMAIL_FROM_ADDRESS; 
    526                 $subject = HOTSPOT_NETWORK_NAME._(" lost username request"); 
     441                $headers .= "From: ".$network->getValidationEmailFromAddress(); 
     442                $subject = $network->getName()._(" lost username request"); 
    527443                $body = _("Hello,\nYou have requested that the authentication server send you your username:\nUsername: ").$username._("\n\nHave a nice day,\nThe Team"); 
    528444 
     
    547463                        else 
    548464                        { 
     465                                $network = $this->getNetwork(); 
    549466                                $headers = 'MIME-Version: 1.0'."\r\n"; 
    550467                                $headers .= 'Content-type: text/plain; charset=UTF-8'."\r\n"; 
    551                                 $headers .= "From: ".VALIDATION_EMAIL_FROM_ADDRESS; 
    552                                 $subject = HOTSPOT_NETWORK_NAME._(" new user validation"); 
     468                                $headers .= "From: ".$network->getValidationEmailFromAddress(); 
     469                                $subject = $network->getName()._(" new user validation"); 
    553470                                $url = "http://".$_SERVER["SERVER_NAME"]."/validate.php?user_id=".$this->getId()."&token=".$this->getValidationToken(); 
    554471                                $body = _("Hello,\nPlease follow the link below to validate your account.\n").$url._("\n\nThank you,\nThe Team."); 
     
    565482        { 
    566483                global $db; 
    567  
     484                $network = $this->getNetwork(); 
    568485                $new_password = $this->randomPass(); 
    569486                $this->setPassword($new_password); 
     
    572489                $headers = 'MIME-Version: 1.0'."\r\n"; 
    573490                $headers .= 'Content-type: text/plain; charset=UTF-8'."\r\n"; 
    574                 $headers .= "From: ".VALIDATION_EMAIL_FROM_ADDRESS; 
    575                 $subject = HOTSPOT_NETWORK_NAME._(" new password request"); 
     491                $headers .= "From: ".$network->getValidationEmailFromAddress(); 
     492                $subject = $network->getName()._(" new password request"); 
    576493                $body = _("Hello,\nYou have requested that the authentication server send you a new password:\nUsername: ").$username._("\nPassword: ").$new_password._("\n\nHave a nice day,\nThe Team"); 
    577494 
  • trunk/wifidog-auth/wifidog/config.php

    r686 r708  
    1717define('SYSTEM_PATH', '/'); 
    1818/**< Set this to true if your server has SSL available, otherwise, passwords will be transmitted in clear text over the air */ 
    19 define('SSL_AVAILABLE', true); 
    20 /** @deprecated version - 2005-04-19 */ 
    21 define('HOTSPOT_NETWORK_NAME', 'Île sans fil'); 
    22 define('HOTSPOT_NETWORK_URL', 'http://www.ilesansfil.org/'); 
    23 define('TECH_SUPPORT_EMAIL', 'tech@ilesansfil.org'); 
    24 define('UNKNOWN_HOSTPOT_NAME', 'Unknown HotSpot'); 
     19define('SSL_AVAILABLE', false); 
    2520 
    26 define('VALIDATION_GRACE_TIME', 20); /**< Number of minutes after new account creation during which internet access is available to validate your account.  Once elapsed, you have to validate from home... */ 
    27 define('VALIDATION_EMAIL_FROM_ADDRESS', 'validation@ilesansfil.org'); 
    2821/* RSS support.  If set to true, MAGPIERSS must be installed in MAGPIE_REL_PATH */ 
    2922define('RSS_SUPPORT', true); 
     
    7164define('LOCAL_CONTENT_REL_PATH', 'local_content/');//Path to the directory containing the different node specific directories.  Relative to BASE_URL_PATH 
    7265 
    73 // Authentication sources section 
    74 /* The array index for the source must match the account_origin in the user table */ 
    75  
    76 // Local User authenticators 
    77 require_once BASEPATH.'classes/AuthenticatorLocalUser.php'; 
    78  
    79 /********************************************** 
    80  * BIG FAT WARNING 
    81  * DO NOT remove this authenticator under any circumstance 
    82  * you SHOULD NOT change its name either 
    83  * The system relies heavily on its main authenticator to do 
    84  * multiple tasks with users... 
    85  * ******************************************** 
    86  */ 
    87 define('LOCAL_USER_ACCOUNT_ORIGIN', 'LOCAL_USER'); 
    88 $AUTH_SOURCE_ARRAY[LOCAL_USER_ACCOUNT_ORIGIN]=array( 
    89                              'name'=>HOTSPOT_NETWORK_NAME, 
    90                              'authenticator'=>new AuthenticatorLocalUser(LOCAL_USER_ACCOUNT_ORIGIN)); 
    91                               
    92 // RADIUS authenticators ( see AuthenticatorRadius constuctor doc for details ) 
    93 /* 
    94 require_once BASEPATH.'classes/AuthenticatorRadius.php'; 
    95  
    96 define('IDRC_ACCOUNT_ORIGIN', 'IDRC_RADIUS_USER'); 
    97 $AUTH_SOURCE_ARRAY[IDRC_ACCOUNT_ORIGIN]=array( 
    98                              'name'=>"IDRC RADIUS Server", 
    99                              'authenticator'=>new AuthenticatorRadius(IDRC_ACCOUNT_ORIGIN, "192.168.0.11", 1812, 1813, "secret_key", "CHAP_MD5")); 
    100 */ 
    101  
    10266/*These are the file names of the different templates that can be put in the CONTENT_PATH/(node_id)/ folders */ 
    10367define('STYLESHEET_NAME', 'stylesheet.css'); 
  • trunk/wifidog-auth/wifidog/content/index.php

    r655 r708  
    2525define('BASEPATH', '../'); 
    2626require_once BASEPATH.'include/common.php'; 
     27require_once BASEPATH.'classes/MainUI.php'; 
    2728require_once BASEPATH.'include/common_interface.php'; 
    2829require_once BASEPATH.'classes/Node.php'; 
    29 require_once BASEPATH.'classes/MainUI.php'; 
    3030 
    3131if (CONF_USE_CRON_FOR_DB_CLEANUP == false) 
     
    9292$ui->setToolContent($tool_html); 
    9393 
    94 $hotspot_network_name = HOTSPOT_NETWORK_NAME; 
    95 $hotspot_network_url = HOTSPOT_NETWORK_URL; 
    96 $network_logo_url = COMMON_CONTENT_URL.NETWORK_LOGO_NAME; 
    97 $network_logo_banner_url = COMMON_CONTENT_URL.NETWORK_LOGO_BANNER_NAME; 
    98  
    9994$hotspot_logo_url = find_local_content_url(HOTSPOT_LOGO_NAME); 
    100 $hotspot_logo_banner_url = find_local_content_url(HOTSPOT_LOGO_BANNER_NAME); 
    10195 
    10296$html = ''; 
  • trunk/wifidog-auth/wifidog/hotspot_status.php

    r695 r708  
    6262                 
    6363                // Network metadata 
     64                $network = Network::getCurrentNetwork(); 
    6465                $network_metadata_node = $xmldoc->createElement("networkMetadata"); 
    6566                $network_metadata_node = $hotspot_status_root_node->appendChild($network_metadata_node); 
    66                 $network_name_node = $xmldoc->createElement("networkUri", htmlspecialchars(HOTSPOT_NETWORK_URL, ENT_QUOTES)); 
     67                $network_name_node = $xmldoc->createElement("networkUri", htmlspecialchars($network->getHomepageURL(), ENT_QUOTES)); 
    6768                $network_metadata_node->appendChild($network_name_node); 
    68                 $network_name_node = $xmldoc->createElement("name", htmlspecialchars(HOTSPOT_NETWORK_NAME, ENT_QUOTES)); 
     69                $network_name_node = $xmldoc->createElement("name", htmlspecialchars($network->getName(), ENT_QUOTES)); 
    6970                $network_metadata_node->appendChild($network_name_node); 
    70                 $network_url_node = $xmldoc->createElement("websiteUrl", htmlspecialchars(HOTSPOT_NETWORK_URL, ENT_QUOTES)); 
     71                $network_url_node = $xmldoc->createElement("websiteUrl", htmlspecialchars($network->getHomepageURL(), ENT_QUOTES)); 
    7172                $network_metadata_node->appendChild($network_url_node); 
    72                 $network_mail_node = $xmldoc->createElement("techSupportEmail", TECH_SUPPORT_EMAIL); 
    73                 $network_metadata_node->appendChild($network_mail_node); 
     73                $email = Network::GetCurrentNetwork()->getTechSupportEmail(); 
     74                if(!empty($email)) 
     75                { 
     76                        $network_mail_node = $xmldoc->createElement("techSupportEmail", $email); 
     77                        $network_metadata_node->appendChild($network_mail_node); 
     78                } 
    7479                $nodes_count_node = $xmldoc->createElement("hotspotsCount", count($node_results)); 
    7580                $network_metadata_node->appendChild($nodes_count_node); 
     
    9095                        foreach ($node_results as $node_row) 
    9196                        { 
     97                                $node=Node::getObject($node_row['node_id']); 
     98                                $network=$node->getNetwork(); 
    9299                                $hotspot = $xmldoc->createElement("hotspot"); 
    93100                                $hotspot = $hotspots_metadata_node->appendChild($hotspot); 
     
    299306                $title = $channel->appendChild($title); 
    300307 
    301                 $textnode = $xmldoc->createTextNode(HOTSPOT_NETWORK_NAME._(": Newest HotSpots")); 
     308                $textnode = $xmldoc->createTextNode($network->getName()._(": Newest HotSpots")); 
    302309                $title->appendChild($textnode); 
    303310 
     
    305312                $link = $xmldoc->createElement("link"); 
    306313                $channel->appendChild($link); 
    307                 $textnode = $xmldoc->createTextNode(HOTSPOT_NETWORK_URL); 
     314                $textnode = $xmldoc->createTextNode($network->getHomepageURL()); 
    308315                $link->appendChild($textnode); 
    309316 
     
    311318                $description = $xmldoc->createElement("description"); 
    312319                $channel->appendChild($description); 
    313                 $textnode = $xmldoc->createTextNode(_("WiFiDog list of the most recent HotSpots opened by the network: ").HOTSPOT_NETWORK_NAME); 
     320                $textnode = $xmldoc->createTextNode(_("WiFiDog list of the most recent HotSpots opened by the network: ").$network->getName()); 
    314321                $description->appendChild($textnode); 
    315322 
     
    325332                $copyright = $xmldoc->createElement("copyright"); 
    326333                $channel->appendChild($copyright); 
    327                 $textnode = $xmldoc->createTextNode(_("Copyright ").HOTSPOT_NETWORK_NAME); 
     334                $textnode = $xmldoc->createTextNode(_("Copyright ").$network->getName()); 
    328335                $copyright->appendChild($textnode); 
    329336 
    330337                /* managingEditor */ 
    331338 
     339 
    332340                /* webMaster */ 
    333  
    334                 $webMaster = $xmldoc->createElement("webMaster"); 
    335                 $channel->appendChild($webMaster); 
    336                 $textnode = $xmldoc->createTextNode(TECH_SUPPORT_EMAIL); 
    337                 $webMaster->appendChild($textnode); 
     341                $email = Network::GetCurrentNetwork()->getTechSupportEmail(); 
     342                if(!empty($email)) 
     343                { 
     344                        $webMaster = $xmldoc->createElement("webMaster"); 
     345                        $channel->appendChild($webMaster); 
     346                        $textnode = $xmldoc->createTextNode($email); 
     347                        $webMaster->appendChild($textnode); 
     348                } 
    338349 
    339350                /* pubDate */ 
     
    383394                $title = $xmldoc->createElement("title"); 
    384395                $image->appendChild($title); 
    385                 $textnode = $xmldoc->createTextNode(HOTSPOT_NETWORK_NAME); 
     396                $textnode = $xmldoc->createTextNode($network->getName()); 
    386397                $title->appendChild($textnode); 
    387398                /* url */ 
     
    393404                $link = $xmldoc->createElement("link"); 
    394405                $image->appendChild($link); 
    395                 $textnode = $xmldoc->createTextNode(HOTSPOT_NETWORK_URL); 
     406                $textnode = $xmldoc->createTextNode($network->getHomepageURL()); 
    396407                $link->appendChild($textnode); 
    397408                /* width */ 
     
    553564                                $guid->setAttribute('isPermaLink', 'false'); 
    554565                                $item->appendChild($guid); 
    555                                 $textnode = $xmldoc->createTextNode(HOTSPOT_NETWORK_URL.$node_row['node_id']); 
     566                                $textnode = $xmldoc->createTextNode($network->getHomepageURL().$node_row['node_id']); 
    556567                                $guid->appendChild($textnode); 
    557568 
     
    589600                $title = $channel->appendChild($title); 
    590601 
    591                 $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME._(": Newest HotSpots"))); 
     602                $textnode = $xmldoc->createTextNode(utf8_encode($network->getName()._(": Newest HotSpots"))); 
    592603                $title->appendChild($textnode); 
    593604 
     
    595606                $link = $xmldoc->createElement("link"); 
    596607                $channel->appendChild($link); 
    597                 $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); 
     608                $textnode = $xmldoc->createTextNode(utf8_encode($network->getHomepageURL())); 
    598609                $link->appendChild($textnode); 
    599610 
     
    601612                $description = $xmldoc->createElement("description"); 
    602613                $channel->appendChild($description); 
    603                 $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by the network: ").HOTSPOT_NETWORK_NAME)); 
     614                $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by the network: ").$network->getName())); 
    604615                $description->appendChild($textnode); 
    605616 
     
    615626                $copyright = $xmldoc->createElement("copyright"); 
    616627                $channel->appendChild($copyright); 
    617                 $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").HOTSPOT_NETWORK_NAME)); 
     628                $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").$network->getName())); 
    618629                $copyright->appendChild($textnode); 
    619630 
     
    621632 
    622633                /* webMaster */ 
    623  
    624                 $webMaster = $xmldoc->createElement("webMaster"); 
    625                 $channel->appendChild($webMaster); 
    626                 $textnode = $xmldoc->createTextNode(utf8_encode(TECH_SUPPORT_EMAIL)); 
    627                 $webMaster->appendChild($textnode); 
    628  
     634                $email = Network::GetCurrentNetwork()->getTechSupportEmail(); 
     635                if(!empty($email)) 
     636                { 
     637                        $webMaster = $xmldoc->createElement("webMaster"); 
     638                        $channel->appendChild($webMaster); 
     639                        $textnode = $xmldoc->createTextNode($email); 
     640                        $webMaster->appendChild($textnode); 
     641                } 
     642                 
    629643                /* pubDate */ 
    630644                $pubDate = $xmldoc->createElement("pubDate"); 
     
    673687                $title = $xmldoc->createElement("title"); 
    674688                $image->appendChild($title); 
    675                 $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME)); 
     689                $textnode = $xmldoc->createTextNode(utf8_encode($network->getName())); 
    676690                $title->appendChild($textnode); 
    677691                /* url */ 
     
    683697                $link = $xmldoc->createElement("link"); 
    684698                $image->appendChild($link); 
    685                 $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); 
     699                $textnode = $xmldoc->createTextNode(utf8_encode($network->getHomepageURL())); 
    686700                $link->appendChild($textnode); 
    687701                /* width */ 
     
    808822                                $guid->setAttribute('isPermaLink', 'false'); 
    809823                                $item->appendChild($guid); 
    810                                 $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL.$node_row['node_id'])); 
     824                                $textnode = $xmldoc->createTextNode(utf8_encode($network->getHomepageURL().$node_row['node_id'])); 
    811825                                $guid->appendChild($textnode); 
    812826 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r699 r708  
    2828require_once BASEPATH.'classes/AbstractDb.php'; 
    2929require_once BASEPATH.'classes/Session.php'; 
    30 define('REQUIRED_SCHEMA_VERSION', 25); 
     30define('REQUIRED_SCHEMA_VERSION', 26); 
    3131 
    3232/** Check that the database schema is up to date.  If it isn't, offer to update it. */ 
     
    3434{ 
    3535        global $db; 
    36  
    37         //check_users_not_empty(); 
    3836        $db->ExecSqlUniqueRes("SELECT * FROM schema_info WHERE tag='schema_version'", $row, false); 
    3937        if (empty ($row)) 
     
    7472{ 
    7573        // Extract the first account origin, assume it's the default 
    76         global $AUTH_SOURCE_ARRAY; 
    77         if (!empty ($AUTH_SOURCE_ARRAY)) 
    78         { 
    79                 $default_account_origin = array_values(array_keys($AUTH_SOURCE_ARRAY)); 
    80                 $default_account_origin = $default_account_origin[0]; 
    81         } 
    82  
    83         if (!empty ($default_account_origin)) 
     74        $network = Network::getDefaultNetwork(); 
     75        if (!empty ($network)) 
    8476        { 
    8577                global $db; 
    86                 $db->ExecSqlUniqueRes("SELECT user_id FROM users WHERE account_origin = '$default_account_origin' LIMIT 1", $row, false); 
     78                $db->ExecSqlUniqueRes("SELECT user_id FROM users WHERE account_origin = '{$network->getId()}' LIMIT 1", $row, false); 
    8779                if ($row == null) 
    8880                { 
    8981                        echo "<html><head><h1>"; 
    90                         echo _("No user matches the default account origin, a new user admin/admin will be created. Change the password as soon as possible !"); 
     82                        echo _("No user matches the default network, a new user admin/admin will be created. Change the password as soon as possible !"); 
    9183                        echo "</html></head>"; 
    9284                        $sql = "BEGIN;"; 
     
    10193        { 
    10294                echo "<html><head><h1>"; 
    103                 echo _("Could not get a default account origin, make sure you config.php has at least one AUTH_SOURCE_ARRAY entry."); 
     95                echo _("Could not get a default network!"); 
    10496                echo "</html></head>"; 
    10597                exit (); 
     
    134126                        { 
    135127                                $user_id = $db->EscapeString($row['user_id']); 
    136                                 $sql .= "UPDATE users SET username='$user_id', user_id='".get_guid()."', account_origin='".LOCAL_USER_ACCOUNT_ORIGIN."' WHERE user_id='$user_id';\n"; 
     128                                $sql .= "UPDATE users SET username='$user_id', user_id='".get_guid()."', account_origin='LOCAL_USER' WHERE user_id='$user_id';\n"; 
    137129                        } 
    138130                        $sql .= "CREATE UNIQUE INDEX idx_unique_username_and_account_origin ON users (username, account_origin);\n"; 
     
    567559                        $sql .= "DROP TABLE node_tech_officers;\n"; 
    568560                } 
    569                  
     561                         
     562                $new_schema_version = 26; 
     563                if ($schema_version < $new_schema_version) 
     564                { 
     565                        echo "<h2>Preparing SQL statements to update schema to version  $new_schema_version</h2>\n"; 
     566                        $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 
     567                        $sql .= "CREATE TABLE networks ( \n"; 
     568                        $sql .= "  network_id text NOT NULL PRIMARY KEY,\n"; 
     569                        $sql .= "  network_authenticator_class text NOT NULL CHECK (network_authenticator_class<>''),\n"; 
     570                        $sql .= "  network_authenticator_params text,\n"; 
     571                        $sql .= "  is_default_network boolean NOT NULL DEFAULT FALSE,\n"; 
     572                        $sql .= "  name text NOT NULL DEFAULT 'Unnamed network' CHECK (name<>''),\n"; 
     573                        $sql .= "  creation_date date NOT NULL DEFAULT now(),\n"; 
     574                        $sql .= "  homepage_url text,\n"; 
     575                        $sql .= "  tech_support_email text,\n"; 
     576                        $sql .= "  validation_grace_time interval NOT NULL DEFAULT '1200 seconds',\n"; 
     577                        $sql .= "  validation_email_from_address text NOT NULL CHECK (validation_email_from_address<>'') DEFAULT 'validation@wifidognetwork',\n"; 
     578                        $sql .= "  allow_multiple_login BOOLEAN NOT NULL DEFAULT FALSE,\n"; 
     579                        $sql .= "  allow_splash_only_nodes BOOLEAN NOT NULL DEFAULT FALSE,\n"; 
     580                        $sql .= "  allow_custom_portal_redirect BOOLEAN NOT NULL DEFAULT FALSE\n"; 
     581                        $sql .= ");\n"; 
     582                        $sql .= "INSERT INTO networks (network_id, network_authenticator_class, network_authenticator_params) SELECT  account_origin, COALESCE('AuthenticatorLocalUser') as network_authenticator_class, account_origin FROM users GROUP BY (account_origin) ORDER BY min(reg_date);\n"; 
     583                        $sql .= "UPDATE networks SET is_default_network=TRUE WHERE network_id=(SELECT account_origin FROM users GROUP BY (account_origin) ORDER BY min(reg_date) LIMIT 1);\n"; 
     584                        $sql .= "ALTER TABLE users ADD CONSTRAINT account_origin_fkey FOREIGN KEY (account_origin) REFERENCES networks (network_id) ON UPDATE CASCADE ON DELETE RESTRICT;\n"; 
     585                        $sql .= "ALTER TABLE nodes ADD COLUMN network_id text; \n"; 
     586                        $sql .= "UPDATE nodes SET network_id=(SELECT account_origin FROM users GROUP BY (account_origin) ORDER BY min(reg_date) LIMIT 1);\n";                    
     587                        $sql .= "ALTER TABLE nodes ALTER COLUMN network_id SET NOT NULL; \n"; 
     588                        $sql .= "ALTER TABLE nodes ADD CONSTRAINT network_id_fkey FOREIGN KEY (network_id) REFERENCES networks ON UPDATE CASCADE ON DELETE RESTRICT;\n"; 
     589                        $sql .= "ALTER TABLE network_has_content ADD CONSTRAINT network_id_fkey FOREIGN KEY (network_id) REFERENCES networks ON UPDATE CASCADE ON DELETE CASCADE;\n"; 
     590 
     591                        $sql .= "CREATE TABLE network_stakeholders ( \n"; 
     592                        $sql .= "  network_id text REFERENCES networks,\n"; 
     593                        $sql .= "  user_id VARCHAR(45) REFERENCES users,\n"; 
     594                        $sql .= "  is_admin BOOLEAN NOT NULL DEFAULT FALSE,\n"; 
     595                        $sql .= "  is_stat_viewer BOOLEAN NOT NULL DEFAULT FALSE,\n"; 
     596                        $sql .= "PRIMARY KEY (network_id, user_id)\n"; 
     597                        $sql .= ");\n"; 
     598                } 
    570599                $db->ExecSqlUpdate("BEGIN;\n$sql\nCOMMIT;\n", true); 
    571600                //$db->ExecSqlUpdate("BEGIN;\n$sql\nROLLBACK;\n", true); 
  • trunk/wifidog-auth/wifidog/index.php

    r673 r708  
    2626define('BASEPATH', './'); 
    2727require_once BASEPATH.'include/common.php'; 
     28require_once BASEPATH.'classes/MainUI.php'; 
    2829require_once BASEPATH.'include/common_interface.php'; 
    2930require_once BASEPATH.'classes/Node.php'; 
    30 require_once BASEPATH.'classes/MainUI.php'; 
    3131 
    3232$num_valid_users = $stats->getNumValidUsers(); 
  • trunk/wifidog-auth/wifidog/install.php

    r698 r708  
    12371237    print "<H1>Network</H1>"; 
    12381238 
    1239     $HOTSPOT_NETWORK_NAME          = $configArray['HOTSPOT_NETWORK_NAME']; 
    1240     $HOTSPOT_NETWORK_URL           = $configArray['HOTSPOT_NETWORK_URL']; 
    1241     $TECH_SUPPORT_EMAIL            = $configArray['TECH_SUPPORT_EMAIL']; 
    1242     //$UNKNOWN_HOSTPOT_NAME          = $configArray['UNKNOWN_HOSTPOT_NAME']; 
    1243     $VALIDATION_GRACE_TIME         = $configArray['VALIDATION_GRACE_TIME']; 
    1244     $VALIDATION_EMAIL_FROM_ADDRESS = $configArray['VALIDATION_EMAIL_FROM_ADDRESS'];     
     1239    //$HOTSPOT_NETWORK_NAME          = $configArray['HOTSPOT_NETWORK_NAME']; 
     1240    //$HOTSPOT_NETWORK_URL           = $configArray['HOTSPOT_NETWORK_URL']; 
     1241    //$TECH_SUPPORT_EMAIL            = $configArray['TECH_SUPPORT_EMAIL']; 
     1242    //$VALIDATION_GRACE_TIME         = $configArray['VALIDATION_GRACE_TIME']; 
     1243    //$VALIDATION_EMAIL_FROM_ADDRESS = $configArray['VALIDATION_EMAIL_FROM_ADDRESS'];     
    12451244 
    12461245    print <<< EndHTML 
     
    12661265<script type="text/javascript"> 
    12671266  function submitOptionsValue() { 
    1268     newConfig("HOTSPOT_NETWORK_NAME='" + document.myform.HOTSPOT_NETWORK_NAME.value + "'"); 
    1269     newConfig("HOTSPOT_NETWORK_URL='" + document.myform.HOTSPOT_NETWORK_URL.value + "'"); 
    1270     newConfig("TECH_SUPPORT_EMAIL='" + document.myform.TECH_SUPPORT_EMAIL.value + "'"); 
    1271    /* newConfig("UNKNOWN_HOSTPOT_NAME='" + document.myform.UNKNOWN_HOSTPOT_NAME.value + "'"); */ 
    1272     newConfig("VALIDATION_GRACE_TIME=" + document.myform.VALIDATION_GRACE_TIME.value); 
    1273     newConfig("VALIDATION_EMAIL_FROM_ADDRESS='" + document.myform.VALIDATION_EMAIL_FROM_ADDRESS.value + "'"); 
     1267    //newConfig("HOTSPOT_NETWORK_NAME='" + document.myform.HOTSPOT_NETWORK_NAME.value + "'"); 
     1268    //newConfig("HOTSPOT_NETWORK_URL='" + document.myform.HOTSPOT_NETWORK_URL.value + "'"); 
     1269    //newConfig("TECH_SUPPORT_EMAIL='" + document.myform.TECH_SUPPORT_EMAIL.value + "'"); 
     1270    //newConfig("VALIDATION_GRACE_TIME=" + document.myform.VALIDATION_GRACE_TIME.value); 
     1271    //newConfig("VALIDATION_EMAIL_FROM_ADDRESS='" + document.myform.VALIDATION_EMAIL_FROM_ADDRESS.value + "'"); 
    12741272  } 
    12751273</script> 
     
    14191417 
    14201418<B>Create the wifidog database</B> 
    1421 <PRE>  <I>postgres@yourserver $></I> createdb -O wifidog wifidog 
     1419<PRE>  <I>postgres@yourserver $></I> createdb wifidog --encoding=UTF-8 --owner=wifidog 
    14221420  CREATE DATABASE  
    14231421</PRE> 
  • trunk/wifidog-auth/wifidog/login/index.php

    r655 r708  
    7878} 
    7979 
    80 // Add the auth servers list to smarty variables 
    81 isset ($AUTH_SOURCE_ARRAY) && $smarty->assign('auth_sources', $AUTH_SOURCE_ARRAY); 
    82 // Pass the account_origin along, if it's set 
    83 isset ($_REQUEST["auth_source"]) && $smarty->assign('selected_auth_source', $_REQUEST["auth_source"]); 
    84  
    8580$node = null; 
    8681if (!empty ($_REQUEST['gw_id'])) 
     
    9287                $node = Node :: getObject($_REQUEST['gw_id']); 
    9388                $hotspot_name = $node->getName(); 
     89                $network = $node->getNetwork(); 
    9490        } 
    9591        catch (Exception $e) 
     
    10399{ 
    104100        /* Gateway ID is not set... Virtual login */ 
     101        $network = Network::getCurrentNetwork(); 
    105102} 
    106103 
     
    174171 
    175172// HTML body 
    176 $hotspot_network_name = HOTSPOT_NETWORK_NAME; 
    177 $hotspot_network_url = HOTSPOT_NETWORK_URL; 
     173$hotspot_network_name = $network->getName(); 
     174$hotspot_network_url = $network->getHomepageURL(); 
    178175$network_logo_banner_url = COMMON_CONTENT_URL.NETWORK_LOGO_BANNER_NAME; 
    179176 
  • trunk/wifidog-auth/wifidog/lost_password.php

    r567 r708  
    3636        $username = $db->EscapeString($_REQUEST['username']); 
    3737        $email = $db->EscapeString($_REQUEST['email']); 
    38         // If the source is present and that it's in our AUTH_SOURCE_ARRAY, save it to a var for later use 
    39                 $_REQUEST['auth_source'] && in_array($_REQUEST['auth_source'], array_keys($AUTH_SOURCE_ARRAY)) && $account_origin = $_REQUEST['auth_source']; 
     38 
     39                $account_origin = Network::getObject($_REQUEST['auth_source']); 
    4040 
    4141        try { 
     
    6969$sources = array (); 
    7070// Preserve keys 
    71 foreach (array_keys($AUTH_SOURCE_ARRAY) as $auth_source_key) 
    72         if ($AUTH_SOURCE_ARRAY[$auth_source_key]['authenticator']->isRegistrationPermitted()) 
    73                 $sources[$auth_source_key] = $AUTH_SOURCE_ARRAY[$auth_source_key]; 
    74  
     71$network_array=Network::getAllNetworks(); 
     72foreach ($network_array as $network) 
     73        if ($network->getAuthenticator()->isRegistrationPermitted()) 
     74                $sources[$network->getId()] = $network->getName(); 
     75                 
    7576isset ($sources) && $smarty->assign('auth_sources', $sources); 
    7677// Pass the account_origin along, if it's set 
    7778isset ($_REQUEST["auth_source"]) && $smarty->assign('selected_auth_source', $_REQUEST["auth_source"]); 
    7879 
    79 //$smarty->display("templates/lost_password.html"); 
    8080$ui = new MainUI(); 
    8181$smarty->assign('SelectNetworkUI', Network::getSelectNetworkUI('auth_source')); 
  • trunk/wifidog-auth/wifidog/lost_username.php

    r567 r708  
    3131 
    3232if (isset($_REQUEST["submit"])) { 
    33         // If the source is present and that it's in our AUTH_SOURCE_ARRAY, save it to a var for later use 
    34         $_REQUEST['auth_source'] && in_array($_REQUEST['auth_source'], array_keys($AUTH_SOURCE_ARRAY)) && $account_origin = $_REQUEST['auth_source']; 
    35          
     33                $account_origin = Networt::getObject($_REQUEST['auth_source']);  
    3634    try { 
    3735        if(empty($account_origin)) 
     
    6159$sources = array (); 
    6260// Preserve keys 
    63 foreach (array_keys($AUTH_SOURCE_ARRAY) as $auth_source_key) 
    64         if ($AUTH_SOURCE_ARRAY[$auth_source_key]['authenticator']->isRegistrationPermitted()) 
    65                 $sources[$auth_source_key] = $AUTH_SOURCE_ARRAY[$auth_source_key]; 
    66  
     61$network_array=Network::getAllNetworks(); 
     62foreach ($network_array as $network) 
     63        if ($network->getAuthenticator()->isRegistrationPermitted()) 
     64                $sources[$network->getId()] = $network->getName(); 
     65                 
    6766isset ($sources) && $smarty->assign('auth_sources', $sources); 
    6867// Pass the account_origin along, if it's set 
    6968isset ($_REQUEST["auth_source"]) && $smarty->assign('selected_auth_source', $_REQUEST["auth_source"]); 
    7069 
    71 //$smarty->display("templates/lost_username.html"); 
    7270$ui = new MainUI(); 
    7371$smarty->assign('SelectNetworkUI', Network::getSelectNetworkUI('auth_source')); 
  • trunk/wifidog-auth/wifidog/portal/index.php

    r655 r708  
    6666if ($current_node != null) 
    6767{ 
     68        $network = $node->getNetwork(); 
    6869        $current_node_id = $current_node->getId(); 
    6970        $online_users = $current_node->getOnlineUsers(); 
     
    8485else 
    8586{ 
     87        $network = Network::getCurrentNetwork(); 
    8688        $current_node_id = null; 
    8789        $tool_html .= _("You are not currently at a hotspot..."); 
     
    204206$ui->setToolContent($tool_html); 
    205207 
    206 $hotspot_network_name = HOTSPOT_NETWORK_NAME; 
    207 $hotspot_network_url = HOTSPOT_NETWORK_URL; 
     208$hotspot_network_name = $network->getName(); 
     209$hotspot_network_url = $network->getHomepageURL(); 
    208210$network_logo_url = COMMON_CONTENT_URL.NETWORK_LOGO_NAME; 
    209211$network_logo_banner_url = COMMON_CONTENT_URL.NETWORK_LOGO_BANNER_NAME; 
  • trunk/wifidog-auth/wifidog/resend_validation.php

    r567 r708  
    3434        $smarty->assign("error", _("Please specify a username")); 
    3535    } else { 
    36         // If the source is present and that it's in our AUTH_SOURCE_ARRAY, save it to a var for later use 
    37                 $_REQUEST['auth_source'] && in_array($_REQUEST['auth_source'], array_keys($AUTH_SOURCE_ARRAY)) && $account_origin = $_REQUEST['auth_source']; 
    38                  
     36                $account_origin = Networt::getObject($_REQUEST['auth_source']);          
    3937        try { 
    4038                if(empty($account_origin)) 
     
    6260$sources = array (); 
    6361// Preserve keys 
    64 foreach (array_keys($AUTH_SOURCE_ARRAY) as $auth_source_key) 
    65         if ($AUTH_SOURCE_ARRAY[$auth_source_key]['authenticator']->isRegistrationPermitted()) 
    66                 $sources[$auth_source_key] = $AUTH_SOURCE_ARRAY[$auth_source_key]; 
     62$network_array=Network::getAllNetworks(); 
     63foreach ($network_array as $network) 
     64        if ($network->getAuthenticator()->isRegistrationPermitted()) 
     65                $sources[$network->getId()] = $network->getName(); 
    6766                 
    6867isset ($sources) && $smarty->assign('auth_sources', $sources); 
  • trunk/wifidog-auth/wifidog/signup.php

    r642 r708  
    8181        $smarty->assign('username', $username); 
    8282        $smarty->assign('email', $email); 
    83         // If the source is present and that it's in our AUTH_SOURCE_ARRAY, save it to a var for later use 
    84         $_REQUEST['auth_source'] && in_array($_REQUEST['auth_source'], array_keys($AUTH_SOURCE_ARRAY)) && $account_origin = $_REQUEST['auth_source']; 
    85  
     83                $account_origin = Networt::getObject($_REQUEST['auth_source']); 
    8684        try 
    8785        { 
     
    136134        } 
    137135} 
    138  
    139136// Add the auth servers list to smarty variables 
    140137$sources = array (); 
    141138// Preserve keys 
    142 foreach (array_keys($AUTH_SOURCE_ARRAY) as $auth_source_key) 
    143         if ($AUTH_SOURCE_ARRAY[$auth_source_key]['authenticator']->isRegistrationPermitted()) 
    144                 $sources[$auth_source_key] = $AUTH_SOURCE_ARRAY[$auth_source_key]; 
    145  
     139$network_array=Network::getAllNetworks(); 
     140foreach ($network_array as $network) 
     141        if ($network->getAuthenticator()->isRegistrationPermitted()) 
     142                $sources[$network->getId()] = $network->getName(); 
     143                 
    146144isset ($sources) && $smarty->assign('auth_sources', $sources); 
    147145// Pass the account_origin along, if it's set 
    148146isset ($_REQUEST["auth_source"]) && $smarty->assign('selected_auth_source', $_REQUEST["auth_source"]); 
    149147 
    150 //$smarty->display("templates/signup.html"); 
    151148$ui = new MainUI(); 
    152149$smarty->assign('SelectNetworkUI', Network::getSelectNetworkUI('auth_source'));