use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\Config;
+use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Photo;
*
* Question: Do we really need these three methods?
*/
- if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+ if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
header('HTTP/1.1 304 Not Modified');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
header('Etag: ' . $_SERVER['HTTP_IF_NONE_MATCH']);
$direct_cache = false;
}
+ if (empty($_REQUEST['url'])) {
+ System::httpExit(400, ["title" => L10n::t('Bad Request.')]);
+ }
+
if (!$direct_cache) {
$urlhash = 'pic:' . sha1($_REQUEST['url']);
$cachefile = get_cachefile(hash('md5', $_REQUEST['url']));
if ($cachefile != '' && file_exists($cachefile)) {
$img_str = file_get_contents($cachefile);
- $mime = image_type_to_mime_type(exif_imagetype($cachefile));
+ $mime = mime_content_type($cachefile);
header('Content-type: ' . $mime);
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
$tempfile = tempnam(get_temppath(), 'cache');
file_put_contents($tempfile, $img_str);
- $mime = image_type_to_mime_type(exif_imagetype($tempfile));
+ $mime = mime_content_type($tempfile);
unlink($tempfile);
// If there is an error then return a blank image