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

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