Changeset 1453

Show
Ignore:
Timestamp:
02/25/10 15:56:33 (2 years ago)
Author:
gbastien
Message:
  • Added possibility to have a deployed geolocated node not show on map (quick fix) (#706)
  • When producing anonymised data export, two files are produced, one for the geolocated nodes and one for the connections (#705)
  • Additions and bug fixes to web service: can now logout and auth returns both error code and message
  • Starting work on #707 as needed
Location:
trunk/wifidog-auth
Files:
12 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1440 r1453  
    11# $Id$ 
     2 
     32010-02-25 Geneviève Bastien <gbastien@versatic.net> 
     4 * Added constraint to hotspot_graph_element_has_content (#701) 
     5 * Bug fix: when creating new nodes and node groups, they are now automatically added as children of the network in the new hierarchy structure. 
     6 * Added possibility to have a deployed geolocated node not show on map (quick fix) (#706) 
     7 * When producing anonymised data export, two files are produced, one for the geolocated nodes and one for the connections (#705) 
     8 * Additions and bug fixes to web service: can now logout and auth returns both error code and message 
     9 * Starting work on #707 as needed 
    210 
    3112010-01-28 Geneviève Bastien <gbastien@versatic.net> 
  • trunk/wifidog-auth/wifidog/admin/stats.php

    r1292 r1453  
    8383                $stats_title = _("Network information for")." '".$networkObject->getName()."'"; 
    8484        } 
     85        elseif (isset($_REQUEST['file']) && isset($_REQUEST['type'])) { 
     86            $filename = $_REQUEST['file']; 
     87            $type = $_REQUEST['type']; 
     88            if (User :: getCurrentUser()->DEPRECATEDisSuperAdmin())  { 
     89            // The file is valid for one hour, because it contains sensitive data and we don't want to open a security breach 
     90            if (file_exists($filename) && (filectime($filename) > (time() - 60*60)) ) { 
     91                header('Content-Type: application/octet-stream'); 
     92              header('Content-Disposition: inline; filename="anonymised_'.$type.'.sql"'); 
     93              header("Content-Transfer-Encoding: binary"); 
     94              header("Pragma: no-cache"); 
     95              header("Expires: 0"); 
     96              $fp=fopen($filename,"r"); 
     97              print fread($fp,filesize($filename)); 
     98              fclose($fp); 
     99              exit(); 
     100            } else { 
     101                if (!file_exists($filename)) { 
     102                    throw new Exception(sprintf(_("File %s does not exist"),  $filename)); 
     103                } 
     104                if (filectime($filename) > (time() - 60*60)) { 
     105                    throw new Exception(sprintf(_("The statistics file for anonymised_%s.sql has expired."), $type)); 
     106                } 
     107            } 
     108            } else { 
     109                throw new Exception(_("These reports are only available to server administrators.")); 
     110            } 
     111        } 
    85112        else { 
    86113            $stats_title = null; 
  • trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLocalUser.php

    r1428 r1453  
    101101     * @param string $password Clear text password. 
    102102     * @param string $errmsg   Reference of error message 
     103     * @param int $errno       Reference to error code 
    103104     * 
    104105     * @return object The actual User object if login was successfull, false 
    105106     *                otherwise. 
    106107     */ 
    107     public function login($username, $password, &$errmsg = null) 
     108    public function login($username, $password, &$errmsg = null, &$errno = 0) 
    108109    { 
    109110        //echo "DEBUG:  login($username, $password, $errmsg)<br/>"; 
     
    115116        $username = $db->escapeString($username); 
    116117        if (empty($username)) { 
    117             $errmsg .= sprintf(_("Fatal error:  Username cannot be empty")); 
     118            $errmsg .= sprintf(getErrorText(ERR_NO_USERNAME)); 
     119            $errno = ERR_NO_USERNAME; 
    118120            $retval = false; 
    119121        } 
     
    131133                $user = User::getObject($user_info['user_id']); 
    132134 
    133                 if ($user->isUserValid($errmsg)) { 
     135                if ($user->isUserValid($errmsg, $errno)) { 
    134136                    $retval = &$user; 
    135137                    $errmsg = _("Login successfull"); 
     
    147149 
    148150                if ($user_info == null) { 
    149                     $errmsg = _('Unknown username or email'); 
     151                    $errmsg = getErrorText(ERR_UNKNOWN_USERNAME); 
     152                    $errno = ERR_UNKNOWN_USERNAME; 
    150153                } else { 
    151                     $errmsg = _('Incorrect password (Maybe you have CAPS LOCK on?)'); 
     154                    $errmsg = getErrorText(ERR_WRONG_PASSWORD); 
     155                    $errno = ERR_WRONG_PASSWORD; 
    152156                } 
    153157 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r1444 r1453  
    825825        $this->refresh(); 
    826826    } 
    827  
     827     
     828    /** 
     829     * Returns whether the node should be shown on a map or is invisible 
     830     * 
     831     */ 
     832 
     833    public function showOnMap() 
     834    { 
     835        return (($this->_row['show_node_on_map'] == 't') ? true : false); 
     836    } 
     837 
     838    /** Set if this node be shown on map 
     839     * @param $value The new value, true or false 
     840     * @return true on success, false on failure */ 
     841    function setShowOnMap($value) 
     842    { 
     843        $retval = true; 
     844        if ($value != $this->showOnMap()) 
     845        { 
     846            $db = AbstractDb::getObject(); 
     847            $value ? $value = 'TRUE' : $value = 'FALSE'; 
     848            $retval = $db->execSqlUpdate("UPDATE nodes SET show_node_on_map = {$value} WHERE node_id = '{$this->getId()}'", false); 
     849            $this->refresh(); 
     850        } 
     851        return $retval; 
     852    } 
     853     
    828854    public function getCivicNumber() 
    829855    { 
     
    13071333        $_data = InterfaceElements::generateInputText("node_" . $node_id . "_map_url", $this->getMapURL(), "node_map_url_input"); 
    13081334        $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_map_url", $_title, $_data); 
     1335         
     1336        $_title = _("Show node on map"); 
     1337        $help = _("Should this node be visible on the map when deployed?"); 
     1338        $_data = InterfaceElements::generateInputCheckbox("node_" . $node_id . "_show_on_map", "", _("Yes"), $this->showOnMap(), "node_show_on_map_input"); 
     1339        $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_show_on_map", $_title, $_data, $help); 
    13091340 
    13101341        // Build section 
     
    15091540            $this->setGisLocation(new GisPoint($_REQUEST[$gis_lat_name], $_REQUEST[$gis_long_name], .0)); 
    15101541        } 
     1542         
     1543        $name = "node_".$node_id."_show_on_map"; 
     1544        $this->setShowOnMap(empty ($_REQUEST[$name]) ? false : true); 
    15111545 
    15121546        // Statistics 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListXML.php

    r1421 r1453  
    331331                    $_hotspotGis->setAttribute("lat", $_gisData->getLatitude()); 
    332332                    $_hotspotGis->setAttribute("long", $_gisData->getLongitude()); 
     333                    $_hotspotGis->setAttribute("show", $_node->showOnMap()); 
    333334                    $_hotspot->appendChild($_hotspotGis); 
    334335                } 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/AnonymisedDataExport.php

    r1421 r1453  
    9999        else 
    100100        { 
    101             header('Content-Type: application/octet-stream'); 
    102             header('Content-Disposition: inline; filename="anonymised_data.sql"'); 
    103             header("Content-Transfer-Encoding: binary"); 
    104  
    105             $html  .= <<<EOT 
    106             CREATE TABLE connections_anonymised 
    107             ( 
    108             conn_id text NOT NULL, 
    109             timestamp_in timestamp, 
    110             node_id text, 
    111             timestamp_out timestamp, 
    112             user_id text NOT NULL DEFAULT '', 
    113             user_mac text, 
    114             incoming int8, 
    115             outgoing int8 
    116             ); 
     101            /** Starting   sql file with geolocation data */ 
     102            $tmpdir = sys_get_temp_dir(); 
     103            $nodefile = tempnam($tmpdir, 'wd'); 
     104            $nfilehndl = fopen($nodefile, 'w'); 
     105            $datafile = tempnam($tmpdir, 'wd'); 
     106            $datahndl = fopen($datafile, 'w'); 
     107             
     108            if (!$nfilehndl || !$datahndl) { 
     109                $html .= "<p class='error'>"._("Could not create files for anonymised data")."</p>"; 
     110                 
     111            } else { 
     112                /* header('Content-Type: application/octet-stream'); 
     113                header('Content-Disposition: inline; filename="anonymised_nodes.sql"'); 
     114                header("Content-Transfer-Encoding: binary"); */ 
     115                 
     116                $text  = <<<EOT 
     117                CREATE TABLE nodes_anonymised 
     118                ( 
     119                node_id text NOT NULL, 
     120                latitude  NUMERIC(16, 6), 
     121                longitude  NUMERIC(16, 6) 
     122                ); 
    117123EOT; 
    118 $html .= "\n"; 
    119             echo $html; 
    120             $distinguish_users_by = $this->stats->getDistinguishUsersBy(); 
    121  
    122             $candidate_connections_sql = $this->stats->getSqlCandidateConnectionsQuery("conn_id, users.user_id, nodes.node_id, connections.user_id, user_mac, timestamp_in, timestamp_out, incoming, outgoing ", true); 
    123  
    124             $sql = "$candidate_connections_sql ORDER BY timestamp_in DESC"; 
    125             $db->execSqlRaw($sql, $resultHandle, false); 
    126             if($resultHandle) { 
    127                 while($row=pg_fetch_array($resultHandle,null,PGSQL_ASSOC)) 
    128                 { 
    129  
    130                     $keys = null; 
    131                     $values = null; 
    132                     $first = true; 
    133                     foreach ($row as $key=>$value) 
     124                $text .= "\n"; 
     125     
     126                fwrite($nfilehndl, $text); 
     127                 
     128                $node_constraint = $this->stats->getSqlNodeConstraint('nodes.node_id'); 
     129                $network_constraint = $this->stats->getSqlNetworkConstraint('nodes.network_id'); 
     130                $sql = "SELECT node_id, latitude, longitude \n"; 
     131                $sql .= "FROM nodes \n"; 
     132                $sql .= "WHERE 1=1 {$node_constraint} {$network_constraint}"; 
     133                 
     134                $db->execSql($sql, $nodes); 
     135                 
     136                if ($nodes) { 
     137                    foreach($nodes as $row) { 
     138                        $keys = null; 
     139                        $values = null; 
     140                        $first = true; 
     141                        foreach ($row as $key=>$value) 
     142                        { 
     143                            if($key == 'user_id' || $key == 'node_id' || $key == 'conn_id' || $key == 'user_mac' ) { 
     144                                $value = "'".$this->getNonRepeatableHash($value)."'"; 
     145                            } 
     146                            else if ($key == 'latitude' && empty ($value)) { 
     147                                $value = 'NULL'; 
     148                            } 
     149                            else if ($key == 'longitude' && empty ($value)) { 
     150                                $value = 'NULL'; 
     151                            } 
     152                            else { 
     153                                $value = "'$value'"; 
     154                            } 
     155                            if(!$first) { 
     156                                $keys .= ', '; 
     157                                $values .= ', '; 
     158                            } 
     159                            else { 
     160                                $first = false; 
     161                            } 
     162                            $keys .= $key; 
     163                            $values .= $value; 
     164                        } 
     165                        //fwrite($temp, "INSERT INTO connections_anonymised ($keys) VALUES ($values);\n"); 
     166                        fwrite($nfilehndl, "INSERT INTO nodes_anonymised ($keys) VALUES ($values);\n"); 
     167                    } 
     168                } 
     169                 
     170                 
     171                /** End sql file with node data */ 
     172                 
     173                /** Get the sql file with anonymised connection data */ 
     174              /*  header('Content-Type: application/octet-stream'); 
     175                header('Content-Disposition: inline; filename="anonymised_data.sql"'); 
     176                header("Content-Transfer-Encoding: binary");*/ 
     177     
     178                $text = <<<EOT 
     179                CREATE TABLE connections_anonymised 
     180                ( 
     181                conn_id text NOT NULL, 
     182                timestamp_in timestamp, 
     183                node_id text, 
     184                timestamp_out timestamp, 
     185                user_id text NOT NULL DEFAULT '', 
     186                user_mac text, 
     187                incoming int8, 
     188                outgoing int8 
     189                ); 
     190EOT; 
     191                $text .= "\n"; 
     192             
     193                fwrite($datahndl,  $text); 
     194                $distinguish_users_by = $this->stats->getDistinguishUsersBy(); 
     195     
     196                $candidate_connections_sql = $this->stats->getSqlCandidateConnectionsQuery("conn_id, users.user_id, nodes.node_id, connections.user_id, user_mac, timestamp_in, timestamp_out, incoming, outgoing ", true); 
     197     
     198                $sql = "$candidate_connections_sql ORDER BY timestamp_in DESC"; 
     199                $db->execSqlRaw($sql, $resultHandle, false); 
     200                if($resultHandle) { 
     201                    while($row=pg_fetch_array($resultHandle,null,PGSQL_ASSOC)) 
    134202                    { 
    135                         if($key == 'user_id' || $key == 'node_id' || $key == 'conn_id' || $key == 'user_mac' ) { 
    136                             $value = "'".$this->getNonRepeatableHash($value)."'"; 
     203     
     204                        $keys = null; 
     205                        $values = null; 
     206                        $first = true; 
     207                        foreach ($row as $key=>$value) 
     208                        { 
     209                            if($key == 'user_id' || $key == 'node_id' || $key == 'conn_id' || $key == 'user_mac' ) { 
     210                                $value = "'".$this->getNonRepeatableHash($value)."'"; 
     211                            } 
     212                            else if ($key == 'timestamp_out' && empty ($value)) { 
     213                                $value = 'NULL'; 
     214                            } 
     215                            else { 
     216                                $value = "'$value'"; 
     217                            } 
     218                            if(!$first) { 
     219                                $keys .= ', '; 
     220                                $values .= ', '; 
     221                            } 
     222                            else { 
     223                                $first = false; 
     224                            } 
     225                            $keys .= $key; 
     226                            $values .= $value; 
    137227                        } 
    138                         else if ($key == 'timestamp_out' && empty ($value)) { 
    139                             $value = 'NULL'; 
    140                         } 
    141                         else { 
    142                             $value = "'$value'"; 
    143                         } 
    144                         if(!$first) { 
    145                             $keys .= ', '; 
    146                             $values .= ', '; 
    147                         } 
    148                         else { 
    149                             $first = false; 
    150                         } 
    151                         $keys .= $key; 
    152                         $values .= $value; 
     228                        //fwrite($temp, "INSERT INTO connections_anonymised ($keys) VALUES ($values);\n"); 
     229                        fwrite($datahndl, "INSERT INTO connections_anonymised ($keys) VALUES ($values);\n"); 
    153230                    } 
    154                     //fwrite($temp, "INSERT INTO connections_anonymised ($keys) VALUES ($values);\n"); 
    155                     echo "INSERT INTO connections_anonymised ($keys) VALUES ($values);\n"; 
    156231                } 
     232                fclose($datahndl); 
     233                fclose($nfilehndl); 
     234                 
     235                $html .= <<<EOS 
     236                <script type="text/javascript"> 
     237                                window.open('/admin/stats.php?file=$nodefile&type=node', 'Node File'); 
     238                                window.open('/admin/stats.php?file=$datafile&type=data', 'Data file'); 
     239                                                                </script> 
     240EOS; 
     241                 
     242                 
    157243            } 
    158             exit; 
    159244        } 
    160245        return $html; 
  • trunk/wifidog-auth/wifidog/classes/User.php

    r1439 r1453  
    516516 
    517517    /** Is the user valid?  Valid means that the account is validated or hasn't exhausted it's validation period. 
    518      $errmsg: Returs the reason why the account is or isn't valid */ 
    519     function isUserValid(& $errmsg = null) { 
     518     $errmsg: Returs the reason why the account is or isn't valid 
     519     $errno: Returns an error code identifying the error */ 
     520    function isUserValid(& $errmsg = null, &$errno = 0) { 
    520521        global $account_status_to_text; 
    521522        $db = AbstractDb::getObject(); 
     
    530531 
    531532            if ($user_info['validation_grace_time_expired'] == 't') { 
    532                 $errmsg = sprintf(_("Sorry, your %.0f 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."), $user_info['validation_grace_time']/60); 
     533                $errmsg = sprintf(getErrorText(ERR_VALIDATION_EXPIRED), $user_info['validation_grace_time']/60); 
     534                $errno = ERR_VALIDATION_EXPIRED; 
    533535                $retval = false; 
    534536            } else { 
     
    537539            } 
    538540        } else { 
    539             $errmsg = _("Sorry, your account is not valid: ") . $account_status_to_text[$account_status]; 
     541            $errmsg = getErrorText(ERR_ACCOUNT_INVALID) . $account_status_to_text[$account_status]; 
     542            $errno = ERR_ACCOUNT_INVALID; 
    540543            $retval = false; 
    541544        } 
  • trunk/wifidog-auth/wifidog/include/common.php

    r1428 r1453  
    158158/* End of Other constants */ 
    159159 
     160/* defin error codes */ 
     161define ('ERR_UNKNOWN_USERNAME', 20001); 
     162define ('ERR_WRONG_PASSWORD', 20002); 
     163define ('ERR_NO_USERNAME', 20003); 
     164define ('ERR_VALIDATION_EXPIRED', 20004); 
     165define ('ERR_ACCOUNT_INVALID', 20005); 
     166 
     167function getErrorText($errorCode) { 
     168    switch ($errorCode) { 
     169        case ERR_UNKNOWN_USERNAME: $text = _('Unknown username or email'); break; 
     170        case ERR_WRONG_PASSWORD: $text = _('Incorrect password (Maybe you have CAPS LOCK on?)'); break; 
     171        case ERR_NO_USERNAME: $text = _("Fatal error:  Username cannot be empty"); break; 
     172        case ERR_VALIDATION_EXPIRED: $text = _("Sorry, your %.0f 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."); break; 
     173        case ERR_ACCOUNT_INVALID: $text = _("Sorry, your account is not valid: "); break; 
     174        default: $text = $errorCode; break; 
     175    } 
     176    return $text; 
     177} 
     178/* End error code definitions */ 
     179 
    160180/** Convert a password hash form a NoCat passwd file into the same format as get_password_hash(). 
    161181 * @return The 32 character hash. 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r1452 r1453  
    4848 * Define current database schema version 
    4949 */ 
    50 define('REQUIRED_SCHEMA_VERSION', 69); 
     50define('REQUIRED_SCHEMA_VERSION', 70); 
    5151/** Used to test a new shecma version before modyfying the database */ 
    5252define('SCHEMA_UPDATE_TEST_MODE', false); 
     
    15341534        $sql .= "\n\nALTER TABLE hotspot_graph_element_has_content ADD CONSTRAINT contentfk FOREIGN KEY (content_id) REFERENCES content(content_id) ON UPDATE CASCADE ON DELETE CASCADE;\n"; 
    15351535    } 
     1536     
     1537    $new_schema_version = 70; 
     1538    if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 
     1539        printUpdateVersion($new_schema_version); 
     1540        $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 
     1541        $sql .= "\nALTER TABLE nodes ADD COLUMN show_node_on_map boolean NOT NULL DEFAULT true;"; 
     1542    } 
    15361543    
    15371544    /* 
  • trunk/wifidog-auth/wifidog/js/hotspots_status_map.js

    r1409 r1453  
    321321        var gis = hotspots[i].getElementsByTagName("gisCenterLatLong"); 
    322322 
    323         if (hotspotId.length == 1 && gis.length == 1 && gis[0].getAttribute("lat") != "" && gis[0].getAttribute("long") != "") { 
     323        if (hotspotId.length == 1 && gis.length == 1 && gis[0].getAttribute("lat") != "" && gis[0].getAttribute("long") != "" && gis[0].getAttribute("show") == "1") { 
    324324            // Extract GIS data 
    325325            var point = new GLatLng(parseFloat(gis[0].getAttribute("lat")), parseFloat(gis[0].getAttribute("long"))); 
  • trunk/wifidog-auth/wifidog/ws/classes/WifidogWS/V1.php

    r1439 r1453  
    103103                        'NumOnlineUsers' => 'NumOnlineUsers', 
    104104                        'CreationDate' => 'CreationDate', 
    105                         'Status' => 'Status', 
     105                        'Status' => 'DeploymentStatus', 
    106106                        'OpeningDate' => 'CreationDate',  
    107107                                                                        'Connected_users' => 'OnlineUsers'), 
     
    150150        foreach($infields as $field) { 
    151151            if (isset(self::$_allowedFields[$objectClass][$field])) 
    152                 $fields[] = self::$_allowedFields[$objectClass][$field]; 
     152                $fields[$field] = self::$_allowedFields[$objectClass][$field]; 
    153153            else 
    154                 $fields[] = "$field.forbidden"; 
     154                $fields[$field] = "$field.forbidden"; 
    155155        } 
    156156        return $fields; 
     
    189189                $username = (isset($this->_params['username']) ? $this->_params['username']:''); 
    190190                $password = (isset($this->_params['password']) ? $this->_params['password']:''); 
    191                 $this->executeAuth($username, $password, $gw_id, $gw_address, $mac, $gw_port, $from); 
     191                $logout = (isset($this->_params['logout']) ? $this->_params['logout']:false); 
     192                $this->executeAuth($username, $password, $gw_id, $gw_address, $mac, $gw_port, $from, $logout); 
    192193                break; 
    193194            default: 
     
    204205     * @param $gw_id      The gateway id 
    205206     * @param $gw_ip      The gateway's ip addresss 
     207     * @param $mac                        The mac address of the user 
     208     * @param $gw_port    The port of the gateway's http server 
     209     * @param $from                     The ip address of the user on the node 
     210     * @param $logout                   Whether the user wants to logout 
    206211     * @return unknown_type 
    207212     */ 
    208     protected function executeAuth($username = null, $password = null, $gw_id = null, $gw_ip = null, $mac = null, $gw_port = null, $from = null) { 
     213    protected function executeAuth($username = null, $password = null, $gw_id = null, $gw_ip = null, $mac = null, $gw_port = null, $from = null, $logout = false) { 
    209214        $this->_outputArr['auth'] = 0; 
    210215         
     
    240245            if (!$token) throw new WSException("User authenticated but cannot generate connection token.", WSException::PROCESS_ERROR); 
    241246        } else { 
    242             // Authenticate the user on the requested network 
    243             $user = $network->getAuthenticator()->login($username, $password, $errMsg); 
    244             if (!$user) { 
    245                 $this->_outputArr['auth'] = 0; 
    246                 $this->_outputArr['explanation'] = $errMsg; 
     247            if (!$logout) { 
     248                // Authenticate the user on the requested network 
     249                $user = $network->getAuthenticator()->login($username, $password, $errMsg, $errNo); 
     250                if (!$user) { 
     251                    $this->_outputArr['auth'] = 0; 
     252                    $this->_outputArr['explanation'] = $errMsg; 
     253                    $this->_outputArr['errorcode'] = $errNo; 
     254                } else { 
     255                    $this->_outputArr['auth'] = 1; 
     256                    if (!is_null($node)) { 
     257                        $token = $user->generateConnectionTokenNoSession($node, $from, $mac); 
     258                        
     259                        if (!$token) throw new WSException("User authenticated but cannot generate connection token.", WSException::PROCESS_ERROR); 
     260                    } 
     261                } 
    247262            } else { 
     263                $user = User::getUserByUsernameOrEmail($username); 
     264                User::setCurrentUser($user); 
     265                $network->getAuthenticator()->logout(); 
    248266                $this->_outputArr['auth'] = 1; 
    249                 if (!is_null($node)) { 
    250                     $token = $user->generateConnectionTokenNoSession($node, $from, $mac); 
    251                     
    252                     if (!$token) throw new WSException("User authenticated but cannot generate connection token.", WSException::PROCESS_ERROR); 
    253                 } 
    254267            } 
    255268        } 
     
    298311        $fields = $this->mapFields($objectClass, $fields); 
    299312        if (empty($fields)) { 
    300             $fields = array_keys(self::$_allowedFields[$objectClass]); 
     313            $fields = self::$_allowedFields[$objectClass]; 
    301314        }  
    302315        $allowedFields = self::$_allowedFields[$objectClass]; 
     
    362375        }  
    363376 
     377        if (!isset($objectList)) { 
     378            throw new WSException("Object list for '{$objectClass}' is not supported.", WSException::GENERIC_EXCEPTION); 
     379        } 
    364380        $this->_outputArr = self::filterRet($objectList, $fields); 
    365381    } 
     
    389405                    } 
    390406                    $retFields = array(); 
    391                     foreach ($fields as $field) { 
     407                    foreach ($fields as $fkey => $field) { 
    392408                        $forbiddenfield = explode(".", $field); 
    393409                        if (! (count($forbiddenfield) == 2)) { 
    394410                            $methodName = 'get'.$field; 
    395411                            if (method_exists($value, $methodName)) { 
    396                                  
    397                                 $retFields[$field] = self::filterRet($value->$methodName()); 
     412                                $retFields[is_string($fkey)?$fkey:$field] = self::filterRet($value->$methodName()); 
    398413                            } else { 
    399                                 $retFields[$field] = 'unknown'; 
     414                                $retFields[is_string($fkey)?$fkey:$field] = 'unknown'; 
    400415                            } 
    401416                        } else 
  • trunk/wifidog-auth/wifidog/ws/index.php

    r1444 r1453  
    7171 */ 
    7272require_once('../include/common.php'); 
     73require_once('../include/language.php'); 
    7374require_once('ws/classes/WifidogWS.php'); 
    7475require_once('ws/classes/WSOutput.php');