dataroot)) { $data_root = $CONFIG->dataroot; } if (!isset($data_root)) { $db_config = new \Elgg\Database\Config($CONFIG); if ($db_config->isDatabaseSplit()) { $read_settings = $db_config->getConnectionConfig(\Elgg\Database\Config::READ); } else { $read_settings = $db_config->getConnectionConfig(\Elgg\Database\Config::READ_WRITE); } $mysql_dblink = @mysql_connect($read_settings["host"], $read_settings["user"], $read_settings["password"], true); if ($mysql_dblink) { if (@mysql_select_db($read_settings["database"], $mysql_dblink)) { $q = "SELECT name, value FROM {$db_config->getTablePrefix()}datalists WHERE name = 'dataroot'"; $result = mysql_query($q, $mysql_dblink); if ($result) { $row = mysql_fetch_object($result); while ($row) { if ($row->name == 'dataroot') { $data_root = $row->value; } $row = mysql_fetch_object($result); } } @mysql_close($mysql_dblink); } } } if (isset($data_root)) { $locator = new \Elgg\EntityDirLocator($guid); $entity_path = $data_root . $locator->getPath(); $filename = $entity_path . "blogs/{$blog_guid}{$size}.jpg"; $filecontents = @file_get_contents($filename); // try fallback size if (!$filecontents && $size !== "medium") { $filename = $entity_path . "blogs/{$blog_guid}medium.jpg"; $filecontents = @file_get_contents($filename); } if ($filecontents) { $filesize = strlen($filecontents); 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\""); echo $filecontents; exit; } } // something went wrong so 404 header("HTTP/1.1 404 Not Found"); exit;