]> git.mxchange.org Git - friendica.git/blob - mod/photos.php
ca05f651bc72ae28e402bdfe92804051f9edbade
[friendica.git] / mod / photos.php
1 <?php
2
3 require_once('Photo.php');
4 require_once('view/acl_selectors.php');
5
6 function photos_init(&$a) {
7
8         if($a->argc > 1) {
9                 $nick = $a->argv[1];
10                 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
11                         dbesc($nick)
12                 );
13
14                 if(! count($r))
15                         return;
16
17                 $a->data['user'] = $r[0];
18
19                 $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d",
20                         intval($a->data['user']['uid'])
21                 );
22
23                 if(count($albums)) {
24                         $a->data['albums'] = $albums;
25
26                         $o .= '<h4><a href="' . $a->get_baseurl() . '/profile/' . $a->data['user']['nickname'] . '">' . $a->data['user']['username'] . '</a></h4>';
27                         $o .= '<h4>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '">' . t('Photo Albums') . '</a></h4>';
28                 
29                         $o .= '<ul>';
30                         foreach($albums as $album) {
31                                 if((! strlen($album['album'])) || ($album['album'] == t('Contact Photos')))
32                                         continue;
33                                 $o .= '<li>' . '<a href="photos/' . $a->argv[1] . '/album/' . bin2hex($album['album']) . '" />' . $album['album'] . '</a></li>'; 
34                         }
35                         $o .= '</ul>';
36                 }
37                 $a->page['aside'] .= $o;
38         }
39
40
41 }
42
43
44
45
46 function photos_post(&$a) {
47
48
49         if(! local_user()) {
50                 notice( t('Permission denied.') . EOL );
51                 killme();
52         }
53
54         if(($a->argc > 1) && (x($_POST,'desc') !== false)) {
55                 $desc = notags(trim($_POST['desc']));
56                 $tags = notags(trim($_POST['tags']));
57                 $item_id = intval($_POST['item_id']);
58                 $id = $a->argv[1];
59
60                 $r = q("UPDATE `photo` SET `desc` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
61                         dbesc($desc),
62                         intval($id),
63                         intval($_SESSION['uid'])
64                 );
65                 $r = q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
66                         dbesc($tags),
67                         intval($item_id),
68                         intval($_SESSION['uid'])
69                 );
70
71                 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
72                 return; // NOTREACHED
73         }
74
75
76
77         $r = q("SELECT * FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1",
78                 intval($_SESSION['uid'])
79         );
80
81         $contact_record = $r[0];        
82
83         if(! x($_FILES,'userfile'))
84                 killme();
85
86         if($_POST['partitionCount'])
87                 $java_upload = true;
88         else
89                 $java_upload = false;
90
91         $album =  notags(trim($_POST['album']));
92         $newalbum = notags(trim($_POST['newalbum']));
93
94         if(! strlen($album)) {
95                 if(strlen($newalbum))
96                         $album = $newalbum;
97                 else
98                         $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
99         }
100
101         $str_group_allow = '';
102         $group_allow = $_POST['group_allow'];
103         if(is_array($group_allow)) {
104                 array_walk($group_allow,'sanitise_acl');
105                 $str_group_allow = implode('',$group_allow);
106         }
107
108         $str_contact_allow = '';
109         $contact_allow = $_POST['contact_allow'];
110         if(is_array($contact_allow)) {
111                 array_walk($contact_allow,'sanitise_acl');
112                 $str_contact_allow = implode('',$contact_allow);
113         }
114
115         $str_group_deny = '';
116         $group_deny = $_POST['group_deny'];
117         if(is_array($group_deny)) {
118                 array_walk($group_deny,'sanitise_acl');
119                 $str_group_deny = implode('',$group_deny);
120         }
121
122         $str_contact_deny = '';
123         $contact_deny = $_POST['contact_deny'];
124         if(is_array($contact_deny)) {
125                 array_walk($contact_deny,'sanitise_acl');
126                 $str_contact_deny = implode('',$contact_deny);
127         }
128
129
130         $src      = $_FILES['userfile']['tmp_name'];
131         $filename = basename($_FILES['userfile']['name']);
132         $filesize = intval($_FILES['userfile']['size']);
133
134         $imagedata = @file_get_contents($src);
135         $ph = new Photo($imagedata);
136
137         if(! ($image = $ph->getImage())) {
138                 notice( t('Unable to process image.') . EOL );
139                 @unlink($src);
140                 killme();
141         }
142
143         @unlink($src);
144
145         $width = $ph->getWidth();
146         $height = $ph->getHeight();
147
148         $smallest = 0;
149
150         $photo_hash = hash('md5',uniqid(mt_rand(),true));
151         
152         $r = $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
153
154         if(! $r) {
155                 notice( t('Image upload failed.') . EOL );
156                 killme();
157         }
158
159         if($width > 640 || $height > 640) {
160                 $ph->scaleImage(640);
161                 $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
162                 $smallest = 1;
163         }
164
165         if($width > 320 || $height > 320) {
166                 $ph->scaleImage(320);
167                 $ph->store($_SESSION['uid'], 0, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
168                 $smallest = 2;
169         }
170         
171         $basename = basename($filename);
172
173         // Create item container
174
175         $body = '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $photo_hash . ']' 
176                 . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]' 
177                 . '[/url]';
178
179                         do {
180                         $dups = false;
181                         $item_hash = random_string();
182
183                         $uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $profile_uid . ':' . $item_hash;
184
185                         $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
186                         dbesc($uri));
187                         if(count($r))
188                                 $dups = true;
189                 } while($dups == true);
190
191
192                 $r = q("INSERT INTO `item` (`uid`, `type`, `resource-id`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`,
193                         `edited`, `uri`, `parent-uri`, `title`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`)
194                         VALUES( %d, '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
195                         intval($_SESSION['uid']),
196                         dbesc('photo'),
197                         dbesc($photo_hash),                     
198                         intval($contact_record['id']),
199                         dbesc($contact_record['name']),
200                         dbesc($contact_record['url']),
201                         dbesc($contact_record['thumb']),
202                         datetime_convert(),
203                         datetime_convert(),
204                         dbesc($uri),
205                         dbesc($uri),
206                         dbesc($title),
207                         dbesc($body),
208                         dbesc($str_contact_allow),
209                         dbesc($str_group_allow),
210                         dbesc($str_contact_deny),
211                         dbesc($str_group_deny)
212
213                 );
214                 if($r) {
215
216                         $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
217                                 dbesc($uri)
218                         );
219                         if(count($r))
220                                 q("UPDATE `item` SET `parent` = %d, `last-child` = 1 WHERE `id` = %d LIMIT 1",
221                                 intval($r[0]['id']),
222                                 intval($r[0]['id'])
223                         );
224         
225                 }
226
227         // if album has no featured photo, promote one.
228
229
230         if(! $java_upload) {
231                 goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
232                 return; // NOTREACHED
233         }
234
235         killme();
236         return; // NOTREACHED
237
238 }
239
240
241
242 function photos_content(&$a) {
243
244         // URLs:
245         // photos/name
246         // photos/name/upload
247         // photos/name/album/xxxxx
248         // photos/name/album/xxxxx/edit
249         // photos/name/album/xxxxx/drop
250         // photos/name/image/xxxxx
251         // photos/name/image/xxxxx/edit
252         // photos/name/image/xxxxx/drop
253
254         if(! x($a->data,'user')) {
255                 notice( t('No photos selected') . EOL );
256                 return;
257         }
258
259         $_SESSION['photo_return'] = $a->cmd;
260
261         //
262         // Parse arguments 
263         //
264
265         if($a->argc > 3) {
266                 $datatype = $a->argv[2];
267                 $datum = $a->argv[3];
268         }
269         elseif(($a->argc > 2) && ($a->argv[2] == 'upload'))
270                 $datatype = 'upload';
271         else
272                 $datatype = 'summary';
273
274         if($a->argc > 4)
275                 $cmd = $a->argv[4];
276         else
277                 $cmd = 'view';
278
279         //
280         // Setup permissions structures
281         //
282
283         $owner_uid = $a->data['user']['uid'];
284
285         if(remote_user()) {
286                 $contact_id = $_SESSION['visitor_id'];
287                 $groups = init_groups_visitor($contact_id);
288         }
289
290         // default permissions - anonymous user
291
292         $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
293
294         // Profile owner - everything is visible
295
296         if(local_user() && ($_SESSION['uid'] == $owner_uid)) {
297                 $sql_extra = '';        
298         }
299         elseif(remote_user()) {
300                 // authenticated visitor - here lie dragons
301                 $gs = '<<>>'; // should be impossible to match
302                 if(count($groups)) {
303                         foreach($groups as $g)
304                                 $gs .= '|<' . intval($g) . '>';
305                 } 
306                 $sql_extra = sprintf(
307                         " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' ) 
308                           AND ( `deny_cid`  = '' OR  NOT `deny_cid` REGEXP '<%d>' ) 
309                           AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' )
310                           AND ( `deny_gid`  = '' OR NOT `deny_gid` REGEXP '%s') ",
311
312                         intval($_SESSION['visitor_id']),
313                         intval($_SESSION['visitor_id']),
314                         dbesc($gs),
315                         dbesc($gs)
316                 );
317         }
318
319         //
320         // dispatch request
321         //
322
323
324         if($datatype == 'upload') {
325                 if( ! (local_user() && ($_SESSION['uid'] == $a->data['user']['uid']))) {
326                         notice( t('Permission denied.'));
327                         return;
328                 }
329                 $albumselect = '<select id="photos-upload-album-select" name="album" size="4">';
330
331                 $albumselect .= '<option value="" selected="selected" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
332                 if(count($a->data['albums'])) {
333                         foreach($a->data['albums'] as $album) {
334                                 if(($album['album'] == '') || ($album['album'] == t('Contact Photos')))
335                                         continue;
336                                 $albumselect .= '<option value="' . $album['album'] . '">' . $album['album'] . '</option>';
337                         }
338                 }
339                 $albumselect .= '</select>';
340                 $tpl = file_get_contents('view/photos_upload.tpl');
341                 $o .= replace_macros($tpl,array(
342                         '$pagename' => t('Upload Photos'),
343                         '$sessid' => session_id(),
344                         '$newalbum' => t('New album name: '),
345                         '$existalbumtext' => t('or existing album name: '),
346                         '$filestext' => t('Select files to upload: '),
347                         '$albumselect' => $albumselect,
348                         '$permissions' => t('Permissions'),
349                         '$aclselect' => populate_acl($a->user),
350                         '$archive' => $a->get_baseurl() . '/jumploader_z.jar',
351                         '$nojava' => t('Use the following controls only if the Java uploader (above) fails to launch.'),
352                         '$uploadurl' => $a->get_baseurl() . '/photos',
353                         '$submit' => t('Submit')
354                 ));
355
356                 return $o; 
357
358         }
359
360         if($datatype == 'album') {
361
362                 $album = hex2bin($datum);
363
364                 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s' 
365                         $sql_extra GROUP BY `resource-id`",
366                         intval($a->data['user']['uid']),
367                         dbesc($album)
368                 );
369                 if(count($r))
370                         $a->set_pager_total(count($r));
371
372
373                 $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s' 
374                         $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
375                         intval($a->data['user']['uid']),
376                         dbesc($album),
377                         intval($a->pager['start']),
378                         intval($a->pager['itemspage'])
379                 );
380
381                 $o .= '<h3>' . $album . '</h3>';
382
383                 $tpl = file_get_contents('view/photo_album.tpl');
384                 if(count($r))
385                         foreach($r as $rr) {
386                                 $o .= replace_macros($tpl,array(
387                                         '$id' => $rr['id'],
388                                         '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
389                                         '$phototitle' => t('View Photo'),
390                                         '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
391                                         '$imgalt' => $rr['filename']
392                                 ));
393
394                 }
395                 $o .= '<div id="photo-album-end"></div>';
396                 return $o;
397
398         }       
399
400
401         if($datatype == 'image') {
402
403                 require_once('security.php');
404                 require_once('bbcode.php');
405
406                 // fetch image, item containing image, then comments
407
408                 $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' 
409                         $sql_extra ORDER BY `scale` ASC ",
410                         intval($a->data['user']['uid']),
411                         dbesc($datum)
412                 );
413
414                 if(! count($ph)) {
415                         notice( t('Photo not available') . EOL );
416                         return;
417                 }
418
419                 if(count($ph) == 1)
420                         $hires = $lores = $ph[0];
421                 if(count($ph) > 1) {
422                         if($ph[1]['scale'] == 2) {
423                                 // original is 640 or less, we can display it directly
424                                 $hires = $lores = $ph[0];
425                         }
426                         else {
427                         $hires = $ph[0];
428                         $lores = $ph[1];
429                         }
430                 }
431
432                 
433                 $o .= '<h3>' . '<a href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']) . '">' . $ph[0]['album'] . '</a></h3>';
434  
435                 if(local_user() && ($ph[0]['uid'] == $_SESSION['uid'])) {
436                         $o .= '<div id="photo-edit-link-wrap" ><a id="photo-edit-link" href="' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/edit' . '">' . t('Edit photo') . '</a></div>';
437                 }
438
439
440                 $o .= '<a href="' . $a->get_baseurl() . '/photo/' 
441                         . $hires['resource-id'] . '-' . $hires['scale'] . '.jpg" title="' 
442                         . t('View Full Size') . '" ><img src="' . $a->get_baseurl() . '/photo/' 
443                         . $lores['resource-id'] . '-' . $lores['scale'] . '.jpg' . '" /></a>';
444
445
446                 // Do we have an item for this photo?
447
448                 $i1 = q("SELECT * FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
449                         dbesc($datum)
450                 );
451                 if(count($i1)) {
452 //dbg(2);
453                         $r = q("SELECT COUNT(*) AS `total`
454                                 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
455                                 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0
456                                 AND NOT `item`.`type` IN ( 'remote', 'net-comment') 
457                                 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 
458                                 $sql_extra ",
459                                 dbesc($i1[0]['uri']),
460                                 dbesc($i1[0]['uri'])
461
462                         );
463
464                         if(count($r))
465                                 $a->set_pager_total($r[0]['total']);
466
467
468                         $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
469                                 `contact`.`name`, `contact`.`photo`, `contact`.`url`, 
470                                 `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, 
471                                 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
472                                 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
473                                 WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0
474                                 AND NOT `item`.`type` IN ( 'remote', 'net-comment') 
475                                 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
476                                 $sql_extra
477                                 ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
478                                 dbesc($i1[0]['uri']),
479                                 dbesc($i1[0]['uri']),
480                                 intval($a->pager['start']),
481                                 intval($a->pager['itemspage'])
482
483                         );
484
485
486                         $o .= '<div id="photo-caption" >' . $ph[0]['desc'] . '</div>';
487
488                         if(strlen($i1[0]['tag'])) {
489                                 // parse tags and add links     
490                                 $o .= '<div id="in-this-photo-text">' . t('In this photo: ') . '</div>';
491                                 $o .= '<div id="in-this-photo">' . $i1[0]['tag'] . '</div>';
492                         }
493
494                         if($cmd == 'edit') {
495                                 $edit_tpl = file_get_contents('view/photo_edit.tpl');
496                                 $o .= replace_macros($edit_tpl, array(
497                                         '$id' => $ph[0]['id'],
498                                         '$capt_label' => t('Caption'),
499                                         '$caption' => $ph[0]['desc'],
500                                         '$tag_label' => t('Tags'),
501                                         '$tags' => $i1[0]['tag'],
502                                         '$item_id' => $i1[0]['id'],
503                                         '$submit' => t('Submit') 
504
505                                 ));
506                         }
507
508                         // pull out how many people like the photo
509
510                         $cmnt_tpl = file_get_contents('view/comment_item.tpl');
511                         $tpl = file_get_contents('view/photo_item.tpl');
512                         $return_url = $a->cmd;
513
514                         if(can_write_wall($a,$a->data['user']['uid'])) {
515                                 if($i1[0]['last-child']) {
516                                         $o .= replace_macros($cmnt_tpl,array(
517                                                 '$return_path' => $return_url,
518                                                 '$type' => 'wall-comment',
519                                                 '$id' => $i1[0]['id'],
520                                                 '$parent' => $i1[0]['id'],
521                                                 '$profile_uid' =>  $a->data['user']['uid'],
522                                                 '$ww' => ''
523                                         ));
524                                 }
525                         }
526
527
528                         // display comments
529                         if(count($r)) {
530                                 foreach($r as $item) {
531                                         $comment = '';
532                                         $template = $tpl;
533                         
534                                         $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
535                         
536                                         if(can_write_wall($a,$a->data['user']['uid'])) {
537                                                 if($item['last-child']) {
538                                                         $comment = replace_macros($cmnt_tpl,array(
539                                                                 '$return_path' => $return_url,
540                                                                 '$type' => 'wall-comment',
541                                                                 '$id' => $item['item_id'],
542                                                                 '$parent' => $item['parent'],
543                                                                 '$profile_uid' =>  $a->data['user']['uid'],
544                                                                 '$ww' => ''
545                                                         ));
546                                                 }
547                                         }
548
549                                         $profile_url = $item['url'];
550
551
552                                         if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] ))
553                                                 $profile_url = $redirect_url;
554
555  
556                                         $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
557                                         $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
558                                         $profile_link = $profile_url;
559
560                                         $drop = '';
561
562                                         if(($item['contact-id'] == $_SESSION['visitor_id']) || ($item['uid'] == $_SESSION['uid']))
563                                                 $drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
564
565
566                                         $o .= replace_macros($template,array(
567                                                 '$id' => $item['item_id'],
568                                                 '$profile_url' => $profile_link,
569                                                 '$name' => $profile_name,
570                                                 '$thumb' => $profile_avatar,
571                                                 '$title' => $item['title'],
572                                                 '$body' => bbcode($item['body']),
573                                                 '$ago' => relative_date($item['created']),
574                                                 '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
575                                                 '$drop' => $drop,
576                                                 '$comment' => $comment
577                                         ));
578                                 }
579                         }
580
581                         $o .= paginate($a);
582                 }
583                 return $o;
584         }
585
586         // Default - show recent photos with upload link (if applicable)
587
588         $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' 
589                 $sql_extra GROUP BY `resource-id`",
590                 intval($a->data['user']['uid']),
591                 dbesc( t('Contact Photos'))
592         );
593         if(count($r))
594                 $a->set_pager_total(count($r));
595
596
597         $r = q("SELECT `resource-id`, `album`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' 
598                 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
599                 intval($a->data['user']['uid']),
600                 dbesc( t('Contact Photos')),
601                 intval($a->pager['start']),
602                 intval($a->pager['itemspage'])
603         );
604
605         $o .= '<h3>' . t('Recent Photos') . '</h3>';
606
607         if( local_user() && ($_SESSION['uid'] == $a->data['user']['uid'])) {
608                 $o .= '<div id="photo-top-links"><a id="photo-top-upload-link" href="'. $a->get_baseurl() . '/photos/' 
609                         . $a->data['user']['nickname'] . '/upload' . '">' . t('Upload New Photos') . '</a></div>';
610         }
611
612         $tpl = file_get_contents('view/photo_top.tpl');
613         if(count($r)) {
614                 foreach($r as $rr) {
615                         $o .= replace_macros($tpl,array(
616                                 '$id' => $rr['id'],
617                                 '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] 
618                                         . '/image/' . $rr['resource-id'],
619                                 '$phototitle' => t('View Photo'),
620                                 '$imgsrc' => $a->get_baseurl() . '/photo/' 
621                                         . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
622                                 '$albumlink' => $a->get_baseurl . '/photos/' 
623                                         . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
624                                 '$albumname' => $rr['album'],
625                                 '$albumalt' => t('View Album'),
626                                 '$imgalt' => $rr['filename']
627                         ));
628
629                 }
630                 $o .= '<div id="photo-top-end"></div>';
631         }
632         return $o;
633 }