X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fphoto.php;h=54418f730d09e1789208dd78447bb9d0376359c6;hb=a16e8d97f6c2935d5a5e136362a698580db4c64a;hp=dc7d8567833086377dfa4dce5bcc390e58850ec7;hpb=92b501aa835cbad4e70784875d732923bc5bfd65;p=friendica.git diff --git a/mod/photo.php b/mod/photo.php index dc7d856783..54418f730d 100644 --- a/mod/photo.php +++ b/mod/photo.php @@ -4,10 +4,9 @@ * @file mod/photo.php */ use Friendica\App; -use Friendica\Database\DBM; +use Friendica\Database\DBA; use Friendica\Object\Image; - -require_once 'include/security.php'; +use Friendica\Util\Security; function photo_init(App $a) { @@ -39,7 +38,9 @@ function photo_init(App $a) if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { 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']); + if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) { + header('Etag: ' . $_SERVER['HTTP_IF_NONE_MATCH']); + } header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT"); header("Cache-Control: max-age=31536000"); if (function_exists('header_remove')) { @@ -50,7 +51,7 @@ function photo_init(App $a) exit; } - $default = 'images/person-175.jpg'; + $default = 'images/person-300.jpg'; $public = true; if (isset($type)) { @@ -71,7 +72,7 @@ function photo_init(App $a) break; } - $uid = str_replace(array('.jpg', '.png', '.gif'), array('', '', ''), $person); + $uid = str_replace(['.jpg', '.png', '.gif'], ['', '', ''], $person); foreach (Image::supportedTypes() AS $m => $e) { $uid = str_replace('.' . $e, '', $uid); @@ -81,7 +82,7 @@ function photo_init(App $a) intval($resolution), intval($uid) ); - if (DBM::is_result($r)) { + if (DBA::isResult($r)) { $data = $r[0]['data']; $mimetype = $r[0]['type']; } @@ -92,7 +93,7 @@ function photo_init(App $a) } else { // Other photos $resolution = 0; - $photo = str_replace(array('.jpg', '.png', '.gif'), array('', '', ''), $photo); + $photo = str_replace(['.jpg', '.png', '.gif'], ['', '', ''], $photo); foreach (Image::supportedTypes() AS $m => $e) { $photo = str_replace('.' . $e, '', $photo); @@ -105,18 +106,18 @@ function photo_init(App $a) // check if the photo exists and get the owner of the photo $r = q("SELECT `uid` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", - dbesc($photo), + DBA::escape($photo), intval($resolution) ); - if (DBM::is_result($r)) { - $sql_extra = permissions_sql($r[0]['uid']); + if (DBA::isResult($r)) { + $sql_extra = Security::getPermissionsSQLByUserId($r[0]['uid']); // Now we'll see if we can access the photo $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `scale` <= %d $sql_extra ORDER BY scale DESC LIMIT 1", - dbesc($photo), + DBA::escape($photo), intval($resolution) ); - if (DBM::is_result($r)) { + if (DBA::isResult($r)) { $resolution = $r[0]['scale']; $data = $r[0]['data']; $mimetype = $r[0]['type']; @@ -136,7 +137,7 @@ function photo_init(App $a) if (isset($resolution)) { switch ($resolution) { case 4: - $data = file_get_contents('images/person-175.jpg'); + $data = file_get_contents('images/person-300.jpg'); $mimetype = 'image/jpeg'; break; case 5: @@ -190,7 +191,7 @@ function photo_init(App $a) // If the photo is public and there is an existing photo directory store the photo there if ($public and $file != '') { // If the photo path isn't there, try to create it - $basepath = $a->get_basepath(); + $basepath = $a->getBasePath(); if (!is_dir($basepath . "/photo")) { if (is_writable($basepath)) { mkdir($basepath . "/photo");