Просмотр файла gchat/inc/cache.class.php

Размер файла: 904B
  1. <?php
  2.  
  3. class gcache
  4. {
  5. var $cacheFile;
  6. function __construct ()
  7. {
  8. /* Читаем переданные параметры */
  9. if (!empty ($_GET['room']))
  10. {
  11. $roomID = (int) $_GET['room'];
  12. $this->cacheFile = 'r'.$roomID;
  13. if (empty ($_GET['page']))
  14. {
  15. $this->cacheFile .= 'p1';
  16. }
  17. else
  18. {
  19. $pageID = (int) $_GET['page'];
  20. $this->cacheFile .= 'p'.$pageID;
  21. }
  22. }
  23. $this->cacheFile = 'cache/'.$this->cacheFile.'.txt';
  24. }
  25.  
  26. function readCache ()
  27. {
  28. if (file_exists ($this->cacheFile))
  29. {
  30. return file_get_contents ($this->cacheFile);
  31. }
  32. else
  33. return false;
  34. }
  35. function writeCache ($content = null)
  36. {
  37. if (!$content)
  38. return false;
  39. $cache = fopen ($this->cacheFile, 'w');
  40. fwrite ($cache, $content);
  41. fclose ($cache);
  42. }
  43. function cacheExists ()
  44. {
  45. if (file_exists ($this->cacheFile))
  46. {
  47. return true;
  48. }
  49. else
  50. return false;
  51. }
  52. }