Changeset 1391
- Timestamp:
- 06/09/09 21:16:53 (4 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 1 added
- 20 modified
-
CHANGELOG (modified) (1 diff)
-
wifidog/classes/Authenticator.php (modified) (1 diff)
-
wifidog/classes/FormSelectGenerator.php (modified) (1 diff)
-
wifidog/classes/MainUI.php (modified) (1 diff)
-
wifidog/classes/Network.php (modified) (3 diffs)
-
wifidog/classes/Node.php (modified) (8 diffs)
-
wifidog/classes/NodeList.php (modified) (2 diffs)
-
wifidog/classes/NodeLists/NodeListHTML.php (modified) (5 diffs)
-
wifidog/classes/Server.php (modified) (5 diffs)
-
wifidog/hotspot_status.php (modified) (1 diff)
-
wifidog/hotspots_map.php (modified) (1 diff)
-
wifidog/include/schema_validate.php (modified) (6 diffs)
-
wifidog/index.php (modified) (2 diffs)
-
wifidog/lost_password.php (modified) (1 diff)
-
wifidog/lost_username.php (modified) (1 diff)
-
wifidog/node_list.php (modified) (2 diffs)
-
wifidog/resend_validation.php (modified) (1 diff)
-
wifidog/signup.php (modified) (3 diffs)
-
wifidog/templates/node_list.html (modified) (1 diff)
-
wifidog/templates/sites/hotspot_status.tpl (modified) (1 diff)
-
wifidog/templates/sites/indexglobaluser.tpl (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1387 r1391 1 1 # $Id$ 2 2009-06-09 Benoit Grégoire <benoitg@coeus.ca> 3 * Commit slightly modified patch contributed by Zap Sherbrooke: Allow using the multiple account feature while keeping a common userbase. Enabled in server configuration. 4 5 2 6 2008-10-13 Robin Jones 3 7 * fixed #498 curley brace missing in portal.php -
trunk/wifidog-auth/wifidog/classes/Authenticator.php
r1351 r1391 143 143 $smarty=SmartyWiFiDog::getObject(); 144 144 // Set network selector 145 $smarty->assign('selectNetworkUI', Network::getSelectUI('auth_source', $networkUserData)); 145 $network_array = Network::getAllNetworks(); 146 $default_network = Network::getDefaultNetwork(); 147 148 foreach ($network_array as $network) { 149 if ($network->getName() == $default_network) 150 $default_network_param = $network->getId(); 151 } 152 if (Server::getServer()->getUseGlobalUserAccounts()) 153 $smarty->assign('selectNetworkUI', "<input type=\"hidden\" name=\"auth_source\" value='$default_network_param' />"); 154 else 155 $smarty->assign('selectNetworkUI', Network::getSelectUI('auth_source', $networkUserData)); 156 146 157 // Set user details 147 158 $smarty->assign('user_id', $selectedUser ? $selectedUser->getId() : ""); -
trunk/wifidog-auth/wifidog/classes/FormSelectGenerator.php
r1170 r1391 193 193 * @return string The HTML SELECT element definition string For example: "onclick='submit();' 194 194 */ 195 public static function generateFromArray($array, $selectedPrimaryKey, $userPrefix, $objectPrefix, $allowNullValues, $nullCaptionString = ' - - - ', $additionalSelectAttribute = "", $max_length = -1) 196 { 195 public static function generateFromArray($array, $selectedPrimaryKey, $userPrefix, $objectPrefix, $allowNullValues, $nullCaptionString = null, $additionalSelectAttribute = "", $max_length = -1) 196 { 197 $nullCaptionString = $nullCaptionString===null?' - - - ':$nullCaptionString; 197 198 $retval = ""; 198 199 $retval .= "<select id='{$userPrefix}{$objectPrefix}' name='{$userPrefix}{$objectPrefix}' {$additionalSelectAttribute}>\n"; -
trunk/wifidog-auth/wifidog/classes/MainUI.php
r1364 r1391 229 229 230 230 // Set default title 231 $this->title = Network :: getCurrentNetwork()->getName() . ' ' . _("authentication server"); 231 if(Server::getServer()->getUseGlobalUserAccounts()) { 232 $this->title = _("authentication server"); 233 } else { 234 $this->title = Network :: getCurrentNetwork()->getName() . ' ' . _("authentication server"); 235 } 232 236 // Init the content array 233 237 $current_content_sql = "SELECT display_area FROM content_available_display_areas\n"; -
trunk/wifidog-auth/wifidog/classes/Network.php
r1384 r1391 236 236 public static function getSelectUI($user_prefix, $userData=null) 237 237 { 238 $userData=$userData===null?array():$userData; 238 239 $html = ''; 239 240 $name = $user_prefix; 240 241 //pretty_print_r($userData); 241 !empty($userData['preSelectedObject'])?$selected_id=$userData['preSelectedObject']->getId():$selected_id=self::getDefaultNetwork()->getId();242 array_key_exists('preSelectedObject',$userData)?(empty($userData['preSelectedObject'])?$selected_id=null:$selected_id=$userData['preSelectedObject']->getId()):$selected_id=self::getDefaultNetwork()->getId(); 242 243 !empty($userData['additionalWhere'])?$additional_where=$userData['additionalWhere']:$additional_where=null; 243 244 !empty($userData['allowEmpty'])?$allow_empty=$userData['allowEmpty']:$allow_empty=false; 245 !empty($userData['nullCaptionString'])?$nullCaptionString=$userData['nullCaptionString']:$nullCaptionString=null; 246 !empty($userData['onChange'])?$onChangeString=$userData['onChange']:$onChangeString=""; 244 247 245 248 $db = AbstractDb::getObject(); … … 260 263 } 261 264 $html .= _("Network:")." \n"; 262 $html .= FormSelectGenerator :: generateFromArray($tab, $selected_id, $name, null, $allow_empty );265 $html .= FormSelectGenerator :: generateFromArray($tab, $selected_id, $name, null, $allow_empty, $nullCaptionString, "onchange='$onChangeString'"); 263 266 264 267 } else { … … 355 358 $db = AbstractDb::getObject(); 356 359 $network_id_str = $db->escapeString($p_network_id); 360 if ($network_id_str == "") 361 $network_id_str = $db->escapeString(self::getDefaultNetwork()->getId()); 362 357 363 $sql = "SELECT *, EXTRACT(EPOCH FROM validation_grace_time) as validation_grace_time_seconds FROM networks WHERE network_id='$network_id_str'"; 358 364 $row = null; -
trunk/wifidog-auth/wifidog/classes/Node.php
r1384 r1391 629 629 } 630 630 631 /** 632 * Get the selected network ID 633 * 634 * @param string $user_prefix An identifier provided by the programmer to 635 * recognise it's generated form 636 * 637 * @return string The deployment status 638 639 */ 640 public function processSelectNetworkId($user_prefix) 641 { 642 $object = null; 643 $name = "{$user_prefix}"; 644 return $_REQUEST[$name]; 645 } 646 631 647 /** @param $id The id of the node 632 648 * @param $idType 'NODE_ID' or 'GATEWAY_ID'*/ … … 706 722 } 707 723 724 725 function setNetwork(Network $network) 726 { 727 $net = $this->mDb->escapeString($network->getId()); 728 $this->mDb->execSqlUpdate("UPDATE nodes SET network_id = '{$net}' WHERE node_id = '{$this->getId()}'"); 729 $this->refresh(); 730 } 731 732 708 733 /** Get a GisPoint object ; altide is not supported yet 709 734 */ … … 1020 1045 } 1021 1046 1022 /** redirect users to the original requested web page instead of portal1023 Must be enabled in the Network configuration to have any effect1024 @return a string */1025 function getPortalOriginalUrlAllowed()1026 {1027 return (($this->_row['allow_original_url_redirect'] == 't') ? true : false);1028 }1029 1030 /** redirect users to the original requested web page instead of portal1031 Must be enabled in the Network configuration to have any effect1032 @return true on success, false on failure */1033 function setPortalOriginalUrlAllowed($value)1034 {1035 $retval = true;1036 if ($value != $this->getPortalOriginalUrlAllowed())1037 {1038 $db = AbstractDb::getObject();1039 $value ? $value = 'TRUE' : $value = 'FALSE';1040 $retval = $db->execSqlUpdate("UPDATE nodes SET allow_original_url_redirect = '{$value}' WHERE node_id = '{$this->getId()}'", false);1041 $this->refresh();1042 }1043 return $retval;1044 }1047 /** redirect users to the original requested web page instead of portal 1048 Must be enabled in the Network configuration to have any effect 1049 @return a string */ 1050 function getPortalOriginalUrlAllowed() 1051 { 1052 return (($this->_row['allow_original_url_redirect'] == 't') ? true : false); 1053 } 1054 1055 /** redirect users to the original requested web page instead of portal 1056 Must be enabled in the Network configuration to have any effect 1057 @return true on success, false on failure */ 1058 function setPortalOriginalUrlAllowed($value) 1059 { 1060 $retval = true; 1061 if ($value != $this->getPortalOriginalUrlAllowed()) 1062 { 1063 $db = AbstractDb::getObject(); 1064 $value ? $value = 'TRUE' : $value = 'FALSE'; 1065 $retval = $db->execSqlUpdate("UPDATE nodes SET allow_original_url_redirect = '{$value}' WHERE node_id = '{$this->getId()}'", false); 1066 $this->refresh(); 1067 } 1068 return $retval; 1069 } 1045 1070 1046 1071 … … 1071 1096 // Get information about the network 1072 1097 $network = $this->getNetwork(); 1073 1098 1074 1099 $node_id = $this->getId(); 1075 1100 … … 1251 1276 $_data = $this->getSelectDeploymentStatus("node_" . $node_id . "_deployment_status"); 1252 1277 $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_deployment_status", $_title, $_data); 1278 1279 // Network selection 1280 $_title = _("Node Network"); 1281 $_data = Network::getSelectUI("node_" . $node_id . "_network_id", array('preSelectedObject'=>$this->getNetwork())); 1282 $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_network", $_title, $_data); 1253 1283 1254 1284 // is_splash_only_node … … 1443 1473 $this->setDeploymentStatus(self :: processSelectDeploymentStatus($name)); 1444 1474 1475 // Network selection 1476 $name = "node_".$node_id."_network_id"; 1477 $new_network=Network :: processSelectUI($name); 1478 if($new_network!=$this->getNetwork()) { 1479 Security::requirePermission(Permission::P('NETWORK_PERM_ADD_NODE'), $new_network); 1480 $this->setNetwork($new_network); 1481 } 1482 1445 1483 // is_splash_only_node 1446 1484 if ($network->getSplashOnlyNodesAllowed()) … … 1610 1648 /** 1611 1649 * Find out how many users are online this specific Node 1612 * Counts every user account connected (once for every account), except the splash-only user + every mac adresses connecting as the splash-only user1650 * Counts every user account connected (once for every connection) 1613 1651 * @return int Number of online users 1614 1652 * … … 1627 1665 return $row['count']; 1628 1666 } 1667 1629 1668 1630 1669 /** The list of all Technical officers of this node. -
trunk/wifidog-auth/wifidog/classes/NodeList.php
r1256 r1391 59 59 * Directory of NodeList classes 60 60 */ define ('NODE_LIST_CLASSES_DIR', WIFIDOG_ABS_FILE_PATH . "classes/NodeLists"); 61 62 interface AcceptsNullNetwork { } 61 63 abstract class NodeList { 62 64 … … 85 87 $nodeList->setHeader(); 86 88 return $nodeList; 89 } 90 91 /** 92 * Indicates if the specified type of node list accepts null as the network 93 * argument in the constructor 94 * 95 * @param string $nodeListType Type of node list 96 * 97 * @return bool 98 */ 99 public static function getAllowsNullNetwork($nodeListType) 100 { 101 // Check if node list type exists 102 if (in_array($nodeListType, self::getAvailableNodeListTypes())) { 103 require_once(NODE_LIST_CLASSES_DIR . "/NodeList" . $nodeListType . ".php"); 104 } else { 105 return false; 106 } 107 108 $nodeListClass = "NodeList" . $nodeListType; 109 $ifaces = class_implements($nodeListClass); 110 return in_array("AcceptsNullNetwork", $ifaces); 87 111 } 88 112 -
trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListHTML.php
r1316 r1391 64 64 * @copyright 2006 Max Horváth, Horvath Web Consulting 65 65 */ 66 class NodeListHTML extends NodeList {66 class NodeListHTML extends NodeList implements AcceptsNullNetwork { 67 67 68 68 /** … … 122 122 // Init network 123 123 $this->_network = $network; 124 124 125 125 // Init user 126 126 $this->_currentUser = User::getCurrentUser(); … … 129 129 $this->_mainUI = MainUI::getObject(); 130 130 131 $network_where_sql = $network === null?"":"network_id = '" . $db->escapeString($this->_network->getId()) . "' AND "; 132 131 133 // Query the database, sorting by node name 132 $db->execSql("SELECT *, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, EXTRACT(epoch FROM creation_date) as creation_date_epoch, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS is_up FROM nodes WHERE network_id = '" . $db->escapeString($this->_network->getId()) . "' AND(node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') ORDER BY lower(name)", $this->_nodes, false);134 $db->execSql("SELECT *, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, EXTRACT(epoch FROM creation_date) as creation_date_epoch, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS is_up FROM nodes WHERE $network_where_sql (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') ORDER BY lower(name)", $this->_nodes, false); 133 135 } 134 136 … … 166 168 $this->_smarty->assign('num_deployed_nodes', 0); 167 169 $this->_smarty->assign('PdfSupported', false); 170 171 $userData['preSelectedObject'] = $this->_network; 172 $userData['allowEmpty'] = true; 173 $userData['nullCaptionString'] = _("All"); 174 $userData['onChange'] = "submit.click();"; 175 $this->_smarty->assign('selectNetworkUI', Network::getSelectUI('network_id', $userData) . (count(Network::getAllNetworks()) > 1 ? '<input class="submit" type="submit" name="submit" value="' . _("Change network") . '">' : "")); 176 $this->_smarty->assign('selectedNetworkName', $this->_network === null?_("All networks"):$this->_network->getName()); 177 168 178 169 179 /** … … 209 219 */ 210 220 $this->_mainUI->setTitle(_("Hotspot list")); 211 $this->_mainUI->appendHtmlHeadContent('<link rel="alternate" type="application/rss+xml" title="' . $this->_network->getName() . ": " . _("Newest Hotspots") . '" href="' . BASE_SSL_PATH . 'hotspot_status.php?format=RSS">');221 $this->_mainUI->appendHtmlHeadContent('<link rel="alternate" type="application/rss+xml" title="' . ($this->_network === null?_("All networks"):$this->_network->getName()) . ": " . _("Newest Hotspots") . '" href="' . BASE_SSL_PATH . 'hotspot_status.php?format=RSS">'); 212 222 $this->_mainUI->addContent('left_area_middle', $_html); 213 223 $this->_mainUI->addContent('main_area_middle', $_html_body); -
trunk/wifidog-auth/wifidog/classes/Server.php
r1328 r1391 265 265 $html .= "</li>\n"; 266 266 267 268 267 /* 268 * Authentication options 269 */ 270 $title = _("Authentication"); 271 $data = InterfaceElements::generateInputCheckbox("use_global_auth","", _("Use the users of default Virtual Host's network across all networks on the server."), $this->getUseGlobalUserAccounts(), "use_global_auth"); 272 273 $html .= InterfaceElements::generateAdminSectionContainer("server_authentication_options",$title, $data); 274 269 275 /* 270 276 * Access rights … … 275 281 $html .= InterfaceElements::generateAdminSectionContainer("access_rights", _("Access rights"), $html_access_rights); 276 282 } 277 283 278 284 $html .= "</ul>\n"; 279 285 $html .= "</fieldset>\n"; … … 290 296 require_once('classes/User.php'); 291 297 Security::requirePermission(Permission::P('SERVER_PERM_EDIT_SERVER_CONFIG'), $this); 298 // Authentication 299 if (isset($_REQUEST['use_global_auth'])) 300 $this->setUseGlobalUserAccounts($_REQUEST['use_global_auth']); 301 else 302 $this->setUseGlobalUserAccounts(false); 292 303 // Access rights 293 304 require_once('classes/Stakeholder.php'); … … 317 328 { 318 329 $items[] = array('path' => 'server/admin', 319 'title' => _("Server access control"),330 'title' => _("Server configuration"), 320 331 'url' => BASE_URL_PATH.htmlspecialchars("admin/generic_object_admin.php?object_class=Server&action=edit&object_id=".SERVER_ID."") 321 332 ); … … 338 349 } 339 350 351 /** 352 * Getter for UseGlobalUserAccounts 353 * 354 * @return bool 355 */ 356 public function getUseGlobalUserAccounts() 357 { 358 if (array_key_exists('use_global_auth',$this->_row)) 359 return $this->_row['use_global_auth']=='t'; 360 else 361 return False; 362 } 363 364 /** 365 * Setter for UseGlobalUserAccounts 366 * 367 * @param bool $value New value 368 * 369 * @return bool True on success, false on failure 370 */ 371 public function setUseGlobalUserAccounts($value) 372 { 373 $db = AbstractDb::getObject(); 374 $value = $value? true:false; 375 // Init values 376 $retVal = true; 377 378 if ($value != $this->getUseGlobalUserAccounts()) { 379 $value = $value ? 'true' : 'false'; 380 $retVal = $db->execSqlUpdate("UPDATE server SET use_global_auth = {$value} WHERE server_id = '{$this->getId()}'", false); 381 $this->refresh(); 382 } 383 384 return $retVal; 385 } 386 387 /** 388 * Find out how many users are online on the whole server 389 * Counts every user account connected (once for every connection) 390 * @return int Number of online users 391 * 392 * @access public 393 */ 394 public function getTotalNumOnlineUsers() 395 { 396 $db = AbstractDb::getObject(); 397 // Init values 398 $retval = array (); 399 $row = null; 400 $sql = "SELECT COUNT(*) FROM active_connections;"; 401 $db->execSqlUniqueRes($sql, $row, false); 402 403 return $row['count']; 404 } 405 406 /** 407 * Find out how many users are valid in this server's database 408 * 409 * @return int Number of valid users 410 */ 411 public function getTotalNumValidUsers() 412 { 413 414 $db = AbstractDb::getObject(); 415 416 // Init values 417 $retval = 0; 418 $row = null; 419 $useCache = false; 420 $cachedData = null; 421 422 // Create new cache objects (valid for 1 minute) 423 $cache = new Cache('server_num_valid_users', "default", 60); 424 425 // Check if caching has been enabled. 426 if ($cache->isCachingEnabled) { 427 $cachedData = $cache->getCachedData(); 428 429 if ($cachedData) { 430 // Return cached data. 431 $useCache = true; 432 $retval = $cachedData; 433 } 434 } 435 436 if (!$useCache) { 437 // Get number of valid users 438 $network_id = $db->escapeString($this->_id); 439 $db->execSqlUniqueRes("SELECT COUNT(user_id) FROM users WHERE account_status = ".ACCOUNT_STATUS_ALLOWED, $row, false); 440 // String has been found 441 $retval = $row['count']; 442 443 // Check if caching has been enabled. 444 if ($cache->isCachingEnabled) { 445 // Save data into cache, because it wasn't saved into cache before. 446 $cache->saveCachedData($retval); 447 } 448 } 449 450 return $retval; 451 } 452 453 /** 454 * Find out how many nodes are deployed in this server's database 455 * 456 * @return int Number of deployed nodes 457 */ 458 public function getTotalNumDeployedNodes() 459 { 460 461 $db = AbstractDb::getObject(); 462 463 // Init values 464 $retval = 0; 465 $row = null; 466 $useCache = false; 467 $cachedData = null; 468 469 // Create new cache objects (valid for 5 minutes) 470 $cache = new Cache('server_num_deployed_nodes', "default", 300); 471 472 // Check if caching has been enabled. 473 if ($cache->isCachingEnabled) { 474 $cachedData = $cache->getCachedData(); 475 476 if ($cachedData) { 477 // Return cached data. 478 $useCache = true; 479 $retval = $cachedData; 480 } 481 } 482 483 if (!$useCache) { 484 // Get number of deployed nodes 485 $network_id = $db->escapeString($this->_id); 486 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE')", $row, false); 487 488 // String has been found 489 $retval = $row['count']; 490 491 // Check if caching has been enabled. 492 if ($cache->isCachingEnabled) { 493 // Save data into cache, because it wasn't saved into cache before. 494 $cache->saveCachedData($retval); 495 } 496 } 497 498 return $retval; 499 } 500 501 /** 502 * Find out how many deployed nodes are online in this server's database 503 * 504 * @param bool $nonMonitoredOnly Return number of non-monitored nodes only 505 * 506 * @return int Number of deployed nodes which are online 507 */ 508 public function getNumOnlineNodes($nonMonitoredOnly = false) 509 { 510 511 $db = AbstractDb::getObject(); 512 513 // Init values 514 $retval = 0; 515 $row = null; 516 $useCache = false; 517 $cachedData = null; 518 519 // Create new cache objects (valid for 5 minutes) 520 if ($nonMonitoredOnly) { 521 $cache = new Cache('server_num_online_nodes_non_monitored', "default", 300); 522 } else { 523 $cache = new Cache('server_num_online_nodes', "default", 300); 524 } 525 526 // Check if caching has been enabled. 527 if ($cache->isCachingEnabled) { 528 $cachedData = $cache->getCachedData(); 529 530 if ($cachedData) { 531 // Return cached data. 532 $useCache = true; 533 $retval = $cachedData; 534 } 535 } 536 537 if (!$useCache) { 538 // Get number of online nodes 539 $network_id = $db->escapeString($this->_id); 540 541 if ($nonMonitoredOnly) { 542 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE node_deployment_status = 'NON_WIFIDOG_NODE' AND ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) >= interval '5 minutes')", $row, false); 543 } else { 544 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') AND ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes')", $row, false); 545 } 546 547 // String has been found 548 $retval = $row['count']; 549 550 // Check if caching has been enabled. 551 if ($cache->isCachingEnabled) { 552 // Save data into cache, because it wasn't saved into cache before. 553 $cache->saveCachedData($retval); 554 } 555 } 556 557 return $retval; 558 } 340 559 } 341 560 -
trunk/wifidog-auth/wifidog/hotspot_status.php
r1338 r1391 64 64 } 65 65 66 if (!empty ($_REQUEST['network_id'])) { 67 $network = Network::getObject($db->escapeString($_REQUEST['network_id'])); 66 if (isset ($_REQUEST["network_id"])) { 67 $network_id = $_REQUEST["network_id"]; 68 if($network_id == ""){ 69 $network = null; 70 } else { 71 try { 72 $network = Network::getObject($network_id); 73 } catch (Exception $e) { 74 $network = Network::getDefaultNetwork(); 75 } 76 } 68 77 } else { 69 $network = Network::getDefaultNetwork(true);78 $network = Network::getDefaultNetwork(); 70 79 } 71 80 72 if ($network ) {81 if ($network or NodeList::getAllowsNullNetwork($format)) { 73 82 // Init node list type 74 83 $nodeList = NodeList::getObject($format, $network); -
trunk/wifidog-auth/wifidog/hotspots_map.php
r1316 r1391 110 110 // Set network selector 111 111 $preSelectedObject = (!empty($_REQUEST['network_map']) ? Network::getObject($_REQUEST['network_map']) : Network::getCurrentNetwork()); 112 $selectNetworkUI = Network::getSelectUI('network_map', array('preSelectedObject' => $preSelectedObject)); 112 //$selectNetworkUI = Network::getSelectUI('network_map', array('preSelectedObject' => $preSelectedObject, 'onChange' => "javascript: document.lang_form.submit();")); 113 $selectNetworkUI = Network::getSelectUI('network_map', array('preSelectedObject' => $preSelectedObject, 'onChange' => "submit.click();")); 113 114 $smarty->assign('selectNetworkUI', $selectNetworkUI . (count(Network::getAllNetworks()) > 1 ? '<input class="submit" type="submit" name="submit" value="' . _("Change network") . '">' : "")); 114 115 -
trunk/wifidog-auth/wifidog/include/schema_validate.php
r1384 r1391 48 48 * Define current database schema version 49 49 */ 50 define('REQUIRED_SCHEMA_VERSION', 6 3);50 define('REQUIRED_SCHEMA_VERSION', 64); 51 51 /** Used to test a new shecma version before modyfying the database */ 52 52 define('SCHEMA_UPDATE_TEST_MODE', false); … … 1367 1367 1368 1368 $sql .= "INSERT INTO tokens (token_id, token_status, token_creation_date, token_issuer, token_owner) SELECT token AS token_id, token_status, timestamp_in AS token_creation_date, user_id AS token_issuer, user_id AS token_owner FROM connections; \n"; 1369 $sql .= "CREATE INDEX idx_token_status ON tokens (token_status);\n"; 1369 $sql .= "CREATE INDEX idx_token_status ON tokens (token_status);\n"; 1370 1370 $sql .= "ALTER TABLE connections ADD CONSTRAINT fk_tokens FOREIGN KEY (token) REFERENCES tokens (token_id) ON UPDATE CASCADE ON DELETE RESTRICT; \n"; 1371 1371 … … 1381 1381 $sql .= "ALTER TABLE connections ADD COLUMN logout_reason integer;\n"; 1382 1382 $sql .= "ALTER TABLE connections ALTER COLUMN logout_reason SET DEFAULT NULL;\n"; 1383 $sql .= "ALTER TABLE connections RENAME COLUMN token TO token_id;\n"; 1383 $sql .= "ALTER TABLE connections RENAME COLUMN token TO token_id;\n"; 1384 1384 } 1385 1385 $new_schema_version = 61; … … 1403 1403 $sql .= "ALTER TABLE nodes ADD COLUMN connection_limit_node_max_usage_duration_override interval;\n"; 1404 1404 $sql .= "ALTER TABLE nodes ALTER COLUMN connection_limit_node_max_usage_duration_override SET DEFAULT NULL;\n"; 1405 1405 1406 1406 } 1407 1407 $new_schema_version = 62; … … 1414 1414 1415 1415 $sql .= "ALTER TABLE nodes ALTER COLUMN connection_limit_node_max_total_bytes_override TYPE bigint;\n"; 1416 1416 1417 1417 } 1418 1418 $new_schema_version = 63; 1419 1419 if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 1420 1420 printUpdateVersion($new_schema_version); 1421 $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n";1421 $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 1422 1422 1423 1423 $sql .= "ALTER TABLE networks ADD column allow_original_url_redirect bool; \n"; … … 1426 1426 $sql .= "ALTER TABLE nodes ADD column allow_original_URL_redirect bool; \n"; 1427 1427 $sql .= "ALTER TABLE nodes ALTER COLUMN allow_original_URL_redirect SET DEFAULT FALSE;\n"; 1428 } 1429 $new_schema_version = 64; 1430 if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 1431 printUpdateVersion($new_schema_version); 1432 $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 1433 $sql .= "ALTER TABLE server ADD use_global_auth bool NOT NULL DEFAULT FALSE;\n"; 1428 1434 } 1429 1435 /* -
trunk/wifidog-auth/wifidog/index.php
r1253 r1391 74 74 $smarty->assign('googleMapsEnabled', defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED); 75 75 76 $net = Network::getCurrentNetwork(); 77 $smarty->assign('networkNumValidUsers', $net ? $net->getNumValidUsers() : 0); 76 if(Server::getServer()->getUseGlobalUserAccounts()) { 77 $server = Server::getServer(); 78 $smarty->assign('serverNumValidUsers', $server ? $server->getTotalNumValidUsers() : 0); 79 $smarty->assign('serverNumOnlineUsers', $server ? $server->getTotalNumOnlineUsers() : 0); 80 $smarty->assign('serverNumDeployedNodes', $server ? $server->getTotalNumDeployedNodes() : 0); 81 $smarty->assign('serverNumOnlineNodes', $server ? $server->getNumOnlineNodes() : 0); 82 $smarty->assign('serverNumNonMonitoredNodes', $server ? $server->getNumOnlineNodes(true) : 0); 83 // Compile HTML code 84 $html_body = $smarty->fetch("templates/sites/indexglobaluser.tpl"); 85 } else { 86 $net = Network::getCurrentNetwork(); 87 $smarty->assign('networkNumValidUsers', $net ? $net->getNumValidUsers() : 0); 88 // Compile HTML code 89 $html_body = $smarty->fetch("templates/sites/index.tpl"); 90 } 78 91 79 / / Compile HTML code80 $html_body = $smarty->fetch("templates/sites/index.tpl"); 81 92 /* 93 * Don't redirect on the index page 94 * 82 95 $currentNode = Node::getCurrentRealNode(); 83 96 if($currentNode){ … … 85 98 exit(); 86 99 } 100 */ 87 101 /* 88 102 * Render output -
trunk/wifidog-auth/wifidog/lost_password.php
r1249 r1391 202 202 } 203 203 204 $smarty->assign('SelectNetworkUI', Network::getSelectUI('auth_source')); 204 if (Server::getServer()->getUseGlobalUserAccounts()) { 205 $default_network_param = Network::getDefaultNetwork()->getId(); 206 $smarty->assign('SelectNetworkUI', "<input type=\"hidden\" name=\"auth_source\" value='$default_network_param' />"); 207 } else { 208 $smarty->assign('SelectNetworkUI', Network::getSelectUI('auth_source')); 209 } 205 210 206 211 // Compile HTML code -
trunk/wifidog-auth/wifidog/lost_username.php
r1249 r1391 185 185 } 186 186 187 $smarty->assign('SelectNetworkUI', Network::getSelectUI('auth_source')); 187 if (Server::getServer()->getUseGlobalUserAccounts()) { 188 $default_network_param = Network::getDefaultNetwork()->getId(); 189 $smarty->assign('SelectNetworkUI', "<input type=\"hidden\" name=\"auth_source\" value='$default_network_param' />"); 190 } else { 191 $smarty->assign('SelectNetworkUI', Network::getSelectUI('auth_source')); 192 } 188 193 189 194 // Compile HTML code -
trunk/wifidog-auth/wifidog/node_list.php
r1259 r1391 98 98 $sort_by_param_sql = $sort_by_param; 99 99 } 100 $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status, last_heartbeat_wifidog_uptime, last_heartbeat_sys_uptime FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' ORDER BY {$sort_by_param_sql}"; 100 } else { 101 $sort_by_param_sql = DEFAULT_SORT_BY_PARAM; 101 102 } 102 else { 103 $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status, last_heartbeat_wifidog_uptime, last_heartbeat_sys_uptime FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' ORDER BY " . DEFAULT_SORT_BY_PARAM; 103 104 if (isset ($_REQUEST["network_id"])) { 105 $network_id = $_REQUEST["network_id"]; 106 if($network_id == ""){ 107 $network = null; 108 } else { 109 try { 110 $network = Network::getObject($network_id); 111 } catch (Exception $e) { 112 $network = Network::getDefaultNetwork(); 113 } 114 } 115 } else { 116 $network = Network::getDefaultNetwork(); 104 117 } 118 $network_id_sql = $network===null?"":"AND network_id = '{$network->getId()}'"; 119 120 $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status, last_heartbeat_wifidog_uptime, last_heartbeat_sys_uptime FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' $network_id_sql ORDER BY {$sort_by_param_sql}"; 105 121 $nodes_results = null; 106 122 $db->execSql($sql, $nodes_results, false); 107 123 108 if ($nodes_results == null) 109 throw new Exception(_("No nodes could not be found in the database")); 124 //Possible to select empty networks, not an error 125 if ($nodes_results === null) 126 $nodes_results = array(); 127 //throw new Exception(_("No nodes could not be found in the database")); 128 110 129 111 130 $deploymentStatuses = array ( … … 148 167 149 168 // Pass values to Smarty 169 $smarty->assign('selectNetworkUI', Network::getSelectUI('network_id', array('preSelectedObject' => $network, 'allowEmpty' => true, 'nullCaptionString' => _("All"), 'onChange' => "submit.click();") ) . (count(Network::getAllNetworks()) > 1 ? '<input class="submit" type="submit" name="submit" value="' . _("Change network") . '">' : "")); 170 if ($network !== null ) { 171 $smarty->assign('selectedNetwork', $network->getName()); 172 } else { 173 $smarty->assign('allNetworks', _("All networks")); 174 } 150 175 $smarty->assign("nodes", $nodes_list); 151 176 $smarty->assign("sort_by_param", $sort_by_param); -
trunk/wifidog-auth/wifidog/resend_validation.php
r1249 r1391 184 184 } 185 185 186 $smarty->assign('SelectNetworkUI', Network::getSelectUI('auth_source')); 186 if (Server::getServer()->getUseGlobalUserAccounts()) { 187 $default_network_param = Network::getDefaultNetwork()->getId(); 188 $smarty->assign('SelectNetworkUI', "<input type=\"hidden\" name=\"auth_source\" value='$default_network_param' />"); 189 } else { 190 $smarty->assign('SelectNetworkUI', Network::getSelectUI('auth_source')); 191 } 187 192 188 193 // Compile HTML code -
trunk/wifidog-auth/wifidog/signup.php
r1249 r1391 320 320 // Preserve keys 321 321 $network_array = Network::getAllNetworks(); 322 $default_network = Network::getDefaultNetwork(); 323 322 324 323 325 foreach ($network_array as $network) { … … 325 327 $sources[$network->getId()] = $network->getName(); 326 328 } 329 if ($network->getName() == $default_network) 330 $default_network_param = $network->getId(); 331 //$default_network_param = $network->getAuthenticatorConstructorParams(); 332 327 333 } 328 334 … … 336 342 } 337 343 338 $smarty->assign('SelectNetworkUI', Network::getSelectUI('auth_source')); 344 if (Server::getServer()->getUseGlobalUserAccounts()) 345 $smarty->assign('SelectNetworkUI', "<input type=\"hidden\" name=\"auth_source\" value='$default_network_param' />"); 346 else 347 $smarty->assign('SelectNetworkUI', Network::getSelectUI('network_id', array('preSelectedObject' => $network)) ); 339 348 340 349 // Compile HTML code -
trunk/wifidog-auth/wifidog/templates/node_list.html
r1257 r1391 1 {if $selectNetworkUI} 2 <form name="hotspots_form" method="post"> 3 {$selectNetworkUI} 4 </form> 5 {/if} 1 6 <div id="node_list"> 2 <h3>{"Status of all nodes of the"|_} {$networkName} {"network"|_}</h3> 7 {if $allNetworks } 8 <h3>{"Status of all nodes on "|_} {$allNetworks}</h3> 9 {else} 10 {if $selectedNetwork} 11 <h3>{"Status of all nodes of the "|_} {$selectedNetwork} {"network"|_}</h3> 12 {else} 13 <h3>{"Status of all nodes of the"|_} {$networkName} {"network"|_}</h3> 14 {/if} 15 {/if} 3 16 <table> 4 17 <thead> -
trunk/wifidog-auth/wifidog/templates/sites/hotspot_status.tpl
r1249 r1391 51 51 BEGIN section MAINCONTENT 52 52 *} 53 54 <form name="hotspots_form" method="post"> 55 <input type="hidden" name="format" value="HTML" /> 56 {$selectNetworkUI} 57 </form> 58 <br /> 59 53 60 <div id="hotspot_status"> 54 61 <table> 55 62 <thead> 56 63 <tr> 57 <th colspan="6">{"Status of the %d open %s Hotspots"|_|sprintf:$num_deployed_nodes:$networkName}</th>64 <th colspan="6">{"Status of the %d open %s Hotspots"|_|sprintf:$num_deployed_nodes:$selectedNetworkName}</th> 58 65 </tr> 59 66 <tr>
