diff options
author | kevinjardine <kevinjardine@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-02-23 21:29:14 +0000 |
---|---|---|
committer | kevinjardine <kevinjardine@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-02-23 21:29:14 +0000 |
commit | 0139841a1c0836f738fe0917ad09d84e356b68ea (patch) | |
tree | aa9d7bb53e90b9e5a80cfaa4d96f83a556268557 /simplecache/view.php | |
parent | 592d51e94bd7071e9b75c069ff91da311ec001ff (diff) | |
download | elgg-0139841a1c0836f738fe0917ad09d84e356b68ea.tar.gz elgg-0139841a1c0836f738fe0917ad09d84e356b68ea.tar.bz2 |
Added the ability to turn simplecache on and off.
git-svn-id: https://code.elgg.org/elgg/trunk@2908 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'simplecache/view.php')
-rw-r--r-- | simplecache/view.php | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/simplecache/view.php b/simplecache/view.php index 475ad22b6..f0d986e5c 100644 --- a/simplecache/view.php +++ b/simplecache/view.php @@ -20,24 +20,43 @@ $contents = '';
if (!isset($viewinput)) $viewinput = $_GET;
- if ($dblink = @mysql_connect($CONFIG->dbhost,$CONFIG->dbuser,$CONFIG->dbpass)) {
+ if ($mysql_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;
+ if (@mysql_select_db($CONFIG->dbname,$mysql_dblink)) {
+ // get dataroot and simplecache_enabled in one select for efficiency
+ $simplecache_enabled = true;
+ if (!isset($dataroot)) {
+ if ($result = mysql_query("select name, value from {$CONFIG->dbprefix}datalists where name in ('dataroot','simplecache_enabled')",$mysql_dblink)) {
+ $row = mysql_fetch_object($result);
+
+ while ($row) {
+ if ($row->name == 'dataroot') {
+ $dataroot = $row->value;
+ } else if ($row->name == 'simplecache_enabled') {
+ $simplecache_enabled = $row->value;
+ }
+ $row = mysql_fetch_object($result);
+ }
+ }
+ }
+
+ if ($simplecache_enabled) {
+ $filename = $dataroot . 'views_simplecache/' . md5($viewtype . $view);
+ if (file_exists($filename))
+ $contents = @file_get_contents($filename);
+ else {
+ echo ''; exit;
+ }
+ } else {
+ mysql_close($mysql_dblink);
+ require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+ $contents = elgg_view($view);
+ header("Content-Length: " . strlen($contents));
}
- $filename = $dataroot . 'views_simplecache/' . md5($viewtype . $view);
- if (file_exists($filename))
- $contents = @file_get_contents($filename);
- else {
- echo ''; exit;
- }
}
}
|