Changeset 315
- Timestamp:
- 01/11/05 23:00:06 (8 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 6 modified
-
ChangeLog (modified) (1 diff)
-
INSTALL (modified) (1 diff)
-
wifidog/classes/RssPressReview.inc (modified) (14 diffs)
-
wifidog/hotspot_status.php (modified) (2 diffs)
-
wifidog/portal/index.php (modified) (5 diffs)
-
wifidog/templates/hotspot_status.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/ChangeLog
r314 r315 1 1 # $Header$ 2 2004-01-10 Benoit Gr�goire <bock@step.polymtl.ca> 2 2004-01-11 Benoit Gr�goire <bock@step.polymtl.ca> 3 * INSTALL: Mandate PHP5 4 * wifidog/hotspot_status.php: Allow export of the list as a RSS feed 5 * wifidog/classes/RssPressReview.inc: Make it truly functionnal. 6 * wifidog/portal/index.php: Support multiple RSS feeds. The system will automatically pick the best 5 entries from all the feeds. It will compensate for disparate publication intervals. An entry from a feed that does not publish often will live longer than an entry from a feed that publishes very often. If a feed doesn't have any entry that makes the cut, it will not appear at all. 7 * wifidog/templates/hotspot_status.html: Add link to the RSS version. 8 9 2004-01-11 Benoit Gr�goire <bock@step.polymtl.ca> 3 10 * wifidog/config.php: Add list of hotspot to network rss feed list (not yet functionnal) 4 11 * wifidog/hotspot_status.php: Allow RSS export of the list of deployed HotSpots. -
trunk/wifidog-auth/INSTALL
r273 r315 1 1 Prerequisites: 2 Smarty template engine http://smarty.php.net/ 3 magpierss http://magpierss.sourceforge.net/ (Required for RSS support. RSS support must be manually disabled if you do not insall it) 4 php's php-xml extention installed. (Required if RSS support is on) 5 php compiled with gettext support (Will be autodetected if unavailable, but you will loose internationalization) 6 PostgreSQL (mysql code also exists, but is looking for a maintainer) 2 -PHP5 3 -Smarty template engine http://smarty.php.net/ 4 -Magpierss http://magpierss.sourceforge.net/ (Required for RSS support. RSS support must be manually disabled if you do not insall it) 5 -php's php-xml extention installed. (Required if RSS support is on) 6 -php's dom extension installed. (Required if you want to export the list of HotSpots as a RSS feed) 7 -php compiled with gettext support (Will be autodetected if unavailable, but you will loose internationalization) 8 -PostgreSQL (mysql code also exists, but is looking for a maintainer) 7 9 8 10 Install files: -
trunk/wifidog-auth/wifidog/classes/RssPressReview.inc
r314 r315 77 77 @return the date in timestamp format of -1 if unavailable 78 78 */ 79 private function get_item_date ( $item, $debug = 0 )80 {81 $retval = -1;82 if(!empty($item['dc']['date']))83 {84 $datestr = $item['dc']['date'];85 }86 else if (!empty($item['pubdate']))87 {88 $datestr = $item['pubdate'];89 }90 else if (!empty($item['date']))91 {92 $datestr = $item['date'];93 }94 else if (!empty($item['created']))95 {96 $datestr = $item['created'];97 }98 else99 {100 if ($debug)101 {102 echo "<p>get_item_date(): No date present!</p>";103 }104 $datestr = null;105 }79 static private function get_item_date ( $item, $debug = 0 ) 80 { 81 $retval = -1; 82 if(!empty($item['dc']['date'])) 83 { 84 $datestr = $item['dc']['date']; 85 } 86 else if (!empty($item['pubdate'])) 87 { 88 $datestr = $item['pubdate']; 89 } 90 else if (!empty($item['date'])) 91 { 92 $datestr = $item['date']; 93 } 94 else if (!empty($item['created'])) 95 { 96 $datestr = $item['created']; 97 } 98 else 99 { 100 if ($debug) 101 { 102 echo "<p>get_item_date(): No date present!</p>"; 103 } 104 $datestr = null; 105 } 106 106 107 if ($datestr==null)108 {109 $retval = -1;110 }111 else112 {113 if ($debug)114 {115 echo "<p>get_item_date(): String to convert: $datestr</p>";116 }107 if ($datestr==null) 108 { 109 $retval = -1; 110 } 111 else 112 { 113 if ($debug) 114 { 115 echo "<p>get_item_date(): String to convert: $datestr</p>"; 116 } 117 117 118 $retval = parse_w3cdtf($datestr);119 if($retval == -1)120 {121 $retval = strtotime($datestr);122 }118 $retval = parse_w3cdtf($datestr); 119 if($retval == -1) 120 { 121 $retval = strtotime($datestr); 122 } 123 123 124 if ($debug)125 {126 if ($retval == -1)127 {128 echo "<p>get_item_date(): Conversion of $datestr failed!</p>";129 }130 else131 {132 echo "<p>get_item_date(): Conversion succeded</p>";133 setlocale(LC_TIME, "fr_CA");134 echo strftime("%c", $retval);135 }136 }137 138 }139 if ($debug)140 {141 echo "<p>get_item_date(): Retval: $retval</p>";142 }143 return $retval;144 145 }124 if ($debug) 125 { 126 if ($retval == -1) 127 { 128 echo "<p>get_item_date(): Conversion of $datestr failed!</p>"; 129 } 130 else 131 { 132 echo "<p>get_item_date(): Conversion succeded</p>"; 133 setlocale(LC_TIME, "fr_CA"); 134 echo strftime("%c", $retval); 135 } 136 } 137 138 } 139 if ($debug) 140 { 141 echo "<p>get_item_date(): Retval: $retval</p>"; 142 } 143 return $retval; 144 145 } 146 146 147 147 /** Inverted comparaison function for adjusted dates (so that the most recent are first */ … … 169 169 return $string; 170 170 } 171 172 /** This is the static comparing function to sort rss items in chronological order: */ 173 static function cmp_date_item($a, $b) 174 { 175 $a_date=self::get_item_date($a); 176 $b_date=self::get_item_date($b); 177 if ($a_date == $b_date) { 178 return 0; 179 } 180 /*echo "cmp_date_item(): a:$a_date, b:$b_date "; 181 echo ($a_date < $b_date) ? +1 : -1;*/ 182 return ($a_date < $b_date) ? +1 : -1; 183 } 184 171 185 172 186 /* … … 201 215 $publication_interval_total = null; //running total of the difference between the date of the current item and the previous one 202 216 $average_publication_interval = null; 203 $previous_item_date ;217 $previous_item_date=null; 204 218 $rss = fetch_rss( $rss_source['url'] ); 205 219 if ( !$rss ) … … 212 226 //$rss->show_channel(); 213 227 //$rss->show_list(); 214 228 229 /* Sort the array in chronological order */ 230 231 /*foreach ($rss->items as $item) {echo "$item[title] ". self::get_item_date($item) . "<br>\n";}*/ 232 if(!uasort($rss->items, array("RssPressReview","cmp_date_item"))) 233 { 234 echo "Error: uasort() failed<br />\n"; 235 } 236 /*foreach ($rss->items as $item) {echo "$item[title] ". self::get_item_date($item) . "<br>\n";}*/ 237 238 /* Calculate the publication interval for this source */ 215 239 foreach ($rss->items as $item) 216 240 { 217 $date = $this->get_item_date($item);241 $date = self::get_item_date($item); 218 242 219 243 if ($date == -1) … … 237 261 $i++; 238 262 }// End foreach items 263 264 239 265 if($i >= 2 && $publication_interval_total != 0) 240 266 { … … 273 299 //print_r($item_date_array); 274 300 275 usort($item_date_array, "$this->cmp");301 usort($item_date_array, array("RssPressReview","cmp")); 276 302 //print_r($item_date_array); 277 303 //echo "</pre>\n"; … … 286 312 /************** Now we actually display the feeds **************/ 287 313 $sidx=0; 314 $rss_html_all_feeds=''; 315 //print_r($rss_sources); 316 reset($rss_sources); 288 317 foreach ($rss_sources as $rss_sources_key => $rss_source) 289 318 { 290 //echo "<h 1>$rss_source[url]</h1>";319 //echo "<h3>$rss_source[url]</h3>"; 291 320 $rss = fetch_rss( $rss_source['url'] ); 292 321 if ( !$rss ) … … 302 331 if ($rss_sources_key!=0) 303 332 { 304 $rss_header .= "<hr />\n";333 //$rss_header .= "<hr />\n"; 305 334 } 306 335 $rss_header .= "<p class=textegris>"._('Source: ')."<b>"; … … 318 347 $header_is_displayed = false; 319 348 $i = 0; 349 /* Sort the items by date, so we get the most recent first */ 350 if(!uasort($rss->items, array("RssPressReview","cmp_date_item"))) 351 { 352 echo "Error: uasort() failed<br />\n"; 353 } 354 320 355 foreach ($rss->items as $item) 321 356 { 322 $date = $this->get_item_date($item);357 $date = self::get_item_date($item); 323 358 $realdate = $date; 324 359 if ($date == -1) … … 329 364 330 365 $average_publication_interval = $rss_sources[$rss_sources_key]['average_publication_interval']; 366 331 367 $adjust_factor = $all_feed_publication_interval/$average_publication_interval; 332 368 $adjusted_date = time()- ((time()-$date)*$adjust_factor); 333 334 //echo "adjusted_date $adjusted_date, min_adjusted_date_to_display $min_adjusted_date_to_display<br>"; 369 //echo "<pre>";print_r($item);echo"</pre>"; 370 /* setlocale(LC_TIME, "fr_CA"); 371 $display_date= strftime("%x", $realdate); 372 echo "$item[title] ($display_date): adjusted_date $adjusted_date, min_adjusted_date_to_display $min_adjusted_date_to_display<br>"; 373 echo "average_publication_interval: $average_publication_interval, adjust_factor: $adjust_factor, date: $date, $adjusted_date: $adjusted_date<br>";*/ 335 374 if ($adjusted_date >= $min_adjusted_date_to_display) 336 375 { … … 340 379 $header_is_displayed = true; 341 380 } 342 $href = $item['link']; 381 if(!empty($item['link'])) 382 { 383 $href = $item['link']; 384 } 385 else 386 { 387 $href = false; 388 } 343 389 $title = $this->convert_string_encoding($item['title']); 344 390 345 $summary = $this->convert_string_encoding($item['summary']); 346 391 if(!empty($item['summary'])) 392 { 393 $summary = $this->convert_string_encoding($item['summary']); 394 } 395 else 396 { 397 $summary = ''; 398 } 347 399 if($realdate!= -1) 348 400 { … … 356 408 357 409 $author=''; 358 if( trim($item['dc']['creator'])!='')410 if(!empty($item['dc']['creator'])) 359 411 { 360 412 $author = trim($item['dc']['creator']); 361 413 } 362 elseif ( trim($item['author'])!='')414 elseif (!empty($item['author'])) 363 415 { 364 416 $author = trim($item['author']); 365 417 } 366 elseif ( trim($item['author_name'])!='')418 elseif (!empty($item['author_name'])) 367 419 { 368 420 $author = trim($item['author_name']); … … 376 428 $dhtml_id = "summary_".mt_rand(1, 10000). "_".$sidx; 377 429 $rss_html .= "<li>\n"; 378 $rss_html .= "<span class='textegrispetit'>$display_date</span><a class='y' onMouseOver=\"changestyle('$dhtml_id','visible');\" onMouseOut=\"changestyle('$dhtml_id','hidden');\" href='$href'>\n"; 379 $rss_html .= "<b>$title</b><br />\n"; 380 $rss_html .= "</a>\n"; 430 $rss_html .= "<span class='textegrispetit'>$display_date</span><span class='y' onMouseOver=\"changestyle('$dhtml_id','visible');\" onMouseOut=\"changestyle('$dhtml_id','hidden');\">\n"; 431 if($href) 432 { 433 $rss_html .= "<a class='y' href='$href'>\n"; 434 } 435 $rss_html .= "<b>$title</b></span><br />\n"; 436 if($href) 437 { 438 $rss_html .= "</a>\n"; 439 } 381 440 $rss_html .= "<div style='z-index: 1000; position: relative'>\n"; 382 441 $rss_html .= "<div style='z-index: 1000;' id='$dhtml_id' class='introduction'> … … 390 449 $sidx++; 391 450 }// End foreach items 451 392 452 if($header_is_displayed) 393 453 { 394 454 $rss_html .= "</ul>\n"; 395 455 } 396 return $rss_html; 397 456 $rss_html_all_feeds .= $rss_html; 398 457 } 399 458 }// End foreach rss feeds 459 return $rss_html_all_feeds; 400 460 error_reporting($old_error_level); 401 461 } -
trunk/wifidog-auth/wifidog/hotspot_status.php
r314 r315 67 67 $title = $channel->appendChild($title); 68 68 69 $textnode = $xmldoc->createTextNode(utf8_encode(_("New ").HOTSPOT_NETWORK_NAME. _("Hotspots")));69 $textnode = $xmldoc->createTextNode(utf8_encode(_("Newest")." ".HOTSPOT_NETWORK_NAME. " ". _("Hotspots"))); 70 70 $title->appendChild($textnode); 71 71 … … 292 292 } 293 293 $smarty->assign("nodes_count", count($node_results)); 294 $smarty->assign("rss_format_url", 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'].'?format=RSS'); 294 295 echo $style->GetHeader(HOTSPOT_NETWORK_NAME.' hotspot status'); 295 296 $smarty->display("hotspot_status.html"); -
trunk/wifidog-auth/wifidog/portal/index.php
r314 r315 46 46 $hotspot_rss_url = UNKNOWN_HOTSPOT_RSS_URL; 47 47 } 48 else49 {50 $smarty->assign('hotspot_name', $node_info['name']);51 $hotspot_rss_url = $node_info['rss_url'];52 }48 else 49 { 50 $smarty->assign('hotspot_name', $node_info['name']); 51 $hotspot_rss_url = $node_info['rss_url']; 52 } 53 53 54 54 /* Find out who is online */ … … 60 60 { 61 61 foreach ($users as $user_info) 62 {63 $smarty->append("online_users", $user_info);64 }62 { 63 $smarty->append("online_users", $user_info); 64 } 65 65 } 66 66 67 67 if(RSS_SUPPORT) 68 68 { 69 // $old_error_level = error_reporting(E_ERROR);69 // $old_error_level = error_reporting(E_ERROR); 70 70 define('MAGPIE_DIR', BASEPATH.MAGPIE_REL_PATH); 71 // require_once(MAGPIE_DIR.'rss_fetch.inc');72 // define('MAGPIE_DEBUG', 0);73 require_once BASEPATH.'classes/RssPressReview.inc';74 $press_review=new RssPressReview;75 $tokens = "/[\s,]+/";76 $network_rss_sources = NETWORK_RSS_URL;77 $network_rss_html = null;78 if(!empty($network_rss_sources))79 {71 // require_once(MAGPIE_DIR.'rss_fetch.inc'); 72 // define('MAGPIE_DEBUG', 0); 73 require_once BASEPATH.'classes/RssPressReview.inc'; 74 $press_review=new RssPressReview; 75 $tokens = "/[\s,]+/"; 76 $network_rss_sources = NETWORK_RSS_URL; 77 $network_rss_html = null; 78 if(!empty($network_rss_sources)) 79 { 80 80 81 $extract_array=null;82 $extract_array = preg_split($tokens, $network_rss_sources);83 //print_r($extract_array);84 foreach($extract_array as $source)85 {86 $network_rss_sources_array[] = array('url' => $source, 'default_publication_interval' => 7*24*3600);87 }88 $network_rss_html=$press_review->get_rss_html($network_rss_sources_array, 5);89 }81 $extract_array=null; 82 $extract_array = preg_split($tokens, $network_rss_sources); 83 //print_r($extract_array); 84 foreach($extract_array as $source) 85 { 86 $network_rss_sources_array[] = array('url' => $source, 'default_publication_interval' => 7*24*3600); 87 } 88 $network_rss_html=$press_review->get_rss_html($network_rss_sources_array, 5); 89 } 90 90 91 $hotspot_rss_html=null;92 if(!empty($hotspot_rss_url))93 {94 $extract_array=null;95 $extract_array = preg_split($tokens, $hotspot_rss_url);96 //print_r($extract_array);97 foreach($extract_array as $source)98 {99 $hotspot_rss_sources_array[] = array('url' => $source, 'default_publication_interval' => 7*24*3600);100 }101 $hotspot_rss_html=$press_review->get_rss_html($hotspot_rss_sources_array, 5);102 }91 $hotspot_rss_html=null; 92 if(!empty($hotspot_rss_url)) 93 { 94 $extract_array=null; 95 $extract_array = preg_split($tokens, $hotspot_rss_url); 96 //print_r($extract_array); 97 foreach($extract_array as $source) 98 { 99 $hotspot_rss_sources_array[] = array('url' => $source, 'default_publication_interval' => 7*24*3600); 100 } 101 $hotspot_rss_html=$press_review->get_rss_html($hotspot_rss_sources_array, 5); 102 } 103 103 /** 104 104 @return the generated html or the error message or an empty string if called without a URL. … … 121 121 $rss_html .= "<ul>\n"; 122 122 foreach ($rss->items as $item) 123 {124 //echo '<pre>'; print_r($item); echo '</pre>';125 $href = $item['link'];126 $title = $item['title'];127 $summary = $item['summary'];128 $rss_html .= "<li><emp><a href=$href>$title</a></emp> $summary</li>\n";129 }123 { 124 //echo '<pre>'; print_r($item); echo '</pre>'; 125 $href = $item['link']; 126 $title = $item['title']; 127 $summary = $item['summary']; 128 $rss_html .= "<li><emp><a href=$href>$title</a></emp> $summary</li>\n"; 129 } 130 130 $rss_html .= "</ul>\n"; 131 131 } … … 143 143 //echo $hotspot_rss_html; 144 144 $smarty->assign("hotspot_rss_html", $hotspot_rss_html); 145 // error_reporting($old_error_level);145 // error_reporting($old_error_level); 146 146 } 147 147 $smarty->assign("user_management_menu", get_user_management_menu()); … … 156 156 $smarty->display(NODE_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME); 157 157 } 158 else159 {160 $smarty->display(DEFAULT_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME);161 }158 else 159 { 160 $smarty->display(DEFAULT_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME); 161 } 162 162 163 163 ?> -
trunk/wifidog-auth/wifidog/templates/hotspot_status.html
r312 r315 7 7 <thead> 8 8 <tr class='spreadsheet'> 9 <th class='spreadsheet' colspan=6>Status of the {$nodes_count} open {$smarty.const.HOTSPOT_NETWORK_NAME} HotSpots </th>9 <th class='spreadsheet' colspan=6>Status of the {$nodes_count} open {$smarty.const.HOTSPOT_NETWORK_NAME} HotSpots (Get this list as a <a href='{$rss_format_url}'>RSS feed</a>)</th> 10 10 </tr> 11 11 <tr class='spreadsheet'>
