BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

feeds.php 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. declare(strict_types = 1);
  3. /**
  4. * Feed start class
  5. *
  6. * Simplified version of script_start,
  7. * used for the sitewide RSS system.
  8. */
  9. # Let's prevent people from clearing feeds
  10. if (isset($_GET['clearcache'])) {
  11. unset($_GET['clearcache']);
  12. }
  13. require_once 'classes/config.php';
  14. $ENV = ENV::go();
  15. require_once "$ENV->SERVER_ROOT/classes/misc.class.php";
  16. require_once "$ENV->SERVER_ROOT/classes/cache.class.php";
  17. require_once "$ENV->SERVER_ROOT/classes/feed.class.php";
  18. # Load the caching class
  19. $Cache = new Cache($ENV->getPriv('MEMCACHED_SERVERS'));
  20. # Load the time class
  21. $Feed = new Feed;
  22. /**
  23. * check_perms
  24. */
  25. function check_perms()
  26. {
  27. return false;
  28. }
  29. /**
  30. * is_number
  31. */
  32. function is_number($Str)
  33. {
  34. if ($Str < 0) {
  35. return false;
  36. }
  37. # We're converting input to an int, then string, and comparing to the original
  38. return ($Str === strval(intval($Str)));
  39. }
  40. /**
  41. * display_str
  42. */
  43. function display_str($Str)
  44. {
  45. if ($Str !== '') {
  46. $Str = make_utf8($Str);
  47. $Str = mb_convert_encoding($Str, 'HTML-ENTITIES', 'UTF-8');
  48. $Str = preg_replace('/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/m', '&amp;', $Str);
  49. $Replace = array(
  50. "'",'"','<','>',
  51. '&#128;','&#130;','&#131;','&#132;','&#133;','&#134;','&#135;','&#136;',
  52. '&#137;','&#138;','&#139;','&#140;','&#142;','&#145;','&#146;','&#147;',
  53. '&#148;','&#149;','&#150;','&#151;','&#152;','&#153;','&#154;','&#155;',
  54. '&#156;','&#158;','&#159;'
  55. );
  56. $With = array(
  57. '&#39;','&quot;','&lt;','&gt;',
  58. '&#8364;','&#8218;','&#402;','&#8222;','&#8230;','&#8224;','&#8225;','&#710;',
  59. '&#8240;','&#352;','&#8249;','&#338;','&#381;','&#8216;','&#8217;','&#8220;',
  60. '&#8221;','&#8226;','&#8211;','&#8212;','&#732;','&#8482;','&#353;','&#8250;',
  61. '&#339;','&#382;','&#376;'
  62. );
  63. $Str = str_replace($Replace, $With, $Str);
  64. }
  65. return $Str;
  66. }
  67. /**
  68. * make_utf8
  69. */
  70. function make_utf8($Str)
  71. {
  72. if ($Str !== '') {
  73. if (is_utf8($Str)) {
  74. $Encoding = 'UTF-8';
  75. }
  76. if (empty($Encoding)) {
  77. $Encoding = mb_detect_encoding($Str, 'UTF-8, ISO-8859-1');
  78. }
  79. if (empty($Encoding)) {
  80. $Encoding = 'ISO-8859-1';
  81. }
  82. if ($Encoding === 'UTF-8') {
  83. return $Str;
  84. } else {
  85. return @mb_convert_encoding($Str, 'UTF-8', $Encoding);
  86. }
  87. }
  88. }
  89. /**
  90. * is_utf8
  91. */
  92. function is_utf8($Str)
  93. {
  94. return preg_match(
  95. '%^(?:
  96. [\x09\x0A\x0D\x20-\x7E] // ASCII
  97. | [\xC2-\xDF][\x80-\xBF] // Non-overlong 2-byte
  98. | \xE0[\xA0-\xBF][\x80-\xBF] // Excluding overlongs
  99. | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} // Straight 3-byte
  100. | \xED[\x80-\x9F][\x80-\xBF] // Excluding surrogates
  101. | \xF0[\x90-\xBF][\x80-\xBF]{2} // Planes 1-3
  102. | [\xF1-\xF3][\x80-\xBF]{3} // Planes 4-15
  103. | \xF4[\x80-\x8F][\x80-\xBF]{2} // Plane 16
  104. )*$%xs',
  105. $Str
  106. );
  107. }
  108. /**
  109. * display_array
  110. */
  111. function display_array($Array, $Escape = [])
  112. {
  113. foreach ($Array as $Key => $Val) {
  114. if ((!is_array($Escape) && $Escape === true) || !in_array($Key, $Escape)) {
  115. $Array[$Key] = display_str($Val);
  116. }
  117. }
  118. return $Array;
  119. }
  120. /**
  121. * site_url
  122. *
  123. * Print the site's URL and appropriate URI scheme,
  124. * including the trailing slash.
  125. */
  126. function site_url()
  127. {
  128. $ENV = ENV::go();
  129. return "https://$ENV->SITE_DOMAIN/";
  130. }
  131. # Set the headers
  132. header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
  133. header('Pragma:');
  134. header('Expires: '.date('D, d M Y H:i:s', time() + (2 * 60 * 60)).' GMT');
  135. header('Last-Modified: '.date('D, d M Y H:i:s').' GMT');
  136. # Load the feeds section
  137. require_once "$ENV->SERVER_ROOT/sections/feeds/index.php";