Advertisement
Guest User

Untitled

a guest
Jun 27th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <?php
  2.  
  3. include_once('config.php');
  4. include_once('functions.php');
  5.  
  6. if (file_exists(SFORI_FILENAME))
  7. {
  8. //get last modification day difference from current
  9. $date = new DateTime();
  10. $dayDiff = abs( $date->getTimestamp() - filemtime(SFORI_FILENAME) )/86400;
  11.  
  12. //if time diff from now > 28 days
  13. //empty the file content
  14. //get data from the link
  15. //save it in text file
  16. if( $dayDiff > 28 )
  17. {
  18. $handle = fopen(SFORI_FILENAME, 'w') or die('Cannot open file: '.SFORI_FILENAME);
  19. if ($handle !== false)
  20. ftruncate($handle, 0);
  21.  
  22. $data = get_data_from_url(SFORI_WEBSITE);
  23. fwrite($handle, $data);
  24. fclose($handle);
  25. }
  26. }
  27. else
  28. {
  29. //create a file
  30. $handle = fopen(SFORI_FILENAME, 'w') or die('Cannot open file: '.SFORI_FILENAME);
  31. fclose($handle);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement