3 require_once('Photo.php');
5 function wall_upload_post(&$a) {
9 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
22 $page_owner_uid = $r[0]['uid'];
23 $page_owner_nick = $r[0]['nickname'];
24 $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
26 if((local_user()) && (local_user() == $page_owner_uid))
29 if($community_page && remote_user()) {
30 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
31 intval(remote_user()),
32 intval($page_owner_uid)
36 $visitor = remote_user();
42 notice( t('Permission denied.') . EOL );
46 if(! x($_FILES,'userfile'))
49 $src = $_FILES['userfile']['tmp_name'];
50 $filename = basename($_FILES['userfile']['name']);
51 $filesize = intval($_FILES['userfile']['size']);
53 $maximagesize = get_config('system','maximagesize');
55 if(($maximagesize) && ($filesize > $maximagesize)) {
56 notice( sprintf(t('Image exceeds size limit of %d'), $maximagesize) . EOL);
61 $imagedata = @file_get_contents($src);
62 $ph = new Photo($imagedata);
64 if(! $ph->is_valid()) {
65 echo ( t('Unable to process image.') . EOL);
72 $width = $ph->getWidth();
73 $height = $ph->getHeight();
75 $hash = photo_new_resource();
79 $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 0, 0, '<0>');
82 echo ( t('Image upload failed.') . EOL);
86 if($width > 640 || $height > 640) {
88 $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 1, 0, '<0>');
93 if($width > 320 || $height > 320) {
95 $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 2, 0, '<0>' );
100 $basename = basename($filename);
101 echo '<br /><br /><a href="' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '" ><img src="' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.jpg\" alt=\"$basename\" /></a><br /><br />";