functions.readrss.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /* $Id: functions.readrss.php 1914 2006-12-16 08:50:50Z b4rt $ */
  3. /*******************************************************************************
  4. LICENSE
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License (GPL)
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  14. *******************************************************************************/
  15. /**
  16. * html_entity_decode for for PHP < 4.3
  17. *
  18. * @param $string
  19. * @param $opt
  20. * @return
  21. */
  22. if (!function_exists('html_entity_decode')) {
  23. function html_entity_decode($string, $opt = ENT_COMPAT) {
  24. $trans_tbl = get_html_translation_table (HTML_ENTITIES);
  25. $trans_tbl = array_flip ($trans_tbl);
  26. if ($opt & 1) {
  27. // Translating single quotes
  28. // Add single quote to translation table;
  29. // doesn't appear to be there by default
  30. $trans_tbl["&apos;"] = "'";
  31. }
  32. if (!($opt & 2)) {
  33. // Not translating double quotes
  34. // Remove double quote from translation table
  35. unset($trans_tbl["&quot;"]);
  36. }
  37. return strtr ($string, $trans_tbl);
  38. }
  39. }
  40. /**
  41. * Scrub the description to take out the ugly long URLs
  42. *
  43. * @param $desc
  44. * @param $title
  45. * @return
  46. */
  47. function ScrubDescription($desc, $title) {
  48. $rtnValue = "";
  49. $parts = explode("</a>", $desc);
  50. $replace = preg_replace('/">.*$/', '">'.$title."</a>", $parts[0]);
  51. if (strpos($parts[1], "Search:") !== false)
  52. $parts[1] = $parts[1]."</a>\n";
  53. for ($inx = 2; $inx < count($parts); $inx++) {
  54. if (strpos($parts[$inx], "Info: <a ") !== false) {
  55. // We have an Info: and URL to clean
  56. $parts[$inx] = preg_replace('/">.*$/', '" target="_blank">Read More...</a>', $parts[$inx]);
  57. }
  58. }
  59. $rtnValue = $replace;
  60. for ($inx = 1; $inx < count($parts); $inx++)
  61. $rtnValue .= $parts[$inx];
  62. return $rtnValue;
  63. }
  64. /**
  65. * get rss links
  66. *
  67. * @return array
  68. */
  69. function GetRSSLinks() {
  70. global $cfg, $db;
  71. $link_array = array();
  72. $sql = "SELECT rid, url FROM tf_rss ORDER BY rid";
  73. $link_array = $db->GetAssoc($sql);
  74. if ($db->ErrorNo() != 0) dbError($sql);
  75. $result = $db->execute($sql);
  76. //return $link_array; //Old Query//
  77. while($row = $result->FetchRow()){
  78. $return[$row['rid']] = $row['url'];
  79. //var_dump($row); //Test//
  80. }
  81. return $return;
  82. }
  83. }
  84. ?>