summaryrefslogtreecommitdiff
blob: c3b8270fb666585ae74853e00f305df2e3100860 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?

	if(!$nocache) {
		require_once 'Cache/Lite.php';
		
		$cache_id = md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
		
		if($_COOKIE)
			$cache_id = md5($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] . md5(implode(" ", array_keys($_COOKIE))));
		
		// Use /tmp/znurt if we can hack it
		if((!is_dir("/tmp/znurt") && mkdir("/tmp/znurt")) || (is_dir("/tmp/znurt") && is_writable("/tmp/znurt")))
			$cache_tmp_dir = "/tmp/znurt/";
		else
			$cache_tmp_dir = "/tmp/";
		
		$cache_options = array(
			'cacheDir' => $cache_tmp_dir,
			'lifeTime' => 3600,
		);
		
		$cache = new Cache_Lite($cache_options);
		if($znurt && $data = $cache->get($cache_id)) {
			echo $data;
			die;
		}
		
		// Start caching if on live site
		if($znurt && !$nocache) {
			// Start caching
			ob_start();
		}
	}
	
?>