From 0139841a1c0836f738fe0917ad09d84e356b68ea Mon Sep 17 00:00:00 2001 From: kevinjardine Date: Mon, 23 Feb 2009 21:29:14 +0000 Subject: Added the ability to turn simplecache on and off. git-svn-id: https://code.elgg.org/elgg/trunk@2908 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/profile/icondirect.php | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'mod/profile') 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"); -- cgit v1.2.3