helper_output.php 976 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: helper_output.php 31663 2012-09-19 09:56:03Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class helper_output {
  12. protected static function _header() {
  13. global $_G;
  14. ob_end_clean();
  15. $_G['gzipcompress'] ? ob_start('ob_gzhandler') : ob_start();
  16. @header("Expires: -1");
  17. @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
  18. @header("Pragma: no-cache");
  19. @header("Content-type: text/xml; charset=".CHARSET);
  20. }
  21. public static function xml($s) {
  22. self::_header();
  23. echo '<?xml version="1.0" encoding="'.CHARSET.'"?>'."\r\n", '<root><![CDATA[', $s, ']]></root>';
  24. exit();
  25. }
  26. public static function json($data) {
  27. self::_header();
  28. echo helper_json::encode($data);
  29. exit();
  30. }
  31. public static function html($s) {
  32. self::_header();
  33. echo $s;
  34. exit();
  35. }
  36. }
  37. ?>