Oppaitime's version of Gazelle

feeds.php 3.7KB

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