| 39 | | Header("Cache-control: private, no-cache, must-revalidate"); |
| 40 | | Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
| 41 | | Header("Pragma: no-cache"); |
| 42 | | Header("Content-Type: text/xml; charset=UTF-8"); |
| 43 | | |
| 44 | | $xmldoc = new DOMDocument(); |
| 45 | | $xmldoc->formatOutput = true; |
| 46 | | //$xmldoc->encoding="iso-8859-15"; |
| 47 | | $rss = $xmldoc->createElement("rss"); |
| 48 | | $xmldoc->appendChild($rss); |
| 49 | | $rss->setAttribute('version', '2.0'); |
| 50 | | |
| 51 | | /* channel */ |
| 52 | | $channel = $xmldoc->createElement("channel"); |
| 53 | | $rss->appendChild($channel); |
| 54 | | |
| 55 | | /**************** Required channel elements ********************/ |
| | 39 | Header("Cache-control: private, no-cache, must-revalidate"); |
| | 40 | Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date |
| | 41 | Header("Pragma: no-cache"); |
| | 42 | Header("Content-Type: text/xml; charset=UTF-8"); |
| | 43 | |
| | 44 | $xmldoc = new DOMDocument(); |
| | 45 | $xmldoc->formatOutput = true; |
| | 46 | //$xmldoc->encoding="iso-8859-15"; |
| | 47 | $rss = $xmldoc->createElement("rss"); |
| | 48 | $xmldoc->appendChild($rss); |
| | 49 | $rss->setAttribute('version', '2.0'); |
| | 50 | |
| | 51 | /* channel */ |
| | 52 | $channel = $xmldoc->createElement("channel"); |
| | 53 | $rss->appendChild($channel); |
| | 54 | |
| | 55 | /**************** Required channel elements ********************/ |
| | 56 | /* title */ |
| | 57 | $title = $xmldoc->createElement("title"); |
| | 58 | $title = $channel->appendChild($title); |
| | 59 | |
| | 60 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME._(": Newest HotSpots"))); |
| | 61 | $title->appendChild($textnode); |
| | 62 | |
| | 63 | /* link */ |
| | 64 | $link = $xmldoc->createElement("link"); |
| | 65 | $channel->appendChild($link); |
| | 66 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); |
| | 67 | $link->appendChild($textnode); |
| | 68 | |
| | 69 | /* description */ |
| | 70 | $description = $xmldoc->createElement("description"); |
| | 71 | $channel->appendChild($description); |
| | 72 | $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by the network: ").HOTSPOT_NETWORK_NAME)); |
| | 73 | $description->appendChild($textnode); |
| | 74 | |
| | 75 | /****************** Optional channel elements *******************/ |
| | 76 | /* language */ |
| | 77 | /**@todo Make language selectable */ |
| | 78 | $language = $xmldoc->createElement("language"); |
| | 79 | $channel->appendChild($language); |
| | 80 | $textnode = $xmldoc->createTextNode("en-CA"); |
| | 81 | $language->appendChild($textnode); |
| | 82 | |
| | 83 | /* copyright */ |
| | 84 | $copyright = $xmldoc->createElement("copyright"); |
| | 85 | $channel->appendChild($copyright); |
| | 86 | $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").HOTSPOT_NETWORK_NAME)); |
| | 87 | $copyright->appendChild($textnode); |
| | 88 | |
| | 89 | /* managingEditor */ |
| | 90 | |
| | 91 | /* webMaster */ |
| | 92 | |
| | 93 | $webMaster = $xmldoc->createElement("webMaster"); |
| | 94 | $channel->appendChild($webMaster); |
| | 95 | $textnode = $xmldoc->createTextNode(utf8_encode(TECH_SUPPORT_EMAIL)); |
| | 96 | $webMaster->appendChild($textnode); |
| | 97 | |
| | 98 | /* pubDate */ |
| | 99 | $pubDate = $xmldoc->createElement("pubDate"); |
| | 100 | $channel->appendChild($pubDate); |
| | 101 | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", time()))); |
| | 102 | $pubDate->appendChild($textnode); |
| | 103 | |
| | 104 | /* lastBuildDate */ |
| | 105 | //<lastBuildDate> -- The date-time the last time the content of the channel changed. |
| | 106 | /* Make a request through the database for the latest modification date of an object. |
| | 107 | * Maybe it should be an object property? */ |
| | 108 | $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); |
| | 109 | |
| | 110 | $lastBuildDate = $xmldoc->createElement("lastBuildDate"); |
| | 111 | $channel->appendChild($lastBuildDate); |
| | 112 | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened'])); |
| | 113 | $lastBuildDate->appendChild($textnode); |
| | 114 | |
| | 115 | /* category */ |
| | 116 | /* Specify one or more categories that the channel belongs to. |
| | 117 | * Follows the same rules as the <item>-level category element.*/ |
| | 118 | |
| | 119 | /* generator */ |
| | 120 | $generator = $xmldoc->createElement("generator"); |
| | 121 | $channel->appendChild($generator); |
| | 122 | $textnode = $xmldoc->createTextNode(utf8_encode(WIFIDOG_NAME . " " . WIFIDOG_VERSION)); |
| | 123 | $generator->appendChild($textnode); |
| | 124 | |
| | 125 | /* docs */ |
| | 126 | $docs = $xmldoc->createElement("docs"); |
| | 127 | $channel->appendChild($docs); |
| | 128 | $textnode = $xmldoc->createTextNode(utf8_encode("http://blogs.law.harvard.edu/tech/rss")); |
| | 129 | $docs->appendChild($textnode); |
| | 130 | |
| | 131 | /* cloud */ |
| | 132 | /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/ |
| | 133 | |
| | 134 | /* ttl */ |
| | 135 | /* 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.*/ |
| | 136 | |
| | 137 | /* image */ |
| | 138 | $image = $xmldoc->createElement("image"); |
| | 139 | $channel->appendChild($image); |
| | 140 | |
| | 141 | /* title */ |
| | 142 | $title = $xmldoc->createElement("title"); |
| | 143 | $image->appendChild($title); |
| | 144 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME)); |
| | 145 | $title->appendChild($textnode); |
| | 146 | /* url */ |
| | 147 | $url = $xmldoc->createElement("url"); |
| | 148 | $image->appendChild($url); |
| | 149 | $textnode = $xmldoc->createTextNode(utf8_encode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME)); |
| | 150 | $url->appendChild($textnode); |
| | 151 | /* link */ |
| | 152 | $link = $xmldoc->createElement("link"); |
| | 153 | $image->appendChild($link); |
| | 154 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); |
| | 155 | $link->appendChild($textnode); |
| | 156 | /* width */ |
| | 157 | /* |
| | 158 | $width = $xmldoc->createElement("width"); |
| | 159 | $image->appendChild($width); |
| | 160 | $textnode = $xmldoc->createTextNode('135'); |
| | 161 | $width->appendChild($textnode); |
| | 162 | */ |
| | 163 | /* height */ |
| | 164 | /* |
| | 165 | $height = $xmldoc->createElement("height"); |
| | 166 | $image->appendChild($height); |
| | 167 | $textnode = $xmldoc->createTextNode('109'); |
| | 168 | $height->appendChild($textnode); |
| | 169 | */ |
| | 170 | /* description */ |
| | 171 | /* |
| | 172 | $description = $xmldoc->createElement("description"); |
| | 173 | $image->appendChild($description); |
| | 174 | $textnode = $xmldoc->createTextNode("Le portail des TIC"); |
| | 175 | $description->appendChild($textnode); |
| | 176 | */ |
| | 177 | |
| | 178 | /* rating */ |
| | 179 | /* textInput */ |
| | 180 | /* skipHours */ |
| | 181 | /* skipDays */ |
| | 182 | |
| | 183 | $i=0; |
| | 184 | |
| | 185 | foreach($node_results as $node_row) { |
| | 186 | |
| | 187 | $item = $xmldoc->createElement("item"); |
| | 188 | $item = $channel->appendChild($item); |
| | 189 | |
| 71 | | $channel->appendChild($description); |
| 72 | | $textnode = $xmldoc->createTextNode(utf8_encode(_("WiFiDog list of the most recent HotSpots opened by ").HOTSPOT_NETWORK_NAME)); |
| | 209 | $item->appendChild($description); |
| | 210 | $description_text='<p>'; |
| | 211 | if($node_row['node_deployment_status'] != 'NON_WIFIDOG_NODE') |
| | 212 | { |
| | 213 | if($node_row['is_up']=='t') |
| | 214 | { |
| | 215 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_up.png'> "; |
| | 216 | } |
| | 217 | else |
| | 218 | { |
| | 219 | $description_text .= "<img src='".BASE_URL_PATH."images/hotspot_status_down.png'> "; |
| | 220 | } |
| | 221 | } |
| | 222 | |
| | 223 | if(!empty($node_row['description'])) |
| | 224 | { |
| | 225 | $description_text.= $node_row['description']; |
| | 226 | } |
| | 227 | $description_text.= "</p>\n"; |
| | 228 | $description_text.="<p>\n"; |
| | 229 | if(!empty($node_row['street_address'])) |
| | 230 | { |
| | 231 | $description_text.= ""._("Address:")." ".$node_row['street_address']." "; |
| | 232 | } |
| | 233 | if(!empty($node_row['map_url'])) |
| | 234 | { |
| | 235 | $description_text.=" <a href='".$node_row['map_url']."'>"._("See Map")."</a> "; |
| | 236 | } |
| | 237 | $description_text.= "<br/>\n"; |
| | 238 | if(!empty($node_row['mass_transit_info'])) |
| | 239 | { |
| | 240 | $description_text.=""._("Mass transit:")." ".$node_row['mass_transit_info']."<br/>\n"; |
| | 241 | } |
| | 242 | $description_text.= "</p>\n"; |
| | 243 | if(!empty($node_row['public_email']) || !empty($node_row['public_phone_number'])) |
| | 244 | { |
| | 245 | $description_text.="<p>"._("Contact:"); |
| | 246 | |
| | 247 | if(!empty($node_row['public_phone_number'])) |
| | 248 | { |
| | 249 | $description_text.=" $node_row[public_phone_number] "; |
| | 250 | } |
| | 251 | if(!empty($node_row['public_email'])) |
| | 252 | { |
| | 253 | $description_text.=" <a href='".$node_row['public_email']."'>$node_row[public_email]</a> "; |
| | 254 | } |
| | 255 | $description_text.="</p>\n"; |
| | 256 | } |
| | 257 | $textnode = $xmldoc->createTextNode(utf8_encode($description_text)); |
| 74 | | |
| 75 | | /****************** Optional channel elements *******************/ |
| 76 | | /* language */ |
| 77 | | /**@todo Make language selectable */ |
| 78 | | $language = $xmldoc->createElement("language"); |
| 79 | | $channel->appendChild($language); |
| 80 | | $textnode = $xmldoc->createTextNode("en-CA"); |
| 81 | | $language->appendChild($textnode); |
| 82 | | |
| 83 | | /* copyright */ |
| 84 | | $copyright = $xmldoc->createElement("copyright"); |
| 85 | | $channel->appendChild($copyright); |
| 86 | | $textnode = $xmldoc->createTextNode(utf8_encode(_("Copyright ").HOTSPOT_NETWORK_NAME)); |
| 87 | | $copyright->appendChild($textnode); |
| 88 | | |
| 89 | | /* managingEditor */ |
| 90 | | |
| 91 | | /* webMaster */ |
| 92 | | |
| 93 | | $webMaster = $xmldoc->createElement("webMaster"); |
| 94 | | $channel->appendChild($webMaster); |
| 95 | | $textnode = $xmldoc->createTextNode(utf8_encode(TECH_SUPPORT_EMAIL)); |
| 96 | | $webMaster->appendChild($textnode); |
| 97 | | |
| 98 | | /* pubDate */ |
| 99 | | $pubDate = $xmldoc->createElement("pubDate"); |
| 100 | | $channel->appendChild($pubDate); |
| 101 | | $textnode = $xmldoc->createTextNode(utf8_encode(gmdate("D, d M Y H:i:s \G\M\T", time()))); |
| 102 | | $pubDate->appendChild($textnode); |
| 103 | | |
| 104 | | /* lastBuildDate */ |
| 105 | | //<lastBuildDate> -- The date-time the last time the content of the channel changed. |
| 106 | | /* Make a request through the database for the latest modification date of an object. |
| 107 | | * Maybe it should be an object property? */ |
| 108 | | $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); |
| 109 | | |
| 110 | | $lastBuildDate = $xmldoc->createElement("lastBuildDate"); |
| 111 | | $channel->appendChild($lastBuildDate); |
| 112 | | $textnode = $xmldoc->createTextNode(gmdate("D, d M Y H:i:s \G\M\T", $last_hotspot_row['date_last_hotspot_opened'])); |
| 113 | | $lastBuildDate->appendChild($textnode); |
| 114 | | |
| | 259 | |
| | 260 | /* author */ |
| | 261 | /* |
| | 262 | $author = $xmldoc->createElement("author"); |
| | 263 | $item->appendChild($author); |
| | 264 | $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')'); |
| | 265 | $author->appendChild($textnode); |
| | 266 | */ |
| 116 | | /* Specify one or more categories that the channel belongs to. |
| 117 | | * Follows the same rules as the <item>-level category element.*/ |
| 118 | | |
| 119 | | /* generator */ |
| 120 | | $generator = $xmldoc->createElement("generator"); |
| 121 | | $channel->appendChild($generator); |
| 122 | | $textnode = $xmldoc->createTextNode(utf8_encode(WIFIDOG_NAME . " " . WIFIDOG_VERSION)); |
| 123 | | $generator->appendChild($textnode); |
| 124 | | |
| 125 | | /* docs */ |
| 126 | | $docs = $xmldoc->createElement("docs"); |
| 127 | | $channel->appendChild($docs); |
| 128 | | $textnode = $xmldoc->createTextNode(utf8_encode("http://blogs.law.harvard.edu/tech/rss")); |
| 129 | | $docs->appendChild($textnode); |
| 130 | | |
| 131 | | /* cloud */ |
| 132 | | /* Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.*/ |
| 133 | | |
| 134 | | /* ttl */ |
| 135 | | /* 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.*/ |
| 136 | | |
| 137 | | /* image */ |
| 138 | | $image = $xmldoc->createElement("image"); |
| 139 | | $channel->appendChild($image); |
| 140 | | |
| 141 | | /* title */ |
| 142 | | $title = $xmldoc->createElement("title"); |
| 143 | | $image->appendChild($title); |
| 144 | | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_NAME)); |
| 145 | | $title->appendChild($textnode); |
| 146 | | /* url */ |
| 147 | | $url = $xmldoc->createElement("url"); |
| 148 | | $image->appendChild($url); |
| 149 | | $textnode = $xmldoc->createTextNode(utf8_encode(COMMON_CONTENT_URL.NETWORK_LOGO_NAME)); |
| 150 | | $url->appendChild($textnode); |
| 151 | | /* link */ |
| 152 | | $link = $xmldoc->createElement("link"); |
| 153 | | $image->appendChild($link); |
| 154 | | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL)); |
| 155 | | $link->appendChild($textnode); |
| 156 | | /* width */ |
| 157 | | /* |
| 158 | | $width = $xmldoc->createElement("width"); |
| 159 | | $image->appendChild($width); |
| 160 | | $textnode = $xmldoc->createTextNode('135'); |
| 161 | | $width->appendChild($textnode); |
| 162 | | */ |
| 163 | | /* height */ |
| 164 | | /* |
| 165 | | $height = $xmldoc->createElement("height"); |
| 166 | | $image->appendChild($height); |
| 167 | | $textnode = $xmldoc->createTextNode('109'); |
| 168 | | $height->appendChild($textnode); |
| 169 | | */ |
| 170 | | /* description */ |
| 171 | | /* |
| 172 | | $description = $xmldoc->createElement("description"); |
| 173 | | $image->appendChild($description); |
| 174 | | $textnode = $xmldoc->createTextNode("Le portail des TIC"); |
| 175 | | $description->appendChild($textnode); |
| 176 | | */ |
| 177 | | |
| 178 | | /* rating */ |
| 179 | | /* textInput */ |
| 180 | | /* skipHours */ |
| 181 | | /* skipDays */ |
| 182 | | |
| 183 | | $i=0; |
| 184 | | |
| 185 | | foreach($node_results as $node_row) { |
| 186 | | |
| 187 | | $item = $xmldoc->createElement("item"); |
| 188 | | $item = $channel->appendChild($item); |
| 189 | | |
| 190 | | /* title */ |
| 191 | | /* lom_1_2_title_langstrings_id */ |
| 192 | | $title = $xmldoc->createElement("title"); |
| 193 | | $item->appendChild($title); |
| 194 | | $title_str = $node_row['name']; |
| 195 | | |
| 196 | | if($node_row['is_up']=='t') |
| 197 | | { |
| 198 | | $title_str .= " (Currently Up)"; |
| 199 | | } |
| 200 | | else |
| 201 | | { |
| 202 | | $title_str .= " (Currently Down)"; |
| 203 | | } |
| 204 | | $textnode = $xmldoc->createTextNode(utf8_encode($title_str)); |
| 205 | | $title->appendChild($textnode); |
| 206 | | |
| 207 | | /* link */ |
| 208 | | if(!empty($node_row['home_page_url'])) |
| 209 | | { |
| 210 | | $link = $xmldoc->createElement("link"); |
| 211 | | $item->appendChild($link); |
| 212 | | $textnode = $xmldoc->createTextNode(utf8_encode($node_row['home_page_url'])); |
| 213 | | $link->appendChild($textnode); |
| 214 | | } |
| 215 | | |
| 216 | | /* description */ |
| 217 | | /* lom_1_4_descriptions_has_langstrings */ |
| 218 | | $description = $xmldoc->createElement("description"); |
| 219 | | $item->appendChild($description); |
| 220 | | $description_text=''; |
| 221 | | if(!empty($node_row['description'])) |
| 222 | | { |
| 223 | | $description_text.=$node_row['description']; |
| 224 | | } |
| 225 | | if(!empty($node_row['street_address'])) |
| 226 | | { |
| 227 | | $description_text.= " "._("Address:")." ".$node_row['street_address']; |
| 228 | | } |
| 229 | | if(!empty($node_row['mass_transit_info'])) |
| 230 | | { |
| 231 | | $description_text.=" "._("Mass transit:")." ".$node_row['mass_transit_info']; |
| 232 | | } |
| 233 | | $textnode = $xmldoc->createTextNode(utf8_encode($description_text)); |
| 234 | | $description->appendChild($textnode); |
| 235 | | |
| 236 | | /* author */ |
| 237 | | /* |
| 238 | | $author = $xmldoc->createElement("author"); |
| 239 | | $item->appendChild($author); |
| 240 | | $textnode = $xmldoc->createTextNode($author_vcard->GetEmail().' ('.$author_vcard->GetName().')'); |
| 241 | | $author->appendChild($textnode); |
| 242 | | */ |
| 243 | | /* category */ |
| 244 | | |
| 245 | | /* comments */ |
| 246 | | /** Link to page once page is available **/ |
| 247 | | /* enclosure */ |
| 248 | | /* guid */ |
| 249 | | |
| 250 | | $guid = $xmldoc->createElement("guid"); |
| 251 | | $guid->setAttribute('isPermaLink', 'false'); |
| 252 | | $item->appendChild($guid); |
| 253 | | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL.$node_row['node_id'])); |
| 254 | | $guid->appendChild($textnode); |
| | 268 | |
| | 269 | /* comments */ |
| | 270 | /** Link to page once page is available **/ |
| | 271 | /* enclosure */ |
| | 272 | /* guid */ |
| | 273 | |
| | 274 | $guid = $xmldoc->createElement("guid"); |
| | 275 | $guid->setAttribute('isPermaLink', 'false'); |
| | 276 | $item->appendChild($guid); |
| | 277 | $textnode = $xmldoc->createTextNode(utf8_encode(HOTSPOT_NETWORK_URL.$node_row['node_id'])); |
| | 278 | $guid->appendChild($textnode); |