root/trunk/wifidog-auth/wifidog/hotspot_status.php @ 661

Revision 661, 26.0 KB (checked in by fproulx, 8 years ago)

2005-07-05 Francois Proulx <francois.proulx@…>

  • Added missing elements in XML exchange format
  • Stable v1.0 for XML exchange format and Google Maps mapping
  • Added GMaps constants to config file
  • Unsmartied index.php , added link to map
  • Check config.php to set corresponding values
  • You can now use hotspot_status.php?format=XML along with xslt query string parament to convert your XML document
  • For this to work, You need to have activated XSLT ( see config file )
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3/********************************************************************\
4 * This program is free software; you can redistribute it and/or    *
5 * modify it under the terms of the GNU General Public License as   *
6 * published by the Free Software Foundation; either version 2 of   *
7 * the License, or (at your option) any later version.              *
8 *                                                                  *
9 * This program is distributed in the hope that it will be useful,  *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
12 * GNU General Public License for more details.                     *
13 *                                                                  *
14 * You should have received a copy of the GNU General Public License*
15 * along with this program; if not, contact:                        *
16 *                                                                  *
17 * Free Software Foundation           Voice:  +1-617-542-5942       *
18 * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       *
19 * Boston, MA  02111-1307,  USA       gnu@gnu.org                   *
20 *                                                                  *
21 \********************************************************************/
22/**@file hotspot_status.php
23 * Network status page
24 * @author Copyright (C) 2004, 2005 Benoit Grégoire and François Proulx
25 */
26
27define('BASEPATH', './');
28require_once BASEPATH.'include/common.php';
29require_once BASEPATH.'include/common_interface.php';
30
31if (!empty ($_REQUEST['format']))
32        $format = $_REQUEST['format'];
33else
34        $format = null;
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);
37switch ($format)
38{
39        // XML format v1.0 by Françcois proulx <francois.proulx@gmail.com>
40        //TODO: rough draft, should be moved to different classes once stabilized
41        case "XML":
42                require_once BASEPATH.'classes/Network.php';
43                require_once BASEPATH.'classes/Node.php';
44               
45                header("Cache-control: private, no-cache, must-revalidate");
46                header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date
47                header("Pragma: no-cache");
48               
49                ob_start();
50               
51                // Prepare an XML DOM Document that will contain all the data concerning the nodes
52                $xmldoc = new DOMDocument();
53                $xmldoc->formatOutput = true;
54               
55                // Root node
56                $hotspot_status_root_node = $xmldoc->createElement("wifidogVenuesStatus");
57                $hotspot_status_root_node->setAttribute('version', '1.0');
58                $xmldoc->appendChild($hotspot_status_root_node);
59               
60                // Document metadata
61                $document_gendate_node = $xmldoc->createElement("generationDateTime", gmdate("Y-m-d\Th:m:s\Z"));
62                $hotspot_status_root_node->appendChild($document_gendate_node);
63               
64                // Network metadata
65                $network_metadata_node = $xmldoc->createElement("networkMetadata");
66                $network_metadata_node = $hotspot_status_root_node->appendChild($network_metadata_node);
67                $network_name_node = $xmldoc->createElement("name", HOTSPOT_NETWORK_NAME);
68                $network_metadata_node->appendChild($network_name_node);
69                $network_url_node = $xmldoc->createElement("websiteUrl", HOTSPOT_NETWORK_URL);
70                $network_metadata_node->appendChild($network_url_node);
71                $network_mail_node = $xmldoc->createElement("techSupportEmail", TECH_SUPPORT_EMAIL);
72                $network_metadata_node->appendChild($network_mail_node);
73                $nodes_count_node = $xmldoc->createElement("venuesCount", count($node_results));
74                $network_metadata_node->appendChild($nodes_count_node);
75                $network_validusers_node = $xmldoc->createElement("validSubscribedUsersCount", $stats->getNumValidUsers());
76                $network_metadata_node->appendChild($network_validusers_node);
77               
78                // Get number of online users
79                $online_users_count = 0;
80                if ($node_results)
81                        foreach ($node_results as $node_row)
82                                $online_users_count = $stats->getNumOnlineUsers($node_row['node_id']);
83                       
84                $network_onlineusers_node = $xmldoc->createElement("onlineUsersCount", $online_users_count);
85                $network_metadata_node->appendChild($network_onlineusers_node);
86               
87               
88                if ($node_results)
89                {
90                        // Nodes statusadata
91                        $nodes_status_node = $xmldoc->createElement("venuesMetadata");
92                        $nodes_status_node = $hotspot_status_root_node->appendChild($nodes_status_node);
93                       
94                        foreach ($node_results as $node_row)
95                        {
96                                $node = $xmldoc->createElement("venue");
97                                $node = $nodes_status_node->appendChild($node);
98                               
99                                // Node ID
100                                $id = $xmldoc->createElement("venueId", $node_row['node_id']);
101                                $node->appendChild($id);
102                               
103                                // Node name
104                                if (!empty ($node_row['name']))
105                                {
106                                        $name = $xmldoc->createElement("name", $node_row['name']);
107                                        $node->appendChild($name);
108                                }
109                               
110                                // Node deployment status
111                                if (!empty ($node_row['node_deployment_status']))
112                                {
113                                        $dep_status = $xmldoc->createElement("deploymentStatus", $node_row['node_deployment_status']);
114                                        $node->appendChild($dep_status);
115                                }
116                               
117                                // Creation date
118                                if (!empty ($node_row['creation_date']))
119                                {
120                                        $creation_date = $xmldoc->createElement("creationDate", $node_row['creation_date']);
121                                        $node->appendChild($creation_date);
122                                }
123                               
124                                // Last heartbeat
125                                if (!empty ($node_row['last_heartbeat_timestamp']))
126                                {
127                                        $creation_date = $xmldoc->createElement("lastHeartbeat", $node_row['last_heartbeat_timestamp']);
128                                        $node->appendChild($creation_date);
129                                }
130
131                                // Node Website URL
132                                if (!empty ($node_row['home_page_url']))
133                                {
134                                        $url = $xmldoc->createElement("webSiteUrl", $node_row['home_page_url']);
135                                        $node->appendChild($url);
136                                }
137                               
138                                // Node heartbeat
139                                if (!empty ($node_row['node_deployment_status']) && $node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE')
140                                {
141                                        if ($node_row['is_up'] == 't')
142                                                $status = $xmldoc->createElement("status", "up");
143                                        else
144                                                $status = $xmldoc->createElement("status", "down");
145                                        $node->appendChild($status);
146                                }
147                               
148                                // Description
149                                if (!empty ($node_row['description']))
150                                {
151                                        $desc = $xmldoc->createElement("description", $node_row['description']);
152                                        $node->appendChild($desc);
153                                }
154
155                                // Map Url
156                                if (!empty ($node_row['map_url']))
157                                {
158                                        $map_url = $xmldoc->createElement("mapUrl", htmlspecialchars($node_row['map_url'], ENT_QUOTES));
159                                        $node->appendChild($map_url);
160                                }
161                               
162                                // Mass transit info
163                                if (!empty ($node_row['mass_transit_info']))
164                                {
165                                        $transit = $xmldoc->createElement("massTransitInfo", $node_row['mass_transit_info']);
166                                        $node->appendChild($transit);
167                                }
168                               
169                                // Contact e-mail
170                                if (!empty ($node_row['public_email']))
171                                {
172                                        $contact_email = $xmldoc->createElement("contactEmail", $node_row['public_email']);
173                                        $node->appendChild($contact_email);
174                                }
175                               
176                                // Contact phone
177                                if (!empty ($node_row['public_phone_number']))
178                                {
179                                        $contact_phone = $xmldoc->createElement("contactPhoneNumber", $node_row['public_phone_number']);
180                                        $node->appendChild($contact_phone);
181                                }
182                               
183                                // Street address
184                                if (!empty ($node_row['street_address']))
185                                {
186                                        $street_addr = $xmldoc->createElement("streetAddress", $node_row['street_address']);
187                                        $node->appendChild($street_addr);
188                                }
189                               
190                                // Long / Lat
191                                if (!empty ($node_row['longitude']) && !empty ($node_row['latitude']))
192                                {
193                                        $gis = $xmldoc->createElement("gisLatLong");
194                                        $gis->setAttribute("lat",  $node_row['latitude']);
195                                        $gis->setAttribute("long",  $node_row['longitude']);
196                                        $node->appendChild($gis);
197                                }
198                        }
199                }
200               
201                ob_clean();
202               
203                // If a XSL transform stylesheet has been specified, try to us it.
204                if(defined('XSLT_SUPPORT') && XSLT_SUPPORT == true && !empty($_REQUEST['xslt']) && ($xslt_dom = @DomDocument::load($_REQUEST['xslt'])) !== false)
205                {
206                        // Load the XSLT
207                        $xslt_proc = new XsltProcessor();
208                        $xslt_proc->importStyleSheet($xslt_dom);
209                       
210                        // Prepare HTML
211                        header("Content-Type: text/html; charset=UTF-8");
212                        echo $xslt_proc->transformToXML($xmldoc);
213                }
214                else
215                {
216                        header("Content-Type: text/xml; charset=UTF-8");
217                        echo $xmldoc->saveXML();
218                }
219               
220                break;
221        case "RSS" :
222                Header("Cache-control: private, no-cache, must-revalidate");
223                Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date
224                Header("Pragma: no-cache");
225                Header("Content-Type: text/xml; charset=UTF-8");
226
227                $xmldoc = new DOMDocument();
228                $xmldoc->formatOutput = true;
229                //$xmldoc->encoding="iso-8859-15";
230                $rss = $xmldoc->createElement("rss");
231                $xmldoc->appendChild($rss);
232                $rss->setAttribute('version', '2.0');
233
234                /* channel */
235                $channel = $xmldoc->createElement("channel");
236                $rss->appendChild($channel);
237
238                /**************** Required channel elements ********************/
239                /* title */
240                $title = $xmldoc->createElement("title");
241                $title = $channel->appendChild($title);
242
243                $textnode = $xmldoc->createTextNode(HOTSPOT_NETWORK_NAME._(": Newest HotSpots"));
244                $title->appendChild($textnode);
245
246                /* link */
247                $link = $xmldoc->createElement("link");
248                $channel->appendChild($link);
249                $textnode = $xmldoc->createTextNode(HOTSPOT_NETWORK_URL);
250                $link->appendChild($textnode);
251
252                /* description */
253                $description = $xmldoc->createElement("description");
254                $channel->appendChild($description);
255                $textnode = $xmldoc->createTextNode(_("WiFiDog list of the most recent HotSpots opened by the network: ").HOTSPOT_NETWORK_NAME);
256                $description->appendChild($textnode);
257
258                /****************** Optional channel elements *******************/
259                /* language */
260                /**@todo Make language selectable */
261                $language = $xmldoc->createElement("language");
262                $channel->appendChild($language);
263                $textnode = $xmldoc->createTextNode("en-CA");
264                $language->appendChild($textnode);
265
266                /* copyright */
267                $copyright = $xmldoc->createElement("copyright");
268                $channel->appendChild($copyright);
269                $textnode = $xmldoc->createTextNode(_("Copyright ").HOTSPOT_NETWORK_NAME);
270                $copyright->appendChild($textnode);
271
272                /* managingEditor */
273
274                /* webMaster */
275
276                $webMaster = $xmldoc->createElement("webMaster");
277                $channel->appendChild($webMaster);
278                $textnode = $xmldoc->createTextNode(TECH_SUPPORT_EMAIL);
279                $webMaster->appendChild($textnode);
280
281                /* pubDate */
282                $pubDate = $xmldoc->createElement("pubDate");
283                $channel->appendChild($pubDate);
284                $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", time()));
285                $pubDate->appendChild($textnode);
286
287                /* lastBuildDate */
288                //<lastBuildDate> -- The date-time the last time the content of the channel changed.
289                /* Make a request through the database for the latest modification date of an object. 
290                 * Maybe it should be an object property? */
291                $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);
292
293                $lastBuildDate = $xmldoc->createElement("lastBuildDate");
294                $channel->appendChild($lastBuildDate);
295                $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened']));
296                $lastBuildDate->appendChild($textnode);
297
298                /* category */
299                /* Specify one or more categories that the channel belongs to.
300                 *  Follows the same rules as the <item>-level category element.*/
301
302                /* generator */
303                $generator = $xmldoc->createElement("generator");
304                $channel->appendChild($generator);
305                $textnode = $xmldoc->createTextNode(WIFIDOG_NAME." ".WIFIDOG_VERSION);
306                $generator->appendChild($textnode);
307
308                /* docs */
309                $docs = $xmldoc->createElement("docs");
310                $channel->appendChild($docs);
311                $textnode = $xmldoc->createTextNode("http://blogs.law.harvard.edu/tech/rss");
312                $docs->appendChild($textnode);
313
314                /* cloud */
315                /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/
316
317                /* ttl */
318                /* 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.*/
319
320                /* image */
321                $image = $xmldoc->createElement("image");
322                $channel->appendChild($image);
323
324                /* title */
325                $title = $xmldoc->createElement("title");
326                $image->appendChild($title);
327                $textnode = $xmldoc->createTextNode(HOTSPOT_NETWORK_NAME);
328                $title->appendChild($textnode);
329                /* url */
330                $url = $xmldoc->createElement("url");
331                $image->appendChild($url);
332                $textnode = $xmldoc->createTextNode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME);
333                $url->appendChild($textnode);
334                /* link */
335                $link = $xmldoc->createElement("link");
336                $image->appendChild($link);
337                $textnode = $xmldoc->createTextNode(HOTSPOT_NETWORK_URL);
338                $link->appendChild($textnode);
339                /* width */
340                /*
341                 $width = $xmldoc->createElement("width");
342                 $image->appendChild($width);
343                 $textnode = $xmldoc->createTextNode('135');
344                 $width->appendChild($textnode);
345                */
346                /* height */
347                /*
348                 $height = $xmldoc->createElement("height");
349                 $image->appendChild($height);
350                 $textnode = $xmldoc->createTextNode('109');
351                 $height->appendChild($textnode);
352                */
353                /* description */
354                /*
355                 $description = $xmldoc->createElement("description");
356                 $image->appendChild($description);
357                 $textnode = $xmldoc->createTextNode("Le portail des TIC");
358                 $description->appendChild($textnode);
359                */
360
361                /* rating */
362                /* textInput */
363                /* skipHours */
364                /* skipDays */
365
366                $i = 0;
367
368                if ($node_results)
369                        foreach ($node_results as $node_row)
370                        {
371
372                                $item = $xmldoc->createElement("item");
373                                $item = $channel->appendChild($item);
374
375                                /* title */
376                                /* lom_1_2_title_langstrings_id */
377                                $title = $xmldoc->createElement("title");
378                                $item->appendChild($title);
379                                $title_str = $node_row['name'];
380                                $textnode = $xmldoc->createTextNode($title_str);
381                                $title->appendChild($textnode);
382
383                                /* link */
384                                if (!empty ($node_row['home_page_url']))
385                                {
386                                        $link = $xmldoc->createElement("link");
387                                        $item->appendChild($link);
388                                        $textnode = $xmldoc->createTextNode($node_row['home_page_url']);
389                                        $link->appendChild($textnode);
390                                }
391
392                                /* description */
393                                $description = $xmldoc->createElement("description");
394                                $item->appendChild($description);
395                                $description_text = '<p>';
396
397                                if ($node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE')
398                                {
399                                        if ($node_row['is_up'] == 't')
400                                        {
401                                                $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_up.png'> ";
402                                        }
403                                        else
404                                        {
405                                                $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_down.png'> ";
406                                        }
407                                }
408
409                                if (!empty ($node_row['description']))
410                                {
411                                        $description_text .= $node_row['description'];
412                                }
413                                $description_text .= "</p>\n";
414                                $description_text .= "<p>\n";
415                                if (!empty ($node_row['street_address']))
416                                {
417                                        $description_text .= ""._("Address:")." ".$node_row['street_address']." ";
418                                }
419                                if (!empty ($node_row['map_url']))
420                                {
421                                        $description_text .= " <a href='".$node_row['map_url']."'>"._("See Map")."</a> ";
422                                }
423                                $description_text .= "<br/>\n";
424                                if (!empty ($node_row['mass_transit_info']))
425                                {
426                                        $description_text .= ""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n";
427                                }
428                                $description_text .= "</p>\n";
429                                if (!empty ($node_row['public_email']) || !empty ($node_row['public_phone_number']))
430                                {
431                                        $description_text .= "<p>"._("Contact:");
432
433                                        if (!empty ($node_row['public_phone_number']))
434                                        {
435                                                $description_text .= " $node_row[public_phone_number] ";
436                                        }
437                                        if (!empty ($node_row['public_email']))
438                                        {
439                                                $description_text .= " <a href='".$node_row['public_email']."'>$node_row[public_email]</a> ";
440                                        }
441                                        $description_text .= "</p>\n";
442                                }
443                                $textnode = $xmldoc->createTextNode($description_text);
444                                $description->appendChild($textnode);
445
446                                /* author */
447                                /*
448                                 $author = $xmldoc->createElement("author");
449                                 $item->appendChild($author);
450                                 $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')');
451                                 $author->appendChild($textnode);
452                                */
453                                /* category */
454
455                                /* comments */
456                                /** Link to page once page is available **/
457                                /* enclosure */
458                                /* guid */
459
460                                $guid = $xmldoc->createElement("guid");
461                                $guid->setAttribute('isPermaLink', 'false');
462                                $item->appendChild($guid);
463                                $textnode = $xmldoc->createTextNode(HOTSPOT_NETWORK_URL.$node_row['node_id']);
464                                $guid->appendChild($textnode);
465
466                                /* pubDate */
467                                $pubDate = $xmldoc->createElement("pubDate");
468                                $item->appendChild($pubDate);
469                                $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $node_row['creation_date_epoch']));
470                                $pubDate->appendChild($textnode);
471
472                                /* source */
473                        }
474                @ ob_clean();
475                echo $xmldoc->saveXML();
476                break;
477        case "WIFI411_CSV" :
478                /* Header("Cache-control: private, no-cache, must-revalidate");
479                 Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date
480                 Header("Pragma: no-cache");
481                 Header("Content-Type: text/xml; charset=UTF-8");*/
482
483                $xmldoc = new DOMDocument();
484                $xmldoc->formatOutput = true;
485                //$xmldoc->encoding="iso-8859-15";
486                $rss = $xmldoc->createElement("rss");
487                $xmldoc->appendChild($rss);
488                $rss->setAttribute('version', '2.0');
489
490                /* channel */
491                $channel = $xmldoc->createElement("channel");
492                $rss->appendChild($channel);
493
494                /**************** Required channel elements ********************/
495                /* title */
496                $title = $xmldoc->createElement("title");
497                $title = $channel->appendChild($title);
498
499                $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME._(": Newest HotSpots")));
500                $title->appendChild($textnode);
501
502                /* link */
503                $link = $xmldoc->createElement("link");
504                $channel->appendChild($link);
505                $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL));
506                $link->appendChild($textnode);
507
508                /* description */
509                $description = $xmldoc->createElement("description");
510                $channel->appendChild($description);
511                $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by the network: ").HOTSPOT_NETWORK_NAME));
512                $description->appendChild($textnode);
513
514                /****************** Optional channel elements *******************/
515                /* language */
516                /**@todo Make language selectable */
517                $language = $xmldoc->createElement("language");
518                $channel->appendChild($language);
519                $textnode = $xmldoc->createTextNode("en-CA");
520                $language->appendChild($textnode);
521
522                /* copyright */
523                $copyright = $xmldoc->createElement("copyright");
524                $channel->appendChild($copyright);
525                $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").HOTSPOT_NETWORK_NAME));
526                $copyright->appendChild($textnode);
527
528                /* managingEditor */
529
530                /* webMaster */
531
532                $webMaster = $xmldoc->createElement("webMaster");
533                $channel->appendChild($webMaster);
534                $textnode = $xmldoc->createTextNode(utf8_encode(TECH_SUPPORT_EMAIL));
535                $webMaster->appendChild($textnode);
536
537                /* pubDate */
538                $pubDate = $xmldoc->createElement("pubDate");
539                $channel->appendChild($pubDate);
540                $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", time())));
541                $pubDate->appendChild($textnode);
542
543                /* lastBuildDate */
544                //<lastBuildDate> -- The date-time the last time the content of the channel changed.
545                /* Make a request through the database for the latest modification date of an object. 
546                 * Maybe it should be an object property? */
547                $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);
548
549                $lastBuildDate = $xmldoc->createElement("lastBuildDate");
550                $channel->appendChild($lastBuildDate);
551                $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened']));
552                $lastBuildDate->appendChild($textnode);
553
554                /* category */
555                /* Specify one or more categories that the channel belongs to.
556                 *  Follows the same rules as the <item>-level category element.*/
557
558                /* generator */
559                $generator = $xmldoc->createElement("generator");
560                $channel->appendChild($generator);
561                $textnode = $xmldoc->createTextNode(utf8_encode(WIFIDOG_NAME." ".WIFIDOG_VERSION));
562                $generator->appendChild($textnode);
563
564                /* docs */
565                $docs = $xmldoc->createElement("docs");
566                $channel->appendChild($docs);
567                $textnode = $xmldoc->createTextNode(utf8_encode("http://blogs.law.harvard.edu/tech/rss"));
568                $docs->appendChild($textnode);
569
570                /* cloud */
571                /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/
572
573                /* ttl */
574                /* 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.*/
575
576                /* image */
577                $image = $xmldoc->createElement("image");
578                $channel->appendChild($image);
579
580                /* title */
581                $title = $xmldoc->createElement("title");
582                $image->appendChild($title);
583                $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME));
584                $title->appendChild($textnode);
585                /* url */
586                $url = $xmldoc->createElement("url");
587                $image->appendChild($url);
588                $textnode = $xmldoc->createTextNode(utf8_encode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME));
589                $url->appendChild($textnode);
590                /* link */
591                $link = $xmldoc->createElement("link");
592                $image->appendChild($link);
593                $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL));
594                $link->appendChild($textnode);
595                /* width */
596                /*
597                 $width = $xmldoc->createElement("width");
598                 $image->appendChild($width);
599                 $textnode = $xmldoc->createTextNode('135');
600                 $width->appendChild($textnode);
601                */
602                /* height */
603                /*
604                 $height = $xmldoc->createElement("height");
605                 $image->appendChild($height);
606                 $textnode = $xmldoc->createTextNode('109');
607                 $height->appendChild($textnode);
608                */
609                /* description */
610                /*
611                 $description = $xmldoc->createElement("description");
612                 $image->appendChild($description);
613                 $textnode = $xmldoc->createTextNode("Le portail des TIC");
614                 $description->appendChild($textnode);
615                */
616
617                /* rating */
618                /* textInput */
619                /* skipHours */
620                /* skipDays */
621
622                $i = 0;
623
624                if ($node_results)
625                        foreach ($node_results as $node_row)
626                        {
627
628                                $item = $xmldoc->createElement("item");
629                                $item = $channel->appendChild($item);
630
631                                /* title */
632                                /* lom_1_2_title_langstrings_id */
633                                $title = $xmldoc->createElement("title");
634                                $item->appendChild($title);
635                                $title_str = $node_row['name'];
636                                $textnode = $xmldoc->createTextNode(utf8_encode($title_str));
637                                $title->appendChild($textnode);
638
639                                /* link */
640                                if (!empty ($node_row['home_page_url']))
641                                {
642                                        $link = $xmldoc->createElement("link");
643                                        $item->appendChild($link);
644                                        $textnode = $xmldoc->createTextNode(utf8_encode($node_row['home_page_url']));
645                                        $link->appendChild($textnode);
646                                }
647
648                                /* description */
649                                $description = $xmldoc->createElement("description");
650                                $item->appendChild($description);
651                                $description_text = '<p>';
652                                if ($node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE')
653                                {
654                                        if ($node_row['is_up'] == 't')
655                                        {
656                                                $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_up.png'> ";
657                                        }
658                                        else
659                                        {
660                                                $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_down.png'> ";
661                                        }
662                                }
663
664                                if (!empty ($node_row['description']))
665                                {
666                                        $description_text .= $node_row['description'];
667                                }
668                                $description_text .= "</p>\n";
669                                $description_text .= "<p>\n";
670                                if (!empty ($node_row['street_address']))
671                                {
672                                        $description_text .= ""._("Address:")." ".$node_row['street_address']." ";
673                                }
674                                if (!empty ($node_row['map_url']))
675                                {
676                                        $description_text .= " <a href='".$node_row['map_url']."'>"._("See Map")."</a> ";
677                                }
678                                $description_text .= "<br/>\n";
679                                if (!empty ($node_row['mass_transit_info']))
680                                {
681                                        $description_text .= ""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n";
682                                }
683                                $description_text .= "</p>\n";
684                                if (!empty ($node_row['public_email']) || !empty ($node_row['public_phone_number']))
685                                {
686                                        $description_text .= "<p>"._("Contact:");
687
688                                        if (!empty ($node_row['public_phone_number']))
689                                        {
690                                                $description_text .= " $node_row[public_phone_number] ";
691                                        }
692                                        if (!empty ($node_row['public_email']))
693                                        {
694                                                $description_text .= " <a href='".$node_row['public_email']."'>$node_row[public_email]</a> ";
695                                        }
696                                        $description_text .= "</p>\n";
697                                }
698                                $textnode = $xmldoc->createTextNode(utf8_encode($description_text));
699                                $description->appendChild($textnode);
700
701                                /* author */
702                                /*
703                                 $author = $xmldoc->createElement("author");
704                                 $item->appendChild($author);
705                                 $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')');
706                                 $author->appendChild($textnode);
707                                */
708                                /* category */
709
710                                /* comments */
711                                /** Link to page once page is available **/
712                                /* enclosure */
713                                /* guid */
714
715                                $guid = $xmldoc->createElement("guid");
716                                $guid->setAttribute('isPermaLink', 'false');
717                                $item->appendChild($guid);
718                                $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL.$node_row['node_id']));
719                                $guid->appendChild($textnode);
720
721                                /* pubDate */
722                                $pubDate = $xmldoc->createElement("pubDate");
723                                $item->appendChild($pubDate);
724                                $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", $node_row['creation_date_epoch'])));
725                                $pubDate->appendChild($textnode);
726
727                                /* source */
728                        }
729                ob_clean();
730                echo $xmldoc->saveXML();
731                break;
732        default :
733                if ($node_results)
734                        foreach ($node_results as $node_row)
735                        {
736                                $node_row['num_online_users'] = $stats->getNumOnlineUsers($node_row['node_id']);
737                                $smarty->append("nodes", $node_row);
738                        }
739                $smarty->assign("num_deployed_nodes", count($node_results));
740
741                require_once BASEPATH.'classes/MainUI.php';
742               
743                if(defined('GMAPS_VENUES_STATUS_MAP_ENABLED') && GMAPS_VENUES_STATUS_MAP_ENABLED == true)
744                {
745                        $tool_html = '<p class="indent">'."\n";
746                        $tool_html .= "<ul class='users_list'>\n";
747                        $tool_html .= "<li><a href='venues_map.php'>"._('Deployed HotSpots map')."</a></li>";
748                        $tool_html .= "</ul>\n";
749                        $tool_html .= '</p>'."\n";
750                }
751                else
752                        $tool_html = "";
753               
754                $ui = new MainUI();
755                $ui->setToolContent($tool_html);
756                $ui->setTitle(_("Hotspot list"));
757                $ui->setMainContent($smarty->fetch("templates/hotspot_status.html"));
758                $ui->display();
759}
760?>
Note: See TracBrowser for help on using the browser.