X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Ffbrowser.php;h=81284d6b91ef27d654d9c078d2333ab295b41176;hb=1eadcb48552ef0ae1f0bae22103c77b21e2ec517;hp=359e83e111e9f14889c975eefadab2e809974c36;hpb=08c24fd4fa60c6ca891978ab926cbba5ec418466;p=friendica.git diff --git a/mod/fbrowser.php b/mod/fbrowser.php index 359e83e111..81284d6b91 100644 --- a/mod/fbrowser.php +++ b/mod/fbrowser.php @@ -1,5 +1,22 @@ . + * * @package Friendica\modules * @subpackage FileBrowser * @author Fabio Comuni @@ -7,6 +24,7 @@ use Friendica\App; use Friendica\Core\Renderer; +use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Photo; @@ -21,11 +39,11 @@ use Friendica\Util\Strings; function fbrowser_content(App $a) { if (!local_user()) { - exit(); + System::exit(); } if (DI::args()->getArgc() == 1) { - exit(); + System::exit(); } // Needed to match the correct template in a module that uses a different theme than the user/site/default @@ -45,12 +63,12 @@ function fbrowser_content(App $a) $sql_extra = ""; $sql_extra2 = " ORDER BY created DESC LIMIT 0, 10"; - if (DI::args()->getArgc()==2) { - $photos = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' ", - intval(local_user()), - DBA::escape(Photo::CONTACT_PHOTOS), - DBA::escape(DI::l10n()->t(Photo::CONTACT_PHOTOS)) - ); + if (DI::args()->getArgc() == 2) { + $photos = DBA::toArray(DBA::p("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = ? AND NOT `photo-type` IN (?, ?)", + local_user(), + Photo::CONTACT_AVATAR, + Photo::CONTACT_BANNER + )); $albums = array_column($photos, 'album'); } @@ -62,14 +80,14 @@ function fbrowser_content(App $a) $path[$album] = $album; } - $r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`, + $r = DBA::toArray(DBA::p("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`, min(`scale`) AS `hiq`, max(`scale`) AS `loq`, ANY_VALUE(`desc`) AS `desc`, ANY_VALUE(`created`) AS `created` - FROM `photo` WHERE `uid` = %d $sql_extra AND `album` != '%s' AND `album` != '%s' + FROM `photo` WHERE `uid` = ? $sql_extra AND NOT `photo-type` IN (?, ?) GROUP BY `resource-id` $sql_extra2", - intval(local_user()), - DBA::escape(Photo::CONTACT_PHOTOS), - DBA::escape(DI::l10n()->t(Photo::CONTACT_PHOTOS)) - ); + local_user(), + Photo::CONTACT_AVATAR, + Photo::CONTACT_BANNER + )); function _map_files1($rr) { @@ -79,7 +97,7 @@ function fbrowser_content(App $a) $filename_e = $rr['filename']; // Take the largest picture that is smaller or equal 640 pixels - $photo = Photo::selectFirst(['scale'], ["`resource-id` = ? AND `height` <= ? AND `width` <= ?", $rr['resource-id'], 640, 640, ['order' => ['scale']]]); + $photo = Photo::selectFirst(['scale'], ["`resource-id` = ? AND `height` <= ? AND `width` <= ?", $rr['resource-id'], 640, 640], ['order' => ['scale']]); $scale = $photo['scale'] ?? $rr['loq']; return [ @@ -121,7 +139,7 @@ function fbrowser_content(App $a) $tpl = Renderer::getMarkupTemplate($template_file); $o = Renderer::replaceMacros($tpl, [ '$type' => 'file', - '$path' => [ [ "", DI::l10n()->t("Files")] ], + '$path' => ['' => DI::l10n()->t('Files')], '$folders' => false, '$files' => $files, '$cancel' => DI::l10n()->t('Cancel'), @@ -136,7 +154,6 @@ function fbrowser_content(App $a) if (!empty($_GET['mode'])) { return $o; } else { - echo $o; - exit(); + System::httpExit($o); } }