3 require_once('Photo.php');
5 function wall_upload_post(&$a) {
9 $r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
24 $page_owner_uid = $r[0]['uid'];
25 $default_cid = $r[0]['id'];
26 $page_owner_nick = $r[0]['nickname'];
27 $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
29 if((local_user()) && (local_user() == $page_owner_uid))
32 if($community_page && remote_user()) {
33 $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
34 intval(remote_user()),
35 intval($page_owner_uid)
39 $visitor = remote_user();
40 $default_cid = $visitor;
46 notice( t('Permission denied.') . EOL );
50 if(! x($_FILES,'userfile'))
53 $src = $_FILES['userfile']['tmp_name'];
54 $filename = basename($_FILES['userfile']['name']);
55 $filesize = intval($_FILES['userfile']['size']);
57 $maximagesize = get_config('system','maximagesize');
59 if(($maximagesize) && ($filesize > $maximagesize)) {
60 echo sprintf( t('Image exceeds size limit of %d'), $maximagesize) . EOL;
65 $imagedata = @file_get_contents($src);
66 $ph = new Photo($imagedata);
68 if(! $ph->is_valid()) {
69 echo ( t('Unable to process image.') . EOL);
76 $width = $ph->getWidth();
77 $height = $ph->getHeight();
79 $hash = photo_new_resource();
83 $defperm = '<' . $default_cid . '>';
85 $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 0, 0, $defperm);
88 echo ( t('Image upload failed.') . EOL);
92 if($width > 640 || $height > 640) {
94 $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 1, 0, $defperm);
99 if($width > 320 || $height > 320) {
100 $ph->scaleImage(320);
101 $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 2, 0, $defperm);
106 $basename = basename($filename);
109 /* mod Waitman Gobble NO WARRANTY */
111 //if we get the signal then return the image url info in BBCODE, otherwise this outputs the info and bails (for the ajax image uploader on wall post)
112 if ($_REQUEST['hush']!='yeah') {
115 if(local_user() && intval(get_pconfig(local_user(),'system','plaintext')))
116 echo "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.jpg[/img][/url]\n\n";
118 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 />";
122 $m = '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.jpg[/img][/url]";
125 /* mod Waitman Gobble NO WARRANTY */