X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fphotos.php;h=3ce6f9934d27f8d4eb2d5d002ecf87a6b276f953;hb=b6fe837a643c9c7bb63a5196d4d14c508f3fce55;hp=3e0ec5802e350b6857f744c02df661dbbe36f9b9;hpb=4e7a5dc56ebb8d99ed06b0b303c4ee24460ae6a8;p=friendica.git diff --git a/mod/photos.php b/mod/photos.php index 3e0ec5802e..3ce6f9934d 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -33,20 +33,32 @@ function photos_init(&$a) { if(count($albums)) { $a->data['albums'] = $albums; - $o .= '

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

'; - $o .= '

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

'; - - $o .= ''; + if(local_user() && $a->data['user']['uid'] == local_user()) { + $o .= ''; + } + + $o .= ''; } if(! x($a->page,'aside')) @@ -87,15 +99,11 @@ EOT; 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; @@ -279,6 +287,7 @@ function photos_post(&$a) { if(($a->argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) { + $desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : ''); $rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : ''); $item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0); @@ -292,7 +301,61 @@ function photos_post(&$a) { if(! strlen($albname)) $albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y'); + + + if((x($_POST,'rotate') !== false) && (intval($_POST['rotate']) == 1)) { + logger('rotate'); + + $r = q("select * from photo where `resource-id` = '%s' and uid = %d and scale = 0 limit 1", + dbesc($resource_id), + intval($page_owner_uid) + ); + if(count($r)) { + $ph = new Photo($r[0]['data']); + if($ph->is_valid()) { + $ph->rotate(270); + + $width = $ph->getWidth(); + $height = $ph->getHeight(); + + $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 0 limit 1", + dbesc($ph->imageString()), + intval($height), + intval($width), + dbesc($resource_id), + intval($page_owner_uid) + ); + + if($width > 640 || $height > 640) { + $ph->scaleImage(640); + $width = $ph->getWidth(); + $height = $ph->getHeight(); + $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 1 limit 1", + dbesc($ph->imageString()), + intval($height), + intval($width), + dbesc($resource_id), + intval($page_owner_uid) + ); + } + + if($width > 320 || $height > 320) { + $ph->scaleImage(320); + $width = $ph->getWidth(); + $height = $ph->getHeight(); + + $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 2 limit 1", + dbesc($ph->imageString()), + intval($height), + intval($width), + dbesc($resource_id), + intval($page_owner_uid) + ); + } + } + } + } $p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ORDER BY `scale` DESC", dbesc($resource_id), @@ -322,7 +385,6 @@ function photos_post(&$a) { // Create item container $title = ''; - $basename = basename($filename); $uri = item_new_uri($a->get_hostname(),$page_owner_uid); $arr = array(); @@ -347,6 +409,7 @@ function photos_post(&$a) { $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]' @@ -406,7 +469,18 @@ function photos_post(&$a) { } else { $newname = $name; - if(strstr($name,'_') || 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), @@ -414,7 +488,8 @@ function photos_post(&$a) { ); } 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) ); @@ -504,7 +579,7 @@ function photos_post(&$a) { $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" ; @@ -551,7 +626,7 @@ function photos_post(&$a) { $album = notags(trim($_REQUEST['album'])); $newalbum = notags(trim($_REQUEST['newalbum'])); - logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , 'LOGGER_DEBUG'); + logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG); if(! strlen($album)) { if(strlen($newalbum)) @@ -578,6 +653,9 @@ function photos_post(&$a) { $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']))); @@ -620,13 +698,13 @@ function photos_post(&$a) { return; } - logger('mod/photos.php: photos_post(): loading the contents of ' . $src , 'LOGGER_DEBUG'); + logger('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG); $imagedata = @file_get_contents($src); $ph = new Photo($imagedata); if(! $ph->is_valid()) { - logger('mod/photos.php: photos_post(): unable to process image' , 'LOGGER_DEBUG'); + logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG); notice( t('Unable to process image.') . EOL ); @unlink($src); $foo = 0; @@ -646,7 +724,7 @@ function photos_post(&$a) { $r = $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny); if(! $r) { - logger('mod/photos.php: photos_post(): image store failed' , 'LOGGER_DEBUG'); + logger('mod/photos.php: photos_post(): image store failed' , LOGGER_DEBUG); notice( t('Image upload failed.') . EOL ); killme(); } @@ -690,6 +768,8 @@ function photos_post(&$a) { $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]'; @@ -723,6 +803,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 @@ -816,11 +897,7 @@ function photos_content(&$a) { } } - $r = q("SELECT `hidewall` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", - intval($owner_uid) - ); - - if(count($r) && $r[0]['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) { + if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) { notice( t('Access to this item is restricted.') . EOL); return; } @@ -830,18 +907,8 @@ function photos_content(&$a) { $o = ""; // tabs - $tpl = get_markup_template('profile_tabs.tpl'); $_is_owner = (local_user() && (local_user() == $owner_uid)); - $o .= replace_macros($tpl,array( - '$url' => $a->get_baseurl() . '/profile/' .$a->data['user']['nickname'], - '$phototab' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'], - '$status' => t('Status'), - '$profile' => t('Profile'), - '$photos' => t('Photos'), - '$events' => (($_is_owner) ? t('Events') : ''), - '$notes' => (($_is_owner) ? t('Personal Notes') : ''), - '$activetab' => "photos", - )); + $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']); // // dispatch request @@ -853,14 +920,21 @@ function photos_content(&$a) { notice( t('Permission denied.')); return; } + + + $selname = (($datum) ? hex2bin($datum) : ''); + + $albumselect = '