X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fphotos.php;h=466fe44d3e2c6b026f408085b9bfb52daae818fe;hb=84805501449aa03e86d985f3e2d9734184cea0db;hp=86754cdf4e20b1d44cae3ec576ccfa40168b9c81;hpb=3b51f28d257e556b74e61b7d5340bcc54a3e3311;p=friendica.git diff --git a/mod/photos.php b/mod/photos.php old mode 100644 new mode 100755 index 86754cdf4e..466fe44d3e --- a/mod/photos.php +++ b/mod/photos.php @@ -3,6 +3,7 @@ require_once('include/Photo.php'); require_once('include/items.php'); require_once('include/acl_selectors.php'); require_once('include/bbcode.php'); +require_once('include/security.php'); function photos_init(&$a) { @@ -23,28 +24,71 @@ function photos_init(&$a) { $a->data['user'] = $r[0]; - $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d", + $sql_extra = permissions_sql($a->data['user']['uid']); + + $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra ", intval($a->data['user']['uid']) ); if(count($albums)) { $a->data['albums'] = $albums; - $o .= '

' . $a->data['user']['username'] . '

'; - $o .= '

' . '' . t('Photo Albums') . '

'; - + $o .= '
'; + $o .= '
' . $a->data['user']['username'] . '
'; + $o .= '
' . $a->data['user']['username'] . '
'; + $o .= '
'; + + $o .= ''; } if(! x($a->page,'aside')) $a->page['aside'] = ''; $a->page['aside'] .= $o; + + + $a->page['htmlhead'] .= " +EOT; } return; @@ -54,15 +98,11 @@ function photos_init(&$a) { function photos_post(&$a) { -logger('mod/photos.php: photos_post(): begin' , 'LOGGER_DEBUG'); + logger('mod-photos: photos_post: begin' , 'LOGGER_DEBUG'); -foreach($_REQUEST AS $key => $val) { - logger('mod/photos.php: photos_post(): $_REQUEST key: ' . $key . ' val: ' . $val , 'LOGGER_DEBUG'); -} -foreach($_FILES AS $key => $val) { - logger('mod/photos.php: photos_post(): $_FILES key: ' . $key . ' val: ' . $val , 'LOGGER_DEBUG'); -} + logger('mod_photos: REQUEST ' . print_r($_REQUEST,true), LOGGER_DATA); + logger('mod_photos: FILES ' . print_r($_FILES,true), LOGGER_DATA); $can_post = false; $visitor = 0; @@ -107,7 +147,7 @@ foreach($_FILES AS $key => $val) { if(($a->argc > 3) && ($a->argv[2] === 'album')) { $album = hex2bin($a->argv[3]); - if($album == t('Profile Photos') || $album == t('Contact Photos')) { + if($album === t('Profile Photos') || $album === 'Contact Photos' || $album === t('Contact Photos')) { goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); return; // NOTREACHED } @@ -314,6 +354,7 @@ foreach($_FILES AS $key => $val) { $arr['deny_gid'] = $p[0]['deny_gid']; $arr['last-child'] = 1; $arr['visible'] = $visibility; + $arr['origin'] = 1; $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]' @@ -350,6 +391,8 @@ foreach($_FILES AS $key => $val) { if(count($tags)) { foreach($tags as $tag) { + if(isset($profile)) + unset($profile); if(strpos($tag,'@') === 0) { $name = substr($tag,1); if((strpos($name,'@')) || (strpos($name,'http://'))) { @@ -371,7 +414,18 @@ foreach($_FILES AS $key => $val) { } else { $newname = $name; - if(strstr($name,'_')) { + $alias = ''; + $tagcid = 0; + if(strrpos($newname,'+')) + $tagcid = intval(substr($newname,strrpos($newname,'+') + 1)); + + if($tagcid) { + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($tagcid), + intval($profile_uid) + ); + } + elseif(strstr($name,'_') || strstr($name,' ')) { $newname = str_replace('_',' ',$name); $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1", dbesc($newname), @@ -379,7 +433,8 @@ foreach($_FILES AS $key => $val) { ); } else { - $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1", + dbesc($name), dbesc($name), intval($page_owner_uid) ); @@ -469,7 +524,7 @@ foreach($_FILES AS $key => $val) { $arr['target-type'] = ACTIVITY_OBJ_PHOTO; $arr['tag'] = $tagged[4]; $arr['inform'] = $tagged[2]; - + $arr['origin'] = 1; $arr['body'] = '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]' . ' ' . t('was tagged in a') . ' ' . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('photo') . '[/url]' . ' ' . t('by') . ' ' . '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]' ; $arr['body'] .= "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.jpg' . '[/img][/url]' . "\n" ; @@ -484,8 +539,15 @@ foreach($_FILES AS $key => $val) { $arr['target'] .= '' . xmlify('' . "\n" . '') . ''; $item_id = item_store($arr); - if($item_id) + if($item_id) { + q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1", + dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id), + intval($page_owner_uid), + intval($item_id) + ); + proc_run('php',"include/notifier.php","tag","$item_id"); + } } } @@ -522,13 +584,13 @@ foreach($_FILES AS $key => $val) { * * We create a wall item for every photo, but we don't want to * overwhelm the data stream with a hundred newly uploaded photos. - * So we will make one photo (the first one uploaded to this album) + * So we will make the first photo uploaded to this album in the last several hours * visible by default, the rest will become visible over time when and if * they acquire comments, likes, dislikes, and/or tags * */ - $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d", + $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `created` > UTC_TIMESTAMP() - INTERVAL 3 HOUR ", dbesc($album), intval($page_owner_uid) ); @@ -536,6 +598,9 @@ foreach($_FILES AS $key => $val) { $visible = 1; else $visible = 0; + + if(intval($_REQUEST['not_visible']) || $_REQUEST['not_visible'] === 'true') + $visible = 0; $str_group_allow = perms2str(((is_array($_REQUEST['group_allow'])) ? $_REQUEST['group_allow'] : explode(',',$_REQUEST['group_allow']))); $str_contact_allow = perms2str(((is_array($_REQUEST['contact_allow'])) ? $_REQUEST['contact_allow'] : explode(',',$_REQUEST['contact_allow']))); @@ -557,11 +622,24 @@ foreach($_FILES AS $key => $val) { $filesize = intval($_FILES['userfile']['size']); } + + logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ' . $filesize . ' bytes', LOGGER_DEBUG); + $maximagesize = get_config('system','maximagesize'); if(($maximagesize) && ($filesize > $maximagesize)) { notice( t('Image exceeds size limit of ') . $maximagesize . EOL); @unlink($src); + $foo = 0; + call_hooks('photo_post_end',$foo); + return; + } + + if(! $filesize) { + notice( t('Image file is empty.') . EOL); + @unlink($src); + $foo = 0; + call_hooks('photo_post_end',$foo); return; } @@ -574,6 +652,8 @@ foreach($_FILES AS $key => $val) { logger('mod/photos.php: photos_post(): unable to process image' , 'LOGGER_DEBUG'); notice( t('Unable to process image.') . EOL ); @unlink($src); + $foo = 0; + call_hooks('photo_post_end',$foo); killme(); } @@ -633,6 +713,8 @@ foreach($_FILES AS $key => $val) { $arr['deny_gid'] = $str_group_deny; $arr['last-child'] = 1; $arr['visible'] = $visible; + $arr['origin'] = 1; + $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']' . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]' . '[/url]'; @@ -666,6 +748,7 @@ function photos_content(&$a) { // URLs: // photos/name // photos/name/upload + // photos/name/upload/xxxxx (xxxxx is album name) // photos/name/album/xxxxx // photos/name/album/xxxxx/edit // photos/name/image/xxxxx @@ -759,34 +842,18 @@ function photos_content(&$a) { } } - // default permissions - anonymous user + if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) { + notice( t('Access to this item is restricted.') . EOL); + return; + } - $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' "; + $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups); - // Profile owner - everything is visible + $o = ""; - if(local_user() && (local_user() == $owner_uid)) { - $sql_extra = ''; - } - elseif(remote_user()) { - // authenticated visitor - here lie dragons - $gs = '<<>>'; // should be impossible to match - if(count($groups)) { - foreach($groups as $g) - $gs .= '|<' . intval($g) . '>'; - } - $sql_extra = sprintf( - " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' ) - AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' ) - AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' ) - AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ", - - intval(remote_user()), - intval(remote_user()), - dbesc($gs), - dbesc($gs) - ); - } + // tabs + $_is_owner = (local_user() && (local_user() == $owner_uid)); + $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']); // // dispatch request @@ -798,14 +865,21 @@ function photos_content(&$a) { notice( t('Permission denied.')); return; } + + + $selname = (($datum) ? hex2bin($datum) : ''); + + $albumselect = '