X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fphotos.php;h=4110e805778841af8ca284d808f0e37cf61b2f16;hb=0dfa57948f152a90a4d8093419a2ea5ced07349c;hp=ac54e0e096f8095369cb165fcf28f392e318d928;hpb=5adfeb0bd5fed2f793332056c03bb7c043d5fc69;p=friendica.git diff --git a/mod/photos.php b/mod/photos.php index ac54e0e096..4110e80577 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -3,6 +3,7 @@ use Friendica\App; use Friendica\Core\System; use Friendica\Core\Config; +use Friendica\Core\Worker; use Friendica\Network\Probe; require_once 'include/Photo.php'; @@ -21,7 +22,7 @@ function photos_init(App $a) { auto_redir($a, $a->argv[1]); } - if ((get_config('system', 'block_public')) && (! local_user()) && (! remote_user())) { + if ((Config::get('system', 'block_public')) && (! local_user()) && (! remote_user())) { return; } @@ -29,7 +30,7 @@ function photos_init(App $a) { if ($a->argc > 1) { $nick = $a->argv[1]; - $user = qu("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", + $user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", dbesc($nick) ); @@ -153,7 +154,7 @@ function photos_post(App $a) { } if ($contact_id) { - $r = qu("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", + $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval($page_owner_uid) ); @@ -170,7 +171,7 @@ function photos_post(App $a) { killme(); } - $r = qu("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` + $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1", intval($page_owner_uid) ); @@ -192,7 +193,7 @@ function photos_post(App $a) { return; // NOTREACHED } - $r = qu("SELECT `album` FROM `photo` WHERE `album` = '%s' AND `uid` = %d", + $r = q("SELECT `album` FROM `photo` WHERE `album` = '%s' AND `uid` = %d", dbesc($album), intval($page_owner_uid) ); @@ -304,7 +305,7 @@ function photos_post(App $a) { // send the notification upstream/downstream as the case may be if ($rr['visible']) { - proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id); + Worker::add(PRIORITY_HIGH, "notifier", "drop", $drop_id); } } } @@ -381,7 +382,7 @@ function photos_post(App $a) { photo_albums($page_owner_uid, true); if ($i[0]['visible']) { - proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id); + Worker::add(PRIORITY_HIGH, "notifier", "drop", $drop_id); } } } @@ -729,7 +730,7 @@ function photos_post(App $a) { $item_id = item_store($arr); if ($item_id) { - proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id); + Worker::add(PRIORITY_HIGH, "notifier", "tag", $item_id); } } } @@ -810,7 +811,7 @@ function photos_post(App $a) { logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG); - $maximagesize = get_config('system','maximagesize'); + $maximagesize = Config::get('system','maximagesize'); if (($maximagesize) && ($filesize > $maximagesize)) { notice( sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize)) . EOL); @@ -832,24 +833,6 @@ function photos_post(App $a) { $imagedata = @file_get_contents($src); - - $limit = service_class_fetch($a->data['user']['uid'], 'photo_upload_limit'); - - if ($limit) { - $r = q("SELECT SUM(OCTET_LENGTH(`data`)) AS `total` FROM `photo` WHERE `uid` = %d AND `scale` = 0 AND `album` != 'Contact Photos'", - intval($a->data['user']['uid']) - ); - $size = $r[0]['total']; - - if (($size + strlen($imagedata)) > $limit) { - notice( upgrade_message() . EOL ); - @unlink($src); - $foo = 0; - call_hooks('photo_post_end',$foo); - killme(); - } - } - $ph = new Photo($imagedata, $type); if (! $ph->is_valid()) { @@ -864,7 +847,7 @@ function photos_post(App $a) { $exif = $ph->orient($src); @unlink($src); - $max_length = get_config('system', 'max_image_length'); + $max_length = Config::get('system', 'max_image_length'); if (! $max_length) { $max_length = MAX_IMAGE_LENGTH; } @@ -952,7 +935,7 @@ function photos_post(App $a) { photo_albums($page_owner_uid, true); if ($visible) { - proc_run(PRIORITY_HIGH, "include/notifier.php", 'wall-new', $item_id); + Worker::add(PRIORITY_HIGH, "notifier", 'wall-new', $item_id); } call_hooks('photo_post_end',intval($item_id)); @@ -978,7 +961,7 @@ function photos_content(App $a) { // photos/name/image/xxxxx/edit - if ((get_config('system', 'block_public')) && (! local_user()) && (! remote_user())) { + if ((Config::get('system', 'block_public')) && (! local_user()) && (! remote_user())) { notice( t('Public access denied.') . EOL); return; } @@ -1145,15 +1128,6 @@ function photos_content(App $a) { )); $usage_message = ''; - $limit = service_class_fetch($a->data['user']['uid'], 'photo_upload_limit'); - if ($limit !== false) { - - $r = q("SELECT SUM(`datasize`) AS `total` FROM `photo` WHERE `uid` = %d AND `scale` = 0 AND `album` != 'Contact Photos'", - intval($a->data['user']['uid']) - ); - $usage_message = sprintf(t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 ); - } - // Private/public post links for the non-JS ACL form $private_post = 1; @@ -1378,7 +1352,7 @@ function photos_content(App $a) { else $order = 'DESC'; - $prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0 + $prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0 $sql_extra ORDER BY `created` $order ", dbesc($ph[0]['album']), intval($owner_uid) @@ -1478,7 +1452,7 @@ function photos_content(App $a) { if (dbm::is_result($linked_items)) { $link_item = $linked_items[0]; - $r = qu("SELECT COUNT(*) AS `total` + $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 @@ -1495,7 +1469,7 @@ function photos_content(App $a) { } - $r = qu("SELECT `item`.*, `item`.`id` AS `item_id`, + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, `contact`.`thumb`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` @@ -1835,7 +1809,7 @@ function photos_content(App $a) { // Default - show recent photos with upload link (if applicable) //$o = ''; - $r = qu("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' + $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra GROUP BY `resource-id`", intval($a->data['user']['uid']), dbesc('Contact Photos'), @@ -1846,7 +1820,7 @@ function photos_content(App $a) { $a->set_pager_itemspage(20); } - $r = qu("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`, + $r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`, ANY_VALUE(`album`) AS `album`, max(`scale`) AS `scale`, ANY_VALUE(`created`) AS `created` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'