| 1 | <?php |
|---|
| 2 | /********************************************************************\ |
|---|
| 3 | * This program is free software; you can redistribute it and/or * |
|---|
| 4 | * modify it under the terms of the GNU General Public License as * |
|---|
| 5 | * published by the Free Software Foundation; either version 2 of * |
|---|
| 6 | * the License, or (at your option) any later version. * |
|---|
| 7 | * * |
|---|
| 8 | * This program is distributed in the hope that it will be useful, * |
|---|
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|---|
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
|---|
| 11 | * GNU General Public License for more details. * |
|---|
| 12 | * * |
|---|
| 13 | * You should have received a copy of the GNU General Public License* |
|---|
| 14 | * along with this program; if not, contact: * |
|---|
| 15 | * * |
|---|
| 16 | * Free Software Foundation Voice: +1-617-542-5942 * |
|---|
| 17 | * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * |
|---|
| 18 | * Boston, MA 02111-1307, USA gnu@gnu.org * |
|---|
| 19 | * * |
|---|
| 20 | \********************************************************************/ |
|---|
| 21 | /**@file hotspot_status.php |
|---|
| 22 | * Network status page |
|---|
| 23 | * @author Copyright (C) 2004 Benoit Gr�goire |
|---|
| 24 | */ |
|---|
| 25 | |
|---|
| 26 | define('BASEPATH','./'); |
|---|
| 27 | require_once BASEPATH.'include/common.php'; |
|---|
| 28 | require_once BASEPATH.'include/common_interface.php'; |
|---|
| 29 | |
|---|
| 30 | if(!empty($_REQUEST['format'])) { |
|---|
| 31 | $format = $_REQUEST['format']; |
|---|
| 32 | } else { |
|---|
| 33 | $format = null; |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | $db->ExecSql("SELECT *, (NOW()-last_heartbeat_timestamp) AS since_last_heartbeat, EXTRACT(epoch FROM creation_date) as creation_date_epoch, CASE WHEN ((NOW()-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS is_up FROM nodes WHERE node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE' ORDER BY creation_date", $node_results, false); |
|---|
| 37 | if ($format == 'RSS') { |
|---|
| 38 | Header("Cache-control: private, no-cache, must-revalidate"); |
|---|
| 39 | Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
|---|
| 40 | Header("Pragma: no-cache"); |
|---|
| 41 | Header("Content-Type: text/xml; charset=UTF-8"); |
|---|
| 42 | |
|---|
| 43 | $xmldoc = new DOMDocument(); |
|---|
| 44 | $xmldoc->formatOutput = true; |
|---|
| 45 | //$xmldoc->encoding="iso-8859-15"; |
|---|
| 46 | $rss = $xmldoc->createElement("rss"); |
|---|
| 47 | $xmldoc->appendChild($rss); |
|---|
| 48 | $rss->setAttribute('version', '2.0'); |
|---|
| 49 | |
|---|
| 50 | /* channel */ |
|---|
| 51 | $channel = $xmldoc->createElement("channel"); |
|---|
| 52 | $rss->appendChild($channel); |
|---|
| 53 | |
|---|
| 54 | /**************** Required channel elements ********************/ |
|---|
| 55 | /* title */ |
|---|
| 56 | $title = $xmldoc->createElement("title"); |
|---|
| 57 | $title = $channel->appendChild($title); |
|---|
| 58 | |
|---|
| 59 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME._(": Newest HotSpots"))); |
|---|
| 60 | $title->appendChild($textnode); |
|---|
| 61 | |
|---|
| 62 | /* link */ |
|---|
| 63 | $link = $xmldoc->createElement("link"); |
|---|
| 64 | $channel->appendChild($link); |
|---|
| 65 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); |
|---|
| 66 | $link->appendChild($textnode); |
|---|
| 67 | |
|---|
| 68 | /* description */ |
|---|
| 69 | $description = $xmldoc->createElement("description"); |
|---|
| 70 | $channel->appendChild($description); |
|---|
| 71 | $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by the network: ").HOTSPOT_NETWORK_NAME)); |
|---|
| 72 | $description->appendChild($textnode); |
|---|
| 73 | |
|---|
| 74 | /****************** Optional channel elements *******************/ |
|---|
| 75 | /* language */ |
|---|
| 76 | /**@todo Make language selectable */ |
|---|
| 77 | $language = $xmldoc->createElement("language"); |
|---|
| 78 | $channel->appendChild($language); |
|---|
| 79 | $textnode = $xmldoc->createTextNode("en-CA"); |
|---|
| 80 | $language->appendChild($textnode); |
|---|
| 81 | |
|---|
| 82 | /* copyright */ |
|---|
| 83 | $copyright = $xmldoc->createElement("copyright"); |
|---|
| 84 | $channel->appendChild($copyright); |
|---|
| 85 | $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").HOTSPOT_NETWORK_NAME)); |
|---|
| 86 | $copyright->appendChild($textnode); |
|---|
| 87 | |
|---|
| 88 | /* managingEditor */ |
|---|
| 89 | |
|---|
| 90 | /* webMaster */ |
|---|
| 91 | |
|---|
| 92 | $webMaster = $xmldoc->createElement("webMaster"); |
|---|
| 93 | $channel->appendChild($webMaster); |
|---|
| 94 | $textnode = $xmldoc->createTextNode(utf8_encode(TECH_SUPPORT_EMAIL)); |
|---|
| 95 | $webMaster->appendChild($textnode); |
|---|
| 96 | |
|---|
| 97 | /* pubDate */ |
|---|
| 98 | $pubDate = $xmldoc->createElement("pubDate"); |
|---|
| 99 | $channel->appendChild($pubDate); |
|---|
| 100 | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", time()))); |
|---|
| 101 | $pubDate->appendChild($textnode); |
|---|
| 102 | |
|---|
| 103 | /* lastBuildDate */ |
|---|
| 104 | //<lastBuildDate> -- The date-time the last time the content of the channel changed. |
|---|
| 105 | /* Make a request through the database for the latest modification date of an object. |
|---|
| 106 | * Maybe it should be an object property? */ |
|---|
| 107 | $db->ExecSqlUniqueRes("SELECT EXTRACT(epoch FROM MAX(creation_date)) as date_last_hotspot_opened FROM nodes WHERE node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE' ", $last_hotspot_row, false); |
|---|
| 108 | |
|---|
| 109 | $lastBuildDate = $xmldoc->createElement("lastBuildDate"); |
|---|
| 110 | $channel->appendChild($lastBuildDate); |
|---|
| 111 | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened'])); |
|---|
| 112 | $lastBuildDate->appendChild($textnode); |
|---|
| 113 | |
|---|
| 114 | /* category */ |
|---|
| 115 | /* Specify one or more categories that the channel belongs to. |
|---|
| 116 | * Follows the same rules as the <item>-level category element.*/ |
|---|
| 117 | |
|---|
| 118 | /* generator */ |
|---|
| 119 | $generator = $xmldoc->createElement("generator"); |
|---|
| 120 | $channel->appendChild($generator); |
|---|
| 121 | $textnode = $xmldoc->createTextNode(utf8_encode(WIFIDOG_NAME . " " . WIFIDOG_VERSION)); |
|---|
| 122 | $generator->appendChild($textnode); |
|---|
| 123 | |
|---|
| 124 | /* docs */ |
|---|
| 125 | $docs = $xmldoc->createElement("docs"); |
|---|
| 126 | $channel->appendChild($docs); |
|---|
| 127 | $textnode = $xmldoc->createTextNode(utf8_encode("http://blogs.law.harvard.edu/tech/rss")); |
|---|
| 128 | $docs->appendChild($textnode); |
|---|
| 129 | |
|---|
| 130 | /* cloud */ |
|---|
| 131 | /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/ |
|---|
| 132 | |
|---|
| 133 | /* ttl */ |
|---|
| 134 | /* ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source.*/ |
|---|
| 135 | |
|---|
| 136 | /* image */ |
|---|
| 137 | $image = $xmldoc->createElement("image"); |
|---|
| 138 | $channel->appendChild($image); |
|---|
| 139 | |
|---|
| 140 | /* title */ |
|---|
| 141 | $title = $xmldoc->createElement("title"); |
|---|
| 142 | $image->appendChild($title); |
|---|
| 143 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME)); |
|---|
| 144 | $title->appendChild($textnode); |
|---|
| 145 | /* url */ |
|---|
| 146 | $url = $xmldoc->createElement("url"); |
|---|
| 147 | $image->appendChild($url); |
|---|
| 148 | $textnode = $xmldoc->createTextNode(utf8_encode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME)); |
|---|
| 149 | $url->appendChild($textnode); |
|---|
| 150 | /* link */ |
|---|
| 151 | $link = $xmldoc->createElement("link"); |
|---|
| 152 | $image->appendChild($link); |
|---|
| 153 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); |
|---|
| 154 | $link->appendChild($textnode); |
|---|
| 155 | /* width */ |
|---|
| 156 | /* |
|---|
| 157 | $width = $xmldoc->createElement("width"); |
|---|
| 158 | $image->appendChild($width); |
|---|
| 159 | $textnode = $xmldoc->createTextNode('135'); |
|---|
| 160 | $width->appendChild($textnode); |
|---|
| 161 | */ |
|---|
| 162 | /* height */ |
|---|
| 163 | /* |
|---|
| 164 | $height = $xmldoc->createElement("height"); |
|---|
| 165 | $image->appendChild($height); |
|---|
| 166 | $textnode = $xmldoc->createTextNode('109'); |
|---|
| 167 | $height->appendChild($textnode); |
|---|
| 168 | */ |
|---|
| 169 | /* description */ |
|---|
| 170 | /* |
|---|
| 171 | $description = $xmldoc->createElement("description"); |
|---|
| 172 | $image->appendChild($description); |
|---|
| 173 | $textnode = $xmldoc->createTextNode("Le portail des TIC"); |
|---|
| 174 | $description->appendChild($textnode); |
|---|
| 175 | */ |
|---|
| 176 | |
|---|
| 177 | /* rating */ |
|---|
| 178 | /* textInput */ |
|---|
| 179 | /* skipHours */ |
|---|
| 180 | /* skipDays */ |
|---|
| 181 | |
|---|
| 182 | $i=0; |
|---|
| 183 | |
|---|
| 184 | foreach($node_results as $node_row) { |
|---|
| 185 | |
|---|
| 186 | $item = $xmldoc->createElement("item"); |
|---|
| 187 | $item = $channel->appendChild($item); |
|---|
| 188 | |
|---|
| 189 | /* title */ |
|---|
| 190 | /* lom_1_2_title_langstrings_id */ |
|---|
| 191 | $title = $xmldoc->createElement("title"); |
|---|
| 192 | $item->appendChild($title); |
|---|
| 193 | $title_str = $node_row['name']; |
|---|
| 194 | $textnode = $xmldoc->createTextNode(utf8_encode($title_str)); |
|---|
| 195 | $title->appendChild($textnode); |
|---|
| 196 | |
|---|
| 197 | /* link */ |
|---|
| 198 | if(!empty($node_row['home_page_url'])) |
|---|
| 199 | { |
|---|
| 200 | $link = $xmldoc->createElement("link"); |
|---|
| 201 | $item->appendChild($link); |
|---|
| 202 | $textnode = $xmldoc->createTextNode(utf8_encode($node_row['home_page_url'])); |
|---|
| 203 | $link->appendChild($textnode); |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | /* description */ |
|---|
| 207 | $description = $xmldoc->createElement("description"); |
|---|
| 208 | $item->appendChild($description); |
|---|
| 209 | $description_text='<p>'; |
|---|
| 210 | |
|---|
| 211 | if($node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE') |
|---|
| 212 | { |
|---|
| 213 | if($node_row['is_up']=='t') |
|---|
| 214 | { |
|---|
| 215 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_up.png'> "; |
|---|
| 216 | } |
|---|
| 217 | else |
|---|
| 218 | { |
|---|
| 219 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_down.png'> "; |
|---|
| 220 | } |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | if(!empty($node_row['description'])) |
|---|
| 224 | { |
|---|
| 225 | $description_text.= $node_row['description']; |
|---|
| 226 | } |
|---|
| 227 | $description_text.= "</p>\n"; |
|---|
| 228 | $description_text.="<p>\n"; |
|---|
| 229 | if(!empty($node_row['street_address'])) |
|---|
| 230 | { |
|---|
| 231 | $description_text.= ""._("Address:")." ".$node_row['street_address']." "; |
|---|
| 232 | } |
|---|
| 233 | if(!empty($node_row['map_url'])) |
|---|
| 234 | { |
|---|
| 235 | $description_text.=" <a href='".$node_row['map_url']."'>"._("See Map")."</a> "; |
|---|
| 236 | } |
|---|
| 237 | $description_text.= "<br/>\n"; |
|---|
| 238 | if(!empty($node_row['mass_transit_info'])) |
|---|
| 239 | { |
|---|
| 240 | $description_text.=""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n"; |
|---|
| 241 | } |
|---|
| 242 | $description_text.= "</p>\n"; |
|---|
| 243 | if(!empty($node_row['public_email']) || !empty($node_row['public_phone_number'])) |
|---|
| 244 | { |
|---|
| 245 | $description_text.="<p>"._("Contact:"); |
|---|
| 246 | |
|---|
| 247 | if(!empty($node_row['public_phone_number'])) |
|---|
| 248 | { |
|---|
| 249 | $description_text.=" $node_row[public_phone_number] "; |
|---|
| 250 | } |
|---|
| 251 | if(!empty($node_row['public_email'])) |
|---|
| 252 | { |
|---|
| 253 | $description_text.=" <a href='".$node_row['public_email']."'>$node_row[public_email]</a> "; |
|---|
| 254 | } |
|---|
| 255 | $description_text.="</p>\n"; |
|---|
| 256 | } |
|---|
| 257 | $textnode = $xmldoc->createTextNode(utf8_encode($description_text)); |
|---|
| 258 | $description->appendChild($textnode); |
|---|
| 259 | |
|---|
| 260 | /* author */ |
|---|
| 261 | /* |
|---|
| 262 | $author = $xmldoc->createElement("author"); |
|---|
| 263 | $item->appendChild($author); |
|---|
| 264 | $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')'); |
|---|
| 265 | $author->appendChild($textnode); |
|---|
| 266 | */ |
|---|
| 267 | /* category */ |
|---|
| 268 | |
|---|
| 269 | /* comments */ |
|---|
| 270 | /** Link to page once page is available **/ |
|---|
| 271 | /* enclosure */ |
|---|
| 272 | /* guid */ |
|---|
| 273 | |
|---|
| 274 | $guid = $xmldoc->createElement("guid"); |
|---|
| 275 | $guid->setAttribute('isPermaLink', 'false'); |
|---|
| 276 | $item->appendChild($guid); |
|---|
| 277 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL.$node_row['node_id'])); |
|---|
| 278 | $guid->appendChild($textnode); |
|---|
| 279 | |
|---|
| 280 | /* pubDate */ |
|---|
| 281 | $pubDate = $xmldoc->createElement("pubDate"); |
|---|
| 282 | $item->appendChild($pubDate); |
|---|
| 283 | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", $node_row['creation_date_epoch']))); |
|---|
| 284 | $pubDate->appendChild($textnode); |
|---|
| 285 | |
|---|
| 286 | /* source */ |
|---|
| 287 | } |
|---|
| 288 | @ob_clean(); |
|---|
| 289 | echo $xmldoc->saveXML(); |
|---|
| 290 | } |
|---|
| 291 | else if ($format == 'WIFI411_CSV') { |
|---|
| 292 | /* Header("Cache-control: private, no-cache, must-revalidate"); |
|---|
| 293 | Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
|---|
| 294 | Header("Pragma: no-cache"); |
|---|
| 295 | Header("Content-Type: text/xml; charset=UTF-8");*/ |
|---|
| 296 | |
|---|
| 297 | $xmldoc = new DOMDocument(); |
|---|
| 298 | $xmldoc->formatOutput = true; |
|---|
| 299 | //$xmldoc->encoding="iso-8859-15"; |
|---|
| 300 | $rss = $xmldoc->createElement("rss"); |
|---|
| 301 | $xmldoc->appendChild($rss); |
|---|
| 302 | $rss->setAttribute('version', '2.0'); |
|---|
| 303 | |
|---|
| 304 | /* channel */ |
|---|
| 305 | $channel = $xmldoc->createElement("channel"); |
|---|
| 306 | $rss->appendChild($channel); |
|---|
| 307 | |
|---|
| 308 | /**************** Required channel elements ********************/ |
|---|
| 309 | /* title */ |
|---|
| 310 | $title = $xmldoc->createElement("title"); |
|---|
| 311 | $title = $channel->appendChild($title); |
|---|
| 312 | |
|---|
| 313 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME._(": Newest HotSpots"))); |
|---|
| 314 | $title->appendChild($textnode); |
|---|
| 315 | |
|---|
| 316 | /* link */ |
|---|
| 317 | $link = $xmldoc->createElement("link"); |
|---|
| 318 | $channel->appendChild($link); |
|---|
| 319 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); |
|---|
| 320 | $link->appendChild($textnode); |
|---|
| 321 | |
|---|
| 322 | /* description */ |
|---|
| 323 | $description = $xmldoc->createElement("description"); |
|---|
| 324 | $channel->appendChild($description); |
|---|
| 325 | $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by the network: ").HOTSPOT_NETWORK_NAME)); |
|---|
| 326 | $description->appendChild($textnode); |
|---|
| 327 | |
|---|
| 328 | /****************** Optional channel elements *******************/ |
|---|
| 329 | /* language */ |
|---|
| 330 | /**@todo Make language selectable */ |
|---|
| 331 | $language = $xmldoc->createElement("language"); |
|---|
| 332 | $channel->appendChild($language); |
|---|
| 333 | $textnode = $xmldoc->createTextNode("en-CA"); |
|---|
| 334 | $language->appendChild($textnode); |
|---|
| 335 | |
|---|
| 336 | /* copyright */ |
|---|
| 337 | $copyright = $xmldoc->createElement("copyright"); |
|---|
| 338 | $channel->appendChild($copyright); |
|---|
| 339 | $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").HOTSPOT_NETWORK_NAME)); |
|---|
| 340 | $copyright->appendChild($textnode); |
|---|
| 341 | |
|---|
| 342 | /* managingEditor */ |
|---|
| 343 | |
|---|
| 344 | /* webMaster */ |
|---|
| 345 | |
|---|
| 346 | $webMaster = $xmldoc->createElement("webMaster"); |
|---|
| 347 | $channel->appendChild($webMaster); |
|---|
| 348 | $textnode = $xmldoc->createTextNode(utf8_encode(TECH_SUPPORT_EMAIL)); |
|---|
| 349 | $webMaster->appendChild($textnode); |
|---|
| 350 | |
|---|
| 351 | /* pubDate */ |
|---|
| 352 | $pubDate = $xmldoc->createElement("pubDate"); |
|---|
| 353 | $channel->appendChild($pubDate); |
|---|
| 354 | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", time()))); |
|---|
| 355 | $pubDate->appendChild($textnode); |
|---|
| 356 | |
|---|
| 357 | /* lastBuildDate */ |
|---|
| 358 | //<lastBuildDate> -- The date-time the last time the content of the channel changed. |
|---|
| 359 | /* Make a request through the database for the latest modification date of an object. |
|---|
| 360 | * Maybe it should be an object property? */ |
|---|
| 361 | $db->ExecSqlUniqueRes("SELECT EXTRACT(epoch FROM MAX(creation_date)) as date_last_hotspot_opened FROM nodes WHERE node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE' ", $last_hotspot_row, false); |
|---|
| 362 | |
|---|
| 363 | $lastBuildDate = $xmldoc->createElement("lastBuildDate"); |
|---|
| 364 | $channel->appendChild($lastBuildDate); |
|---|
| 365 | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened'])); |
|---|
| 366 | $lastBuildDate->appendChild($textnode); |
|---|
| 367 | |
|---|
| 368 | /* category */ |
|---|
| 369 | /* Specify one or more categories that the channel belongs to. |
|---|
| 370 | * Follows the same rules as the <item>-level category element.*/ |
|---|
| 371 | |
|---|
| 372 | /* generator */ |
|---|
| 373 | $generator = $xmldoc->createElement("generator"); |
|---|
| 374 | $channel->appendChild($generator); |
|---|
| 375 | $textnode = $xmldoc->createTextNode(utf8_encode(WIFIDOG_NAME . " " . WIFIDOG_VERSION)); |
|---|
| 376 | $generator->appendChild($textnode); |
|---|
| 377 | |
|---|
| 378 | /* docs */ |
|---|
| 379 | $docs = $xmldoc->createElement("docs"); |
|---|
| 380 | $channel->appendChild($docs); |
|---|
| 381 | $textnode = $xmldoc->createTextNode(utf8_encode("http://blogs.law.harvard.edu/tech/rss")); |
|---|
| 382 | $docs->appendChild($textnode); |
|---|
| 383 | |
|---|
| 384 | /* cloud */ |
|---|
| 385 | /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/ |
|---|
| 386 | |
|---|
| 387 | /* ttl */ |
|---|
| 388 | /* ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source.*/ |
|---|
| 389 | |
|---|
| 390 | /* image */ |
|---|
| 391 | $image = $xmldoc->createElement("image"); |
|---|
| 392 | $channel->appendChild($image); |
|---|
| 393 | |
|---|
| 394 | /* title */ |
|---|
| 395 | $title = $xmldoc->createElement("title"); |
|---|
| 396 | $image->appendChild($title); |
|---|
| 397 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME)); |
|---|
| 398 | $title->appendChild($textnode); |
|---|
| 399 | /* url */ |
|---|
| 400 | $url = $xmldoc->createElement("url"); |
|---|
| 401 | $image->appendChild($url); |
|---|
| 402 | $textnode = $xmldoc->createTextNode(utf8_encode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME)); |
|---|
| 403 | $url->appendChild($textnode); |
|---|
| 404 | /* link */ |
|---|
| 405 | $link = $xmldoc->createElement("link"); |
|---|
| 406 | $image->appendChild($link); |
|---|
| 407 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); |
|---|
| 408 | $link->appendChild($textnode); |
|---|
| 409 | /* width */ |
|---|
| 410 | /* |
|---|
| 411 | $width = $xmldoc->createElement("width"); |
|---|
| 412 | $image->appendChild($width); |
|---|
| 413 | $textnode = $xmldoc->createTextNode('135'); |
|---|
| 414 | $width->appendChild($textnode); |
|---|
| 415 | */ |
|---|
| 416 | /* height */ |
|---|
| 417 | /* |
|---|
| 418 | $height = $xmldoc->createElement("height"); |
|---|
| 419 | $image->appendChild($height); |
|---|
| 420 | $textnode = $xmldoc->createTextNode('109'); |
|---|
| 421 | $height->appendChild($textnode); |
|---|
| 422 | */ |
|---|
| 423 | /* description */ |
|---|
| 424 | /* |
|---|
| 425 | $description = $xmldoc->createElement("description"); |
|---|
| 426 | $image->appendChild($description); |
|---|
| 427 | $textnode = $xmldoc->createTextNode("Le portail des TIC"); |
|---|
| 428 | $description->appendChild($textnode); |
|---|
| 429 | */ |
|---|
| 430 | |
|---|
| 431 | /* rating */ |
|---|
| 432 | /* textInput */ |
|---|
| 433 | /* skipHours */ |
|---|
| 434 | /* skipDays */ |
|---|
| 435 | |
|---|
| 436 | $i=0; |
|---|
| 437 | |
|---|
| 438 | foreach($node_results as $node_row) { |
|---|
| 439 | |
|---|
| 440 | $item = $xmldoc->createElement("item"); |
|---|
| 441 | $item = $channel->appendChild($item); |
|---|
| 442 | |
|---|
| 443 | /* title */ |
|---|
| 444 | /* lom_1_2_title_langstrings_id */ |
|---|
| 445 | $title = $xmldoc->createElement("title"); |
|---|
| 446 | $item->appendChild($title); |
|---|
| 447 | $title_str = $node_row['name']; |
|---|
| 448 | $textnode = $xmldoc->createTextNode(utf8_encode($title_str)); |
|---|
| 449 | $title->appendChild($textnode); |
|---|
| 450 | |
|---|
| 451 | /* link */ |
|---|
| 452 | if(!empty($node_row['home_page_url'])) |
|---|
| 453 | { |
|---|
| 454 | $link = $xmldoc->createElement("link"); |
|---|
| 455 | $item->appendChild($link); |
|---|
| 456 | $textnode = $xmldoc->createTextNode(utf8_encode($node_row['home_page_url'])); |
|---|
| 457 | $link->appendChild($textnode); |
|---|
| 458 | } |
|---|
| 459 | |
|---|
| 460 | /* description */ |
|---|
| 461 | $description = $xmldoc->createElement("description"); |
|---|
| 462 | $item->appendChild($description); |
|---|
| 463 | $description_text='<p>'; |
|---|
| 464 | if($node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE') |
|---|
| 465 | { |
|---|
| 466 | if($node_row['is_up']=='t') |
|---|
| 467 | { |
|---|
| 468 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_up.png'> "; |
|---|
| 469 | } |
|---|
| 470 | else |
|---|
| 471 | { |
|---|
| 472 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_down.png'> "; |
|---|
| 473 | } |
|---|
| 474 | } |
|---|
| 475 | |
|---|
| 476 | if(!empty($node_row['description'])) |
|---|
| 477 | { |
|---|
| 478 | $description_text.= $node_row['description']; |
|---|
| 479 | } |
|---|
| 480 | $description_text.= "</p>\n"; |
|---|
| 481 | $description_text.="<p>\n"; |
|---|
| 482 | if(!empty($node_row['street_address'])) |
|---|
| 483 | { |
|---|
| 484 | $description_text.= ""._("Address:")." ".$node_row['street_address']." "; |
|---|
| 485 | } |
|---|
| 486 | if(!empty($node_row['map_url'])) |
|---|
| 487 | { |
|---|
| 488 | $description_text.=" <a href='".$node_row['map_url']."'>"._("See Map")."</a> "; |
|---|
| 489 | } |
|---|
| 490 | $description_text.= "<br/>\n"; |
|---|
| 491 | if(!empty($node_row['mass_transit_info'])) |
|---|
| 492 | { |
|---|
| 493 | $description_text.=""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n"; |
|---|
| 494 | } |
|---|
| 495 | $description_text.= "</p>\n"; |
|---|
| 496 | if(!empty($node_row['public_email']) || !empty($node_row['public_phone_number'])) |
|---|
| 497 | { |
|---|
| 498 | $description_text.="<p>"._("Contact:"); |
|---|
| 499 | |
|---|
| 500 | if(!empty($node_row['public_phone_number'])) |
|---|
| 501 | { |
|---|
| 502 | $description_text.=" $node_row[public_phone_number] "; |
|---|
| 503 | } |
|---|
| 504 | if(!empty($node_row['public_email'])) |
|---|
| 505 | { |
|---|
| 506 | $description_text.=" <a href='".$node_row['public_email']."'>$node_row[public_email]</a> "; |
|---|
| 507 | } |
|---|
| 508 | $description_text.="</p>\n"; |
|---|
| 509 | } |
|---|
| 510 | $textnode = $xmldoc->createTextNode(utf8_encode($description_text)); |
|---|
| 511 | $description->appendChild($textnode); |
|---|
| 512 | |
|---|
| 513 | /* author */ |
|---|
| 514 | /* |
|---|
| 515 | $author = $xmldoc->createElement("author"); |
|---|
| 516 | $item->appendChild($author); |
|---|
| 517 | $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')'); |
|---|
| 518 | $author->appendChild($textnode); |
|---|
| 519 | */ |
|---|
| 520 | /* category */ |
|---|
| 521 | |
|---|
| 522 | /* comments */ |
|---|
| 523 | /** Link to page once page is available **/ |
|---|
| 524 | /* enclosure */ |
|---|
| 525 | /* guid */ |
|---|
| 526 | |
|---|
| 527 | $guid = $xmldoc->createElement("guid"); |
|---|
| 528 | $guid->setAttribute('isPermaLink', 'false'); |
|---|
| 529 | $item->appendChild($guid); |
|---|
| 530 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL.$node_row['node_id'])); |
|---|
| 531 | $guid->appendChild($textnode); |
|---|
| 532 | |
|---|
| 533 | /* pubDate */ |
|---|
| 534 | $pubDate = $xmldoc->createElement("pubDate"); |
|---|
| 535 | $item->appendChild($pubDate); |
|---|
| 536 | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", $node_row['creation_date_epoch']))); |
|---|
| 537 | $pubDate->appendChild($textnode); |
|---|
| 538 | |
|---|
| 539 | /* source */ |
|---|
| 540 | } |
|---|
| 541 | ob_clean(); |
|---|
| 542 | echo $xmldoc->saveXML(); |
|---|
| 543 | } |
|---|
| 544 | else { |
|---|
| 545 | foreach($node_results as $node_row) { |
|---|
| 546 | $node_row['num_online_users'] = $stats->getNumOnlineUsers($node_row['node_id']); |
|---|
| 547 | $smarty->append("nodes", $node_row); |
|---|
| 548 | } |
|---|
| 549 | $smarty->assign("num_deployed_nodes", count($node_results)); |
|---|
| 550 | $smarty->assign("title", "hotspot_status"); |
|---|
| 551 | $smarty->display("templates/hotspot_status.html"); |
|---|
| 552 | } |
|---|
| 553 | ?> |
|---|