Changeset 1253

Show
Ignore:
Timestamp:
07/16/07 01:11:27 (6 years ago)
Author:
benoitg
Message:
  • Node.php: Improve getCurrentRealNode()
  • Implement #4: Allow the user to easily come back to the portal by typing in the root auth server adress from a hotspot.
  • Log the system information sent with the gateway since almost forever: sys_uptime, sys_memfree, sys_load, wifidog_uptime
  • NodeStatus?.php: Include the above information
  • node_list.html: Include wifidog_uptime if the hotspot is up.
  • Menu.php: Sort menus alphabetically according to the user's locale. TODO: Implement menu weights.
  • NodeLists?: Only list node types that have dependencies met in the menu. Refactor the NodeLists? for proper object-orientation.


Location:
trunk/wifidog-auth
Files:
21 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1252 r1253  
     12007-06-16  Benoit Grégoire  <bock@step.polymtl.ca> 
     2        * Node.php:  Improve getCurrentRealNode() 
     3        * Implement #4:  Allow the user to easily come back to the portal by typing in the root auth server adress from a hotspot. 
     4        * Log the system information sent with the gateway since almost forever:  sys_uptime, sys_memfree, sys_load, wifidog_uptime 
     5        * NodeStatus.php:  Include the above information 
     6        * node_list.html:  Include wifidog_uptime if the hotspot is up. 
     7        * Menu.php:  Sort menus alphabetically according to the user's locale.  TODO:  Implement menu weights. 
     8        * NodeLists:  Only list node types that have dependencies met in the menu.  Refactor the NodeLists for proper object-orientation. 
     9         
    1102007-06-12  Benoit Grégoire  <bock@step.polymtl.ca> 
    211        * MainUI.php:  Fix label problem in language chooser. 
  • trunk/wifidog-auth/wifidog/classes/Menu.php

    r1249 r1253  
    118118    } 
    119119    /** Takes an array_walk_recursive compatible callback.  Will be called for each menu item */ 
    120     private function menuArrayWalkRecursiveReal($menuArray, $menuItemIdx, $funcname, &$userdata = null) { 
     120    private static function menuArrayWalkRecursiveReal($menuArray, $menuItemIdx, $funcname, &$userdata = null) { 
    121121        //echo "menuArrayWalkRecursive called with menuArray:"; pretty_print_r($menuArray); 
    122122        $retval = true; 
     
    137137    public function menuArrayWalkRecursive($funcname, &$userdata = null) { 
    138138        return self::menuArrayWalkRecursiveReal($this->_menuArray, 0, $funcname, &$userdata); 
     139    } 
     140    /** Compare menu items according to it's title output passed to strcoll().  The toString 
     141     * output is converted to ISO-8859-1 before sorting to allow strcoll() to be used 
     142     *  for locale-specific sorting. 
     143     */ 
     144    public static function titlestrcoll($object1, $object2) 
     145    { 
     146        //echo "CMP: ".$object1['title']." vs ". $object2['title']."<br/>\n"; 
     147        return strcoll ( utf8_decode($object1['title']), utf8_decode($object2['title']) ); 
     148    } 
     149     
     150    /** Sort the menu using a user defined sort function */ 
     151    private static function menuArraySort(&$menuArray, $funcname, &$userdata = null) { 
     152        //echo "menuArraySort called with menuArray:"; pretty_print_r($menuArray); 
     153        $retval = true; 
     154        //Sort childrens 
     155        $retval = uasort($menuArray['childrens'], $funcname); 
     156        foreach ($menuArray['childrens'] as $menuItemIdx => &$menuItem) { 
     157            //Recursive call 
     158            //pretty_print_r($menuItem); 
     159            //echo "Recusively calling for $menuItemIdx<br/>"; 
     160            $retval = $retval & self::menuArraySort($menuItem, $funcname, &$userdata); 
     161        } 
     162        return $retval; 
    139163    } 
    140164 
     
    165189        $this->processHookMenu('Network'); 
    166190        $this->processHookMenu('User'); 
    167                 $this->processHookMenu('Content'); 
    168                                 $this->processHookMenu('NodeList'); 
     191        $this->processHookMenu('Content'); 
     192        $this->processHookMenu('NodeList'); 
    169193        $this->processHookMenu('Role'); 
    170194        $this->processHookMenu('VirtualHost'); 
    171195        $this->processHookMenu('ContentTypeFilter'); 
    172196        $this->processHookMenu('ProfileTemplate'); 
     197        self::menuArraySort($this->_menuArray, array('Menu','titlestrcoll')); 
    173198        //pretty_print_r($this->_menuArray); 
    174199    } 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r1249 r1253  
    142142    public static function getCurrentRealNode() 
    143143    { 
    144         static $currentRealNode; 
    145         static $currentRealNodeComputed; 
     144        static $currentRealNode;//For caching 
     145        static $currentRealNodeComputed;//For caching 
     146        $currentIp = $_SERVER['REMOTE_ADDR']; 
     147        //For testing: 
     148        //$currentIp = '24.201.12.219'; 
    146149        if(!isset($currentRealNodeComputed)) 
    147150        { 
    148151            $currentRealNodeComputed=true; 
    149152            $db = AbstractDb::getObject(); 
    150             $sql = "SELECT node_id, last_heartbeat_ip from nodes WHERE last_heartbeat_ip='$_SERVER[REMOTE_ADDR]' ORDER BY last_heartbeat_timestamp DESC"; 
     153            $sql_ip = "SELECT node_id from nodes WHERE last_heartbeat_ip='$currentIp' ORDER BY last_heartbeat_timestamp DESC"; 
    151154            $node_rows = null; 
    152             $db->execSql($sql, $node_rows, false); 
     155            $db->execSql($sql_ip, $node_rows, false); 
    153156            $num_match = count($node_rows); 
    154157            if ($num_match == 0) 
    155158            { 
    156  
    157159                // User is not physically connected to a node 
    158160                $currentRealNode = null; 
    159161            } 
    160             else 
    161             if ($num_match = 1) 
     162            else if ($num_match == 1) 
    162163            { 
    163164                // Only a single node matches, the user is presumed to be there 
     
    166167            else 
    167168            { 
    168                 /* We have more than one node matching the IP (the nodes are behind the same NAT). 
    169                  * We will try to discriminate by finding which node the user last authenticated against. 
    170                  * If the IP matches, we can be pretty certain the user is there. 
    171                  */ 
     169                /* We have more than one node matching the IP (the nodes are behind the same NAT).*/ 
    172170                $currentRealNode = null; 
    173171                $current_user = User :: getCurrentUser(); 
    174172                if ($current_user != null) 
    175173                { 
     174                    /* We will try to discriminate by finding which node the user last authenticated against. 
     175                     * If the IP matches, we can be pretty certain the user is there. 
     176                     */ 
    176177                    $current_user_id = $current_user->getId(); 
    177                     $_SERVER['REMOTE_ADDR']; 
    178                     $sql = "SELECT node_id, last_heartbeat_ip from connections NATURAL JOIN nodes WHERE user_id='$current_user_id' ORDER BY last_updated DESC "; 
    179                     $db->execSql($sql, $node_rows, false); 
    180                     $node_row = $node_rows[0]; 
    181                     if ($node_row != null && $node_row['last_heartbeat_ip'] == $_SERVER['REMOTE_ADDR']) 
     178                    $sql = "SELECT node_id, last_heartbeat_ip, name, last_updated from connections NATURAL JOIN nodes WHERE user_id='$current_user_id' AND node_id IN ($sql_ip) ORDER BY last_updated DESC "; 
     179                    //$db->execSql($sql, $tmp, true); 
     180                    $db->execSqlUniqueRes("$sql LIMIT 1", $node_row, false); 
     181                    if ($node_row != null) 
    182182                    { 
    183183                        $currentRealNode = self::getObject($node_row['node_id']); 
    184184                    } 
    185185                } 
     186                else { 
     187                    /* Darn, the user doesn't have a session open, we can only take the first node in the list, which is marginaly better than nothing */ 
     188                    $currentRealNode = self::getObject($node_rows[0]['node_id']); 
     189                } 
    186190            } 
    187191        } 
    188  
    189192        return $currentRealNode; 
    190193    } 
     
    806809    } 
    807810 
     811    function getLastHeartbeatWifidogUptime() 
     812    { 
     813        return $this->_row['last_heartbeat_wifidog_uptime']; 
     814    } 
     815     
     816    function getLastHeartbeatSysUptime() 
     817    { 
     818        return $this->_row['last_heartbeat_sys_uptime']; 
     819    } 
     820     
     821    function getLastHeartbeatSysLoad() 
     822    { 
     823        return $this->_row['last_heartbeat_sys_load']; 
     824    } 
     825     
     826    function getLastHeartbeatSysMemfree() 
     827    { 
     828        return $this->_row['last_heartbeat_sys_memfree']; 
     829    } 
     830       
    808831    function getLastHeartbeatTimestamp() 
    809832    { 
  • trunk/wifidog-auth/wifidog/classes/NodeList.php

    r1249 r1253  
    5959 * Directory of NodeList classes 
    6060 */   define ('NODE_LIST_CLASSES_DIR', WIFIDOG_ABS_FILE_PATH . "classes/NodeLists"); 
    61 class NodeList { 
    62     /** 
    63      * Directory of NodeList classes 
    64      * 
    65      * @var string 
    66      * 
    67  
    68      */ 
    69  
    70  
    71     /** 
    72      * NodeList being used 
    73      * 
    74      * @var object 
    75      */ 
    76     public $nodeList; 
     61abstract class NodeList { 
     62 
    7763 
    7864    /** 
     
    8470     * @return void 
    8571     */ 
    86     public function __construct($nodeListType, &$network) 
     72    public static function &getObject($nodeListType, &$network) 
    8773    { 
    8874        // Check if node list type exists 
     
    9379        } 
    9480 
    95         $_nodeListClass = "NodeList" . $nodeListType; 
    96         $this->nodeList = new $_nodeListClass($network); 
     81        $nodeListClass = "NodeList" . $nodeListType; 
     82        $nodeList = new $nodeListClass($network); 
    9783 
    9884        // Set header of node list if node list class supports it 
    99         if (method_exists($this->nodeList, "setHeader")) { 
    100             $this->nodeList->setHeader(); 
    101         } 
     85        $nodeList->setHeader(); 
     86        return $nodeList; 
    10287    } 
    10388 
     
    166151        return $_nodeListTypes; 
    167152    } 
     153     
     154    /** 
     155     * Sets header of output.  If not extended, doesn't touch headers. 
     156     * 
     157     * @return void 
     158     */ 
     159    public function setHeader() 
     160    { 
     161        ; 
     162    } 
     163     
     164    /** 
     165     * Does the node list have all required dependencies, etc.?  In not redefined by the child class, 
     166     * returns true 
     167     * 
     168     * @return true or false 
     169     */ 
     170    static public function isAvailable() 
     171    { 
     172        return true; 
     173    }     
     174    /** 
     175     * Displays the output of this node list. 
     176         * 
     177     * @return void 
     178     */ 
     179    abstract public function getOutput(); 
     180 
    168181    /** Menu hook function */ 
    169182    static public function hookMenu() { 
     
    178191        //pretty_print_r($listTypes); 
    179192        foreach ($listTypes as $type) { 
     193                    $nodeListClass = "NodeList" . $type; 
     194                    require_once("classes/NodeLists/NodeList{$type}.php"); 
     195            if(call_user_func(array($nodeListClass, 'isAvailable'))) { 
    180196            $items[] = array('path' => 'node_lists/'.$type, 
    181197            'title' => sprintf(_("List in %s format"), $type), 
    182198            'url' => BASE_URL_PATH."hotspot_status.php?format=$type" 
    183199            ); 
     200            } 
    184201        } 
    185202        $items[] = array('path' => 'node_lists/technical_status', 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListHTML.php

    r1249 r1253  
    3737 * @package    WiFiDogAuthServer 
    3838 * @subpackage NodeLists 
     39 * @author     Benoit Grégoire <bock@step.polymtl.ca> 
     40 * @author     Francois Proulx <francois.proulx@gmail.com> 
    3941 * @author     Max Horváth <max.horvath@freenet.de> 
     42 * @copyright  2004-2007 Benoit Grégoire, Technologies Coeus inc. 
    4043 * @copyright  2006 Max Horváth, Horvath Web Consulting 
    41  * @version    Subversion $Id: Content.php 974 2006-02-25 15:08:12Z max-horvath $ 
     44 * @version    Subversion $Id: $ 
    4245 * @link       http://www.wifidog.org/ 
    4346 */ 
     
    4750 */ 
    4851require_once('classes/Dependency.php'); 
     52require_once('classes/NodeList.php'); 
    4953require_once('classes/Network.php'); 
    5054require_once('classes/Node.php'); 
     
    6064 * @copyright  2006 Max Horváth, Horvath Web Consulting 
    6165 */ 
    62 class NodeListHTML { 
     66class NodeListHTML extends NodeList{ 
    6367 
    6468    /** 
     
    142146 
    143147    /** 
    144      * Retreives the output of this object. 
    145      * 
    146      * @param bool $return_object This parameter doesn't have any effect in 
    147      *                            the class 
    148      * 
     148     * Displays the output of this node list. 
     149         * 
    149150     * @return void 
    150151     * 
     
    156157     * @copyright  2006 Max Horváth, Horvath Web Consulting 
    157158     */ 
    158     public function getOutput($return_object = false) 
     159    public function getOutput() 
    159160    { 
    160         // Init ALL smarty SWITCH values 
    161         $this->_smarty->assign('sectionTOOLCONTENT', false); 
    162         $this->_smarty->assign('sectionMAINCONTENT', false); 
    163161 
    164162        // Init ALL smarty values 
     
    169167        $this->_smarty->assign('num_deployed_nodes', 0); 
    170168        $this->_smarty->assign('PdfSupported', false); 
    171  
    172         /* 
    173          * Tool content 
    174          */ 
    175169 
    176170        /** 
     
    194188 
    195189        // Reset ALL smarty SWITCH values 
    196         $this->_smarty->assign('sectionTOOLCONTENT', false); 
    197190        $this->_smarty->assign('sectionMAINCONTENT', false); 
    198191 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListJiWireCSV.php

    r1192 r1253  
    4747require_once('classes/Network.php'); 
    4848require_once('classes/Node.php'); 
    49  
     49require_once('classes/NodeList.php'); 
    5050/** 
    5151 * Defines the JiWire CSV type of node list 
     
    5656 * @copyright  (c) 2006 François Proulx 
    5757 */ 
    58 class NodeListJiWireCSV { 
     58class NodeListJiWireCSV extends NodeList { 
    5959 
    6060        /** 
     
    119119    /** 
    120120     * Retreives the output of this object. 
    121      * 
    122      * @param bool $return_object If true this function only returns the DOM object 
    123121     * 
    124122     * @return string The XML output 
     
    131129     * @copyright  2006 Max Horváth, Horvath Web Consulting 
    132130     */ 
    133     public function getOutput($return_object = false) 
     131    public function getOutput() 
    134132    { 
    135133                $this->_csv_document = "jiwire_ref, status, provider_id, provider_name, address, address2, city, state, country, postal_code, website_url, email, phone, fax, location_name, location_type_id, field17, node_type, ssid, fee_comments, equipement, standard_802_11, MAC_address, network_drop, latitude, longitude\r\n"; 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListKML.php

    r1192 r1253  
    5050require_once('classes/Network.php'); 
    5151require_once('classes/Node.php'); 
     52require_once('classes/NodeList.php'); 
    5253 
    5354/** 
     
    5960 * @copyright  2006 Joe Bowser 
    6061 */ 
    61 class NodeListKML { 
     62class NodeListKML extends NodeList{ 
    6263 
    6364    /** 
     
    122123 
    123124    /** 
    124      * Retreives the output of this object. 
    125      * 
    126      * @param bool $return_object If true this function only returns the DOM object 
    127      * 
    128      * @return string The XML output 
     125     * Displays the output of this object. 
     126     * 
     127     * @return void 
    129128     * 
    130129     * @author     Benoit Gregoire <bock@step.polymtl.ca> 
     
    137136         * @copyright  2006 Joe Bowser 
    138137     */ 
    139     public function getOutput($return_object = false) 
     138    public function getOutput() 
    140139    { 
    141140                $_kml = $this->_xmldoc->createElement("kml"); 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListPDF.php

    r1249 r1253  
    3939 * @author     Max Horváth <max.horvath@freenet.de> 
    4040 * @copyright  2006 Max Horváth, Horvath Web Consulting 
    41  * @version    Subversion $Id: Content.php 974 2006-02-25 15:08:12Z max-horvath $ 
     41 * @version    Subversion $Id: $ 
    4242 * @link       http://www.wifidog.org/ 
    4343 */ 
     
    4747 */ 
    4848require_once('classes/Dependency.php'); 
     49require_once('classes/NodeList.php'); 
    4950require_once('classes/MainUI.php'); 
    5051require_once('classes/Network.php'); 
     
    5859 
    5960    if (PHP_OS != "Windows" && PHP_OS != "Darwin" && @file_exists('/proc/loadavg') && $_loadavgFile = @file_get_contents('/proc/loadavg')) { 
    60         $_loadavg = explode(' ', $_loadavgFile); 
    61  
    62         if (trim($_loadavg[0]) > 5) { 
    63                 $_serverBusy = true; 
    64         } 
     61        $_loadavg = explode(' ', $_loadavgFile); 
     62 
     63        if (trim($_loadavg[0]) > 5) { 
     64            $_serverBusy = true; 
     65        } 
    6566    } 
    6667 
     
    183184                $this->_lastRC4Key = ''; 
    184185                $this->padding = "\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08" . 
    185                                  "\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A"; 
     186                "\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A"; 
    186187            } 
    187188 
     
    314315                        // Define which array data to use 
    315316                        switch ($_i) { 
    316                         case 0: 
    317                             $_dataPart = $_row['name']; 
    318                             break; 
    319  
    320                         case 1: 
    321                             $_dataPart = $_row['civic_number'] . " " . $_row['street_name']; 
    322                             break; 
    323                         case 2: 
    324                             $_dataPart = $_row['postal_code']; 
    325                             break; 
    326  
    327                         case 3: 
    328                             $_dataPart = $_row['city']; 
    329                             break; 
    330  
    331                         case 4: 
    332                             $_dataPart = $_row['province']; 
    333                             break; 
    334  
    335                         case 5: 
    336                             $_dataPart = $_row['public_phone_number']; 
    337                             break; 
    338  
    339                         case 6: 
    340                             $_dataPart = $_row['public_email']; 
    341                             break; 
    342  
    343                         case 7: 
    344                             $_dataPart = str_replace(array("http://", "https://"), "", $_row['home_page_url']); 
    345                             break; 
    346  
    347                         default: 
    348                             throw new Exception("Error: PdfWifidog::nodeList(): Fatal error while defining which array data to use."); 
    349                             break; 
     317                            case 0: 
     318                                $_dataPart = $_row['name']; 
     319                                break; 
     320 
     321                            case 1: 
     322                                $_dataPart = $_row['civic_number'] . " " . $_row['street_name']; 
     323                                break; 
     324                            case 2: 
     325                                $_dataPart = $_row['postal_code']; 
     326                                break; 
     327 
     328                            case 3: 
     329                                $_dataPart = $_row['city']; 
     330                                break; 
     331 
     332                            case 4: 
     333                                $_dataPart = $_row['province']; 
     334                                break; 
     335 
     336                            case 5: 
     337                                $_dataPart = $_row['public_phone_number']; 
     338                                break; 
     339 
     340                            case 6: 
     341                                $_dataPart = $_row['public_email']; 
     342                                break; 
     343 
     344                            case 7: 
     345                                $_dataPart = str_replace(array("http://", "https://"), "", $_row['home_page_url']); 
     346                                break; 
     347 
     348                            default: 
     349                                throw new Exception("Error: PdfWifidog::nodeList(): Fatal error while defining which array data to use."); 
     350                                break; 
    350351                        } 
    351352 
     
    362363                        // Define which array data to use 
    363364                        switch ($_i) { 
    364                         case 0: 
    365                             $_dataPart = $_row['name']; 
    366                             break; 
    367  
    368                         case 1: 
    369                             if (defined("ORDER_CIVIC_NUMBER") && ORDER_CIVIC_NUMBER == "street_name_first") { 
    370                                 $_dataPart = $_row['street_name'] . " " . $_row['civic_number']; 
    371                             } else { 
    372                                 $_dataPart = $_row['civic_number'] . " " . $_row['street_name']; 
    373                             } 
    374                             break; 
    375                         case 2: 
    376                             $_dataPart = $_row['postal_code']; 
    377                             break; 
    378  
    379                         case 3: 
    380                             $_dataPart = $_row['city']; 
    381                             break; 
    382  
    383                         case 4: 
    384                             $_dataPart = $_row['province']; 
    385                             break; 
    386  
    387                         case 5: 
    388                             $_dataPart = $_row['public_phone_number']; 
    389                             break; 
    390  
    391                         case 6: 
    392                             $_dataPart = $_row['public_email']; 
    393                             break; 
    394  
    395                         case 7: 
    396                             $_dataPart = str_replace(array("http://", "https://"), "", $_row['home_page_url']); 
    397                             break; 
    398  
    399                         default: 
    400                             throw new Exception("Error: PdfWifidog::nodeList(): Fatal error while defining which array data to use."); 
    401                             break; 
     365                            case 0: 
     366                                $_dataPart = $_row['name']; 
     367                                break; 
     368 
     369                            case 1: 
     370                                if (defined("ORDER_CIVIC_NUMBER") && ORDER_CIVIC_NUMBER == "street_name_first") { 
     371                                    $_dataPart = $_row['street_name'] . " " . $_row['civic_number']; 
     372                                } else { 
     373                                    $_dataPart = $_row['civic_number'] . " " . $_row['street_name']; 
     374                                } 
     375                                break; 
     376                            case 2: 
     377                                $_dataPart = $_row['postal_code']; 
     378                                break; 
     379 
     380                            case 3: 
     381                                $_dataPart = $_row['city']; 
     382                                break; 
     383 
     384                            case 4: 
     385                                $_dataPart = $_row['province']; 
     386                                break; 
     387 
     388                            case 5: 
     389                                $_dataPart = $_row['public_phone_number']; 
     390                                break; 
     391 
     392                            case 6: 
     393                                $_dataPart = $_row['public_email']; 
     394                                break; 
     395 
     396                            case 7: 
     397                                $_dataPart = str_replace(array("http://", "https://"), "", $_row['home_page_url']); 
     398                                break; 
     399 
     400                            default: 
     401                                throw new Exception("Error: PdfWifidog::nodeList(): Fatal error while defining which array data to use."); 
     402                                break; 
    402403                        } 
    403404 
     
    433434            function _putinfo() 
    434435            { 
    435                         if (defined("WIFIDOG_NAME")) { 
    436                         $this->_out('/Producer ' . $this->_textstring(WIFIDOG_NAME)); 
    437                         } else { 
    438                         $this->_out('/Producer ' . $this->_textstring('WiFiDog Authentication Server')); 
    439                         } 
    440  
    441                 if (!empty($this->title)) { 
    442                         $this->_out('/Title ' . $this->_textstring($this->title)); 
    443                 } 
    444  
    445                 if (!empty($this->subject)) { 
    446                         $this->_out('/Subject ' . $this->_textstring($this->subject)); 
    447                 } 
    448  
    449                 if (!empty($this->author)) { 
    450                         $this->_out('/Author ' . $this->_textstring($this->author)); 
    451                 } 
    452  
    453                 if (!empty($this->keywords)) { 
    454                         $this->_out('/Keywords ' . $this->_textstring($this->keywords)); 
    455                 } 
    456  
    457                 if (!empty($this->creator)) { 
    458                         $this->_out('/Creator ' . $this->_textstring($this->creator)); 
    459                 } 
    460  
    461                 $this->_out('/CreationDate ' . $this->_textstring('D:' . date('YmdHis'))); 
     436                if (defined("WIFIDOG_NAME")) { 
     437                    $this->_out('/Producer ' . $this->_textstring(WIFIDOG_NAME)); 
     438                } else { 
     439                    $this->_out('/Producer ' . $this->_textstring('WiFiDog Authentication Server')); 
     440                } 
     441 
     442                if (!empty($this->title)) { 
     443                    $this->_out('/Title ' . $this->_textstring($this->title)); 
     444                } 
     445 
     446                if (!empty($this->subject)) { 
     447                    $this->_out('/Subject ' . $this->_textstring($this->subject)); 
     448                } 
     449 
     450                if (!empty($this->author)) { 
     451                    $this->_out('/Author ' . $this->_textstring($this->author)); 
     452                } 
     453 
     454                if (!empty($this->keywords)) { 
     455                    $this->_out('/Keywords ' . $this->_textstring($this->keywords)); 
     456                } 
     457 
     458                if (!empty($this->creator)) { 
     459                    $this->_out('/Creator ' . $this->_textstring($this->creator)); 
     460                } 
     461 
     462                $this->_out('/CreationDate ' . $this->_textstring('D:' . date('YmdHis'))); 
    462463            } 
    463464 
     
    794795        exit(); 
    795796    } 
    796 } else { 
    797     $ui = MainUI::getObject(); 
    798  
    799     $errmsg = _("PDF file cannot be created because the FPDF library is not installed!"); 
    800     $ui->displayError($errmsg); 
    801  
    802     exit(); 
    803797} 
    804798 
     
    811805 * @copyright  2006 Max Horváth, Horvath Web Consulting 
    812806 */ 
    813 class NodeListPDF 
     807class NodeListPDF extends NodeList 
    814808{ 
    815809    /** 
     
    884878     */ 
    885879    private $_currentUser; 
     880 
     881    /** 
     882     * Does the node list have all required dependencies, etc.?  In not redefined by the child class, 
     883     * returns true 
     884     * 
     885     * @return true or false 
     886     */ 
     887    static public function isAvailable() 
     888    { 
     889        return Dependency::check("FPDF"); 
     890    } 
    886891 
    887892    /** 
     
    892897    public function __construct(&$network) 
    893898    { 
    894          
     899 
    895900        $db = AbstractDb::getObject(); 
    896901 
     
    920925            if (defined("PDF_SORT")) { 
    921926                switch (PDF_SORT) { 
    922                 case "street_name": 
    923                 case "postal_code": 
    924                 case "city": 
    925                     $this->_pdfSort = PDF_SORT; 
    926                     break; 
    927  
    928                 default: 
    929                     $this->_pdfSort = "name"; 
    930                     break; 
     927                    case "street_name": 
     928                    case "postal_code": 
     929                    case "city": 
     930                        $this->_pdfSort = PDF_SORT; 
     931                        break; 
     932 
     933                    default: 
     934                        $this->_pdfSort = "name"; 
     935                        break; 
    931936 
    932937                } 
     
    956961            $this->_pdf->SetKeywords($this->_network->getName() . ", " . _("Hotspots")); 
    957962 
    958                 if (defined("WIFIDOG_NAME")) { 
     963            if (defined("WIFIDOG_NAME")) { 
    959964                $this->_pdf->SetCreator(WIFIDOG_NAME); 
    960                 } 
     965            } 
    961966 
    962967            // Define styles 
     
    9991004 
    10001005    /** 
    1001      * Retreives the output of this object. 
    1002      * 
    1003      * @param bool $return_object This parameter doesn't have any effect in 
    1004      *                            the class 
     1006     * Displays the output of this object. 
    10051007     * 
    10061008     * @return string The PDF file 
    10071009     */ 
    1008     public function getOutput($return_object = false) 
     1010    public function getOutput() 
    10091011    { 
    10101012        // Init values 
     
    10591061                    break; 
    10601062 
    1061                 } 
     1063            } 
    10621064 
    10631065            $this->_pdf->Write(10, utf8_decode(sprintf(_("This list contains all Hotspots of %s sorted by %s."), $this->_network->getName(), $_sortBy))); 
     
    10851087            // Compile PDF file 
    10861088            $this->_pdf->Output(); 
     1089        } 
     1090        else { 
     1091            $ui = MainUI::getObject(); 
     1092 
     1093            $errmsg = _("PDF file cannot be created because the FPDF library is not installed!"); 
     1094            $ui->displayError($errmsg); 
     1095 
     1096            exit(); 
    10871097        } 
    10881098    } 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListRSS.php

    r1192 r1253  
    4646 * Load required classes 
    4747 */ 
     48require_once('classes/NodeList.php'); 
    4849require_once('classes/Network.php'); 
    4950require_once('classes/Node.php'); 
     
    5758 * @author     Max Horváth <max.horvath@freenet.de> 
    5859 * @copyright  2006 Max Horváth, Horvath Web Consulting 
     60 * @copyright  2004-2007 Benoit Grégoire, Technologies Coeus inc. 
    5961 */ 
    60 class NodeListRSS { 
     62class NodeListRSS extends NodeList{ 
    6163 
    6264    /** 
     
    121123     * Retreives the output of this object. 
    122124     * 
    123      * @param bool $return_object This parameter doesn't have any effect in 
    124      *                            the class 
    125      * 
    126125     * @return void 
    127126     * 
     
    133132     * @copyright  2006 Max Horváth, Horvath Web Consulting 
    134133     */ 
    135     public function getOutput($return_object = false) 
     134    public function getOutput() 
    136135    { 
    137136         
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListXML.php

    r1192 r1253  
    3737 * @package    WiFiDogAuthServer 
    3838 * @subpackage NodeLists 
     39 * @author     Benoit Grégoire <bock@step.polymtl.ca> 
     40 * @author     Francois Proulx <francois.proulx@gmail.com> 
    3941 * @author     Max Horváth <max.horvath@freenet.de> 
     42 * @copyright  2004-2007 Benoit Grégoire, Technologies Coeus inc. 
    4043 * @copyright  2006 Max Horváth, Horvath Web Consulting 
    41  * @version    Subversion $Id: Content.php 974 2006-02-25 15:08:12Z max-horvath $ 
     44 * @version    Subversion $Id: $ 
    4245 * @link       http://www.wifidog.org/ 
    4346 */ 
     
    4649 * Load required classes 
    4750 */ 
     51require_once('classes/NodeList.php'); 
    4852require_once('classes/Network.php'); 
    4953require_once('classes/Node.php'); 
     
    5458 * @package    WiFiDogAuthServer 
    5559 * @subpackage NodeLists 
     60 * @author     Benoit Grégoire <bock@step.polymtl.ca> 
     61 * @author     Francois Proulx <francois.proulx@gmail.com> 
    5662 * @author     Max Horváth <max.horvath@freenet.de> 
     63 * @copyright  2004-2007 Benoit Grégoire, Technologies Coeus inc. 
    5764 * @copyright  2006 Max Horváth, Horvath Web Consulting 
    5865 */ 
    59 class NodeListXML { 
     66class NodeListXML extends NodeList{ 
    6067 
    6168    /** 
     
    9097    public function __construct(&$network) 
    9198    { 
    92          
     99 
    93100        $db = AbstractDb::getObject(); 
    94101 
     
    207214                $_nodeId = $this->_xmldoc->createElement("nodeId", $_node->getId()); 
    208215                $_nodeMetadataNode->appendChild($_nodeId); 
    209                  
     216 
    210217                // Online Users 
    211218                $_nodeUserNum = $this->_xmldoc->createElement("numOnlineUsers", $_node->GetNumOnlineUsers()); 
     
    225232                } 
    226233 
    227                                 if (($_gisData = $_node->getGisLocation()) !== null) { 
     234                if (($_gisData = $_node->getGisLocation()) !== null) { 
    228235                    $_nodeGis = $this->_xmldoc->createElement("gisLatLong"); 
    229236                    $_nodeGis->setAttribute("lat", $_gisData->getLatitude()); 
     
    320327 
    321328                // Long / Lat 
    322                                 if (($_gisData = $_node->getGisLocation()) !== null) { 
     329                if (($_gisData = $_node->getGisLocation()) !== null) { 
    323330                    $_hotspotGis = $this->_xmldoc->createElement("gisCenterLatLong"); 
    324331                    $_hotspotGis->setAttribute("lat", $_gisData->getLatitude()); 
  • trunk/wifidog-auth/wifidog/classes/Server.php

    r1249 r1253  
    303303        } 
    304304        $items[] = array('path' => 'server', 
    305         'title' => _('Server'), 
     305        'title' => _('Server administration'), 
    306306        'type' => MENU_ITEM_GROUPING); 
    307307 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport.php

    r1249 r1253  
    6868    final public static function &getObject($classname, Statistics $statistics_object) 
    6969    { 
    70         return new $classname ($statistics_object); 
     70        $object = new $classname ($statistics_object); 
     71        return $object; 
    7172    } 
    7273 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/NodeStatus.php

    r1192 r1253  
    117117                $html .= "</tr>"; 
    118118                $html .= "<tr class='odd'>"; 
     119                $html .= "  <th>"._("WifiDog uptime")."</th>"; 
     120                $html .= "  <td>".$nodeObject->getLastHeartbeatWifidogUptime()."</td>"; 
     121                $html .= "</tr>"; 
     122                $html .= "<tr class='even'>"; 
     123                $html .= "  <th>"._("System uptime")."</th>"; 
     124                $html .= "  <td>".$nodeObject->getLastHeartbeatSysUptime()."</td>"; 
     125                $html .= "</tr>"; 
     126                $html .= "<tr class='odd'>"; 
     127                $html .= "  <th>"._("System load")."</th>"; 
     128                $html .= "  <td>".$nodeObject->getLastHeartbeatSysLoad()."</td>"; 
     129                $html .= "</tr>"; 
     130                $html .= "<tr class='even'>"; 
     131                $html .= "  <th>"._("System free memory")."</th>"; 
     132                $html .= "  <td>".$nodeObject->getLastHeartbeatSysMemfree()."</td>"; 
     133                $html .= "</tr>";                 
     134                $html .= "<tr class='odd'>"; 
    119135                $html .= "  <th>"._("IP Address")."</th>"; 
    120136                $html .= "  <td>".$nodeObject->getLastHeartbeatIP()."</td>"; 
  • trunk/wifidog-auth/wifidog/hotspot_status.php

    r1249 r1253  
    4141 * @author     Francois Proulx <francois.proulx@gmail.com> 
    4242 * @author     Max Horváth <max.horvath@freenet.de> 
    43  * @copyright  2004-2006 Benoit Grégoire, Technologies Coeus inc. 
     43 * @copyright  2004-2007 Benoit Grégoire, Technologies Coeus inc. 
    4444 * @copyright  2004-2006 Francois Proulx, Technologies Coeus inc. 
    4545 * @copyright  2006 Max Horváth, Horvath Web Consulting 
     
    7272if ($network) { 
    7373    // Init node list type 
    74     $nodeList = new NodeList($format, $network); 
     74    $nodeList = NodeList::getObject($format, $network); 
    7575    /** 
    7676     * XSLT support for Hotspot status page 
     
    9595                // Prepare HTML 
    9696                header("Content-Type: text/html; charset=UTF-8"); 
    97                 echo $xslt_proc->transformToXML($nodeList->nodeList->getOutput(true)); 
     97                echo $xslt_proc->transformToXML($nodeList->getOutput(true)); 
    9898            } 
    9999        } 
     
    104104    } else { 
    105105        // Deliver node list 
    106         $nodeList->nodeList->getOutput(); 
     106        $nodeList->getOutput(); 
    107107    } 
    108108} 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r1249 r1253  
    4848 * Define current database schema version 
    4949 */ 
    50 define('REQUIRED_SCHEMA_VERSION', 54); 
     50define('REQUIRED_SCHEMA_VERSION', 55); 
    5151/** Used to test a new shecma version before modyfying the database */ 
    5252define('SCHEMA_UPDATE_TEST_MODE', false); 
     
    12661266 
    12671267    } 
    1268  
     1268     $new_schema_version = 55; 
     1269     if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 
     1270     printUpdateVersion($new_schema_version); 
     1271     $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 
     1272        $sql .= "ALTER TABLE nodes ADD COLUMN last_heartbeat_sys_uptime INTEGER;\n";//68 years of uptime should be enough for anybody ;) 
     1273        $sql .= "ALTER TABLE nodes ALTER COLUMN last_heartbeat_sys_uptime SET DEFAULT NULL;\n"; 
     1274        $sql .= "ALTER TABLE nodes ADD COLUMN last_heartbeat_wifidog_uptime INTEGER;\n";//68 years of uptime should be enough for anybody ;) 
     1275        $sql .= "ALTER TABLE nodes ALTER COLUMN last_heartbeat_wifidog_uptime SET DEFAULT NULL;\n"; 
     1276        $sql .= "ALTER TABLE nodes ADD COLUMN last_heartbeat_sys_memfree INTEGER;\n"; 
     1277        $sql .= "ALTER TABLE nodes ALTER COLUMN last_heartbeat_sys_memfree SET DEFAULT NULL;\n"; 
     1278        $sql .= "ALTER TABLE nodes ADD COLUMN last_heartbeat_sys_load real;\n"; 
     1279        $sql .= "ALTER TABLE nodes ALTER COLUMN last_heartbeat_sys_load SET DEFAULT NULL;\n"; 
     1280     } 
    12691281    /* 
    12701282     $new_schema_version = ; 
  • trunk/wifidog-auth/wifidog/index.php

    r1249 r1253  
    5858 
    5959$smarty = SmartyWifidog::getObject(); 
    60 // Init ALL smarty SWITCH values 
    61 $smarty->assign('sectionTOOLCONTENT', false); 
    62 $smarty->assign('sectionMAINCONTENT', false); 
    6360 
    6461// Init ALL smarty values 
     
    6966 
    7067/* 
    71  * Tool content 
    72  */ 
    73  
    74 // Set section of Smarty template 
    75 $smarty->assign('sectionTOOLCONTENT', true); 
    76  
    77 // Compile HTML code 
    78 $html = $smarty->fetch("templates/sites/index.tpl"); 
    79  
    80 /* 
    8168 * Main content 
    8269 */ 
    83  
    84 // Reset ALL smarty SWITCH values 
    85 $smarty->assign('sectionTOOLCONTENT', false); 
    86 $smarty->assign('sectionMAINCONTENT', false); 
    87  
    8870// Set section of Smarty template 
    8971$smarty->assign('sectionMAINCONTENT', true); 
     
    9880$html_body = $smarty->fetch("templates/sites/index.tpl"); 
    9981 
     82$currentNode = Node::getCurrentRealNode(); 
     83if($currentNode){ 
     84    header("Location: ".BASE_URL_PATH."portal/?node_id=".$currentNode->getId()); 
     85    exit(); 
     86} 
    10087/* 
    10188 * Render output 
    10289 */ 
    10390$ui = MainUI::getObject(); 
    104 $ui->addContent('left_area_middle', $html); 
    10591$ui->addContent('main_area_top', $html_body); 
    10692$ui->display(); 
  • trunk/wifidog-auth/wifidog/ping/index.php

    r1133 r1253  
    5151 
    5252echo "Pong"; 
    53 $db = AbstractDb::getObject();  
     53$db = AbstractDb::getObject(); 
    5454$gw_id = $db->escapeString($_REQUEST['gw_id']); 
     55!empty($_REQUEST['sys_uptime'])?$sysUptimeSql = ", last_heartbeat_sys_uptime=".$db->escapeString($_REQUEST['sys_uptime']):$sysUptimeSql=", last_heartbeat_sys_uptime=NULL"; 
     56!empty($_REQUEST['sys_memfree'])?$sysMemfreeSql = ", last_heartbeat_sys_memfree=".$db->escapeString($_REQUEST['sys_memfree']):$sysMemfreeSql=", last_heartbeat_sys_memfree=NULL"; 
     57!empty($_REQUEST['sys_load'])?$sysLoadSql = ", last_heartbeat_sys_load=".$db->escapeString($_REQUEST['sys_load']):$sysLoadSql=", last_heartbeat_sys_load=NULL"; 
     58!empty($_REQUEST['wifidog_uptime'])?$wifidogUptimeSql = ", last_heartbeat_wifidog_uptime=".$db->escapeString($_REQUEST['wifidog_uptime']):$wifidogUptimeSql=", last_heartbeat_wifidog_uptime=NULL"; 
     59 
    5560$user_agent =  $db->escapeString($_SERVER['HTTP_USER_AGENT']); 
    56 $db->execSqlUpdate("UPDATE nodes SET last_heartbeat_ip='$_SERVER[REMOTE_ADDR]', last_heartbeat_timestamp=CURRENT_TIMESTAMP, last_heartbeat_user_agent='$user_agent' WHERE gw_id='$gw_id'"); 
     61$db->execSqlUpdate("UPDATE nodes SET last_heartbeat_ip='$_SERVER[REMOTE_ADDR]', last_heartbeat_timestamp=CURRENT_TIMESTAMP, last_heartbeat_user_agent='$user_agent' $sysUptimeSql $sysMemfreeSql $sysLoadSql $wifidogUptimeSql WHERE gw_id='$gw_id'"); 
    5762 
    5863/* 
  • trunk/wifidog-auth/wifidog/portal/index.php

    r1249 r1253  
    9999} 
    100100 
    101 /* 
    102  * If this node has a custom portal defined, and the network config allows it, 
    103  * redirect to the custom portal 
    104  */ 
    105 $custom_portal_url = $node->getCustomPortalRedirectUrl(); 
    106  
    107 if (!empty ($custom_portal_url) && $network->getCustomPortalRedirectAllowed()) { 
    108     header("Location: {$custom_portal_url}"); 
    109 } 
    110  
    111101$node_id = $node->getId(); 
    112 $portal_template = $node_id.".html"; 
    113102Node :: setCurrentNode($node); 
    114103 
     
    118107    } 
    119108} 
    120  
    121 $smarty->assign('sectionTOOLCONTENT', false); 
     109/* 
     110 * If this node has a custom portal defined, and the network config allows it, 
     111 * redirect to the custom portal 
     112 */ 
     113$custom_portal_url = $node->getCustomPortalRedirectUrl(); 
     114 
     115if (!empty ($custom_portal_url) && $network->getCustomPortalRedirectAllowed()) { 
     116    header("Location: {$custom_portal_url}"); 
     117    exit; 
     118} 
     119 
    122120$smarty->assign('sectionMAINCONTENT', false); 
    123121 
  • trunk/wifidog-auth/wifidog/profile/index.php

    r1249 r1253  
    8989 
    9090// Init ALL smarty SWITCH values 
    91 $smarty->assign('sectionTOOLCONTENT', false); 
    9291$smarty->assign('sectionMAINCONTENT', false); 
    9392 
  • trunk/wifidog-auth/wifidog/templates/node_list.html

    r1157 r1253  
    3636                    {if $nodes[node].online == 't'} 
    3737                    <img src='{$common_images_url}HotspotStatus/up.gif'> 
     38                        {if $nodes[node].last_heartbeat_wifidog_uptime != ''} 
     39                                {$nodes[node].last_heartbeat_wifidog_uptime.days} {"days"|_} {$nodes[node].last_heartbeat_wifidog_uptime.hours}{"h"|_} {$nodes[node].last_heartbeat_wifidog_uptime.minutes}{"min"|_}<br /> 
     40                        {/if} 
    3841                    {else} 
    3942                    <img src='{$common_images_url}HotspotStatus/down.gif'> 
     
    4750                    <td> 
    4851                    <a href='{$base_ssl_path}login/index.php?gw_id={$nodes[node].gw_id}&gw_address=127.0.0.1&gw_port=80'>{"Login page"|_}</a><br /> 
    49                     <a href='{$base_url_path}portal/index.php?node_id={$nodes[node].node_id}'>{"Portal page"|_}</a> 
     52                    <a href='{$base_url_path}portal/?node_id={$nodes[node].node_id}'>{"Portal page"|_}</a> 
    5053                    </td> 
    5154                    <td style="font-size: 8pt;">{$nodes[node].creation_date}<br> 
  • trunk/wifidog-auth/wifidog/templates/sites/index.tpl

    r1249 r1253  
    4747*} 
    4848 
    49 {if $sectionTOOLCONTENT} 
    50 {* 
    51     BEGIN section TOOLCONTENT 
    52 *} 
    53  
    54 {* 
    55     END section TOOLCONTENT 
    56 *} 
    57 {/if} 
    58  
    5949{if $sectionMAINCONTENT} 
    6050{*