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 4.0KB

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