| 38 | | // XML format v1.0 by François proulx <francois.proulx@gmail.com> |
| 39 | | case "XML": |
| 40 | | // Query the database, sorting by node name |
| 41 | | $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 name", $node_results, false); |
| 42 | | |
| 43 | | require_once BASEPATH.'classes/Network.php'; |
| 44 | | require_once BASEPATH.'classes/Node.php'; |
| 45 | | |
| 46 | | header("Cache-control: private, no-cache, must-revalidate"); |
| 47 | | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
| 48 | | header("Pragma: no-cache"); |
| 49 | | |
| 50 | | ob_start(); |
| 51 | | |
| 52 | | // Prepare an XML DOM Document that will contain all the data concerning the nodes |
| 53 | | $xmldoc = new DOMDocument(); |
| 54 | | $xmldoc->formatOutput = true; |
| 55 | | |
| 56 | | // Root node |
| 57 | | $hotspot_status_root_node = $xmldoc->createElement("wifidogHotspotsStatus"); |
| 58 | | $hotspot_status_root_node->setAttribute('version', '1.0'); |
| 59 | | $xmldoc->appendChild($hotspot_status_root_node); |
| 60 | | |
| 61 | | // Document metadata |
| 62 | | $document_gendate_node = $xmldoc->createElement("generationDateTime", gmdate("Y-m-d\Th:m:s\Z")); |
| 63 | | $hotspot_status_root_node->appendChild($document_gendate_node); |
| 64 | | |
| 65 | | // Network metadata |
| 66 | | $network = Network::getCurrentNetwork(); |
| 67 | | $network_metadata_node = $xmldoc->createElement("networkMetadata"); |
| 68 | | $network_metadata_node = $hotspot_status_root_node->appendChild($network_metadata_node); |
| 69 | | $network_name_node = $xmldoc->createElement("networkUri", htmlspecialchars($network->getHomepageURL(), ENT_QUOTES)); |
| 70 | | $network_metadata_node->appendChild($network_name_node); |
| 71 | | $network_name_node = $xmldoc->createElement("name", htmlspecialchars($network->getName(), ENT_QUOTES)); |
| 72 | | $network_metadata_node->appendChild($network_name_node); |
| 73 | | $network_url_node = $xmldoc->createElement("websiteUrl", htmlspecialchars($network->getHomepageURL(), ENT_QUOTES)); |
| 74 | | $network_metadata_node->appendChild($network_url_node); |
| 75 | | $email = Network::GetCurrentNetwork()->getTechSupportEmail(); |
| 76 | | if(!empty($email)) |
| 77 | | { |
| 78 | | $network_mail_node = $xmldoc->createElement("techSupportEmail", $email); |
| 79 | | $network_metadata_node->appendChild($network_mail_node); |
| 80 | | } |
| 81 | | $nodes_count_node = $xmldoc->createElement("hotspotsCount", count($node_results)); |
| 82 | | $network_metadata_node->appendChild($nodes_count_node); |
| 83 | | $network_validusers_node = $xmldoc->createElement("validSubscribedUsersCount", $network->getNumValidUsers()); |
| 84 | | $network_metadata_node->appendChild($network_validusers_node); |
| 85 | | |
| 86 | | // Get number of online users |
| 87 | | $online_users_count = $network->getNumOnlineUsers(); |
| 88 | | $network_onlineusers_node = $xmldoc->createElement("onlineUsersCount", $online_users_count); |
| 89 | | $network_metadata_node->appendChild($network_onlineusers_node); |
| 90 | | |
| 91 | | if ($node_results) |
| 92 | | { |
| 93 | | // Hotspots metadata |
| 94 | | $hotspots_metadata_node = $xmldoc->createElement("hotspots"); |
| 95 | | $hotspots_metadata_node = $hotspot_status_root_node->appendChild($hotspots_metadata_node); |
| 96 | | |
| 97 | | foreach ($node_results as $node_row) |
| | 43 | switch ($format) |
| | 44 | { |
| | 45 | // XML format v1.0 by François proulx <francois.proulx@gmail.com> |
| | 46 | case "XML" : |
| | 47 | // Query the database, sorting by node name |
| | 48 | $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 network_id = '".$db->EscapeString($network->getId())."' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') ORDER BY name", $node_results, false); |
| | 49 | |
| | 50 | require_once BASEPATH.'classes/Network.php'; |
| | 51 | require_once BASEPATH.'classes/Node.php'; |
| | 52 | |
| | 53 | header("Cache-control: private, no-cache, must-revalidate"); |
| | 54 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
| | 55 | header("Pragma: no-cache"); |
| | 56 | |
| | 57 | ob_start(); |
| | 58 | |
| | 59 | // Prepare an XML DOM Document that will contain all the data concerning the nodes |
| | 60 | $xmldoc = new DOMDocument(); |
| | 61 | $xmldoc->formatOutput = true; |
| | 62 | |
| | 63 | // Root node |
| | 64 | $hotspot_status_root_node = $xmldoc->createElement("wifidogHotspotsStatus"); |
| | 65 | $hotspot_status_root_node->setAttribute('version', '1.0'); |
| | 66 | $xmldoc->appendChild($hotspot_status_root_node); |
| | 67 | |
| | 68 | // Document metadata |
| | 69 | $document_gendate_node = $xmldoc->createElement("generationDateTime", gmdate("Y-m-d\Th:m:s\Z")); |
| | 70 | $hotspot_status_root_node->appendChild($document_gendate_node); |
| | 71 | |
| | 72 | // Network metadata |
| | 73 | $network = Network :: getCurrentNetwork(); |
| | 74 | $network_metadata_node = $xmldoc->createElement("networkMetadata"); |
| | 75 | $network_metadata_node = $hotspot_status_root_node->appendChild($network_metadata_node); |
| | 76 | $network_name_node = $xmldoc->createElement("networkUri", htmlspecialchars($network->getHomepageURL(), ENT_QUOTES)); |
| | 77 | $network_metadata_node->appendChild($network_name_node); |
| | 78 | $network_name_node = $xmldoc->createElement("name", htmlspecialchars($network->getName(), ENT_QUOTES)); |
| | 79 | $network_metadata_node->appendChild($network_name_node); |
| | 80 | $network_url_node = $xmldoc->createElement("websiteUrl", htmlspecialchars($network->getHomepageURL(), ENT_QUOTES)); |
| | 81 | $network_metadata_node->appendChild($network_url_node); |
| | 82 | $email = Network :: GetCurrentNetwork()->getTechSupportEmail(); |
| | 83 | if (!empty ($email)) |
| 111 | | $name = $xmldoc->createElement("name", htmlspecialchars($node_row['name'], ENT_QUOTES)); |
| 112 | | $hotspot->appendChild($name); |
| 113 | | } |
| 114 | | |
| 115 | | // (1..n) A Hotspot has many node |
| 116 | | // WARNING For now, we are simply duplicating the hotspot data in node |
| 117 | | // Until wifidog implements full abstractiong hotspot vs nodes |
| 118 | | $nodes = $xmldoc->createElement("nodes"); |
| 119 | | $hotspot->appendChild($nodes); |
| 120 | | if($nodes) |
| 121 | | { |
| 122 | | $node = $xmldoc->createElement("node"); |
| 123 | | $nodes->appendChild($node); |
| 124 | | |
| 125 | | // Node ID |
| 126 | | $nodeId = $xmldoc->createElement("nodeId", $node_row['node_id']); |
| 127 | | $node->appendChild($nodeId); |
| 128 | | |
| | 106 | $node = Node :: getObject($node_row['node_id']); |
| | 107 | $network = $node->getNetwork(); |
| | 108 | $hotspot = $xmldoc->createElement("hotspot"); |
| | 109 | $hotspot = $hotspots_metadata_node->appendChild($hotspot); |
| | 110 | |
| | 111 | // Hotspot ID |
| | 112 | $id = $xmldoc->createElement("hotspotId", $node_row['node_id']); |
| | 113 | $hotspot->appendChild($id); |
| | 114 | |
| | 115 | // Hotspot name |
| | 116 | if (!empty ($node_row['name'])) |
| | 117 | { |
| | 118 | $name = $xmldoc->createElement("name", htmlspecialchars($node_row['name'], ENT_QUOTES)); |
| | 119 | $hotspot->appendChild($name); |
| | 120 | } |
| | 121 | |
| | 122 | // (1..n) A Hotspot has many node |
| | 123 | // WARNING For now, we are simply duplicating the hotspot data in node |
| | 124 | // Until wifidog implements full abstractiong hotspot vs nodes |
| | 125 | $nodes = $xmldoc->createElement("nodes"); |
| | 126 | $hotspot->appendChild($nodes); |
| | 127 | if ($nodes) |
| | 128 | { |
| | 129 | $node = $xmldoc->createElement("node"); |
| | 130 | $nodes->appendChild($node); |
| | 131 | |
| | 132 | // Node ID |
| | 133 | $nodeId = $xmldoc->createElement("nodeId", $node_row['node_id']); |
| | 134 | $node->appendChild($nodeId); |
| | 135 | |
| | 136 | if (!empty ($node_row['creation_date'])) |
| | 137 | { |
| | 138 | $creation_date = $xmldoc->createElement("creationDate", $node_row['creation_date']); |
| | 139 | $node->appendChild($creation_date); |
| | 140 | } |
| | 141 | |
| | 142 | if (!empty ($node_row['node_deployment_status']) && $node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE') |
| | 143 | { |
| | 144 | if ($node_row['is_up'] == 't') |
| | 145 | $status = $xmldoc->createElement("status", "up"); |
| | 146 | else |
| | 147 | $status = $xmldoc->createElement("status", "down"); |
| | 148 | $node->appendChild($status); |
| | 149 | } |
| | 150 | |
| | 151 | if (!empty ($node_row['longitude']) && !empty ($node_row['latitude'])) |
| | 152 | { |
| | 153 | $gis = $xmldoc->createElement("gisLatLong"); |
| | 154 | $gis->setAttribute("lat", $node_row['latitude']); |
| | 155 | $gis->setAttribute("long", $node_row['longitude']); |
| | 156 | $node->appendChild($gis); |
| | 157 | } |
| | 158 | } |
| | 159 | |
| | 160 | // Hotspot opening date ( for now it's called creation_date ) |
| 140 | | $status = $xmldoc->createElement("status", "down"); |
| 141 | | $node->appendChild($status); |
| 142 | | } |
| 143 | | |
| | 182 | $status = $xmldoc->createElement("globalStatus", "0"); |
| | 183 | $hotspot->appendChild($status); |
| | 184 | } |
| | 185 | |
| | 186 | // Description |
| | 187 | if (!empty ($node_row['description'])) |
| | 188 | { |
| | 189 | $desc = $xmldoc->createElement("description", htmlspecialchars($node_row['description'], ENT_QUOTES)); |
| | 190 | $hotspot->appendChild($desc); |
| | 191 | } |
| | 192 | |
| | 193 | // Map Url |
| | 194 | if (!empty ($node_row['map_url'])) |
| | 195 | { |
| | 196 | $map_url = $xmldoc->createElement("mapUrl", htmlspecialchars($node_row['map_url'], ENT_QUOTES)); |
| | 197 | $hotspot->appendChild($map_url); |
| | 198 | } |
| | 199 | |
| | 200 | // Mass transit info |
| | 201 | if (!empty ($node_row['mass_transit_info'])) |
| | 202 | { |
| | 203 | $transit = $xmldoc->createElement("massTransitInfo", htmlspecialchars($node_row['mass_transit_info'], ENT_QUOTES)); |
| | 204 | $hotspot->appendChild($transit); |
| | 205 | } |
| | 206 | |
| | 207 | // Contact e-mail |
| | 208 | if (!empty ($node_row['public_email'])) |
| | 209 | { |
| | 210 | $contact_email = $xmldoc->createElement("contactEmail", $node_row['public_email']); |
| | 211 | $hotspot->appendChild($contact_email); |
| | 212 | } |
| | 213 | |
| | 214 | // Contact phone |
| | 215 | if (!empty ($node_row['public_phone_number'])) |
| | 216 | { |
| | 217 | $contact_phone = $xmldoc->createElement("contactPhoneNumber", $node_row['public_phone_number']); |
| | 218 | $hotspot->appendChild($contact_phone); |
| | 219 | } |
| | 220 | |
| | 221 | // Civic number |
| | 222 | if (!empty ($node_row['civic_number'])) |
| | 223 | { |
| | 224 | $civic_nbr = $xmldoc->createElement("civicNumber", $node_row['civic_number']); |
| | 225 | $hotspot->appendChild($civic_nbr); |
| | 226 | } |
| | 227 | |
| | 228 | // Street address |
| | 229 | if (!empty ($node_row['street_name'])) |
| | 230 | { |
| | 231 | $street_addr = $xmldoc->createElement("streetAddress", $node_row['street_name']); |
| | 232 | $hotspot->appendChild($street_addr); |
| | 233 | } |
| | 234 | |
| | 235 | // City |
| | 236 | if (!empty ($node_row['city'])) |
| | 237 | { |
| | 238 | $city = $xmldoc->createElement("city", $node_row['city']); |
| | 239 | $hotspot->appendChild($city); |
| | 240 | } |
| | 241 | |
| | 242 | // Province |
| | 243 | if (!empty ($node_row['province'])) |
| | 244 | { |
| | 245 | $province = $xmldoc->createElement("province", $node_row['province']); |
| | 246 | $hotspot->appendChild($province); |
| | 247 | } |
| | 248 | |
| | 249 | // Postal code |
| | 250 | if (!empty ($node_row['postal_code'])) |
| | 251 | { |
| | 252 | $postal_code = $xmldoc->createElement("postalCode", $node_row['postal_code']); |
| | 253 | $hotspot->appendChild($postal_code); |
| | 254 | } |
| | 255 | |
| | 256 | // Country |
| | 257 | if (!empty ($node_row['country'])) |
| | 258 | { |
| | 259 | $country = $xmldoc->createElement("country", $node_row['country']); |
| | 260 | $hotspot->appendChild($country); |
| | 261 | } |
| | 262 | |
| | 263 | // Long / Lat |
| 146 | | $gis = $xmldoc->createElement("gisLatLong"); |
| 147 | | $gis->setAttribute("lat", $node_row['latitude']); |
| 148 | | $gis->setAttribute("long", $node_row['longitude']); |
| 149 | | $node->appendChild($gis); |
| 150 | | } |
| 151 | | } |
| 152 | | |
| 153 | | // Hotspot opening date ( for now it's called creation_date ) |
| 154 | | if (!empty ($node_row['creation_date'])) |
| 155 | | { |
| 156 | | $opening_date = $xmldoc->createElement("openingDate", $node_row['creation_date']); |
| 157 | | $hotspot->appendChild($opening_date); |
| 158 | | } |
| 159 | | |
| 160 | | // Hotspot Website URL |
| 161 | | if (!empty ($node_row['home_page_url'])) |
| 162 | | { |
| 163 | | $url = $xmldoc->createElement("webSiteUrl", htmlspecialchars($node_row['home_page_url'], ENT_QUOTES)); |
| 164 | | $hotspot->appendChild($url); |
| 165 | | } |
| 166 | | |
| 167 | | // Hotspot global status |
| 168 | | if (!empty ($node_row['node_deployment_status']) && $node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE') |
| 169 | | { |
| 170 | | // Until we implement the complete node / hotspot paradigm, |
| 171 | | // we are simply stating that up = 100% and down = 0% |
| 172 | | if ($node_row['is_up'] == 't') |
| 173 | | $status = $xmldoc->createElement("globalStatus", "100"); |
| 174 | | else |
| 175 | | $status = $xmldoc->createElement("globalStatus", "0"); |
| 176 | | $hotspot->appendChild($status); |
| 177 | | } |
| 178 | | |
| 179 | | // Description |
| 180 | | if (!empty ($node_row['description'])) |
| 181 | | { |
| 182 | | $desc = $xmldoc->createElement("description", htmlspecialchars($node_row['description'], ENT_QUOTES)); |
| 183 | | $hotspot->appendChild($desc); |
| 184 | | } |
| 185 | | |
| 186 | | // Map Url |
| 187 | | if (!empty ($node_row['map_url'])) |
| 188 | | { |
| 189 | | $map_url = $xmldoc->createElement("mapUrl", htmlspecialchars($node_row['map_url'], ENT_QUOTES)); |
| 190 | | $hotspot->appendChild($map_url); |
| 191 | | } |
| 192 | | |
| 193 | | // Mass transit info |
| 194 | | if (!empty ($node_row['mass_transit_info'])) |
| 195 | | { |
| 196 | | $transit = $xmldoc->createElement("massTransitInfo", htmlspecialchars($node_row['mass_transit_info'], ENT_QUOTES)); |
| 197 | | $hotspot->appendChild($transit); |
| 198 | | } |
| 199 | | |
| 200 | | // Contact e-mail |
| 201 | | if (!empty ($node_row['public_email'])) |
| 202 | | { |
| 203 | | $contact_email = $xmldoc->createElement("contactEmail", $node_row['public_email']); |
| 204 | | $hotspot->appendChild($contact_email); |
| 205 | | } |
| 206 | | |
| 207 | | // Contact phone |
| 208 | | if (!empty ($node_row['public_phone_number'])) |
| 209 | | { |
| 210 | | $contact_phone = $xmldoc->createElement("contactPhoneNumber", $node_row['public_phone_number']); |
| 211 | | $hotspot->appendChild($contact_phone); |
| 212 | | } |
| 213 | | |
| 214 | | // Civic number |
| 215 | | if (!empty ($node_row['civic_number'])) |
| 216 | | { |
| 217 | | $civic_nbr = $xmldoc->createElement("civicNumber", $node_row['civic_number']); |
| 218 | | $hotspot->appendChild($civic_nbr); |
| 219 | | } |
| 220 | | |
| 221 | | // Street address |
| 222 | | if (!empty ($node_row['street_name'])) |
| 223 | | { |
| 224 | | $street_addr = $xmldoc->createElement("streetAddress", $node_row['street_name']); |
| 225 | | $hotspot->appendChild($street_addr); |
| 226 | | } |
| 227 | | |
| 228 | | // City |
| 229 | | if (!empty ($node_row['city'])) |
| 230 | | { |
| 231 | | $city = $xmldoc->createElement("city", $node_row['city']); |
| 232 | | $hotspot->appendChild($city); |
| 233 | | } |
| 234 | | |
| 235 | | |
| 236 | | // Province |
| 237 | | if (!empty ($node_row['province'])) |
| 238 | | { |
| 239 | | $province = $xmldoc->createElement("province", $node_row['province']); |
| 240 | | $hotspot->appendChild($province); |
| 241 | | } |
| 242 | | |
| 243 | | // Postal code |
| 244 | | if (!empty ($node_row['postal_code'])) |
| 245 | | { |
| 246 | | $postal_code = $xmldoc->createElement("postalCode", $node_row['postal_code']); |
| 247 | | $hotspot->appendChild($postal_code); |
| 248 | | } |
| 249 | | |
| 250 | | // Country |
| 251 | | if (!empty ($node_row['country'])) |
| 252 | | { |
| 253 | | $country = $xmldoc->createElement("country", $node_row['country']); |
| 254 | | $hotspot->appendChild($country); |
| 255 | | } |
| 256 | | |
| 257 | | // Long / Lat |
| 258 | | if (!empty ($node_row['longitude']) && !empty ($node_row['latitude'])) |
| 259 | | { |
| 260 | | $gisCenter = $xmldoc->createElement("gisCenterLatLong"); |
| 261 | | $gisCenter->setAttribute("lat", $node_row['latitude']); |
| 262 | | $gisCenter->setAttribute("long", $node_row['longitude']); |
| 263 | | $hotspot->appendChild($gisCenter); |
| | 266 | $gisCenter = $xmldoc->createElement("gisCenterLatLong"); |
| | 267 | $gisCenter->setAttribute("lat", $node_row['latitude']); |
| | 268 | $gisCenter->setAttribute("long", $node_row['longitude']); |
| | 269 | $hotspot->appendChild($gisCenter); |
| | 270 | } |
| 266 | | } |
| 267 | | |
| 268 | | ob_clean(); |
| 269 | | |
| 270 | | // If a XSL transform stylesheet has been specified, try to us it. |
| 271 | | if(defined('XSLT_SUPPORT') && XSLT_SUPPORT == true && !empty($_REQUEST['xslt']) && ($xslt_dom = @DomDocument::load($_REQUEST['xslt'])) !== false) |
| 272 | | { |
| 273 | | // Load the XSLT |
| 274 | | $xslt_proc = new XsltProcessor(); |
| 275 | | $xslt_proc->importStyleSheet($xslt_dom); |
| 276 | | |
| 277 | | // Prepare HTML |
| 278 | | header("Content-Type: text/html; charset=UTF-8"); |
| 279 | | echo $xslt_proc->transformToXML($xmldoc); |
| 280 | | } |
| 281 | | else |
| 282 | | { |
| 283 | | header("Content-Type: text/xml; charset=UTF-8"); |
| | 273 | |
| | 274 | ob_clean(); |
| | 275 | |
| | 276 | // If a XSL transform stylesheet has been specified, try to us it. |
| | 277 | if (defined('XSLT_SUPPORT') && XSLT_SUPPORT == true && !empty ($_REQUEST['xslt']) && ($xslt_dom = @ DomDocument :: load($_REQUEST['xslt'])) !== false) |
| | 278 | { |
| | 279 | // Load the XSLT |
| | 280 | $xslt_proc = new XsltProcessor(); |
| | 281 | $xslt_proc->importStyleSheet($xslt_dom); |
| | 282 | |
| | 283 | // Prepare HTML |
| | 284 | header("Content-Type: text/html; charset=UTF-8"); |
| | 285 | echo $xslt_proc->transformToXML($xmldoc); |
| | 286 | } |
| | 287 | else |
| | 288 | { |
| | 289 | header("Content-Type: text/xml; charset=UTF-8"); |
| | 290 | echo $xmldoc->saveXML(); |
| | 291 | } |
| | 292 | |
| | 293 | break; |
| | 294 | case "RSS" : |
| | 295 | // Query the database, sorting by creation date |
| | 296 | $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 network_id = '".$db->EscapeString($network->getId())."' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') ORDER BY creation_date", $node_results, false); |
| | 297 | |
| | 298 | Header("Cache-control: private, no-cache, must-revalidate"); |
| | 299 | Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
| | 300 | Header("Pragma: no-cache"); |
| | 301 | Header("Content-Type: text/xml; charset=UTF-8"); |
| | 302 | |
| | 303 | // Network metadata |
| | 304 | $network = Network :: getCurrentNetwork(); |
| | 305 | $xmldoc = new DOMDocument(); |
| | 306 | $xmldoc->formatOutput = true; |
| | 307 | //$xmldoc->encoding="iso-8859-15"; |
| | 308 | $rss = $xmldoc->createElement("rss"); |
| | 309 | $xmldoc->appendChild($rss); |
| | 310 | $rss->setAttribute('version', '2.0'); |
| | 311 | |
| | 312 | /* channel */ |
| | 313 | $channel = $xmldoc->createElement("channel"); |
| | 314 | $rss->appendChild($channel); |
| | 315 | |
| | 316 | /**************** Required channel elements ********************/ |
| | 317 | /* title */ |
| | 318 | $title = $xmldoc->createElement("title"); |
| | 319 | $title = $channel->appendChild($title); |
| | 320 | |
| | 321 | $textnode = $xmldoc->createTextNode($network->getName()._(": Newest HotSpots")); |
| | 322 | $title->appendChild($textnode); |
| | 323 | |
| | 324 | /* link */ |
| | 325 | $link = $xmldoc->createElement("link"); |
| | 326 | $channel->appendChild($link); |
| | 327 | $textnode = $xmldoc->createTextNode($network->getHomepageURL()); |
| | 328 | $link->appendChild($textnode); |
| | 329 | |
| | 330 | /* description */ |
| | 331 | $description = $xmldoc->createElement("description"); |
| | 332 | $channel->appendChild($description); |
| | 333 | $textnode = $xmldoc->createTextNode(_("WiFiDog list of the most recent HotSpots opened by the network: ").$network->getName()); |
| | 334 | $description->appendChild($textnode); |
| | 335 | |
| | 336 | /****************** Optional channel elements *******************/ |
| | 337 | /* language */ |
| | 338 | /**@todo Make language selectable */ |
| | 339 | $language = $xmldoc->createElement("language"); |
| | 340 | $channel->appendChild($language); |
| | 341 | $textnode = $xmldoc->createTextNode("en-CA"); |
| | 342 | $language->appendChild($textnode); |
| | 343 | |
| | 344 | /* copyright */ |
| | 345 | $copyright = $xmldoc->createElement("copyright"); |
| | 346 | $channel->appendChild($copyright); |
| | 347 | $textnode = $xmldoc->createTextNode(_("Copyright ").$network->getName()); |
| | 348 | $copyright->appendChild($textnode); |
| | 349 | |
| | 350 | /* managingEditor */ |
| | 351 | |
| | 352 | /* webMaster */ |
| | 353 | $email = Network :: GetCurrentNetwork()->getTechSupportEmail(); |
| | 354 | if (!empty ($email)) |
| | 355 | { |
| | 356 | $webMaster = $xmldoc->createElement("webMaster"); |
| | 357 | $channel->appendChild($webMaster); |
| | 358 | $textnode = $xmldoc->createTextNode($email); |
| | 359 | $webMaster->appendChild($textnode); |
| | 360 | } |
| | 361 | |
| | 362 | /* pubDate */ |
| | 363 | $pubDate = $xmldoc->createElement("pubDate"); |
| | 364 | $channel->appendChild($pubDate); |
| | 365 | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", time())); |
| | 366 | $pubDate->appendChild($textnode); |
| | 367 | |
| | 368 | /* lastBuildDate */ |
| | 369 | //<lastBuildDate> -- The date-time the last time the content of the channel changed. |
| | 370 | /* Make a request through the database for the latest modification date of an object. |
| | 371 | * Maybe it should be an object property? */ |
| | 372 | $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); |
| | 373 | |
| | 374 | $lastBuildDate = $xmldoc->createElement("lastBuildDate"); |
| | 375 | $channel->appendChild($lastBuildDate); |
| | 376 | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened'])); |
| | 377 | $lastBuildDate->appendChild($textnode); |
| | 378 | |
| | 379 | /* category */ |
| | 380 | /* Specify one or more categories that the channel belongs to. |
| | 381 | * Follows the same rules as the <item>-level category element.*/ |
| | 382 | |
| | 383 | /* generator */ |
| | 384 | $generator = $xmldoc->createElement("generator"); |
| | 385 | $channel->appendChild($generator); |
| | 386 | $textnode = $xmldoc->createTextNode(WIFIDOG_NAME." ".WIFIDOG_VERSION); |
| | 387 | $generator->appendChild($textnode); |
| | 388 | |
| | 389 | /* docs */ |
| | 390 | $docs = $xmldoc->createElement("docs"); |
| | 391 | $channel->appendChild($docs); |
| | 392 | $textnode = $xmldoc->createTextNode("http://blogs.law.harvard.edu/tech/rss"); |
| | 393 | $docs->appendChild($textnode); |
| | 394 | |
| | 395 | /* cloud */ |
| | 396 | /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/ |
| | 397 | |
| | 398 | /* ttl */ |
| | 399 | /* 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.*/ |
| | 400 | |
| | 401 | /* image */ |
| | 402 | $image = $xmldoc->createElement("image"); |
| | 403 | $channel->appendChild($image); |
| | 404 | |
| | 405 | /* title */ |
| | 406 | $title = $xmldoc->createElement("title"); |
| | 407 | $image->appendChild($title); |
| | 408 | $textnode = $xmldoc->createTextNode($network->getName()); |
| | 409 | $title->appendChild($textnode); |
| | 410 | /* url */ |
| | 411 | $url = $xmldoc->createElement("url"); |
| | 412 | $image->appendChild($url); |
| | 413 | $textnode = $xmldoc->createTextNode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME); |
| | 414 | $url->appendChild($textnode); |
| | 415 | /* link */ |
| | 416 | $link = $xmldoc->createElement("link"); |
| | 417 | $image->appendChild($link); |
| | 418 | $textnode = $xmldoc->createTextNode($network->getHomepageURL()); |
| | 419 | $link->appendChild($textnode); |
| | 420 | /* width */ |
| | 421 | /* |
| | 422 | $width = $xmldoc->createElement("width"); |
| | 423 | $image->appendChild($width); |
| | 424 | $textnode = $xmldoc->createTextNode('135'); |
| | 425 | $width->appendChild($textnode); |
| | 426 | */ |
| | 427 | /* height */ |
| | 428 | /* |
| | 429 | $height = $xmldoc->createElement("height"); |
| | 430 | $image->appendChild($height); |
| | 431 | $textnode = $xmldoc->createTextNode('109'); |
| | 432 | $height->appendChild($textnode); |
| | 433 | */ |
| | 434 | /* description */ |
| | 435 | /* |
| | 436 | $description = $xmldoc->createElement("description"); |
| | 437 | $image->appendChild($description); |
| | 438 | $textnode = $xmldoc->createTextNode("Le portail des TIC"); |
| | 439 | $description->appendChild($textnode); |
| | 440 | */ |
| | 441 | |
| | 442 | /* rating */ |
| | 443 | /* textInput */ |
| | 444 | /* skipHours */ |
| | 445 | /* skipDays */ |
| | 446 | |
| | 447 | $i = 0; |
| | 448 | |
| | 449 | if ($node_results) |
| | 450 | foreach ($node_results as $node_row) |
| | 451 | { |
| | 452 | |
| | 453 | $item = $xmldoc->createElement("item"); |
| | 454 | $item = $channel->appendChild($item); |
| | 455 | |
| | 456 | /* title */ |
| | 457 | /* lom_1_2_title_langstrings_id */ |
| | 458 | $title = $xmldoc->createElement("title"); |
| | 459 | $item->appendChild($title); |
| | 460 | $title_str = $node_row['name']; |
| | 461 | $textnode = $xmldoc->createTextNode($title_str); |
| | 462 | $title->appendChild($textnode); |
| | 463 | |
| | 464 | /* link */ |
| | 465 | if (!empty ($node_row['home_page_url'])) |
| | 466 | { |
| | 467 | $link = $xmldoc->createElement("link"); |
| | 468 | $item->appendChild($link); |
| | 469 | $textnode = $xmldoc->createTextNode($node_row['home_page_url']); |
| | 470 | $link->appendChild($textnode); |
| | 471 | } |
| | 472 | |
| | 473 | /* description */ |
| | 474 | $description = $xmldoc->createElement("description"); |
| | 475 | $item->appendChild($description); |
| | 476 | $description_text = '<p>'; |
| | 477 | |
| | 478 | if ($node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE') |
| | 479 | { |
| | 480 | if ($node_row['is_up'] == 't') |
| | 481 | { |
| | 482 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_up.png'> "; |
| | 483 | } |
| | 484 | else |
| | 485 | { |
| | 486 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_down.png'> "; |
| | 487 | } |
| | 488 | } |
| | 489 | |
| | 490 | if (!empty ($node_row['description'])) |
| | 491 | { |
| | 492 | $description_text .= $node_row['description']; |
| | 493 | } |
| | 494 | $description_text .= "</p>\n"; |
| | 495 | $description_text .= "<p>\n"; |
| | 496 | $description_text .= ""._("Address:")." "; |
| | 497 | |
| | 498 | // Civic number |
| | 499 | if (!empty ($node_row['civic_number'])) |
| | 500 | { |
| | 501 | $description_text .= $node_row['civic_number'].", "; |
| | 502 | } |
| | 503 | |
| | 504 | if (!empty ($node_row['street_name'])) |
| | 505 | { |
| | 506 | $description_text .= $node_row['street_name'].", "; |
| | 507 | } |
| | 508 | |
| | 509 | // City |
| | 510 | if (!empty ($node_row['city'])) |
| | 511 | { |
| | 512 | $description_text .= $node_row['city'].", "; |
| | 513 | } |
| | 514 | |
| | 515 | // Province |
| | 516 | if (!empty ($node_row['province'])) |
| | 517 | { |
| | 518 | $description_text .= $node_row['province'].", "; |
| | 519 | } |
| | 520 | |
| | 521 | // Postal code |
| | 522 | if (!empty ($node_row['postal_code'])) |
| | 523 | { |
| | 524 | $description_text .= $node_row['postal_code'].", "; |
| | 525 | } |
| | 526 | |
| | 527 | // Country |
| | 528 | if (!empty ($node_row['country'])) |
| | 529 | { |
| | 530 | $description_text .= $node_row['country']; |
| | 531 | } |
| | 532 | |
| | 533 | if (!empty ($node_row['map_url'])) |
| | 534 | { |
| | 535 | $description_text .= " <a href='".$node_row['map_url']."'>"._("See Map")."</a> "; |
| | 536 | } |
| | 537 | $description_text .= "<br/>\n"; |
| | 538 | if (!empty ($node_row['mass_transit_info'])) |
| | 539 | { |
| | 540 | $description_text .= ""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n"; |
| | 541 | } |
| | 542 | $description_text .= "</p>\n"; |
| | 543 | if (!empty ($node_row['public_email']) || !empty ($node_row['public_phone_number'])) |
| | 544 | { |
| | 545 | $description_text .= "<p>"._("Contact:"); |
| | 546 | |
| | 547 | if (!empty ($node_row['public_phone_number'])) |
| | 548 | { |
| | 549 | $description_text .= " $node_row[public_phone_number] "; |
| | 550 | } |
| | 551 | if (!empty ($node_row['public_email'])) |
| | 552 | { |
| | 553 | $description_text .= " <a href='".$node_row['public_email']."'>$node_row[public_email]</a> "; |
| | 554 | } |
| | 555 | $description_text .= "</p>\n"; |
| | 556 | } |
| | 557 | $textnode = $xmldoc->createTextNode($description_text); |
| | 558 | $description->appendChild($textnode); |
| | 559 | |
| | 560 | /* author */ |
| | 561 | /* |
| | 562 | $author = $xmldoc->createElement("author"); |
| | 563 | $item->appendChild($author); |
| | 564 | $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')'); |
| | 565 | $author->appendChild($textnode); |
| | 566 | */ |
| | 567 | /* category */ |
| | 568 | |
| | 569 | /* comments */ |
| | 570 | /** Link to page once page is available **/ |
| | 571 | /* enclosure */ |
| | 572 | /* guid */ |
| | 573 | |
| | 574 | $guid = $xmldoc->createElement("guid"); |
| | 575 | $guid->setAttribute('isPermaLink', 'false'); |
| | 576 | $item->appendChild($guid); |
| | 577 | $textnode = $xmldoc->createTextNode($network->getHomepageURL().$node_row['node_id']); |
| | 578 | $guid->appendChild($textnode); |
| | 579 | |
| | 580 | /* pubDate */ |
| | 581 | $pubDate = $xmldoc->createElement("pubDate"); |
| | 582 | $item->appendChild($pubDate); |
| | 583 | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $node_row['creation_date_epoch'])); |
| | 584 | $pubDate->appendChild($textnode); |
| | 585 | |
| | 586 | /* source */ |
| | 587 | } |
| | 588 | @ ob_clean(); |
| 285 | | } |
| 286 | | |
| 287 | | break; |
| 288 | | case "RSS" : |
| 289 | | // Query the database, sorting by creation date |
| 290 | | $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); |
| 291 | | |
| 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 | | // Network metadata |
| 298 | | $network = Network::getCurrentNetwork(); |
| 299 | | $xmldoc = new DOMDocument(); |
| 300 | | $xmldoc->formatOutput = true; |
| 301 | | //$xmldoc->encoding="iso-8859-15"; |
| 302 | | $rss = $xmldoc->createElement("rss"); |
| 303 | | $xmldoc->appendChild($rss); |
| 304 | | $rss->setAttribute('version', '2.0'); |
| 305 | | |
| 306 | | /* channel */ |
| 307 | | $channel = $xmldoc->createElement("channel"); |
| 308 | | $rss->appendChild($channel); |
| 309 | | |
| 310 | | /**************** Required channel elements ********************/ |
| 311 | | /* title */ |
| 312 | | $title = $xmldoc->createElement("title"); |
| 313 | | $title = $channel->appendChild($title); |
| 314 | | |
| 315 | | $textnode = $xmldoc->createTextNode($network->getName()._(": Newest HotSpots")); |
| 316 | | $title->appendChild($textnode); |
| 317 | | |
| 318 | | /* link */ |
| 319 | | $link = $xmldoc->createElement("link"); |
| 320 | | $channel->appendChild($link); |
| 321 | | $textnode = $xmldoc->createTextNode($network->getHomepageURL()); |
| 322 | | $link->appendChild($textnode); |
| 323 | | |
| 324 | | /* description */ |
| 325 | | $description = $xmldoc->createElement("description"); |
| 326 | | $channel->appendChild($description); |
| 327 | | $textnode = $xmldoc->createTextNode(_("WiFiDog list of the most recent HotSpots opened by the network: ").$network->getName()); |
| 328 | | $description->appendChild($textnode); |
| 329 | | |
| 330 | | /****************** Optional channel elements *******************/ |
| 331 | | /* language */ |
| 332 | | /**@todo Make language selectable */ |
| 333 | | $language = $xmldoc->createElement("language"); |
| 334 | | $channel->appendChild($language); |
| 335 | | $textnode = $xmldoc->createTextNode("en-CA"); |
| 336 | | $language->appendChild($textnode); |
| 337 | | |
| 338 | | /* copyright */ |
| 339 | | $copyright = $xmldoc->createElement("copyright"); |
| 340 | | $channel->appendChild($copyright); |
| 341 | | $textnode = $xmldoc->createTextNode(_("Copyright ").$network->getName()); |
| 342 | | $copyright->appendChild($textnode); |
| 343 | | |
| 344 | | /* managingEditor */ |
| 345 | | |
| 346 | | |
| 347 | | /* webMaster */ |
| 348 | | $email = Network::GetCurrentNetwork()->getTechSupportEmail(); |
| 349 | | if(!empty($email)) |
| 350 | | { |
| 351 | | $webMaster = $xmldoc->createElement("webMaster"); |
| 352 | | $channel->appendChild($webMaster); |
| 353 | | $textnode = $xmldoc->createTextNode($email); |
| 354 | | $webMaster->appendChild($textnode); |
| 355 | | } |
| 356 | | |
| 357 | | /* pubDate */ |
| 358 | | $pubDate = $xmldoc->createElement("pubDate"); |
| 359 | | $channel->appendChild($pubDate); |
| 360 | | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", time())); |
| 361 | | $pubDate->appendChild($textnode); |
| 362 | | |
| 363 | | /* lastBuildDate */ |
| 364 | | //<lastBuildDate> -- The date-time the last time the content of the channel changed. |
| 365 | | /* Make a request through the database for the latest modification date of an object. |
| 366 | | * Maybe it should be an object property? */ |
| 367 | | $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); |
| 368 | | |
| 369 | | $lastBuildDate = $xmldoc->createElement("lastBuildDate"); |
| 370 | | $channel->appendChild($lastBuildDate); |
| 371 | | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened'])); |
| 372 | | $lastBuildDate->appendChild($textnode); |
| 373 | | |
| 374 | | /* category */ |
| 375 | | /* Specify one or more categories that the channel belongs to. |
| 376 | | * Follows the same rules as the <item>-level category element.*/ |
| 377 | | |
| 378 | | /* generator */ |
| 379 | | $generator = $xmldoc->createElement("generator"); |
| 380 | | $channel->appendChild($generator); |
| 381 | | $textnode = $xmldoc->createTextNode(WIFIDOG_NAME." ".WIFIDOG_VERSION); |
| 382 | | $generator->appendChild($textnode); |
| 383 | | |
| 384 | | /* docs */ |
| 385 | | $docs = $xmldoc->createElement("docs"); |
| 386 | | $channel->appendChild($docs); |
| 387 | | $textnode = $xmldoc->createTextNode("http://blogs.law.harvard.edu/tech/rss"); |
| 388 | | $docs->appendChild($textnode); |
| 389 | | |
| 390 | | /* cloud */ |
| 391 | | /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/ |
| 392 | | |
| 393 | | /* ttl */ |
| 394 | | /* 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.*/ |
| 395 | | |
| 396 | | /* image */ |
| 397 | | $image = $xmldoc->createElement("image"); |
| 398 | | $channel->appendChild($image); |
| 399 | | |
| 400 | | /* title */ |
| 401 | | $title = $xmldoc->createElement("title"); |
| 402 | | $image->appendChild($title); |
| 403 | | $textnode = $xmldoc->createTextNode($network->getName()); |
| 404 | | $title->appendChild($textnode); |
| 405 | | /* url */ |
| 406 | | $url = $xmldoc->createElement("url"); |
| 407 | | $image->appendChild($url); |
| 408 | | $textnode = $xmldoc->createTextNode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME); |
| 409 | | $url->appendChild($textnode); |
| 410 | | /* link */ |
| 411 | | $link = $xmldoc->createElement("link"); |
| 412 | | $image->appendChild($link); |
| 413 | | $textnode = $xmldoc->createTextNode($network->getHomepageURL()); |
| 414 | | $link->appendChild($textnode); |
| 415 | | /* width */ |
| 416 | | /* |
| 417 | | $width = $xmldoc->createElement("width"); |
| 418 | | $image->appendChild($width); |
| 419 | | $textnode = $xmldoc->createTextNode('135'); |
| 420 | | $width->appendChild($textnode); |
| 421 | | */ |
| 422 | | /* height */ |
| 423 | | /* |
| 424 | | $height = $xmldoc->createElement("height"); |
| 425 | | $image->appendChild($height); |
| 426 | | $textnode = $xmldoc->createTextNode('109'); |
| 427 | | $height->appendChild($textnode); |
| 428 | | */ |
| 429 | | /* description */ |
| 430 | | /* |
| 431 | | $description = $xmldoc->createElement("description"); |
| 432 | | $image->appendChild($description); |
| 433 | | $textnode = $xmldoc->createTextNode("Le portail des TIC"); |
| 434 | | $description->appendChild($textnode); |
| 435 | | */ |
| 436 | | |
| 437 | | /* rating */ |
| 438 | | /* textInput */ |
| 439 | | /* skipHours */ |
| 440 | | /* skipDays */ |
| 441 | | |
| 442 | | $i = 0; |
| 443 | | |
| 444 | | if ($node_results) |
| 445 | | foreach ($node_results as $node_row) |
| | 590 | break; |
| | 591 | case "WIFI411_CSV" : |
| | 592 | // Query the database, sorting by creation date |
| | 593 | $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 network_id = '".$db->EscapeString($network->getId())."' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') ORDER BY name", $node_results, false); |
| | 594 | |
| | 595 | /* Header("Cache-control: private, no-cache, must-revalidate"); |
| | 596 | Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
| | 597 | Header("Pragma: no-cache"); |
| | 598 | Header("Content-Type: text/xml; charset=UTF-8");*/ |
| | 599 | |
| | 600 | $xmldoc = new DOMDocument(); |
| | 601 | $xmldoc->formatOutput = true; |
| | 602 | //$xmldoc->encoding="iso-8859-15"; |
| | 603 | $rss = $xmldoc->createElement("rss"); |
| | 604 | $xmldoc->appendChild($rss); |
| | 605 | $rss->setAttribute('version', '2.0'); |
| | 606 | |
| | 607 | /* channel */ |
| | 608 | $channel = $xmldoc->createElement("channel"); |
| | 609 | $rss->appendChild($channel); |
| | 610 | |
| | 611 | /**************** Required channel elements ********************/ |
| | 612 | /* title */ |
| | 613 | $title = $xmldoc->createElement("title"); |
| | 614 | $title = $channel->appendChild($title); |
| | 615 | |
| | 616 | $textnode = $xmldoc->createTextNode(utf8_encode($network->getName()._(": Newest HotSpots"))); |
| | 617 | $title->appendChild($textnode); |
| | 618 | |
| | 619 | /* link */ |
| | 620 | $link = $xmldoc->createElement("link"); |
| | 621 | $channel->appendChild($link); |
| | 622 | $textnode = $xmldoc->createTextNode(utf8_encode($network->getHomepageURL())); |
| | 623 | $link->appendChild($textnode); |
| | 624 | |
| | 625 | /* description */ |
| | 626 | $description = $xmldoc->createElement("description"); |
| | 627 | $channel->appendChild($description); |
| | 628 | $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by the network: ").$network->getName())); |
| | 629 | $description->appendChild($textnode); |
| | 630 | |
| | 631 | /****************** Optional channel elements *******************/ |
| | 632 | /* language */ |
| | 633 | /**@todo Make language selectable */ |
| | 634 | $language = $xmldoc->createElement("language"); |
| | 635 | $channel->appendChild($language); |
| | 636 | $textnode = $xmldoc->createTextNode("en-CA"); |
| | 637 | $language->appendChild($textnode); |
| | 638 | |
| | 639 | /* copyright */ |
| | 640 | $copyright = $xmldoc->createElement("copyright"); |
| | 641 | $channel->appendChild($copyright); |
| | 642 | $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").$network->getName())); |
| | 643 | $copyright->appendChild($textnode); |
| | 644 | |
| | 645 | /* managingEditor */ |
| | 646 | |
| | 647 | /* webMaster */ |
| | 648 | $email = Network :: GetCurrentNetwork()->getTechSupportEmail(); |
| | 649 | if (!empty ($email)) |
| 447 | | |
| 448 | | $item = $xmldoc->createElement("item"); |
| 449 | | $item = $channel->appendChild($item); |
| 450 | | |
| 451 | | /* title */ |
| 452 | | /* lom_1_2_title_langstrings_id */ |
| 453 | | $title = $xmldoc->createElement("title"); |
| 454 | | $item->appendChild($title); |
| 455 | | $title_str = $node_row['name']; |
| 456 | | $textnode = $xmldoc->createTextNode($title_str); |
| 457 | | $title->appendChild($textnode); |
| 458 | | |
| 459 | | /* link */ |
| 460 | | if (!empty ($node_row['home_page_url'])) |
| | 651 | $webMaster = $xmldoc->createElement("webMaster"); |
| | 652 | $channel->appendChild($webMaster); |
| | 653 | $textnode = $xmldoc->createTextNode($email); |
| | 654 | $webMaster->appendChild($textnode); |
| | 655 | } |
| | 656 | |
| | 657 | /* pubDate */ |
| | 658 | $pubDate = $xmldoc->createElement("pubDate"); |
| | 659 | $channel->appendChild($pubDate); |
| | 660 | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", time()))); |
| | 661 | $pubDate->appendChild($textnode); |
| | 662 | |
| | 663 | /* lastBuildDate */ |
| | 664 | //<lastBuildDate> -- The date-time the last time the content of the channel changed. |
| | 665 | /* Make a request through the database for the latest modification date of an object. |
| | 666 | * Maybe it should be an object property? */ |
| | 667 | $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); |
| | 668 | |
| | 669 | $lastBuildDate = $xmldoc->createElement("lastBuildDate"); |
| | 670 | $channel->appendChild($lastBuildDate); |
| | 671 | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened'])); |
| | 672 | $lastBuildDate->appendChild($textnode); |
| | 673 | |
| | 674 | /* category */ |
| | 675 | /* Specify one or more categories that the channel belongs to. |
| | 676 | * Follows the same rules as the <item>-level category element.*/ |
| | 677 | |
| | 678 | /* generator */ |
| | 679 | $generator = $xmldoc->createElement("generator"); |
| | 680 | $channel->appendChild($generator); |
| | 681 | $textnode = $xmldoc->createTextNode(utf8_encode(WIFIDOG_NAME." ".WIFIDOG_VERSION)); |
| | 682 | $generator->appendChild($textnode); |
| | 683 | |
| | 684 | /* docs */ |
| | 685 | $docs = $xmldoc->createElement("docs"); |
| | 686 | $channel->appendChild($docs); |
| | 687 | $textnode = $xmldoc->createTextNode(utf8_encode("http://blogs.law.harvard.edu/tech/rss")); |
| | 688 | $docs->appendChild($textnode); |
| | 689 | |
| | 690 | /* cloud */ |
| | 691 | /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/ |
| | 692 | |
| | 693 | /* ttl */ |
| | 694 | /* 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.*/ |
| | 695 | |
| | 696 | /* image */ |
| | 697 | $image = $xmldoc->createElement("image"); |
| | 698 | $channel->appendChild($image); |
| | 699 | |
| | 700 | /* title */ |
| | 701 | $title = $xmldoc->createElement("title"); |
| | 702 | $image->appendChild($title); |
| | 703 | $textnode = $xmldoc->createTextNode(utf8_encode($network->getName())); |
| | 704 | $title->appendChild($textnode); |
| | 705 | /* url */ |
| | 706 | $url = $xmldoc->createElement("url"); |
| | 707 | $image->appendChild($url); |
| | 708 | $textnode = $xmldoc->createTextNode(utf8_encode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME)); |
| | 709 | $url->appendChild($textnode); |
| | 710 | /* link */ |
| | 711 | $link = $xmldoc->createElement("link"); |
| | 712 | $image->appendChild($link); |
| | 713 | $textnode = $xmldoc->createTextNode(utf8_encode($network->getHomepageURL())); |
| | 714 | $link->appendChild($textnode); |
| | 715 | /* width */ |
| | 716 | /* |
| | 717 | $width = $xmldoc->createElement("width"); |
| | 718 | $image->appendChild($width); |
| | 719 | $textnode = $xmldoc->createTextNode('135'); |
| | 720 | $width->appendChild($textnode); |
| | 721 | */ |
| | 722 | /* height */ |
| | 723 | /* |
| | 724 | $height = $xmldoc->createElement("height"); |
| | 725 | $image->appendChild($height); |
| | 726 | $textnode = $xmldoc->createTextNode('109'); |
| | 727 | $height->appendChild($textnode); |
| | 728 | */ |
| | 729 | /* description */ |
| | 730 | /* |
| | 731 | $description = $xmldoc->createElement("description"); |
| | 732 | $image->appendChild($description); |
| | 733 | $textnode = $xmldoc->createTextNode("Le portail des TIC"); |
| | 734 | $description->appendChild($textnode); |
| | 735 | */ |
| | 736 | |
| | 737 | /* rating */ |
| | 738 | /* textInput */ |
| | 739 | /* skipHours */ |
| | 740 | /* skipDays */ |
| | 741 | |
| | 742 | $i = 0; |
| | 743 | |
| | 744 | if ($node_results) |
| | 745 | foreach ($node_results as $node_row) |
| 462 | | $link = $xmldoc->createElement("link"); |
| 463 | | $item->appendChild($link); |
| 464 | | $textnode = $xmldoc->createTextNode($node_row['home_page_url']); |
| 465 | | $link->appendChild($textnode); |
| | 747 | |
| | 748 | $item = $xmldoc->createElement("item"); |
| | 749 | $item = $channel->appendChild($item); |
| | 750 | |
| | 751 | /* title */ |
| | 752 | /* lom_1_2_title_langstrings_id */ |
| | 753 | $title = $xmldoc->createElement("title"); |
| | 754 | $item->appendChild($title); |
| | 755 | $title_str = $node_row['name']; |
| | 756 | $textnode = $xmldoc->createTextNode(utf8_encode($title_str)); |
| | 757 | $title->appendChild($textnode); |
| | 758 | |
| | 759 | /* link */ |
| | 760 | if (!empty ($node_row['home_page_url'])) |
| | 761 | { |
| | 762 | $link = $xmldoc->createElement("link"); |
| | 763 | $item->appendChild($link); |
| | 764 | $textnode = $xmldoc->createTextNode(utf8_encode($node_row['home_page_url'])); |
| | 765 | $link->appendChild($textnode); |
| | 766 | } |
| | 767 | |
| | 768 | /* description */ |
| | 769 | $description = $xmldoc->createElement("description"); |
| | 770 | $item->appendChild($description); |
| | 771 | $description_text = '<p>'; |
| | 772 | if ($node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE') |
| | 773 | { |
| | 774 | if ($node_row['is_up'] == 't') |
| | 775 | { |
| | 776 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_up.png'> "; |
| | 777 | } |
| | 778 | else |
| | 779 | { |
| | 780 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_down.png'> "; |
| | 781 | } |
| | 782 | } |
| | 783 | |
| | 784 | if (!empty ($node_row['description'])) |
| | 785 | { |
| | 786 | $description_text .= $node_row['description']; |
| | 787 | } |
| | 788 | $description_text .= "</p>\n"; |
| | 789 | $description_text .= "<p>\n"; |
| | 790 | if (!empty ($node_row['street_address'])) |
| | 791 | { |
| | 792 | $description_text .= ""._("Address:")." ".$node_row['street_address']." "; |
| | 793 | } |
| | 794 | if (!empty ($node_row['map_url'])) |
| | 795 | { |
| | 796 | $description_text .= " <a href='".$node_row['map_url']."'>"._("See Map")."</a> "; |
| | 797 | } |
| | 798 | $description_text .= "<br/>\n"; |
| | 799 | if (!empty ($node_row['mass_transit_info'])) |
| | 800 | { |
| | 801 | $description_text .= ""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n"; |
| | 802 | } |
| | 803 | $description_text .= "</p>\n"; |
| | 804 | if (!empty ($node_row['public_email']) || !empty ($node_row['public_phone_number'])) |
| | 805 | { |
| | 806 | $description_text .= "<p>"._("Contact:"); |
| | 807 | |
| | 808 | if (!empty ($node_row['public_phone_number'])) |
| | 809 | { |
| | 810 | $description_text .= " $node_row[public_phone_number] "; |
| | 811 | } |
| | 812 | if (!empty ($node_row['public_email'])) |
| | 813 | { |
| | 814 | $description_text .= " <a href='".$node_row['public_email']."'>$node_row[public_email]</a> "; |
| | 815 | } |
| | 816 | $description_text .= "</p>\n"; |
| | 817 | } |
| | 818 | $textnode = $xmldoc->createTextNode(utf8_encode($description_text)); |
| | 819 | $description->appendChild($textnode); |
| | 820 | |
| | 821 | /* author */ |
| | 822 | /* |
| | 823 | $author = $xmldoc->createElement("author"); |
| | 824 | $item->appendChild($author); |
| | 825 | $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')'); |
| | 826 | $author->appendChild($textnode); |
| | 827 | */ |
| | 828 | /* category */ |
| | 829 | |
| | 830 | /* comments */ |
| | 831 | /** Link to page once page is available **/ |
| | 832 | /* enclosure */ |
| | 833 | /* guid */ |
| | 834 | |
| | 835 | $guid = $xmldoc->createElement("guid"); |
| | 836 | $guid->setAttribute('isPermaLink', 'false'); |
| | 837 | $item->appendChild($guid); |
| | 838 | $textnode = $xmldoc->createTextNode(utf8_encode($network->getHomepageURL().$node_row['node_id'])); |
| | 839 | $guid->appendChild($textnode); |
| | 840 | |
| | 841 | /* pubDate */ |
| | 842 | $pubDate = $xmldoc->createElement("pubDate"); |
| | 843 | $item->appendChild($pubDate); |
| | 844 | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", $node_row['creation_date_epoch']))); |
| | 845 | $pubDate->appendChild($textnode); |
| | 846 | |
| | 847 | /* source */ |
| 484 | | |
| 485 | | if (!empty ($node_row['description'])) |
| 486 | | { |
| 487 | | $description_text .= $node_row['description']; |
| 488 | | } |
| 489 | | $description_text .= "</p>\n"; |
| 490 | | $description_text .= "<p>\n"; |
| 491 | | $description_text .= ""._("Address:")." "; |
| 492 | | |
| 493 | | // Civic number |
| 494 | | if (!empty ($node_row['civic_number'])) |
| 495 | | { |
| 496 | | $description_text .= $node_row['civic_number'].", "; |
| 497 | | } |
| 498 | | |
| 499 | | if (!empty ($node_row['street_name'])) |
| 500 | | { |
| 501 | | $description_text .= $node_row['street_name'].", "; |
| 502 | | } |
| 503 | | |
| 504 | | // City |
| 505 | | if (!empty ($node_row['city'])) |
| 506 | | { |
| 507 | | $description_text .= $node_row['city'].", "; |
| 508 | | } |
| 509 | | |
| 510 | | |
| 511 | | // Province |
| 512 | | if (!empty ($node_row['province'])) |
| 513 | | { |
| 514 | | $description_text .= $node_row['province'].", "; |
| 515 | | } |
| 516 | | |
| 517 | | // Postal code |
| 518 | | if (!empty ($node_row['postal_code'])) |
| 519 | | { |
| 520 | | $description_text .= $node_row['postal_code'].", "; |
| 521 | | } |
| 522 | | |
| 523 | | // Country |
| 524 | | if (!empty ($node_row['country'])) |
| 525 | | { |
| 526 | | $description_text .= $node_row['country']; |
| 527 | | } |
| 528 | | |
| 529 | | if (!empty ($node_row['map_url'])) |
| 530 | | { |
| 531 | | $description_text .= " <a href='".$node_row['map_url']."'>"._("See Map")."</a> "; |
| 532 | | } |
| 533 | | $description_text .= "<br/>\n"; |
| 534 | | if (!empty ($node_row['mass_transit_info'])) |
| 535 | | { |
| 536 | | $description_text .= ""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n"; |
| 537 | | } |
| 538 | | $description_text .= "</p>\n"; |
| 539 | | if (!empty ($node_row['public_email']) || !empty ($node_row['public_phone_number'])) |
| 540 | | { |
| 541 | | $description_text .= "<p>"._("Contact:"); |
| 542 | | |
| 543 | | if (!empty ($node_row['public_phone_number'])) |
| 544 | | { |
| 545 | | $description_text .= " $node_row[public_phone_number] "; |
| 546 | | } |
| 547 | | if (!empty ($node_row['public_email'])) |
| 548 | | { |
| 549 | | $description_text .= " <a href='".$node_row['public_email']."'>$node_row[public_email]</a> "; |
| 550 | | } |
| 551 | | $description_text .= "</p>\n"; |
| 552 | | } |
| 553 | | $textnode = $xmldoc->createTextNode($description_text); |
| 554 | | $description->appendChild($textnode); |
| 555 | | |
| 556 | | /* author */ |
| 557 | | /* |
| 558 | | $author = $xmldoc->createElement("author"); |
| 559 | | $item->appendChild($author); |
| 560 | | $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')'); |
| 561 | | $author->appendChild($textnode); |
| 562 | | */ |
| 563 | | /* category */ |
| 564 | | |
| 565 | | /* comments */ |
| 566 | | /** Link to page once page is available **/ |
| 567 | | /* enclosure */ |
| 568 | | /* guid */ |
| 569 | | |
| 570 | | $guid = $xmldoc->createElement("guid"); |
| 571 | | $guid->setAttribute('isPermaLink', 'false'); |
| 572 | | $item->appendChild($guid); |
| 573 | | $textnode = $xmldoc->createTextNode($network->getHomepageURL().$node_row['node_id']); |
| 574 | | $guid->appendChild($textnode); |
| 575 | | |
| 576 | | /* pubDate */ |
| 577 | | $pubDate = $xmldoc->createElement("pubDate"); |
| 578 | | $item->appendChild($pubDate); |
| 579 | | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $node_row['creation_date_epoch'])); |
| 580 | | $pubDate->appendChild($textnode); |
| 581 | | |
| 582 | | /* source */ |
| | 863 | $smarty->assign("num_deployed_nodes", count($node_results)); |
| | 864 | |
| | 865 | require_once BASEPATH.'classes/MainUI.php'; |
| | 866 | |
| | 867 | if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) |
| | 868 | { |
| | 869 | $tool_html = '<p class="indent">'."\n"; |
| | 870 | $tool_html .= "<ul class='users_list'>\n"; |
| | 871 | $tool_html .= "<li><a href='".BASE_NON_SSL_PATH."hotspots_map.php'>"._('Deployed HotSpots map')."</a></li>"; |
| | 872 | $tool_html .= "</ul>\n"; |
| | 873 | $tool_html .= '</p>'."\n"; |
| 584 | | @ ob_clean(); |
| 585 | | echo $xmldoc->saveXML(); |
| 586 | | break; |
| 587 | | case "WIFI411_CSV" : |
| 588 | | // Query the database, sorting by creation date |
| 589 | | $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 name", $node_results, false); |
| 590 | | |
| 591 | | /* Header("Cache-control: private, no-cache, must-revalidate"); |
| 592 | | Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
| 593 | | Header("Pragma: no-cache"); |
| 594 | | Header("Content-Type: text/xml; charset=UTF-8");*/ |
| 595 | | |
| 596 | | $xmldoc = new DOMDocument(); |
| 597 | | $xmldoc->formatOutput = true; |
| 598 | | //$xmldoc->encoding="iso-8859-15"; |
| 599 | | $rss = $xmldoc->createElement("rss"); |
| 600 | | $xmldoc->appendChild($rss); |
| 601 | | $rss->setAttribute('version', '2.0'); |
| 602 | | |
| 603 | | /* channel */ |
| 604 | | $channel = $xmldoc->createElement("channel"); |
| 605 | | $rss->appendChild($channel); |
| 606 | | |
| 607 | | /**************** Required channel elements ********************/ |
| 608 | | /* title */ |
| 609 | | $title = $xmldoc->createElement("title"); |
| 610 | | $title = $channel->appendChild($title); |
| 611 | | |
| 612 | | $textnode = $xmldoc->createTextNode(utf8_encode($network->getName()._(": Newest HotSpots"))); |
| 613 | | $title->appendChild($textnode); |
| 614 | | |
| 615 | | /* link */ |
| 616 | | $link = $xmldoc->createElement("link"); |
| 617 | | $channel->appendChild($link); |
| 618 | | $textnode = $xmldoc->createTextNode(utf8_encode($network->getHomepageURL())); |
| 619 | | $link->appendChild($textnode); |
| 620 | | |
| 621 | | /* description */ |
| 622 | | $description = $xmldoc->createElement("description"); |
| 623 | | $channel->appendChild($description); |
| 624 | | $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by the network: ").$network->getName())); |
| 625 | | $description->appendChild($textnode); |
| 626 | | |
| 627 | | /****************** Optional channel elements *******************/ |
| 628 | | /* language */ |
| 629 | | /**@todo Make language selectable */ |
| 630 | | $language = $xmldoc->createElement("language"); |
| 631 | | $channel->appendChild($language); |
| 632 | | $textnode = $xmldoc->createTextNode("en-CA"); |
| 633 | | $language->appendChild($textnode); |
| 634 | | |
| 635 | | /* copyright */ |
| 636 | | $copyright = $xmldoc->createElement("copyright"); |
| 637 | | $channel->appendChild($copyright); |
| 638 | | $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").$network->getName())); |
| 639 | | $copyright->appendChild($textnode); |
| 640 | | |
| 641 | | /* managingEditor */ |
| 642 | | |
| 643 | | /* webMaster */ |
| 644 | | $email = Network::GetCurrentNetwork()->getTechSupportEmail(); |
| 645 | | if(!empty($email)) |
| 646 | | { |
| 647 | | $webMaster = $xmldoc->createElement("webMaster"); |
| 648 | | $channel->appendChild($webMaster); |
| 649 | | $textnode = $xmldoc->createTextNode($email); |
| 650 | | $webMaster->appendChild($textnode); |
| 651 | | } |
| 652 | | |
| 653 | | /* pubDate */ |
| 654 | | $pubDate = $xmldoc->createElement("pubDate"); |
| 655 | | $channel->appendChild($pubDate); |
| 656 | | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", time()))); |
| 657 | | $pubDate->appendChild($textnode); |
| 658 | | |
| 659 | | /* lastBuildDate */ |
| 660 | | //<lastBuildDate> -- The date-time the last time the content of the channel changed. |
| 661 | | /* Make a request through the database for the latest modification date of an object. |
| 662 | | * Maybe it should be an object property? */ |
| 663 | | $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); |
| 664 | | |
| 665 | | $lastBuildDate = $xmldoc->createElement("lastBuildDate"); |
| 666 | | $channel->appendChild($lastBuildDate); |
| 667 | | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened'])); |
| 668 | | $lastBuildDate->appendChild($textnode); |
| 669 | | |
| 670 | | /* category */ |
| 671 | | /* Specify one or more categories that the channel belongs to. |
| 672 | | * Follows the same rules as the <item>-level category element.*/ |
| 673 | | |
| 674 | | /* generator */ |
| 675 | | $generator = $xmldoc->createElement("generator"); |
| 676 | | $channel->appendChild($generator); |
| 677 | | $textnode = $xmldoc->createTextNode(utf8_encode(WIFIDOG_NAME." ".WIFIDOG_VERSION)); |
| 678 | | $generator->appendChild($textnode); |
| 679 | | |
| 680 | | /* docs */ |
| 681 | | $docs = $xmldoc->createElement("docs"); |
| 682 | | $channel->appendChild($docs); |
| 683 | | $textnode = $xmldoc->createTextNode(utf8_encode("http://blogs.law.harvard.edu/tech/rss")); |
| 684 | | $docs->appendChild($textnode); |
| 685 | | |
| 686 | | /* cloud */ |
| 687 | | /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/ |
| 688 | | |
| 689 | | /* ttl */ |
| 690 | | /* 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.*/ |
| 691 | | |
| 692 | | /* image */ |
| 693 | | $image = $xmldoc->createElement("image"); |
| 694 | | $channel->appendChild($image); |
| 695 | | |
| 696 | | /* title */ |
| 697 | | $title = $xmldoc->createElement("title"); |
| 698 | | $image->appendChild($title); |
| 699 | | $textnode = $xmldoc->createTextNode(utf8_encode($network->getName())); |
| 700 | | $title->appendChild($textnode); |
| 701 | | /* url */ |
| 702 | | $url = $xmldoc->createElement("url"); |
| 703 | | $image->appendChild($url); |
| 704 | | $textnode = $xmldoc->createTextNode(utf8_encode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME)); |
| 705 | | $url->appendChild($textnode); |
| 706 | | /* link */ |
| 707 | | $link = $xmldoc->createElement("link"); |
| 708 | | $image->appendChild($link); |
| 709 | | $textnode = $xmldoc->createTextNode(utf8_encode($network->getHomepageURL())); |
| 710 | | $link->appendChild($textnode); |
| 711 | | /* width */ |
| 712 | | /* |
| 713 | | $width = $xmldoc->createElement("width"); |
| 714 | | $image->appendChild($width); |
| 715 | | $textnode = $xmldoc->createTextNode('135'); |
| 716 | | $width->appendChild($textnode); |
| 717 | | */ |
| 718 | | /* height */ |
| 719 | | /* |
| 720 | | $height = $xmldoc->createElement("height"); |
| 721 | | $image->appendChild($height); |
| 722 | | $textnode = $xmldoc->createTextNode('109'); |
| 723 | | $height->appendChild($textnode); |
| 724 | | */ |
| 725 | | /* description */ |
| 726 | | /* |
| 727 | | $description = $xmldoc->createElement("description"); |
| 728 | | $image->appendChild($description); |
| 729 | | $textnode = $xmldoc->createTextNode("Le portail des TIC"); |
| 730 | | $description->appendChild($textnode); |
| 731 | | */ |
| 732 | | |
| 733 | | /* rating */ |
| 734 | | /* textInput */ |
| 735 | | /* skipHours */ |
| 736 | | /* skipDays */ |
| 737 | | |
| 738 | | $i = 0; |
| 739 | | |
| 740 | | if ($node_results) |
| 741 | | foreach ($node_results as $node_row) |
| 742 | | { |
| 743 | | |
| 744 | | $item = $xmldoc->createElement("item"); |
| 745 | | $item = $channel->appendChild($item); |
| 746 | | |
| 747 | | /* title */ |
| 748 | | /* lom_1_2_title_langstrings_id */ |
| 749 | | $title = $xmldoc->createElement("title"); |
| 750 | | $item->appendChild($title); |
| 751 | | $title_str = $node_row['name']; |
| 752 | | $textnode = $xmldoc->createTextNode(utf8_encode($title_str)); |
| 753 | | $title->appendChild($textnode); |
| 754 | | |
| 755 | | /* link */ |
| 756 | | if (!empty ($node_row['home_page_url'])) |
| 757 | | { |
| 758 | | $link = $xmldoc->createElement("link"); |
| 759 | | $item->appendChild($link); |
| 760 | | $textnode = $xmldoc->createTextNode(utf8_encode($node_row['home_page_url'])); |
| 761 | | $link->appendChild($textnode); |
| 762 | | } |
| 763 | | |
| 764 | | /* description */ |
| 765 | | $description = $xmldoc->createElement("description"); |
| 766 | | $item->appendChild($description); |
| 767 | | $description_text = '<p>'; |
| 768 | | if ($node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE') |
| 769 | | { |
| 770 | | if ($node_row['is_up'] == 't') |
| 771 | | { |
| 772 | | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_up.png'> "; |
| 773 | | } |
| 774 | | else |
| 775 | | { |
| 776 | | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_down.png'> "; |
| 777 | | } |
| 778 | | } |
| 779 | | |
| 780 | | if (!empty ($node_row['description'])) |
| 781 | | { |
| 782 | | $description_text .= $node_row['description']; |
| 783 | | } |
| 784 | | $description_text .= "</p>\n"; |
| 785 | | $description_text .= "<p>\n"; |
| 786 | | if (!empty ($node_row['street_address'])) |
| 787 | | { |
| 788 | | $description_text .= ""._("Address:")." ".$node_row['street_address']." "; |
| 789 | | } |
| 790 | | if (!empty ($node_row['map_url'])) |
| 791 | | { |
| 792 | | $description_text .= " <a href='".$node_row['map_url']."'>"._("See Map")."</a> "; |
| 793 | | } |
| 794 | | $description_text .= "<br/>\n"; |
| 795 | | if (!empty ($node_row['mass_transit_info'])) |
| 796 | | { |
| 797 | | $description_text .= ""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n"; |
| 798 | | } |
| 799 | | $description_text .= "</p>\n"; |
| 800 | | if (!empty ($node_row['public_email']) || !empty ($node_row['public_phone_number'])) |
| 801 | | { |
| 802 | | $description_text .= "<p>"._("Contact:"); |
| 803 | | |
| 804 | | if (!empty ($node_row['public_phone_number'])) |
| 805 | | { |
| 806 | | $description_text .= " $node_row[public_phone_number] "; |
| 807 | | } |
| 808 | | if (!empty ($node_row['public_email'])) |
| 809 | | { |
| 810 | | $description_text .= " <a href='".$node_row['public_email']."'>$node_row[public_email]</a> "; |
| 811 | | } |
| 812 | | $description_text .= "</p>\n"; |
| 813 | | } |
| 814 | | $textnode = $xmldoc->createTextNode(utf8_encode($description_text)); |
| 815 | | $description->appendChild($textnode); |
| 816 | | |
| 817 | | /* author */ |
| 818 | | /* |
| 819 | | $author = $xmldoc->createElement("author"); |
| 820 | | $item->appendChild($author); |
| 821 | | $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')'); |
| 822 | | $author->appendChild($textnode); |
| 823 | | */ |
| 824 | | /* category */ |
| 825 | | |
| 826 | | /* comments */ |
| 827 | | /** Link to page once page is available **/ |
| 828 | | /* enclosure */ |
| 829 | | /* guid */ |
| 830 | | |
| 831 | | $guid = $xmldoc->createElement("guid"); |
| 832 | | $guid->setAttribute('isPermaLink', 'false'); |
| 833 | | $item->appendChild($guid); |
| 834 | | $textnode = $xmldoc->createTextNode(utf8_encode($network->getHomepageURL().$node_row['node_id'])); |
| 835 | | $guid->appendChild($textnode); |
| 836 | | |
| 837 | | /* pubDate */ |
| 838 | | $pubDate = $xmldoc->createElement("pubDate"); |
| 839 | | $item->appendChild($pubDate); |
| 840 | | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", $node_row['creation_date_epoch']))); |
| 841 | | $pubDate->appendChild($textnode); |
| 842 | | |
| 843 | | /* source */ |
| 844 | | } |
| 845 | | ob_clean(); |
| 846 | | echo $xmldoc->saveXML(); |
| 847 | | break; |
| 848 | | default : |
| 849 | | // Query the database, sorting by node name |
| 850 | | $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 name", $node_results, false); |
| 851 | | |
| 852 | | if ($node_results) |
| 853 | | foreach ($node_results as $node_row) |
| 854 | | { |
| 855 | | $node = Node::getObject($node_row['node_id']); |
| 856 | | $node_row['num_online_users'] = $node->getNumOnlineUsers(); |
| 857 | | $smarty->append("nodes", $node_row); |
| 858 | | } |
| 859 | | $smarty->assign("num_deployed_nodes", count($node_results)); |
| 860 | | |
| 861 | | require_once BASEPATH.'classes/MainUI.php'; |
| 862 | | |
| 863 | | if(defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) |
| 864 | | { |
| 865 | | $tool_html = '<p class="indent">'."\n"; |
| 866 | | $tool_html .= "<ul class='users_list'>\n"; |
| 867 | | $tool_html .= "<li><a href='".BASE_NON_SSL_PATH."hotspots_map.php'>"._('Deployed HotSpots map')."</a></li>"; |
| 868 | | $tool_html .= "</ul>\n"; |
| 869 | | $tool_html .= '</p>'."\n"; |
| 870 | | } |
| 871 | | else |
| 872 | | $tool_html = ""; |
| 873 | | |
| 874 | | $ui = new MainUI(); |
| 875 | | $ui->setToolContent($tool_html); |
| 876 | | $ui->setTitle(_("Hotspot list")); |
| 877 | | $ui->setMainContent($smarty->fetch("templates/hotspot_status.html")); |
| 878 | | $ui->display(); |
| | 875 | else |
| | 876 | $tool_html = ""; |
| | 877 | |
| | 878 | $ui = new MainUI(); |
| | 879 | $ui->setToolContent($tool_html); |
| | 880 | $ui->setTitle(_("Hotspot list")); |
| | 881 | $ui->setMainContent($smarty->fetch("templates/hotspot_status.html")); |
| | 882 | $ui->display(); |
| | 883 | } |