| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
|---|
| 4 | |
|---|
| 5 | // +-------------------------------------------------------------------+ |
|---|
| 6 | // | WiFiDog Authentication Server | |
|---|
| 7 | // | ============================= | |
|---|
| 8 | // | | |
|---|
| 9 | // | The WiFiDog Authentication Server is part of the WiFiDog captive | |
|---|
| 10 | // | portal suite. | |
|---|
| 11 | // +-------------------------------------------------------------------+ |
|---|
| 12 | // | PHP version 5 required. | |
|---|
| 13 | // +-------------------------------------------------------------------+ |
|---|
| 14 | // | Homepage: http://www.wifidog.org/ | |
|---|
| 15 | // | Source Forge: http://sourceforge.net/projects/wifidog/ | |
|---|
| 16 | // +-------------------------------------------------------------------+ |
|---|
| 17 | // | This program is free software; you can redistribute it and/or | |
|---|
| 18 | // | modify it under the terms of the GNU General Public License as | |
|---|
| 19 | // | published by the Free Software Foundation; either version 2 of | |
|---|
| 20 | // | the License, or (at your option) any later version. | |
|---|
| 21 | // | | |
|---|
| 22 | // | This program is distributed in the hope that it will be useful, | |
|---|
| 23 | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|---|
| 24 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|---|
| 25 | // | GNU General Public License for more details. | |
|---|
| 26 | // | | |
|---|
| 27 | // | You should have received a copy of the GNU General Public License | |
|---|
| 28 | // | along with this program; if not, contact: | |
|---|
| 29 | // | | |
|---|
| 30 | // | Free Software Foundation Voice: +1-617-542-5942 | |
|---|
| 31 | // | 59 Temple Place - Suite 330 Fax: +1-617-542-2652 | |
|---|
| 32 | // | Boston, MA 02111-1307, USA gnu@gnu.org | |
|---|
| 33 | // | | |
|---|
| 34 | // +-------------------------------------------------------------------+ |
|---|
| 35 | |
|---|
| 36 | /** |
|---|
| 37 | * @package WiFiDogAuthServer |
|---|
| 38 | * @subpackage NodeLists |
|---|
| 39 | * @author Max Horváth <max.horvath@freenet.de> |
|---|
| 40 | * @copyright 2006 Max Horváth, Horvath Web Consulting |
|---|
| 41 | * @version Subversion $Id: Content.php 974 2006-02-25 15:08:12Z max-horvath $ |
|---|
| 42 | * @link http://www.wifidog.org/ |
|---|
| 43 | */ |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * Load required classes |
|---|
| 47 | */ |
|---|
| 48 | require_once('classes/Dependency.php'); |
|---|
| 49 | require_once('classes/Network.php'); |
|---|
| 50 | require_once('classes/Node.php'); |
|---|
| 51 | require_once('classes/MainUI.php'); |
|---|
| 52 | require_once('classes/User.php'); |
|---|
| 53 | |
|---|
| 54 | /** |
|---|
| 55 | * Defines the HTML type of node list |
|---|
| 56 | * |
|---|
| 57 | * @package WiFiDogAuthServer |
|---|
| 58 | * @subpackage NodeLists |
|---|
| 59 | * @author Max Horváth <max.horvath@freenet.de> |
|---|
| 60 | * @copyright 2006 Max Horváth, Horvath Web Consulting |
|---|
| 61 | */ |
|---|
| 62 | class NodeListHTML { |
|---|
| 63 | |
|---|
| 64 | /** |
|---|
| 65 | * Smarty object |
|---|
| 66 | * |
|---|
| 67 | * @var object |
|---|
| 68 | |
|---|
| 69 | */ |
|---|
| 70 | private $_smarty; |
|---|
| 71 | |
|---|
| 72 | /** |
|---|
| 73 | * Network to generate the list from |
|---|
| 74 | * |
|---|
| 75 | * @var object |
|---|
| 76 | |
|---|
| 77 | */ |
|---|
| 78 | private $_network; |
|---|
| 79 | |
|---|
| 80 | /** |
|---|
| 81 | * Nodes to generate the list from |
|---|
| 82 | * |
|---|
| 83 | * @var array |
|---|
| 84 | |
|---|
| 85 | */ |
|---|
| 86 | private $_nodes; |
|---|
| 87 | |
|---|
| 88 | /** |
|---|
| 89 | * Object of current user |
|---|
| 90 | * |
|---|
| 91 | * @var object |
|---|
| 92 | |
|---|
| 93 | */ |
|---|
| 94 | private $_currentUser; |
|---|
| 95 | |
|---|
| 96 | /** |
|---|
| 97 | * Object of MainUI class |
|---|
| 98 | * |
|---|
| 99 | * @var object |
|---|
| 100 | |
|---|
| 101 | */ |
|---|
| 102 | private $_mainUI; |
|---|
| 103 | |
|---|
| 104 | /** |
|---|
| 105 | * Constructor |
|---|
| 106 | * |
|---|
| 107 | * @return void |
|---|
| 108 | */ |
|---|
| 109 | public function __construct(&$network) |
|---|
| 110 | { |
|---|
| 111 | |
|---|
| 112 | $db = AbstractDb::getObject(); |
|---|
| 113 | $smarty = SmartyWifidog::getObject(); |
|---|
| 114 | |
|---|
| 115 | // Init Smarty |
|---|
| 116 | $this->_smarty = &$smarty; |
|---|
| 117 | |
|---|
| 118 | // Init network |
|---|
| 119 | $this->_network = $network; |
|---|
| 120 | |
|---|
| 121 | // Init user |
|---|
| 122 | $this->_currentUser = User::getCurrentUser(); |
|---|
| 123 | |
|---|
| 124 | // Init MainUI class |
|---|
| 125 | $this->_mainUI = MainUI::getObject(); |
|---|
| 126 | |
|---|
| 127 | // Query the database, sorting by node name |
|---|
| 128 | $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); |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | /** |
|---|
| 132 | * Sets header of output |
|---|
| 133 | * |
|---|
| 134 | * @return void |
|---|
| 135 | */ |
|---|
| 136 | public function setHeader() |
|---|
| 137 | { |
|---|
| 138 | header("Cache-control: private, no-cache, must-revalidate"); |
|---|
| 139 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
|---|
| 140 | header("Pragma: no-cache"); |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | /** |
|---|
| 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 | * |
|---|
| 149 | * @return void |
|---|
| 150 | * |
|---|
| 151 | * @author Benoit Grégoire <bock@step.polymtl.ca> |
|---|
| 152 | * @author Francois Proulx <francois.proulx@gmail.com> |
|---|
| 153 | * @author Max Horváth <max.horvath@freenet.de> |
|---|
| 154 | * @copyright 2004-2006 Benoit Grégoire, Technologies Coeus inc. |
|---|
| 155 | * @copyright 2004-2006 Francois Proulx, Technologies Coeus inc. |
|---|
| 156 | * @copyright 2006 Max Horváth, Horvath Web Consulting |
|---|
| 157 | */ |
|---|
| 158 | public function getOutput($return_object = false) |
|---|
| 159 | { |
|---|
| 160 | // Init ALL smarty SWITCH values |
|---|
| 161 | $this->_smarty->assign('sectionTOOLCONTENT', false); |
|---|
| 162 | $this->_smarty->assign('sectionMAINCONTENT', false); |
|---|
| 163 | |
|---|
| 164 | // Init ALL smarty values |
|---|
| 165 | $this->_smarty->assign('DEPRECATEDisSuperAdmin', false); |
|---|
| 166 | $this->_smarty->assign('DEPRECATEDisOwner', false); |
|---|
| 167 | $this->_smarty->assign('GMapsEnabled', false); |
|---|
| 168 | $this->_smarty->assign('nodes', array()); |
|---|
| 169 | $this->_smarty->assign('num_deployed_nodes', 0); |
|---|
| 170 | $this->_smarty->assign('PdfSupported', false); |
|---|
| 171 | |
|---|
| 172 | /* |
|---|
| 173 | * Tool content |
|---|
| 174 | */ |
|---|
| 175 | |
|---|
| 176 | /** |
|---|
| 177 | * Define user security levels for the template |
|---|
| 178 | * |
|---|
| 179 | * These values are used in the default template of WiFoDog but could be used |
|---|
| 180 | * in a customized template to restrict certain links to specific user |
|---|
| 181 | * access levels. |
|---|
| 182 | */ |
|---|
| 183 | $this->_smarty->assign('DEPRECATEDisSuperAdmin', $this->_currentUser && $this->_currentUser->DEPRECATEDisSuperAdmin()); |
|---|
| 184 | $this->_smarty->assign('DEPRECATEDisOwner', $this->_currentUser && $this->_currentUser->DEPRECATEDisOwner()); |
|---|
| 185 | |
|---|
| 186 | if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) { |
|---|
| 187 | $this->_smarty->assign('GMapsEnabled', true); |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | $_html=null; |
|---|
| 191 | /* |
|---|
| 192 | * Main content |
|---|
| 193 | */ |
|---|
| 194 | |
|---|
| 195 | // Reset ALL smarty SWITCH values |
|---|
| 196 | $this->_smarty->assign('sectionTOOLCONTENT', false); |
|---|
| 197 | $this->_smarty->assign('sectionMAINCONTENT', false); |
|---|
| 198 | |
|---|
| 199 | // Set section of Smarty template |
|---|
| 200 | $this->_smarty->assign('sectionMAINCONTENT', true); |
|---|
| 201 | |
|---|
| 202 | // Node details |
|---|
| 203 | if ($this->_nodes) { |
|---|
| 204 | foreach ($this->_nodes as $_nodeData) { |
|---|
| 205 | $_node = Node::getObject($_nodeData['node_id']); |
|---|
| 206 | $_nodeData['num_online_users'] = $_node->getNumOnlineUsers(); |
|---|
| 207 | $this->_smarty->append("nodes", $_nodeData); |
|---|
| 208 | } |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | $this->_smarty->assign("num_deployed_nodes", count($this->_nodes)); |
|---|
| 212 | |
|---|
| 213 | // Compile HTML code |
|---|
| 214 | $_html_body = $this->_smarty->fetch("templates/sites/hotspot_status.tpl"); |
|---|
| 215 | |
|---|
| 216 | /* |
|---|
| 217 | * Compile HTML output |
|---|
| 218 | */ |
|---|
| 219 | $this->_mainUI->setTitle(_("Hotspot list")); |
|---|
| 220 | $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->addContent('left_area_middle', $_html); |
|---|
| 222 | $this->_mainUI->addContent('main_area_middle', $_html_body); |
|---|
| 223 | |
|---|
| 224 | $this->_mainUI->display(); |
|---|
| 225 | } |
|---|
| 226 | |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | /* |
|---|
| 230 | * Local variables: |
|---|
| 231 | * tab-width: 4 |
|---|
| 232 | * c-basic-offset: 4 |
|---|
| 233 | * c-hanging-comment-ender-p: nil |
|---|
| 234 | * End: |
|---|
| 235 | */ |
|---|
| 236 | |
|---|