<?php

	include( dirname(__FILE__) . '/inc/functions.inc.php');

	if( !file_exists( $cfg['cache_dir'] . '/index' ) || date('YmdH',filemtime($cfg['cache_dir'] . '/index' )) != date('YmdH') ) {
		hourlyUpdate();
		$content = getContent();
		deleteContent($content);

		ob_start();
		include_once( $cfg['temp_dir'] . 'index.php' );
		$inc_content = ob_get_contents();
		ob_end_clean();

		// Write to cache file:
		$cache_file = $cfg['cache_dir'] . 'index';
		if ( $handle = fopen($cache_file, 'w') ) {
			fwrite($handle, utf8_encode($inc_content) );
			fclose($handle);
			chmod($cache_file ,0777);
		}
	}
	include_once( $cfg['cache_dir'] . 'index' );
