Changeset 1253
- Timestamp:
- 07/16/07 01:11:27 (6 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 21 modified
-
CHANGELOG (modified) (1 diff)
-
wifidog/classes/Menu.php (modified) (3 diffs)
-
wifidog/classes/Node.php (modified) (3 diffs)
-
wifidog/classes/NodeList.php (modified) (5 diffs)
-
wifidog/classes/NodeLists/NodeListHTML.php (modified) (7 diffs)
-
wifidog/classes/NodeLists/NodeListJiWireCSV.php (modified) (4 diffs)
-
wifidog/classes/NodeLists/NodeListKML.php (modified) (4 diffs)
-
wifidog/classes/NodeLists/NodeListPDF.php (modified) (16 diffs)
-
wifidog/classes/NodeLists/NodeListRSS.php (modified) (4 diffs)
-
wifidog/classes/NodeLists/NodeListXML.php (modified) (7 diffs)
-
wifidog/classes/Server.php (modified) (1 diff)
-
wifidog/classes/StatisticReport.php (modified) (1 diff)
-
wifidog/classes/StatisticReport/NodeStatus.php (modified) (1 diff)
-
wifidog/hotspot_status.php (modified) (4 diffs)
-
wifidog/include/schema_validate.php (modified) (2 diffs)
-
wifidog/index.php (modified) (3 diffs)
-
wifidog/ping/index.php (modified) (1 diff)
-
wifidog/portal/index.php (modified) (2 diffs)
-
wifidog/profile/index.php (modified) (1 diff)
-
wifidog/templates/node_list.html (modified) (2 diffs)
-
wifidog/templates/sites/index.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1252 r1253 1 2007-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 1 10 2007-06-12 Benoit Grégoire <bock@step.polymtl.ca> 2 11 * MainUI.php: Fix label problem in language chooser. -
trunk/wifidog-auth/wifidog/classes/Menu.php
r1249 r1253 118 118 } 119 119 /** 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) { 121 121 //echo "menuArrayWalkRecursive called with menuArray:"; pretty_print_r($menuArray); 122 122 $retval = true; … … 137 137 public function menuArrayWalkRecursive($funcname, &$userdata = null) { 138 138 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; 139 163 } 140 164 … … 165 189 $this->processHookMenu('Network'); 166 190 $this->processHookMenu('User'); 167 $this->processHookMenu('Content');168 $this->processHookMenu('NodeList');191 $this->processHookMenu('Content'); 192 $this->processHookMenu('NodeList'); 169 193 $this->processHookMenu('Role'); 170 194 $this->processHookMenu('VirtualHost'); 171 195 $this->processHookMenu('ContentTypeFilter'); 172 196 $this->processHookMenu('ProfileTemplate'); 197 self::menuArraySort($this->_menuArray, array('Menu','titlestrcoll')); 173 198 //pretty_print_r($this->_menuArray); 174 199 } -
trunk/wifidog-auth/wifidog/classes/Node.php
r1249 r1253 142 142 public static function getCurrentRealNode() 143 143 { 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'; 146 149 if(!isset($currentRealNodeComputed)) 147 150 { 148 151 $currentRealNodeComputed=true; 149 152 $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"; 151 154 $node_rows = null; 152 $db->execSql($sql , $node_rows, false);155 $db->execSql($sql_ip, $node_rows, false); 153 156 $num_match = count($node_rows); 154 157 if ($num_match == 0) 155 158 { 156 157 159 // User is not physically connected to a node 158 160 $currentRealNode = null; 159 161 } 160 else 161 if ($num_match = 1) 162 else if ($num_match == 1) 162 163 { 163 164 // Only a single node matches, the user is presumed to be there … … 166 167 else 167 168 { 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).*/ 172 170 $currentRealNode = null; 173 171 $current_user = User :: getCurrentUser(); 174 172 if ($current_user != null) 175 173 { 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 */ 176 177 $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) 182 182 { 183 183 $currentRealNode = self::getObject($node_row['node_id']); 184 184 } 185 185 } 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 } 186 190 } 187 191 } 188 189 192 return $currentRealNode; 190 193 } … … 806 809 } 807 810 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 808 831 function getLastHeartbeatTimestamp() 809 832 { -
trunk/wifidog-auth/wifidog/classes/NodeList.php
r1249 r1253 59 59 * Directory of NodeList classes 60 60 */ 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; 61 abstract class NodeList { 62 77 63 78 64 /** … … 84 70 * @return void 85 71 */ 86 public function __construct($nodeListType, &$network)72 public static function &getObject($nodeListType, &$network) 87 73 { 88 74 // Check if node list type exists … … 93 79 } 94 80 95 $ _nodeListClass = "NodeList" . $nodeListType;96 $ this->nodeList = new $_nodeListClass($network);81 $nodeListClass = "NodeList" . $nodeListType; 82 $nodeList = new $nodeListClass($network); 97 83 98 84 // 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; 102 87 } 103 88 … … 166 151 return $_nodeListTypes; 167 152 } 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 168 181 /** Menu hook function */ 169 182 static public function hookMenu() { … … 178 191 //pretty_print_r($listTypes); 179 192 foreach ($listTypes as $type) { 193 $nodeListClass = "NodeList" . $type; 194 require_once("classes/NodeLists/NodeList{$type}.php"); 195 if(call_user_func(array($nodeListClass, 'isAvailable'))) { 180 196 $items[] = array('path' => 'node_lists/'.$type, 181 197 'title' => sprintf(_("List in %s format"), $type), 182 198 'url' => BASE_URL_PATH."hotspot_status.php?format=$type" 183 199 ); 200 } 184 201 } 185 202 $items[] = array('path' => 'node_lists/technical_status', -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListHTML.php
r1249 r1253 37 37 * @package WiFiDogAuthServer 38 38 * @subpackage NodeLists 39 * @author Benoit Grégoire <bock@step.polymtl.ca> 40 * @author Francois Proulx <francois.proulx@gmail.com> 39 41 * @author Max Horváth <max.horvath@freenet.de> 42 * @copyright 2004-2007 Benoit Grégoire, Technologies Coeus inc. 40 43 * @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: $ 42 45 * @link http://www.wifidog.org/ 43 46 */ … … 47 50 */ 48 51 require_once('classes/Dependency.php'); 52 require_once('classes/NodeList.php'); 49 53 require_once('classes/Network.php'); 50 54 require_once('classes/Node.php'); … … 60 64 * @copyright 2006 Max Horváth, Horvath Web Consulting 61 65 */ 62 class NodeListHTML {66 class NodeListHTML extends NodeList{ 63 67 64 68 /** … … 142 146 143 147 /** 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 * 149 150 * @return void 150 151 * … … 156 157 * @copyright 2006 Max Horváth, Horvath Web Consulting 157 158 */ 158 public function getOutput( $return_object = false)159 public function getOutput() 159 160 { 160 // Init ALL smarty SWITCH values161 $this->_smarty->assign('sectionTOOLCONTENT', false);162 $this->_smarty->assign('sectionMAINCONTENT', false);163 161 164 162 // Init ALL smarty values … … 169 167 $this->_smarty->assign('num_deployed_nodes', 0); 170 168 $this->_smarty->assign('PdfSupported', false); 171 172 /*173 * Tool content174 */175 169 176 170 /** … … 194 188 195 189 // Reset ALL smarty SWITCH values 196 $this->_smarty->assign('sectionTOOLCONTENT', false);197 190 $this->_smarty->assign('sectionMAINCONTENT', false); 198 191 -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListJiWireCSV.php
r1192 r1253 47 47 require_once('classes/Network.php'); 48 48 require_once('classes/Node.php'); 49 49 require_once('classes/NodeList.php'); 50 50 /** 51 51 * Defines the JiWire CSV type of node list … … 56 56 * @copyright (c) 2006 François Proulx 57 57 */ 58 class NodeListJiWireCSV {58 class NodeListJiWireCSV extends NodeList { 59 59 60 60 /** … … 119 119 /** 120 120 * Retreives the output of this object. 121 *122 * @param bool $return_object If true this function only returns the DOM object123 121 * 124 122 * @return string The XML output … … 131 129 * @copyright 2006 Max Horváth, Horvath Web Consulting 132 130 */ 133 public function getOutput( $return_object = false)131 public function getOutput() 134 132 { 135 133 $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 50 50 require_once('classes/Network.php'); 51 51 require_once('classes/Node.php'); 52 require_once('classes/NodeList.php'); 52 53 53 54 /** … … 59 60 * @copyright 2006 Joe Bowser 60 61 */ 61 class NodeListKML {62 class NodeListKML extends NodeList{ 62 63 63 64 /** … … 122 123 123 124 /** 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 129 128 * 130 129 * @author Benoit Gregoire <bock@step.polymtl.ca> … … 137 136 * @copyright 2006 Joe Bowser 138 137 */ 139 public function getOutput( $return_object = false)138 public function getOutput() 140 139 { 141 140 $_kml = $this->_xmldoc->createElement("kml"); -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListPDF.php
r1249 r1253 39 39 * @author Max Horváth <max.horvath@freenet.de> 40 40 * @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: $ 42 42 * @link http://www.wifidog.org/ 43 43 */ … … 47 47 */ 48 48 require_once('classes/Dependency.php'); 49 require_once('classes/NodeList.php'); 49 50 require_once('classes/MainUI.php'); 50 51 require_once('classes/Network.php'); … … 58 59 59 60 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 } 65 66 } 66 67 … … 183 184 $this->_lastRC4Key = ''; 184 185 $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"; 186 187 } 187 188 … … 314 315 // Define which array data to use 315 316 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; 350 351 } 351 352 … … 362 363 // Define which array data to use 363 364 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; 402 403 } 403 404 … … 433 434 function _putinfo() 434 435 { 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'))); 462 463 } 463 464 … … 794 795 exit(); 795 796 } 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();803 797 } 804 798 … … 811 805 * @copyright 2006 Max Horváth, Horvath Web Consulting 812 806 */ 813 class NodeListPDF 807 class NodeListPDF extends NodeList 814 808 { 815 809 /** … … 884 878 */ 885 879 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 } 886 891 887 892 /** … … 892 897 public function __construct(&$network) 893 898 { 894 899 895 900 $db = AbstractDb::getObject(); 896 901 … … 920 925 if (defined("PDF_SORT")) { 921 926 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; 931 936 932 937 } … … 956 961 $this->_pdf->SetKeywords($this->_network->getName() . ", " . _("Hotspots")); 957 962 958 if (defined("WIFIDOG_NAME")) {963 if (defined("WIFIDOG_NAME")) { 959 964 $this->_pdf->SetCreator(WIFIDOG_NAME); 960 }965 } 961 966 962 967 // Define styles … … 999 1004 1000 1005 /** 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. 1005 1007 * 1006 1008 * @return string The PDF file 1007 1009 */ 1008 public function getOutput( $return_object = false)1010 public function getOutput() 1009 1011 { 1010 1012 // Init values … … 1059 1061 break; 1060 1062 1061 }1063 } 1062 1064 1063 1065 $this->_pdf->Write(10, utf8_decode(sprintf(_("This list contains all Hotspots of %s sorted by %s."), $this->_network->getName(), $_sortBy))); … … 1085 1087 // Compile PDF file 1086 1088 $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(); 1087 1097 } 1088 1098 } -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListRSS.php
r1192 r1253 46 46 * Load required classes 47 47 */ 48 require_once('classes/NodeList.php'); 48 49 require_once('classes/Network.php'); 49 50 require_once('classes/Node.php'); … … 57 58 * @author Max Horváth <max.horvath@freenet.de> 58 59 * @copyright 2006 Max Horváth, Horvath Web Consulting 60 * @copyright 2004-2007 Benoit Grégoire, Technologies Coeus inc. 59 61 */ 60 class NodeListRSS {62 class NodeListRSS extends NodeList{ 61 63 62 64 /** … … 121 123 * Retreives the output of this object. 122 124 * 123 * @param bool $return_object This parameter doesn't have any effect in124 * the class125 *126 125 * @return void 127 126 * … … 133 132 * @copyright 2006 Max Horváth, Horvath Web Consulting 134 133 */ 135 public function getOutput( $return_object = false)134 public function getOutput() 136 135 { 137 136 -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListXML.php
r1192 r1253 37 37 * @package WiFiDogAuthServer 38 38 * @subpackage NodeLists 39 * @author Benoit Grégoire <bock@step.polymtl.ca> 40 * @author Francois Proulx <francois.proulx@gmail.com> 39 41 * @author Max Horváth <max.horvath@freenet.de> 42 * @copyright 2004-2007 Benoit Grégoire, Technologies Coeus inc. 40 43 * @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: $ 42 45 * @link http://www.wifidog.org/ 43 46 */ … … 46 49 * Load required classes 47 50 */ 51 require_once('classes/NodeList.php'); 48 52 require_once('classes/Network.php'); 49 53 require_once('classes/Node.php'); … … 54 58 * @package WiFiDogAuthServer 55 59 * @subpackage NodeLists 60 * @author Benoit Grégoire <bock@step.polymtl.ca> 61 * @author Francois Proulx <francois.proulx@gmail.com> 56 62 * @author Max Horváth <max.horvath@freenet.de> 63 * @copyright 2004-2007 Benoit Grégoire, Technologies Coeus inc. 57 64 * @copyright 2006 Max Horváth, Horvath Web Consulting 58 65 */ 59 class NodeListXML {66 class NodeListXML extends NodeList{ 60 67 61 68 /** … … 90 97 public function __construct(&$network) 91 98 { 92 99 93 100 $db = AbstractDb::getObject(); 94 101 … … 207 214 $_nodeId = $this->_xmldoc->createElement("nodeId", $_node->getId()); 208 215 $_nodeMetadataNode->appendChild($_nodeId); 209 216 210 217 // Online Users 211 218 $_nodeUserNum = $this->_xmldoc->createElement("numOnlineUsers", $_node->GetNumOnlineUsers()); … … 225 232 } 226 233 227 if (($_gisData = $_node->getGisLocation()) !== null) {234 if (($_gisData = $_node->getGisLocation()) !== null) { 228 235 $_nodeGis = $this->_xmldoc->createElement("gisLatLong"); 229 236 $_nodeGis->setAttribute("lat", $_gisData->getLatitude()); … … 320 327 321 328 // Long / Lat 322 if (($_gisData = $_node->getGisLocation()) !== null) {329 if (($_gisData = $_node->getGisLocation()) !== null) { 323 330 $_hotspotGis = $this->_xmldoc->createElement("gisCenterLatLong"); 324 331 $_hotspotGis->setAttribute("lat", $_gisData->getLatitude()); -
trunk/wifidog-auth/wifidog/classes/Server.php
r1249 r1253 303 303 } 304 304 $items[] = array('path' => 'server', 305 'title' => _('Server '),305 'title' => _('Server administration'), 306 306 'type' => MENU_ITEM_GROUPING); 307 307 -
trunk/wifidog-auth/wifidog/classes/StatisticReport.php
r1249 r1253 68 68 final public static function &getObject($classname, Statistics $statistics_object) 69 69 { 70 return new $classname ($statistics_object); 70 $object = new $classname ($statistics_object); 71 return $object; 71 72 } 72 73 -
trunk/wifidog-auth/wifidog/classes/StatisticReport/NodeStatus.php
r1192 r1253 117 117 $html .= "</tr>"; 118 118 $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'>"; 119 135 $html .= " <th>"._("IP Address")."</th>"; 120 136 $html .= " <td>".$nodeObject->getLastHeartbeatIP()."</td>"; -
trunk/wifidog-auth/wifidog/hotspot_status.php
r1249 r1253 41 41 * @author Francois Proulx <francois.proulx@gmail.com> 42 42 * @author Max Horváth <max.horvath@freenet.de> 43 * @copyright 2004-200 6Benoit Grégoire, Technologies Coeus inc.43 * @copyright 2004-2007 Benoit Grégoire, Technologies Coeus inc. 44 44 * @copyright 2004-2006 Francois Proulx, Technologies Coeus inc. 45 45 * @copyright 2006 Max Horváth, Horvath Web Consulting … … 72 72 if ($network) { 73 73 // Init node list type 74 $nodeList = new NodeList($format, $network);74 $nodeList = NodeList::getObject($format, $network); 75 75 /** 76 76 * XSLT support for Hotspot status page … … 95 95 // Prepare HTML 96 96 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)); 98 98 } 99 99 } … … 104 104 } else { 105 105 // Deliver node list 106 $nodeList-> nodeList->getOutput();106 $nodeList->getOutput(); 107 107 } 108 108 } -
trunk/wifidog-auth/wifidog/include/schema_validate.php
r1249 r1253 48 48 * Define current database schema version 49 49 */ 50 define('REQUIRED_SCHEMA_VERSION', 5 4);50 define('REQUIRED_SCHEMA_VERSION', 55); 51 51 /** Used to test a new shecma version before modyfying the database */ 52 52 define('SCHEMA_UPDATE_TEST_MODE', false); … … 1266 1266 1267 1267 } 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 } 1269 1281 /* 1270 1282 $new_schema_version = ; -
trunk/wifidog-auth/wifidog/index.php
r1249 r1253 58 58 59 59 $smarty = SmartyWifidog::getObject(); 60 // Init ALL smarty SWITCH values61 $smarty->assign('sectionTOOLCONTENT', false);62 $smarty->assign('sectionMAINCONTENT', false);63 60 64 61 // Init ALL smarty values … … 69 66 70 67 /* 71 * Tool content72 */73 74 // Set section of Smarty template75 $smarty->assign('sectionTOOLCONTENT', true);76 77 // Compile HTML code78 $html = $smarty->fetch("templates/sites/index.tpl");79 80 /*81 68 * Main content 82 69 */ 83 84 // Reset ALL smarty SWITCH values85 $smarty->assign('sectionTOOLCONTENT', false);86 $smarty->assign('sectionMAINCONTENT', false);87 88 70 // Set section of Smarty template 89 71 $smarty->assign('sectionMAINCONTENT', true); … … 98 80 $html_body = $smarty->fetch("templates/sites/index.tpl"); 99 81 82 $currentNode = Node::getCurrentRealNode(); 83 if($currentNode){ 84 header("Location: ".BASE_URL_PATH."portal/?node_id=".$currentNode->getId()); 85 exit(); 86 } 100 87 /* 101 88 * Render output 102 89 */ 103 90 $ui = MainUI::getObject(); 104 $ui->addContent('left_area_middle', $html);105 91 $ui->addContent('main_area_top', $html_body); 106 92 $ui->display(); -
trunk/wifidog-auth/wifidog/ping/index.php
r1133 r1253 51 51 52 52 echo "Pong"; 53 $db = AbstractDb::getObject(); 53 $db = AbstractDb::getObject(); 54 54 $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 55 60 $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'"); 57 62 58 63 /* -
trunk/wifidog-auth/wifidog/portal/index.php
r1249 r1253 99 99 } 100 100 101 /*102 * If this node has a custom portal defined, and the network config allows it,103 * redirect to the custom portal104 */105 $custom_portal_url = $node->getCustomPortalRedirectUrl();106 107 if (!empty ($custom_portal_url) && $network->getCustomPortalRedirectAllowed()) {108 header("Location: {$custom_portal_url}");109 }110 111 101 $node_id = $node->getId(); 112 $portal_template = $node_id.".html";113 102 Node :: setCurrentNode($node); 114 103 … … 118 107 } 119 108 } 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 115 if (!empty ($custom_portal_url) && $network->getCustomPortalRedirectAllowed()) { 116 header("Location: {$custom_portal_url}"); 117 exit; 118 } 119 122 120 $smarty->assign('sectionMAINCONTENT', false); 123 121 -
trunk/wifidog-auth/wifidog/profile/index.php
r1249 r1253 89 89 90 90 // Init ALL smarty SWITCH values 91 $smarty->assign('sectionTOOLCONTENT', false);92 91 $smarty->assign('sectionMAINCONTENT', false); 93 92 -
trunk/wifidog-auth/wifidog/templates/node_list.html
r1157 r1253 36 36 {if $nodes[node].online == 't'} 37 37 <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} 38 41 {else} 39 42 <img src='{$common_images_url}HotspotStatus/down.gif'> … … 47 50 <td> 48 51 <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> 50 53 </td> 51 54 <td style="font-size: 8pt;">{$nodes[node].creation_date}<br> -
trunk/wifidog-auth/wifidog/templates/sites/index.tpl
r1249 r1253 47 47 *} 48 48 49 {if $sectionTOOLCONTENT}50 {*51 BEGIN section TOOLCONTENT52 *}53 54 {*55 END section TOOLCONTENT56 *}57 {/if}58 59 49 {if $sectionMAINCONTENT} 60 50 {*
