dataroot)) { return rtrim($CONFIG->dataroot, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; } // must get from DB $conf = new \Elgg\Database\Config($CONFIG); $db = new \Elgg\Database($conf, new \Elgg\Logger(new \Elgg\PluginHooksService())); try { $row = $db->getDataRow(" SELECT `value` FROM {$db->getTablePrefix()}datalists WHERE `name` = 'dataroot' "); if (!$row) { return ""; } } catch (\DatabaseException $e) { // we're going to let the engine figure out what's happening... return ''; } return rtrim($row->value, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; }); if ($data_root) { $locator = new \Elgg\EntityDirLocator($guid); $user_path = $data_root . $locator->getPath(); $filename = $user_path . "profile/{$guid}{$size}.jpg"; $filesize = @filesize($filename); if ($filesize) { header("Content-type: image/jpeg"); header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+6 months")), true); header("Pragma: public"); header("Cache-Control: public"); header("Content-Length: $filesize"); header("ETag: \"$etag\""); readfile($filename); exit; } } // something went wrong so load engine and try to forward to default icon require_once $base_dir . "/engine/start.php"; elgg_log("Profile icon direct failed.", "WARNING"); forward("_graphics/icons/user/default{$size}.gif");