Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once('config.php');
- include_once('functions.php');
- if (file_exists(SFORI_FILENAME))
- {
- //get last modification day difference from current
- $date = new DateTime();
- $dayDiff = abs( $date->getTimestamp() - filemtime(SFORI_FILENAME) )/86400;
- //if time diff from now > 28 days
- //empty the file content
- //get data from the link
- //save it in text file
- if( $dayDiff > 28 )
- {
- $handle = fopen(SFORI_FILENAME, 'w') or die('Cannot open file: '.SFORI_FILENAME);
- if ($handle !== false)
- ftruncate($handle, 0);
- $data = get_data_from_url(SFORI_WEBSITE);
- fwrite($handle, $data);
- fclose($handle);
- }
- }
- else
- {
- //create a file
- $handle = fopen(SFORI_FILENAME, 'w') or die('Cannot open file: '.SFORI_FILENAME);
- fclose($handle);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement