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 | |
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
-rw-r--r-- | actions/admin/site/update_basic.php | 16 | ||||
-rw-r--r-- | engine/lib/configuration.php | 6 | ||||
-rw-r--r-- | languages/en.php | 5 | ||||
-rw-r--r-- | mod/profile/icondirect.php | 34 | ||||
-rw-r--r-- | simplecache/view.php | 43 | ||||
-rw-r--r-- | views/default/settings/system.php | 2 |
6 files changed, 83 insertions, 23 deletions
diff --git a/actions/admin/site/update_basic.php b/actions/admin/site/update_basic.php index f5582fb2e..46ac133cc 100644 --- a/actions/admin/site/update_basic.php +++ b/actions/admin/site/update_basic.php @@ -34,6 +34,22 @@ datalist_set('path',sanitise_filepath(get_input('path')));
datalist_set('dataroot',sanitise_filepath(get_input('dataroot')));
+ if (get_input('simplecache_enabled')) {
+ datalist_set('simplecache_enabled',1);
+ elgg_view_regenerate_simplecache();
+ } else {
+ datalist_set('simplecache_enabled',0);
+
+ // purge simple cache
+ if ($handle = opendir($CONFIG->dataroot.'views_simplecache')) {
+ while (false !== ($file = readdir($handle))) {
+ if ($file != "." && $file != "..") {
+ unlink($CONFIG->dataroot.'views_simplecache/'.$file);
+ }
+ }
+ closedir($handle);
+ }
+ }
set_config('language', get_input('language'), $site->getGUID());
diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php index 698bccc73..fb33d7461 100644 --- a/engine/lib/configuration.php +++ b/engine/lib/configuration.php @@ -177,6 +177,12 @@ $dataroot = datalist_get('dataroot');
if (!empty($dataroot))
$CONFIG->dataroot = $dataroot;
+ $simplecache_enabled = datalist_get('simplecache_enabled');
+ if ($simplecache_enabled !== false) {
+ $CONFIG->simplecache_enabled = $simplecache_enabled;
+ } else {
+ $CONFIG->simplecache_enabled = 1;
+ }
if (isset($CONFIG->site) && ($CONFIG->site instanceof ElggSite)) {
$CONFIG->wwwroot = $CONFIG->site->url;
$CONFIG->sitename = $CONFIG->site->name; diff --git a/languages/en.php b/languages/en.php index 62de6f1dd..2a7be9a81 100644 --- a/languages/en.php +++ b/languages/en.php @@ -774,7 +774,10 @@ Alternatively, you can enter your database settings below and we will try and do 'installation:disableapi' => "The RESTful API is a flexible and extensible interface that enables applications to use certain Elgg features remotely.",
'installation:disableapi:label' => "Enable the RESTful API",
-
+
+ 'installation:simplecache:description' => "The simple cache increases performance by caching static content including some CSS and JavaScript files. Normally you will want this on.",
+ 'installation:simplecache:label' => "Use simple cache",
+
'upgrading' => 'Upgrading',
'upgrade:db' => 'Your database was upgraded.',
'upgrade:core' => 'Your elgg installation was upgraded',
diff --git a/mod/profile/icondirect.php b/mod/profile/icondirect.php index ee7f0a5e3..49d230efa 100644 --- a/mod/profile/icondirect.php +++ b/mod/profile/icondirect.php @@ -17,7 +17,7 @@ $contents = '';
- if ($dblink = @mysql_connect($CONFIG->dbhost,$CONFIG->dbuser,$CONFIG->dbpass)) {
+ if ($mysql_dblink = @mysql_connect($CONFIG->dbhost,$CONFIG->dbuser,$CONFIG->dbpass)) {
$username = $_GET['username'];
@@ -57,10 +57,19 @@ $size = "medium";
// Try and get the icon
- if (@mysql_select_db($CONFIG->dbname,$dblink)) {
- if ($result = mysql_query("select value from {$CONFIG->dbprefix}datalists where name = 'dataroot'",$dblink)) {
+ if (@mysql_select_db($CONFIG->dbname,$mysql_dblink)) {
+ // get dataroot and simplecache_enabled in one select for efficiency
+ if ($result = mysql_query("select name, value from {$CONFIG->dbprefix}datalists where name in ('dataroot','simplecache_enabled')",$mysql_dblink)) {
+ $simplecache_enabled = true;
$row = mysql_fetch_object($result);
- $dataroot = $row->value;
+ while ($row) {
+ if ($row->name == 'dataroot') {
+ $dataroot = $row->value;
+ } else if ($row->name == 'simplecache_enabled') {
+ $simplecache_enabled = $row->value;
+ }
+ $row = mysql_fetch_object($result);
+ }
}
$filename = $dataroot . $matrix . "{$username}/profile/" . $username . $size . ".jpg";
$contents = @file_get_contents($filename);
@@ -70,13 +79,18 @@ global $CONFIG, $viewinput;
$viewinput['view'] = 'icon/user/default/'.$size;
- ob_start();
- include(dirname(dirname(dirname(__FILE__))).'/simplecache/view.php');
- $loc = ob_get_clean();
+ if ($simplecache_enabled) {
+ ob_start();
+ include(dirname(dirname(dirname(__FILE__))).'/simplecache/view.php');
+ $loc = ob_get_clean();
+ //$contents = @file_get_contents(dirname(__FILE__) . "/graphics/default{$size}.jpg");
+ } else {
+ mysql_close($mysql_dblink);
+ require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+ $loc = elgg_view($viewinput['view']);
+ }
header('Location: ' . $loc);
- exit;
- //$contents = @file_get_contents(dirname(__FILE__) . "/graphics/default{$size}.jpg");
-
+ exit;
}
header("Content-type: image/jpeg");
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;
- }
}
}
diff --git a/views/default/settings/system.php b/views/default/settings/system.php index 317a1094e..572304e14 100644 --- a/views/default/settings/system.php +++ b/views/default/settings/system.php @@ -38,6 +38,8 @@ $form_body .= "<p class=\"admin_debug\">" . elgg_echo('admin:site:access:warning') . "<br />";
$form_body .= elgg_echo('installation:sitepermissions') . elgg_view('input/access', array('internalname' => 'default_access','value' => $vars['config']->default_access)) . "</p>";
+ $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:simplecache:description') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:simplecache:label')), 'internalname' => 'simplecache_enabled', 'value' => ($vars['config']->simplecache_enabled ? elgg_echo('installation:simplecache:label') : "") )) . "</p>";
+
$form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:debug') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:debug:label')), 'internalname' => 'debug', 'value' => ($vars['config']->debug ? elgg_echo('installation:debug:label') : "") )) . "</p>";
$form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:httpslogin') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:httpslogin:label')), 'internalname' => 'https_login', 'value' => ($vars['config']->https_login ? elgg_echo('installation:httpslogin:label') : "") )) . "</p>";
|