public function run() { if (empty($_GET['id'])) { throw new BadRequest(); } $userId = $_GET['id']; $user = $this->getEntityManager()->getEntity('User', $userId); if (!$user) { throw new NotFound(); } if (isset($_GET['attachmentId'])) { $id = $_GET['attachmentId']; if ($id == 'false') { $id = false; } } else { $id = $user->get('avatarId'); } $size = null; if (!empty($_GET['size'])) { $size = $_GET['size']; } if (!empty($id)) { $this->show($id, $size); } else { $identicon = new \Identicon\Identicon(); if (empty($size)) { $size = 'small'; } if (!empty($this->imageSizes[$size])) { $width = $this->imageSizes[$size][0]; header('Cache-Control: max-age=360000, must-revalidate'); header('Content-Type: image/png'); ob_clean(); flush(); $identicon->displayImage($userId, $width, $this->getColor($userId)); exit; } } }
if ($defaultMode == '404') { err(404, 'File does not exist'); } else { if ($defaultMode == 'redirect') { header('Location: ' . $default); exit; } else { if ($defaultMode == 'local') { $imgFile = $varDir . $targetSize . '/' . $default; if (!file_exists($imgFile)) { err(500, 'Default file is missing'); } } else { if ($defaultMode == 'identicon') { $identicon = new \Identicon\Identicon(); $identicon->displayImage($reqHash, $reqSize); exit; } else { err(500, 'Invalid defaultMode'); } } } } } $stat = stat($imgFile); $etag = sprintf('%x-%x-%x', $stat['ino'], $stat['size'], $stat['mtime'] * 1000000); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag) { header('Etag: "' . $etag . '"'); header('HTTP/1.0 304 Not Modified'); exit; } else {