class_tplfile.php 766 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. if(!defined('IN_DISCUZ')) {
  3. exit('Access Denied');
  4. }
  5. class tplfile {
  6. public static function getphptemplate($content) {
  7. if(strtolower(substr($content, 0, 5)) == '<?php') {
  8. $pos = strpos($content, "\n");
  9. return $pos !== false ? substr($content, $pos + 1) : $content;
  10. } else {
  11. return $content;
  12. }
  13. }
  14. public static function file_exists($file, $nocache = false) {
  15. return file_exists($file) ? 1 : 0;
  16. }
  17. public static function file_get_contents($file) {
  18. return self::getphptemplate(@implode('', file($file)));
  19. }
  20. public static function filemtime($file) {
  21. if(file_exists($file)) {
  22. return filemtime($file);
  23. }
  24. $ext = fileext($file) == 'htm' ? 'php' : 'htm';
  25. $file = substr($file, 0, -4).'.'.$ext;
  26. return @filemtime($file);
  27. }
  28. }