aboutsummaryrefslogtreecommitdiff
path: root/simplecache/view.php
blob: 475ad22b643d5895ee9af96dae039e68a5a89fe7 (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
36
37
38
39
40
41
42
43
44
45
46
<?php

	/**
	 * Simple cache viewer
	 * Bypasses the engine to view simple cached CSS views.
	 * 
	 * @package Elgg
	 * @subpackage Core
	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
	 * @author Curverider Ltd
	 * @copyright Curverider Ltd 2008-2009
	 * @link http://elgg.org/
	 */

	// Get DB settings, connect
		require_once(dirname(dirname(__FILE__)). '/engine/settings.php');
		
		global $CONFIG, $viewinput;
		
		$contents = '';
		if (!isset($viewinput)) $viewinput = $_GET;
		
		if ($dblink = @mysql_connect($CONFIG->dbhost,$CONFIG->dbuser,$CONFIG->dbpass)) {

			$view = $viewinput['view'];
			$viewtype = $viewinput['viewtype'];
			if (empty($viewtype)) $viewtype = 'default';
			
		// Get the dataroot
			if (@mysql_select_db($CONFIG->dbname,$dblink)) {
				if ($result = mysql_query("select value from {$CONFIG->dbprefix}datalists where name = 'dataroot'",$dblink)) {
					$row = mysql_fetch_object($result);
					$dataroot = $row->value;
				}
				$filename = $dataroot . 'views_simplecache/' . md5($viewtype . $view);
				if (file_exists($filename))
					$contents = @file_get_contents($filename);
				 else {
				 	echo ''; exit;
				 }
			}
		}
		
		echo $contents;

?>