[ class tree: phpchartPlus ] [ index: phpchartPlus ] [ all elements ]

Source for file CacheToFile_Strategy.php

Documentation is available at CacheToFile_Strategy.php

  1. <?php
  2.  
  3. /*
  4. **************************************************
  5. Class: CacheToFile_Strategy.php
  6. **************************************************
  7. Author: Tsiavos Chris <jaames@freemail.gr>
  8. Date: October 2004
  9. **************************************************/
  10.  
  11. /**
  12. *Includes the caching strategy interface
  13. */
  14. require_once("CachingStrategy_Interface.php");
  15.  
  16. /**
  17. *Caches the generated image in a file
  18. */
  19. class CacheToFile_Strategy implements CachingStrategy_Interface {
  20.  
  21. public function Initialize($CacheImageType,$CacheForMinutes,$Params) {
  22. $name=explode(".",basename($_SERVER["PHP_SELF"]));
  23. $CacheImage="./".$name[0]."."."cached";
  24. if (file_exists($CacheImage)) {
  25. $CacheTime=(time()-filemtime($CacheImage))/60;
  26. if ($CacheTime<$CacheForMinutes) {
  27. header("Content-type: image/".$CacheImageType);
  28. header("Cache-Control: no-cache");
  29. readfile($CacheImage);
  30. return 1;
  31. }
  32. }
  33. ob_start();
  34. }
  35. public function CacheImage() {
  36. $name=explode(".",basename($_SERVER["PHP_SELF"]));
  37. $CacheImage="./".$name[0].".cached";
  38. $hd=fopen($CacheImage,"w+");
  39. fwrite($hd,ob_get_contents());
  40. fclose($hd);
  41. }
  42.  
  43. }
  44.  
  45. ?>

Documentation generated on Sun, 3 Oct 2004 14:58:50 +0300 by phpDocumentor 1.3.0RC3