2 require_once('include/Photo.php');
3 require_once('include/items.php');
4 require_once('include/acl_selectors.php');
5 require_once('include/bbcode.php');
6 require_once('include/security.php');
9 function photos_init(&$a) {
12 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
19 $r = q("SELECT `user`.*, `contact`.`avatar-date` AS picdate FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 LIMIT 1",
26 $a->data['user'] = $r[0];
28 $sql_extra = permissions_sql($a->data['user']['uid']);
30 $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra ",
31 intval($a->data['user']['uid'])
35 $a->data['albums'] = $albums;
37 $o .= '<div class="vcard">';
38 $o .= '<div class="fn">' . $a->data['user']['username'] . '</div>';
39 $o .= '<div id="profile-photo-wrapper"><img class="photo" style="width: 175px; height: 175px;" src="' . $a->get_baseurl() . '/photo/profile/' . $a->data['user']['uid'] . '.jpg?rev=' . urlencode($a->data['user']['picdate']) . '" alt="' . $a->data['user']['username'] . '" /></div>';
42 if(! intval($a->data['user']['hidewall'])) {
43 $o .= '<div id="side-bar-photos-albums" class="widget">';
44 $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h3>';
47 foreach($albums as $album) {
49 // don't show contact photos. We once translated this name, but then you could still access it under
50 // a different language setting. Now we store the name in English and check in English (and translated for legacy albums).
52 if((! strlen($album['album'])) || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
54 $o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" >' . $album['album'] . '</a></li>';
58 if(local_user() && $a->data['user']['uid'] == local_user()) {
59 $o .= '<div id="photo-albums-upload-link"><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload" >' .t('Upload New Photos') . '</a></div>';
65 if(! x($a->page,'aside'))
66 $a->page['aside'] = '';
67 $a->page['aside'] .= $o;
70 $a->page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "';" ;
72 $a->page['htmlhead'] .= <<< EOT
74 $(document).ready(function() {
76 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
78 $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
79 selstr = $(this).text();
80 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
81 $('#jot-public').hide();
84 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
85 $('#jot-public').show();
101 function photos_post(&$a) {
103 logger('mod-photos: photos_post: begin' , LOGGER_DEBUG);
106 logger('mod_photos: REQUEST ' . print_r($_REQUEST,true), LOGGER_DATA);
107 logger('mod_photos: FILES ' . print_r($_FILES,true), LOGGER_DATA);
109 $phototypes = Photo::supportedTypes();
114 $page_owner_uid = $a->data['user']['uid'];
115 $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
117 if((local_user()) && (local_user() == $page_owner_uid))
120 if($community_page && remote_user()) {
121 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
122 intval(remote_user()),
123 intval($page_owner_uid)
127 $visitor = remote_user();
133 notice( t('Permission denied.') . EOL );
137 $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
138 WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1",
139 intval($page_owner_uid)
143 notice( t('Contact information unavailable') . EOL);
144 logger('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
148 $owner_record = $r[0];
151 if(($a->argc > 3) && ($a->argv[2] === 'album')) {
152 $album = hex2bin($a->argv[3]);
154 if($album === t('Profile Photos') || $album === 'Contact Photos' || $album === t('Contact Photos')) {
155 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
156 return; // NOTREACHED
159 $r = q("SELECT count(*) FROM `photo` WHERE `album` = '%s' AND `uid` = %d",
161 intval($page_owner_uid)
164 notice( t('Album not found.') . EOL);
165 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
166 return; // NOTREACHED
169 $newalbum = notags(trim($_POST['albumname']));
170 if($newalbum != $album) {
171 q("UPDATE `photo` SET `album` = '%s' WHERE `album` = '%s' AND `uid` = %d",
174 intval($page_owner_uid)
176 $newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
177 goaway($a->get_baseurl() . '/' . $newurl);
178 return; // NOTREACHED
182 if($_POST['dropalbum'] == t('Delete Album')) {
186 // get the list of photos we are about to delete
189 $r = q("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `album` = '%s'",
191 intval($page_owner_uid),
196 $r = q("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = %d AND `album` = '%s'",
197 intval(local_user()),
203 $res[] = "'" . dbesc($rr['rid']) . "'" ;
207 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
208 return; // NOTREACHED
211 $str_res = implode(',', $res);
213 // remove the associated photos
215 q("DELETE FROM `photo` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
216 intval($page_owner_uid)
219 // find and delete the corresponding item with all the comments and likes/dislikes
221 $r = q("SELECT `parent-uri` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d",
222 intval($page_owner_uid)
226 q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
227 dbesc(datetime_convert()),
228 dbesc($rr['parent-uri']),
229 intval($page_owner_uid)
232 $drop_id = intval($rr['id']);
234 // send the notification upstream/downstream as the case may be
237 proc_run('php',"include/notifier.php","drop","$drop_id");
241 goaway($a->get_baseurl() . '/photos/' . $a->data['user']['nickname']);
242 return; // NOTREACHED
245 if(($a->argc > 2) && (x($_POST,'delete')) && ($_POST['delete'] == t('Delete Photo'))) {
247 // same as above but remove single photo
250 $r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `resource-id` = '%s' LIMIT 1",
252 intval($page_owner_uid),
257 $r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' LIMIT 1",
258 intval(local_user()),
263 q("DELETE FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'",
264 intval($page_owner_uid),
265 dbesc($r[0]['resource-id'])
267 $i = q("SELECT * FROM `item` WHERE `resource-id` = '%s' AND `uid` = %d LIMIT 1",
268 dbesc($r[0]['resource-id']),
269 intval($page_owner_uid)
272 q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d",
273 dbesc(datetime_convert()),
274 dbesc(datetime_convert()),
276 intval($page_owner_uid)
279 $url = $a->get_baseurl();
280 $drop_id = intval($i[0]['id']);
283 proc_run('php',"include/notifier.php","drop","$drop_id");
287 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
288 return; // NOTREACHED
291 if(($a->argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
294 $desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : '');
295 $rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : '');
296 $item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0);
297 $albname = ((x($_POST,'albname')) ? notags(trim($_POST['albname'])) : '');
298 $str_group_allow = perms2str($_POST['group_allow']);
299 $str_contact_allow = perms2str($_POST['contact_allow']);
300 $str_group_deny = perms2str($_POST['group_deny']);
301 $str_contact_deny = perms2str($_POST['contact_deny']);
303 $resource_id = $a->argv[2];
305 if(! strlen($albname))
306 $albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
309 if((x($_POST,'rotate') !== false) && (intval($_POST['rotate']) == 1)) {
312 $r = q("select * from photo where `resource-id` = '%s' and uid = %d and scale = 0 limit 1",
314 intval($page_owner_uid)
317 $ph = new Photo($r[0]['data'], $r[0]['type']);
318 if($ph->is_valid()) {
321 $width = $ph->getWidth();
322 $height = $ph->getHeight();
324 $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 0 limit 1",
325 dbesc($ph->imageString()),
329 intval($page_owner_uid)
332 if($width > 640 || $height > 640) {
333 $ph->scaleImage(640);
334 $width = $ph->getWidth();
335 $height = $ph->getHeight();
337 $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 1 limit 1",
338 dbesc($ph->imageString()),
342 intval($page_owner_uid)
346 if($width > 320 || $height > 320) {
347 $ph->scaleImage(320);
348 $width = $ph->getWidth();
349 $height = $ph->getHeight();
351 $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 2 limit 1",
352 dbesc($ph->imageString()),
356 intval($page_owner_uid)
363 $p = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ORDER BY `scale` DESC",
365 intval($page_owner_uid)
368 $ext = $phototypes[$p[0]['type']];
369 $r = q("UPDATE `photo` SET `desc` = '%s', `album` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `resource-id` = '%s' AND `uid` = %d",
372 dbesc($str_contact_allow),
373 dbesc($str_group_allow),
374 dbesc($str_contact_deny),
375 dbesc($str_group_deny),
377 intval($page_owner_uid)
381 /* Don't make the item visible if the only change was the album name */
384 if($p[0]['desc'] !== $desc || strlen($rawtags))
389 // Create item container
392 $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
396 $arr['uid'] = $page_owner_uid;
398 $arr['parent-uri'] = $uri;
399 $arr['type'] = 'photo';
401 $arr['resource-id'] = $p[0]['resource-id'];
402 $arr['contact-id'] = $owner_record['id'];
403 $arr['owner-name'] = $owner_record['name'];
404 $arr['owner-link'] = $owner_record['url'];
405 $arr['owner-avatar'] = $owner_record['thumb'];
406 $arr['author-name'] = $owner_record['name'];
407 $arr['author-link'] = $owner_record['url'];
408 $arr['author-avatar'] = $owner_record['thumb'];
409 $arr['title'] = $title;
410 $arr['allow_cid'] = $p[0]['allow_cid'];
411 $arr['allow_gid'] = $p[0]['allow_gid'];
412 $arr['deny_cid'] = $p[0]['deny_cid'];
413 $arr['deny_gid'] = $p[0]['deny_gid'];
414 $arr['last-child'] = 1;
415 $arr['visible'] = $visibility;
418 $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
419 . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]'
422 $item_id = item_store($arr);
427 $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
429 intval($page_owner_uid)
433 $old_tag = $r[0]['tag'];
434 $old_inform = $r[0]['inform'];
437 if(strlen($rawtags)) {
442 // if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
444 $x = substr($rawtags,0,1);
445 if($x !== '@' && $x !== '#')
446 $rawtags = '#' . $rawtags;
449 $tags = get_tags($rawtags);
452 foreach($tags as $tag) {
455 if(strpos($tag,'@') === 0) {
456 $name = substr($tag,1);
457 if((strpos($name,'@')) || (strpos($name,'http://'))) {
459 $links = @lrdd($name);
461 foreach($links as $link) {
462 if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
463 $profile = $link['@attributes']['href'];
464 if($link['@attributes']['rel'] === 'salmon') {
465 $salmon = '$url:' . str_replace(',','%sc',$link['@attributes']['href']);
472 $taginfo[] = array($newname,$profile,$salmon);
478 if(strrpos($newname,'+'))
479 $tagcid = intval(substr($newname,strrpos($newname,'+') + 1));
482 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
487 elseif(strstr($name,'_') || strstr($name,' ')) {
488 $newname = str_replace('_',' ',$name);
489 $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
491 intval($page_owner_uid)
495 $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
498 intval($page_owner_uid)
502 $newname = $r[0]['name'];
503 $profile = $r[0]['url'];
504 $notify = 'cid:' . $r[0]['id'];
511 if(substr($notify,0,4) === 'cid:')
512 $taginfo[] = array($newname,$profile,$notify,$r[0],'@[url=' . str_replace(',','%2c',$profile) . ']' . $newname . '[/url]');
514 $taginfo[] = array($newname,$profile,$notify,null,$str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]');
515 if(strlen($str_tags))
517 $profile = str_replace(',','%2c',$profile);
518 $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]';
525 if(strlen($newtag) && strlen($str_tags))
527 $newtag .= $str_tags;
529 $newinform = $old_inform;
530 if(strlen($newinform) && strlen($inform))
532 $newinform .= $inform;
534 $r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
537 dbesc(datetime_convert()),
538 dbesc(datetime_convert()),
540 intval($page_owner_uid)
544 foreach($p as $scales) {
545 if(intval($scales['scale']) == 2) {
549 if(intval($scales['scale']) == 4) {
555 if(count($taginfo)) {
556 foreach($taginfo as $tagged) {
558 $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
562 $arr['uid'] = $page_owner_uid;
564 $arr['parent-uri'] = $uri;
565 $arr['type'] = 'activity';
567 $arr['contact-id'] = $owner_record['id'];
568 $arr['owner-name'] = $owner_record['name'];
569 $arr['owner-link'] = $owner_record['url'];
570 $arr['owner-avatar'] = $owner_record['thumb'];
571 $arr['author-name'] = $owner_record['name'];
572 $arr['author-link'] = $owner_record['url'];
573 $arr['author-avatar'] = $owner_record['thumb'];
575 $arr['allow_cid'] = $p[0]['allow_cid'];
576 $arr['allow_gid'] = $p[0]['allow_gid'];
577 $arr['deny_cid'] = $p[0]['deny_cid'];
578 $arr['deny_gid'] = $p[0]['deny_gid'];
579 $arr['last-child'] = 1;
581 $arr['verb'] = ACTIVITY_TAG;
582 $arr['object-type'] = ACTIVITY_OBJ_PERSON;
583 $arr['target-type'] = ACTIVITY_OBJ_PHOTO;
584 $arr['tag'] = $tagged[4];
585 $arr['inform'] = $tagged[2];
587 $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]' ;
588 $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 . '.' . $ext . '[/img][/url]' . "\n" ;
590 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>';
591 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n");
593 $arr['object'] .= xmlify('<link rel="photo" type="'.$p[0]['type'].'" href="' . $tagged[3]['photo'] . '" />' . "\n");
594 $arr['object'] .= '</link></object>' . "\n";
596 $arr['target'] = '<target><type>' . ACTIVITY_OBJ_PHOTO . '</type><title>' . $p[0]['desc'] . '</title><id>'
597 . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>';
598 $arr['target'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '" />' . "\n" . '<link rel="preview" type="'.$p[0]['type'].'" href="' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '" />') . '</link></target>';
600 $item_id = item_store($arr);
602 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
603 dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
604 intval($page_owner_uid),
608 proc_run('php',"include/notifier.php","tag","$item_id");
615 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
616 return; // NOTREACHED
621 * default post action - upload a photo
624 call_hooks('photo_post_init', $_POST);
627 * Determine the album to use
630 $album = notags(trim($_REQUEST['album']));
631 $newalbum = notags(trim($_REQUEST['newalbum']));
633 logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG);
635 if(! strlen($album)) {
636 if(strlen($newalbum))
639 $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
644 * We create a wall item for every photo, but we don't want to
645 * overwhelm the data stream with a hundred newly uploaded photos.
646 * So we will make the first photo uploaded to this album in the last several hours
647 * visible by default, the rest will become visible over time when and if
648 * they acquire comments, likes, dislikes, and/or tags
652 $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `created` > UTC_TIMESTAMP() - INTERVAL 3 HOUR ",
654 intval($page_owner_uid)
656 if((! count($r)) || ($album == t('Profile Photos')))
661 if(intval($_REQUEST['not_visible']) || $_REQUEST['not_visible'] === 'true')
664 $str_group_allow = perms2str(((is_array($_REQUEST['group_allow'])) ? $_REQUEST['group_allow'] : explode(',',$_REQUEST['group_allow'])));
665 $str_contact_allow = perms2str(((is_array($_REQUEST['contact_allow'])) ? $_REQUEST['contact_allow'] : explode(',',$_REQUEST['contact_allow'])));
666 $str_group_deny = perms2str(((is_array($_REQUEST['group_deny'])) ? $_REQUEST['group_deny'] : explode(',',$_REQUEST['group_deny'])));
667 $str_contact_deny = perms2str(((is_array($_REQUEST['contact_deny'])) ? $_REQUEST['contact_deny'] : explode(',',$_REQUEST['contact_deny'])));
669 $ret = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
671 call_hooks('photo_post_file',$ret);
673 if(x($ret,'src') && x($ret,'filesize')) {
675 $filename = $ret['filename'];
676 $filesize = $ret['filesize'];
677 $type = $ret['type'];
680 $src = $_FILES['userfile']['tmp_name'];
681 $filename = basename($_FILES['userfile']['name']);
682 $filesize = intval($_FILES['userfile']['size']);
683 $type = $_FILES['userfile']['type'];
685 if ($type=="") $type=guess_image_type($filename);
687 logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
689 $maximagesize = get_config('system','maximagesize');
691 if(($maximagesize) && ($filesize > $maximagesize)) {
692 notice( t('Image exceeds size limit of ') . $maximagesize . EOL);
695 call_hooks('photo_post_end',$foo);
700 notice( t('Image file is empty.') . EOL);
703 call_hooks('photo_post_end',$foo);
707 logger('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG);
709 $imagedata = @file_get_contents($src);
710 $ph = new Photo($imagedata, $type);
712 if(! $ph->is_valid()) {
713 logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG);
714 notice( t('Unable to process image.') . EOL );
717 call_hooks('photo_post_end',$foo);
724 $width = $ph->getWidth();
725 $height = $ph->getHeight();
729 $photo_hash = photo_new_resource();
731 $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);
734 logger('mod/photos.php: photos_post(): image store failed' , LOGGER_DEBUG);
735 notice( t('Image upload failed.') . EOL );
739 if($width > 640 || $height > 640) {
740 $ph->scaleImage(640);
741 $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
745 if($width > 320 || $height > 320) {
746 $ph->scaleImage(320);
747 $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
751 $basename = basename($filename);
752 $uri = item_new_uri($a->get_hostname(), $page_owner_uid);
754 // Create item container
758 $arr['uid'] = $page_owner_uid;
760 $arr['parent-uri'] = $uri;
761 $arr['type'] = 'photo';
763 $arr['resource-id'] = $photo_hash;
764 $arr['contact-id'] = $owner_record['id'];
765 $arr['owner-name'] = $owner_record['name'];
766 $arr['owner-link'] = $owner_record['url'];
767 $arr['owner-avatar'] = $owner_record['thumb'];
768 $arr['author-name'] = $owner_record['name'];
769 $arr['author-link'] = $owner_record['url'];
770 $arr['author-avatar'] = $owner_record['thumb'];
772 $arr['allow_cid'] = $str_contact_allow;
773 $arr['allow_gid'] = $str_group_allow;
774 $arr['deny_cid'] = $str_contact_deny;
775 $arr['deny_gid'] = $str_group_deny;
776 $arr['last-child'] = 1;
777 $arr['visible'] = $visible;
780 $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
781 . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
784 $item_id = item_store($arr);
787 q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
788 dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
789 intval($page_owner_uid),
795 proc_run('php', "include/notifier.php", 'wall-new', $item_id);
797 call_hooks('photo_post_end',intval($item_id));
799 // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
800 // if they do not wish to be redirected
802 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
808 function photos_content(&$a) {
812 // photos/name/upload
813 // photos/name/upload/xxxxx (xxxxx is album name)
814 // photos/name/album/xxxxx
815 // photos/name/album/xxxxx/edit
816 // photos/name/image/xxxxx
817 // photos/name/image/xxxxx/edit
820 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
821 notice( t('Public access denied.') . EOL);
826 require_once('include/bbcode.php');
827 require_once('include/security.php');
828 require_once('include/conversation.php');
830 if(! x($a->data,'user')) {
831 notice( t('No photos selected') . EOL );
835 $phototypes = Photo::supportedTypes();
837 $_SESSION['photo_return'] = $a->cmd;
844 $datatype = $a->argv[2];
845 $datum = $a->argv[3];
847 elseif(($a->argc > 2) && ($a->argv[2] === 'upload'))
848 $datatype = 'upload';
850 $datatype = 'summary';
858 // Setup permissions structures
864 $remote_contact = false;
866 $owner_uid = $a->data['user']['uid'];
868 $community_page = (($a->data['user']['page-flags'] == PAGE_COMMUNITY) ? true : false);
870 if((local_user()) && (local_user() == $owner_uid))
873 if($community_page && remote_user()) {
874 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
875 intval(remote_user()),
881 $remote_contact = true;
882 $visitor = remote_user();
887 // perhaps they're visiting - but not a community page, so they wouldn't have write access
889 if(remote_user() && (! $visitor)) {
890 $contact_id = $_SESSION['visitor_id'];
891 $groups = init_groups_visitor($contact_id);
892 $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
893 intval(remote_user()),
898 $remote_contact = true;
902 if(! $remote_contact) {
904 $contact_id = $_SESSION['cid'];
905 $contact = $a->contact;
909 if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
910 notice( t('Access to this item is restricted.') . EOL);
914 $sql_extra = permissions_sql($owner_uid,$remote_contact,$groups);
919 $_is_owner = (local_user() && (local_user() == $owner_uid));
920 $o .= profile_tabs($a,$_is_owner, $a->data['user']['nickname']);
927 if($datatype === 'upload') {
929 notice( t('Permission denied.'));
934 $selname = (($datum) ? hex2bin($datum) : '');
937 $albumselect = '<select id="photos-upload-album-select" name="album" size="4">';
940 $albumselect .= '<option value="" ' . ((! $selname) ? ' selected="selected" ' : '') . '> </option>';
941 if(count($a->data['albums'])) {
942 foreach($a->data['albums'] as $album) {
943 if(($album['album'] === '') || ($album['album'] === 'Contact Photos') || ($album['album'] === t('Contact Photos')))
945 $selected = (($selname === $album['album']) ? ' selected="selected" ' : '');
946 $albumselect .= '<option value="' . $album['album'] . '"' . $selected . '>' . $album['album'] . '</option>';
950 $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
952 $albumselect .= '</select>';
956 $ret = array('post_url' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'],
957 'addon_text' => $uploader,
958 'default_upload' => true);
961 call_hooks('photo_upload_form',$ret);
963 $default_upload = '<input type="file" name="userfile" /> <div class="photos-upload-submit-wrapper" >
964 <input type="submit" name="submit" value="' . t('Submit') . '" id="photos-upload-submit" /> </div>';
969 $tpl = get_markup_template('photos_upload.tpl');
970 $o .= replace_macros($tpl,array(
971 '$pagename' => t('Upload Photos'),
972 '$sessid' => session_id(),
973 '$nickname' => $a->data['user']['nickname'],
974 '$newalbum' => t('New album name: '),
975 '$existalbumtext' => t('or existing album name: '),
976 '$nosharetext' => t('Do not show a status post for this upload'),
977 '$albumselect' => template_escape($albumselect),
978 '$permissions' => t('Permissions'),
979 '$aclselect' => (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))),
980 '$uploader' => $ret['addon_text'],
981 '$default' => (($ret['default_upload']) ? $default_upload : ''),
982 '$uploadurl' => $ret['post_url']
989 if($datatype === 'album') {
991 $album = hex2bin($datum);
993 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
994 AND `scale` <= 4 $sql_extra GROUP BY `resource-id`",
999 $a->set_pager_total(count($r));
1000 $a->set_pager_itemspage(20);
1003 $r = q("SELECT `resource-id`, `id`, `filename`, type, max(`scale`) AS `scale`, `desc` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
1004 AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
1007 intval($a->pager['start']),
1008 intval($a->pager['itemspage'])
1011 $o .= '<h3>' . $album . '</h3>';
1013 if($cmd === 'edit') {
1014 if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
1016 $edit_tpl = get_markup_template('album_edit.tpl');
1017 $o .= replace_macros($edit_tpl,array(
1018 '$nametext' => t('New album name: '),
1019 '$nickname' => $a->data['user']['nickname'],
1020 '$album' => template_escape($album),
1021 '$hexalbum' => bin2hex($album),
1022 '$submit' => t('Submit'),
1023 '$dropsubmit' => t('Delete Album')
1029 if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
1031 $o .= '<div id="album-edit-link"><a href="'. $a->get_baseurl() . '/photos/'
1032 . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit' . '">'
1033 . t('Edit Album') . '</a></div>';
1039 $o .= '<div class="photos-upload-link" ><a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album) . '" >' . t('Upload New Photos') . '</a></div>';
1042 $tpl = get_markup_template('photo_album.tpl');
1044 $twist = 'rotright';
1045 foreach($r as $rr) {
1046 if($twist == 'rotright')
1049 $twist = 'rotright';
1051 $ext = $phototypes[$rr['type']];
1053 $o .= replace_macros($tpl,array(
1055 '$twist' => ' ' . $twist . rand(2,4),
1056 '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
1057 '$phototitle' => t('View Photo'),
1058 '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
1059 '$imgalt' => template_escape($rr['filename']),
1060 '$desc'=> template_escape($rr['desc'])
1064 $o .= '<div id="photo-album-end"></div>';
1072 if($datatype === 'image') {
1077 // fetch image, item containing image, then comments
1079 $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
1080 $sql_extra ORDER BY `scale` ASC ",
1086 $ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
1092 notice( t('Permission denied. Access to this item may be restricted.'));
1094 notice( t('Photo not available') . EOL );
1101 $prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
1102 $sql_extra ORDER BY `created` DESC ",
1103 dbesc($ph[0]['album']),
1107 if(count($prvnxt)) {
1108 for($z = 0; $z < count($prvnxt); $z++) {
1109 if($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
1113 $prv = count($prvnxt) - 1;
1114 if($nxt >= count($prvnxt))
1119 $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
1120 $prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix;
1121 $nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix;
1126 $hires = $lores = $ph[0];
1127 if(count($ph) > 1) {
1128 if($ph[1]['scale'] == 2) {
1129 // original is 640 or less, we can display it directly
1130 $hires = $lores = $ph[0];
1138 $album_link = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']);
1142 if($can_post && ($ph[0]['uid'] == $owner_uid)) {
1144 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))),
1145 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource-id'], t('Use as profile photo')),
1149 $lock = ( ( ($ph[0]['uid'] == local_user()) && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid'])
1150 || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) )
1151 ? t('Private Message')
1157 if(! $cmd !== 'edit') {
1158 $a->page['htmlhead'] .= '<script>
1159 $(document).keydown(function(event) {' . "\n";
1162 $a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n";
1164 $a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = \'' . $nextlink . '\'; }' . "\n";
1165 $a->page['htmlhead'] .= '});</script>';
1169 $prevlink = array($prevlink, '<div class="icon prev"></div>') ;
1172 'href' => $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
1173 'title'=> t('View Full Size'),
1174 'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis')
1178 $nextlink = array($nextlink, '<div class="icon next"></div>');
1181 // Do we have an item for this photo?
1183 $linked_items = q("SELECT * FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
1186 if(count($linked_items)) {
1187 $link_item = $linked_items[0];
1188 $r = q("SELECT COUNT(*) AS `total`
1189 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
1190 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
1191 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
1192 AND `item`.`uid` = %d
1194 dbesc($link_item['uri']),
1195 dbesc($link_item['uri']),
1196 intval($link_item['uid'])
1201 $a->set_pager_total($r[0]['total']);
1204 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
1205 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`,
1206 `contact`.`rel`, `contact`.`thumb`, `contact`.`self`,
1207 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
1208 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
1209 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
1210 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
1211 AND `item`.`uid` = %d
1213 ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
1214 dbesc($link_item['uri']),
1215 dbesc($link_item['uri']),
1216 intval($link_item['uid']),
1217 intval($a->pager['start']),
1218 intval($a->pager['itemspage'])
1222 if((local_user()) && (local_user() == $link_item['uid'])) {
1223 q("UPDATE `item` SET `unseen` = 0 WHERE `parent` = %d and `uid` = %d",
1224 intval($link_item['parent']),
1225 intval(local_user())
1232 if(count($linked_items) && strlen($link_item['tag'])) {
1233 $arr = explode(',',$link_item['tag']);
1234 // parse tags and add links
1236 foreach($arr as $t) {
1237 if(strlen($tag_str))
1239 $tag_str .= bbcode($t);
1241 $tags = array(t('Tags: '), $tag_str);
1242 if($cmd === 'edit') {
1243 $tags[] = $a->get_baseurl() . '/tagrm/' . $link_item['id'];
1244 $tags[] = t('[Remove any tag]');
1250 if(($cmd === 'edit') && ($can_post)) {
1251 $edit_tpl = get_markup_template('photo_edit.tpl');
1252 $edit = replace_macros($edit_tpl, array(
1253 '$id' => $ph[0]['id'],
1254 '$rotate' => t('Rotate CW'),
1255 '$album' => template_escape($ph[0]['album']),
1256 '$newalbum' => t('New album name'),
1257 '$nickname' => $a->data['user']['nickname'],
1258 '$resource_id' => $ph[0]['resource-id'],
1259 '$capt_label' => t('Caption'),
1260 '$caption' => template_escape($ph[0]['desc']),
1261 '$tag_label' => t('Add a Tag'),
1262 '$tags' => $link_item['tag'],
1263 '$permissions' => t('Permissions'),
1264 '$aclselect' => template_escape(populate_acl($ph[0])),
1265 '$help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'),
1266 '$item_id' => ((count($linked_items)) ? $link_item['id'] : 0),
1267 '$submit' => t('Submit'),
1268 '$delete' => t('Delete Photo')
1272 if(count($linked_items)) {
1274 $cmnt_tpl = get_markup_template('comment_item.tpl');
1275 $tpl = get_markup_template('photo_item.tpl');
1276 $return_url = $a->cmd;
1278 $like_tpl = get_markup_template('like_noshare.tpl');
1282 if($can_post || can_write_wall($a,$owner_uid)) {
1283 $likebuttons = replace_macros($like_tpl,array(
1284 '$id' => $link_item['id'],
1285 '$likethis' => t("I like this \x28toggle\x29"),
1286 '$nolike' => t("I don't like this \x28toggle\x29"),
1287 '$share' => t('Share'),
1288 '$wait' => t('Please wait')
1294 if($can_post || can_write_wall($a,$owner_uid)) {
1295 if($link_item['last-child']) {
1296 $comments .= replace_macros($cmnt_tpl,array(
1297 '$return_path' => '',
1298 '$jsreload' => $return_url,
1299 '$type' => 'wall-comment',
1300 '$id' => $link_item['id'],
1301 '$parent' => $link_item['id'],
1302 '$profile_uid' => $owner_uid,
1303 '$mylink' => $contact['url'],
1304 '$mytitle' => t('This is you'),
1305 '$myphoto' => $contact['thumb'],
1306 '$comment' => t('Comment'),
1307 '$submit' => t('Submit'),
1308 '$preview' => t('Preview'),
1324 foreach($r as $item) {
1325 like_puller($a,$item,$alike,'like');
1326 like_puller($a,$item,$dlike,'dislike');
1329 $like = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : '');
1330 $dislike = ((isset($dlike[$link_item['id']])) ? format_like($dlike[$link_item['id']],$dlike[$link_item['id'] . '-l'],'dislike',$link_item['id']) : '');
1334 if($can_post || can_write_wall($a,$owner_uid)) {
1335 if($link_item['last-child']) {
1336 $comments .= replace_macros($cmnt_tpl,array(
1337 '$return_path' => '',
1338 '$jsreload' => $return_url,
1339 '$type' => 'wall-comment',
1340 '$id' => $link_item['id'],
1341 '$parent' => $link_item['id'],
1342 '$profile_uid' => $owner_uid,
1343 '$mylink' => $contact['url'],
1344 '$mytitle' => t('This is you'),
1345 '$myphoto' => $contact['thumb'],
1346 '$comment' => t('Comment'),
1347 '$submit' => t('Submit'),
1354 foreach($r as $item) {
1359 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent']))
1362 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
1364 if($can_post || can_write_wall($a,$owner_uid)) {
1366 if($item['last-child']) {
1367 $comments .= replace_macros($cmnt_tpl,array(
1368 '$return_path' => '',
1369 '$jsreload' => $return_url,
1370 '$type' => 'wall-comment',
1371 '$id' => $item['item_id'],
1372 '$parent' => $item['parent'],
1373 '$profile_uid' => $owner_uid,
1374 '$mylink' => $contact['url'],
1375 '$mytitle' => t('This is you'),
1376 '$myphoto' => $contact['thumb'],
1377 '$comment' => t('Comment'),
1378 '$submit' => t('Submit'),
1385 if(local_user() && ($item['contact-uid'] == local_user())
1386 && ($item['network'] == 'dfrn') && (! $item['self'] )) {
1387 $profile_url = $redirect_url;
1388 $sparkle = ' sparkle';
1391 $profile_url = $item['url'];
1395 $diff_author = (($item['url'] !== $item['author-link']) ? true : false);
1397 $profile_name = (((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
1398 $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $item['thumb']);
1400 $profile_link = $profile_url;
1404 if(($item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
1405 $drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
1408 $comments .= replace_macros($template,array(
1409 '$id' => $item['item_id'],
1410 '$profile_url' => $profile_link,
1411 '$name' => template_escape($profile_name),
1412 '$thumb' => $profile_avatar,
1413 '$sparkle' => $sparkle,
1414 '$title' => template_escape($item['title']),
1415 '$body' => template_escape(bbcode($item['body'])),
1416 '$ago' => relative_date($item['created']),
1417 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
1419 '$comment' => $comment
1424 $paginate = paginate($a);
1427 $photo_tpl = get_markup_template('photo_view.tpl');
1428 $o .= replace_macros($photo_tpl, array(
1429 '$id' => $ph[0]['id'],
1430 '$album' => array($album_link,template_escape($ph[0]['album'])),
1434 '$prevlink' => $prevlink,
1435 '$nextlink' => $nextlink,
1436 '$desc' => $ph[0]['desc'],
1437 '$tags' => template_escape($tags),
1439 '$likebuttons' => $likebuttons,
1440 '$like' => template_escape($like),
1441 '$dislike' => template_escape($dislike),
1442 '$comments' => $comments,
1443 '$paginate' => $paginate,
1449 // Default - show recent photos with upload link (if applicable)
1452 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
1453 $sql_extra GROUP BY `resource-id`",
1454 intval($a->data['user']['uid']),
1455 dbesc('Contact Photos'),
1456 dbesc( t('Contact Photos'))
1459 $a->set_pager_total(count($r));
1460 $a->set_pager_itemspage(20);
1463 $r = q("SELECT `resource-id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo`
1464 WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
1465 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
1466 intval($a->data['user']['uid']),
1467 dbesc('Contact Photos'),
1468 dbesc( t('Contact Photos')),
1469 intval($a->pager['start']),
1470 intval($a->pager['itemspage'])
1477 $twist = 'rotright';
1478 foreach($r as $rr) {
1479 if($twist == 'rotright')
1482 $twist = 'rotright';
1483 $ext = $phototypes[$rr['type']];
1487 'twist' => ' ' . $twist . rand(2,4),
1488 'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
1489 'title' => t('View Photo'),
1490 'src' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
1491 'alt' => template_escape($rr['filename']),
1493 'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
1494 'name' => template_escape($rr['album']),
1495 'alt' => t('View Album'),
1502 $tpl = get_markup_template('photos_recent.tpl');
1503 $o .= replace_macros($tpl,array(
1504 '$title' => t('Recent Photos'),
1505 '$can_post' => $can_post,
1506 '$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['user']['nickname'].'/upload'),
1507 '$photos' => $photos,