Changeset 708

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

2005-09-01 Benoit Gr�goire <bock@step.polymtl.ca>

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
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 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  
    2121  /**@file node_list.php 
    2222   * Network status page 
    23    * @author Copyright (C) 2004 Benoit Gr�ire 
     23   * @author Copyright (C) 2004 Benoit Gr�goire 
    2424   */ 
    2525define('BASEPATH','../'); 
    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                $h