diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/acl.php | 26 | ||||
-rw-r--r-- | mod/admin.php | 3 | ||||
-rw-r--r-- | mod/contacts.php | 20 | ||||
-rwxr-xr-x[-rw-r--r--] | mod/events.php | 4 | ||||
-rw-r--r-- | mod/fbrowser.php | 18 | ||||
-rw-r--r-- | mod/message.php | 1 | ||||
-rw-r--r-- | mod/msearch.php | 2 | ||||
-rw-r--r-- | mod/network.php | 112 | ||||
-rw-r--r-- | mod/parse_url.php | 5 | ||||
-rw-r--r-- | mod/photo.php | 20 | ||||
-rw-r--r-- | mod/photos.php | 51 | ||||
-rw-r--r-- | mod/profile_photo.php | 13 | ||||
-rw-r--r-- | mod/pubsub.php | 16 | ||||
-rw-r--r-- | mod/salmon.php | 16 | ||||
-rw-r--r-- | mod/wall_upload.php | 37 |
15 files changed, 253 insertions, 91 deletions
diff --git a/mod/acl.php b/mod/acl.php index 1e8898ab6..f3e46efa5 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -1,5 +1,6 @@ <?php /* ACL selector json backend */ + require_once("include/acl_selectors.php"); function acl_init(&$a){ @@ -16,7 +17,8 @@ function acl_init(&$a){ // For use with jquery.autocomplete for private mail completion if(x($_REQUEST,'query') && strlen($_REQUEST['query'])) { - $type = 'm'; + if(! $type) + $type = 'm'; $search = $_REQUEST['query']; } @@ -62,6 +64,18 @@ function acl_init(&$a){ ); $contact_count = (int)$r[0]['c']; + } + elseif ($type == 'a') { + + // autocomplete for Contacts + + $r = q("SELECT COUNT(`id`) AS c FROM `contact` + WHERE `uid` = %d AND `self` = 0 + AND `pending` = 0 $sql_extra2" , + intval(local_user()) + ); + $contact_count = (int)$r[0]['c']; + } else { $contact_count = 0; } @@ -120,11 +134,19 @@ function acl_init(&$a){ dbesc(NETWORK_DIASPORA) ); } + elseif($type == 'a') { + $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact` + WHERE `uid` = %d AND `pending` = 0 + $sql_extra2 + ORDER BY `name` ASC ", + intval(local_user()) + ); + } else $r = array(); - if($type == 'm') { + if($type == 'm' || $type == 'a') { $x = array(); $x['query'] = $search; $x['photos'] = array(); diff --git a/mod/admin.php b/mod/admin.php index 6b1a53a30..56f88a489 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -117,6 +117,9 @@ function admin_content(&$a) { $t = get_markup_template("admin_aside.tpl"); $a->page['aside'] .= replace_macros( $t, array( '$admin' => $aside, + '$admtxt' => t('Admin'), + '$plugadmtxt' => t('Plugin Features'), + '$logtxt' => t('Logs'), '$h_pending' => t('User registrations waiting for confirmation'), '$admurl'=> $a->get_baseurl(true)."/admin/" )); diff --git a/mod/contacts.php b/mod/contacts.php index 769239fe0..a3e3f409b 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -43,6 +43,26 @@ function contacts_init(&$a) { $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= networks_widget('contacts',$_GET['nets']); + $base = $a->get_baseurl(); + + $a->page['htmlhead'] .= '<script src="' . $a->get_baseurl(true) . '/library/jquery_ac/friendica.complete.js" ></script>'; + $a->page['htmlhead'] .= <<< EOT + +<script>$(document).ready(function() { + var a; + a = $("#contacts-search").autocomplete({ + serviceUrl: '$base/acl', + minChars: 2, + width: 350, + }); + a.setOptions({ params: { type: 'a' }}); + +}); + +</script> +EOT; + + } function contacts_post(&$a) { diff --git a/mod/events.php b/mod/events.php index 069046ff9..2a6fb692e 100644..100755 --- a/mod/events.php +++ b/mod/events.php @@ -230,8 +230,8 @@ function events_content(&$a) { $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` WHERE `event`.`uid` = %d - AND (( `adjust` = 0 AND `start` >= '%s' AND `start` <= '%s' ) - OR ( `adjust` = 1 AND `start` >= '%s' AND `start` <= '%s' )) ", + AND (( `adjust` = 0 AND `finish` >= '%s' AND `start` <= '%s' ) + OR ( `adjust` = 1 AND `finish` >= '%s' AND `start` <= '%s' )) ", intval(local_user()), dbesc($start), dbesc($finish), diff --git a/mod/fbrowser.php b/mod/fbrowser.php index 66ff9252e..3f034226e 100644 --- a/mod/fbrowser.php +++ b/mod/fbrowser.php @@ -4,7 +4,9 @@ * @subpackage FileBrowser * @author Fabio Comuni <fabrixxm@kirgroup.com> */ - + +require_once('include/Photo.php'); + /** * @param App $a */ @@ -43,14 +45,22 @@ function fbrowser_content($a){ $path[]=array($a->get_baseurl()."/fbrowser/image/".$a->argv[2]."/", $album); } - $r = q("SELECT `resource-id`, `id`, `filename`, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `desc` + $r = q("SELECT `resource-id`, `id`, `filename`, type, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `desc` FROM `photo` WHERE `uid` = %d $sql_extra GROUP BY `resource-id` $sql_extra2", intval(local_user()) ); - - function files1($rr){ global $a; return array( $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['hiq'] . '.jpg', template_escape($rr['filename']), $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.jpg'); } + function files1($rr){ + global $a; + $types = Photo::supportedTypes(); + $ext = $types[$rr['type']]; + return array( + $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['hiq'] . '.' .$ext, + template_escape($rr['filename']), + $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.'. $ext + ); + } $files = array_map("files1", $r); $tpl = get_markup_template("filebrowser.tpl"); diff --git a/mod/message.php b/mod/message.php index fb2241985..d5bb3dfe4 100644 --- a/mod/message.php +++ b/mod/message.php @@ -25,6 +25,7 @@ function message_init(&$a) { var a; a = $("#recip").autocomplete({ serviceUrl: '$base/acl', + minChars: 2, width: 350, onSelect: function(value,data) { $("#recip-complete").val(data); diff --git a/mod/msearch.php b/mod/msearch.php index 94def7d89..89de5b705 100644 --- a/mod/msearch.php +++ b/mod/msearch.php @@ -28,7 +28,7 @@ function msearch_post(&$a) { $results[] = array( 'name' => $rr['name'], 'url' => $a->get_baseurl() . '/profile/' . $rr['nickname'], - 'photo' => $a->get_baseurl() . '/photo/avatar/' . $rr['uid'] . 'jpg', + 'photo' => $a->get_baseurl() . '/photo/avatar/' . $rr['uid'] . '.jpg', 'tags' => str_replace(array(',',' '),array(' ',' '),$rr['pub_keywords']) ); } diff --git a/mod/network.php b/mod/network.php index b998a3107..bd5946619 100644 --- a/mod/network.php +++ b/mod/network.php @@ -6,7 +6,31 @@ function network_init(&$a) { notice( t('Permission denied.') . EOL); return; } - + + + // fetch last used tab and redirect if needed + $sel_tabs = network_query_get_sel_tab($a); + $last_sel_tabs = get_pconfig(local_user(), 'network.view','tab.selected'); + if (is_array($last_sel_tabs)){ + $tab_urls = array( + '/network?f=&order=comment', //all + '/network?f=&order=post', //postord + '/network?f=&conv=1', //conv + '/network/new', //new + '/network?f=&star=1', //starred + '/network?f=&bmark=1', //bookmarked + '/network?f=&spam=1', //spam + ); + + // redirect if current selected tab is 'no_active' and + // last selected tab is _not_ 'all_active'. + if ($sel_tabs[0] == 'active' && $last_sel_tabs[0]!='active') { + $k = array_search('active', $last_sel_tabs); + //echo "<pre>"; var_dump($sel_tabs, $last_sel_tabs, $tab_urlsm, $k, $tab_urls[$k]); killme(); + goaway($a->get_baseurl() . $tab_urls[$k]); + } + } + $group_id = (($a->argc > 1 && intval($a->argv[1])) ? intval($a->argv[1]) : 0); require_once('include/group.php'); @@ -98,26 +122,23 @@ function saved_searches($search) { } - -function network_content(&$a, $update = 0) { - - require_once('include/conversation.php'); - - if(! local_user()) { - $_SESSION['return_url'] = $a->query_string; - return login(false); - } - - $arr = array('query' => $a->query_string); - - call_hooks('network_content_init', $arr); - - $o = ''; - - // item filter tabs - // TODO: fix this logic, reduce duplication - //$a->page['content'] .= '<div class="tabs-wrapper">'; - +/** + * Return selected tab from query + * + * urls -> returns + * '/network' => $no_active = 'active' + * '/network?f=&order=comment' => $comment_active = 'active' + * '/network?f=&order=post' => $postord_active = 'active' + * '/network?f=&conv=1', => $conv_active = 'active' + * '/network/new', => $new_active = 'active' + * '/network?f=&star=1', => $starred_active = 'active' + * '/network?f=&bmark=1', => $bookmarked_active = 'active' + * '/network?f=&spam=1', => $spam_active = 'active' + * + * @return Array ( $no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active ); + */ +function network_query_get_sel_tab($a) { + $no_active=''; $starred_active = ''; $new_active = ''; $bookmarked_active = ''; @@ -125,6 +146,7 @@ function network_content(&$a, $update = 0) { $search_active = ''; $conv_active = ''; $spam_active = ''; + $postord_active = ''; if(($a->argc > 1 && $a->argv[1] === 'new') || ($a->argc > 2 && $a->argv[2] === 'new')) { @@ -152,28 +174,56 @@ function network_content(&$a, $update = 0) { } + if (($new_active == '') && ($starred_active == '') && ($bookmarked_active == '') && ($conv_active == '') && ($search_active == '') && ($spam_active == '')) { - $all_active = 'active'; + $no_active = 'active'; } + if ($no_active=='active' && x($_GET,'order')) { + switch($_GET['order']){ + case 'post': $postord_active = 'active'; $no_active=''; break; + case 'comment' : $all_active = 'active'; $no_active=''; break; + } + } - $postord_active = ''; + return array($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active); +} + + +function network_content(&$a, $update = 0) { - if($all_active && x($_GET,'order') && $_GET['order'] !== 'comment') { - $all_active = ''; - $postord_active = 'active'; + require_once('include/conversation.php'); + + if(! local_user()) { + $_SESSION['return_url'] = $a->query_string; + return login(false); } - + + $arr = array('query' => $a->query_string); + + call_hooks('network_content_init', $arr); + + $o = ''; + + // item filter tabs + // TODO: fix this logic, reduce duplication + //$a->page['content'] .= '<div class="tabs-wrapper">'; + + list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) = network_query_get_sel_tab($a); + // if no tabs are selected, defaults to comments + if ($no_active=='active') $all_active='active'; + //echo "<pre>"; var_dump($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active); killme(); + // tabs $tabs = array( array( 'label' => t('Commented Order'), - 'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '?f=&cid=' . $_GET['cid'] : ''), + 'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . '?f=&order=comment' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), 'sel'=>$all_active, 'title'=> t('Sort by Comment Date'), ), @@ -215,8 +265,12 @@ function network_content(&$a, $update = 0) { // 'title' => t('Posts flagged as SPAM'), // ), - ); + + // save selected tab, but only if not in search or file mode + if(!x($_GET,'search') && !x($_GET,'file')) { + set_pconfig( local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) ); + } $arr = array('tabs' => $tabs); call_hooks('network_tabs', $arr); diff --git a/mod/parse_url.php b/mod/parse_url.php index 27dac4d5d..cdf2223a8 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -215,8 +215,11 @@ function parse_url_content(&$a) { $i = fetch_url($image); if($i) { + // guess mimetype from headers or filename + $type = guess_image_type($image,true); + require_once('include/Photo.php'); - $ph = new Photo($i); + $ph = new Photo($i, $type); if($ph->is_valid()) { if($ph->getWidth() > 300 || $ph->getHeight() > 300) { $ph->scaleImage(300); diff --git a/mod/photo.php b/mod/photo.php index 3cd8250a9..dee483d83 100644 --- a/mod/photo.php +++ b/mod/photo.php @@ -1,6 +1,7 @@ <?php require_once('include/security.php'); +require_once('include/Photo.php'); function photo_init(&$a) { @@ -75,7 +76,7 @@ function photo_init(&$a) { break; } - $uid = str_replace('.jpg', '', $person); + $uid = str_replace(array('.jpg','.png'),array('',''), $person); $r = q("SELECT * FROM `photo` WHERE `scale` = %d AND `uid` = %d AND `profile` = 1 LIMIT 1", intval($resolution), @@ -83,9 +84,11 @@ function photo_init(&$a) { ); if(count($r)) { $data = $r[0]['data']; + $mimetype = $r[0]['type']; } if(! isset($data)) { $data = file_get_contents($default); + $mimetype = 'image/jpeg'; } } else { @@ -95,7 +98,9 @@ function photo_init(&$a) { */ $resolution = 0; - $photo = str_replace('.jpg','',$photo); + foreach( Photo::supportedTypes() as $m=>$e){ + $photo = str_replace(".$e",'',$photo); + } if(substr($photo,-2,1) == '-') { $resolution = intval(substr($photo,-1,1)); @@ -119,6 +124,7 @@ function photo_init(&$a) { if(count($r)) { $data = $r[0]['data']; + $mimetype = $r[0]['type']; } else { @@ -136,6 +142,7 @@ function photo_init(&$a) { ); if(count($r)) { $data = file_get_contents('images/nosign.jpg'); + $mimetype = 'image/jpeg'; $prvcachecontrol = true; } } @@ -148,12 +155,15 @@ function photo_init(&$a) { case 4: $data = file_get_contents('images/person-175.jpg'); + $mimetype = 'image/jpeg'; break; case 5: $data = file_get_contents('images/person-80.jpg'); + $mimetype = 'image/jpeg'; break; case 6: $data = file_get_contents('images/person-48.jpg'); + $mimetype = 'image/jpeg'; break; default: killme(); @@ -164,11 +174,11 @@ function photo_init(&$a) { } if(isset($customres) && $customres > 0 && $customres < 500) { - require_once('include/Photo.php'); - $ph = new Photo($data); + $ph = new Photo($data, $mimetype); if($ph->is_valid()) { $ph->scaleImageSquare($customres); $data = $ph->imageString(); + $mimetype = $ph->getType(); } } @@ -181,7 +191,7 @@ function photo_init(&$a) { header_remove('pragma'); } - header("Content-type: image/jpeg"); + header("Content-type: ".$mimetype); if($prvcachecontrol) { diff --git a/mod/photos.php b/mod/photos.php index 3ce6f9934..efeab8fa3 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -5,6 +5,7 @@ require_once('include/acl_selectors.php'); require_once('include/bbcode.php'); require_once('include/security.php'); + function photos_init(&$a) { @@ -105,6 +106,8 @@ function photos_post(&$a) { logger('mod_photos: REQUEST ' . print_r($_REQUEST,true), LOGGER_DATA); logger('mod_photos: FILES ' . print_r($_FILES,true), LOGGER_DATA); + $phototypes = Photo::supportedTypes(); + $can_post = false; $visitor = 0; @@ -311,7 +314,7 @@ function photos_post(&$a) { intval($page_owner_uid) ); if(count($r)) { - $ph = new Photo($r[0]['data']); + $ph = new Photo($r[0]['data'], $r[0]['type']); if($ph->is_valid()) { $ph->rotate(270); @@ -362,6 +365,7 @@ function photos_post(&$a) { intval($page_owner_uid) ); if(count($p)) { + $ext = $phototypes[$p[0]['type']]; $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", dbesc($desc), dbesc($albname), @@ -386,7 +390,7 @@ function photos_post(&$a) { $title = ''; $uri = item_new_uri($a->get_hostname(),$page_owner_uid); - + $arr = array(); $arr['uid'] = $page_owner_uid; @@ -412,7 +416,7 @@ function photos_post(&$a) { $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]' + . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.'. $ext . '[/img]' . '[/url]'; $item_id = item_store($arr); @@ -581,17 +585,17 @@ function photos_post(&$a) { $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" ; + $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" ; $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $tagged[0] . '</title><id>' . $tagged[1] . '/' . $tagged[0] . '</id>'; $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $tagged[1] . '" />' . "\n"); if($tagged[3]) - $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $tagged[3]['photo'] . '" />' . "\n"); + $arr['object'] .= xmlify('<link rel="photo" type="'.$p[0]['type'].'" href="' . $tagged[3]['photo'] . '" />' . "\n"); $arr['object'] .= '</link></object>' . "\n"; $arr['target'] = '<target><type>' . ACTIVITY_OBJ_PHOTO . '</type><title>' . $p[0]['desc'] . '</title><id>' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . '</id>'; - $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="image/jpeg" href="' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.jpg' . '" />') . '</link></target>'; + $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>'; $item_id = item_store($arr); if($item_id) { @@ -662,7 +666,7 @@ function photos_post(&$a) { $str_group_deny = perms2str(((is_array($_REQUEST['group_deny'])) ? $_REQUEST['group_deny'] : explode(',',$_REQUEST['group_deny']))); $str_contact_deny = perms2str(((is_array($_REQUEST['contact_deny'])) ? $_REQUEST['contact_deny'] : explode(',',$_REQUEST['contact_deny']))); - $ret = array('src' => '', 'filename' => '', 'filesize' => 0); + $ret = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''); call_hooks('photo_post_file',$ret); @@ -670,15 +674,17 @@ function photos_post(&$a) { $src = $ret['src']; $filename = $ret['filename']; $filesize = $ret['filesize']; + $type = $ret['type']; } else { $src = $_FILES['userfile']['tmp_name']; $filename = basename($_FILES['userfile']['name']); $filesize = intval($_FILES['userfile']['size']); + $type = $_FILES['userfile']['type']; } + if ($type=="") $type=guess_image_type($filename); - - logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ' . $filesize . ' bytes', LOGGER_DEBUG); + logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG); $maximagesize = get_config('system','maximagesize'); @@ -701,7 +707,7 @@ function photos_post(&$a) { logger('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG); $imagedata = @file_get_contents($src); - $ph = new Photo($imagedata); + $ph = new Photo($imagedata, $type); if(! $ph->is_valid()) { logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG); @@ -771,7 +777,7 @@ function photos_post(&$a) { $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]' + . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]' . '[/url]'; $item_id = item_store($arr); @@ -814,8 +820,8 @@ function photos_content(&$a) { notice( t('Public access denied.') . EOL); return; } - - + + require_once('include/bbcode.php'); require_once('include/security.php'); require_once('include/conversation.php'); @@ -825,6 +831,8 @@ function photos_content(&$a) { return; } + $phototypes = Photo::supportedTypes(); + $_SESSION['photo_return'] = $a->cmd; // @@ -991,7 +999,7 @@ function photos_content(&$a) { $a->set_pager_itemspage(20); } - $r = q("SELECT `resource-id`, `id`, `filename`, max(`scale`) AS `scale`, `desc` FROM `photo` WHERE `uid` = %d AND `album` = '%s' + $r = q("SELECT `resource-id`, `id`, `filename`, type, max(`scale`) AS `scale`, `desc` FROM `photo` WHERE `uid` = %d AND `album` = '%s' AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d", intval($owner_uid), dbesc($album), @@ -1038,13 +1046,15 @@ function photos_content(&$a) { $twist = 'rotleft'; else $twist = 'rotright'; + + $ext = $phototypes[$rr['type']]; $o .= replace_macros($tpl,array( '$id' => $rr['id'], '$twist' => ' ' . $twist . rand(2,4), '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'], '$phototitle' => t('View Photo'), - '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg', + '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext, '$imgalt' => template_escape($rr['filename']), '$desc'=> template_escape($rr['desc']) )); @@ -1158,9 +1168,9 @@ function photos_content(&$a) { $prevlink = array($prevlink, '<div class="icon prev"></div>') ; $photo = array( - 'href' => $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.jpg', + 'href' => $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], 'title'=> t('View Full Size'), - 'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.jpg' . '?f=&_u=' . datetime_convert('','','','ymdhis') + 'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis') ); if($nextlink) @@ -1449,7 +1459,7 @@ function photos_content(&$a) { $a->set_pager_itemspage(20); } - $r = q("SELECT `resource-id`, `id`, `filename`, `album`, max(`scale`) AS `scale` FROM `photo` + $r = q("SELECT `resource-id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d", intval($a->data['user']['uid']), @@ -1469,13 +1479,14 @@ function photos_content(&$a) { $twist = 'rotleft'; else $twist = 'rotright'; - + $ext = $phototypes[$rr['type']]; + $photos[] = array( 'id' => $rr['id'], 'twist' => ' ' . $twist . rand(2,4), 'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'], 'title' => t('View Photo'), - 'src' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.jpg', + 'src' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext, 'alt' => template_escape($rr['filename']), 'album' => array( 'link' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), diff --git a/mod/profile_photo.php b/mod/profile_photo.php index ace8dadd4..e44707f9b 100644 --- a/mod/profile_photo.php +++ b/mod/profile_photo.php @@ -53,7 +53,7 @@ function profile_photo_post(&$a) { $base_image = $r[0]; - $im = new Photo($base_image['data']); + $im = new Photo($base_image['data'], $base_image['type']); if($im->is_valid()) { $im->cropImage(175,$srcX,$srcY,$srcW,$srcH); @@ -108,7 +108,9 @@ function profile_photo_post(&$a) { $src = $_FILES['userfile']['tmp_name']; $filename = basename($_FILES['userfile']['name']); $filesize = intval($_FILES['userfile']['size']); - + $filetype = $_FILES['userfile']['type']; + if ($filetype=="") $filetype=guess_image_type($filename); + $maximagesize = get_config('system','maximagesize'); if(($maximagesize) && ($filesize > $maximagesize)) { @@ -118,7 +120,7 @@ function profile_photo_post(&$a) { } $imagedata = @file_get_contents($src); - $ph = new Photo($imagedata); + $ph = new Photo($imagedata, $filetype); if(! $ph->is_valid()) { notice( t('Unable to process image.') . EOL ); @@ -193,7 +195,7 @@ function profile_photo_content(&$a) { goaway($a->get_baseurl() . '/profiles'); return; // NOTREACHED } - $ph = new Photo($r[0]['data']); + $ph = new Photo($r[0]['data'], $r[0]['type']); profile_photo_crop_ui_head($a, $ph); // go ahead as we have jus uploaded a new photo to crop } @@ -214,7 +216,7 @@ function profile_photo_content(&$a) { return $o; } else { - $filename = $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'] . '.jpg'; + $filename = $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'] . '.'.$a->config['imagecrop_ext']; $resolution = $a->config['imagecrop_resolution']; $tpl = get_markup_template("cropbody.tpl"); $o .= replace_macros($tpl,array( @@ -268,6 +270,7 @@ function profile_photo_crop_ui_head(&$a, $ph){ $a->config['imagecrop'] = $hash; $a->config['imagecrop_resolution'] = $smallest; + $a->config['imagecrop_ext'] = $ph->getExt(); $a->page['htmlhead'] .= get_markup_template("crophead.tpl"); return; }} diff --git a/mod/pubsub.php b/mod/pubsub.php index 93d50ef90..64fbda289 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -47,22 +47,30 @@ function pubsub_init(&$a) { $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 LIMIT 1", dbesc($nick) ); - if(! count($r)) + if(! count($r)) { + logger('pubsub: local account not found: ' . $nick); hub_return(false, ''); + } $owner = $r[0]; $sql_extra = ((strlen($hub_verify)) ? sprintf(" AND `hub-verify` = '%s' ", dbesc($hub_verify)) : ''); - $r = q("SELECT * FROM `contact` WHERE `poll` = '%s' AND `id` = %d AND `uid` = %d + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d AND `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1", - dbesc($hub_topic), intval($contact_id), intval($owner['uid']) ); - if(! count($r)) + if(! count($r)) { + logger('pubsub: contact not found.'); hub_return(false, ''); + } + + if(! link_compare($hub_topic,$r[0]['poll'])) { + logger('pubsub: hub topic ' . $hub_topic . ' != ' . $r[0]['poll']); + // should abort but let's humour them. + } $contact = $r[0]; diff --git a/mod/salmon.php b/mod/salmon.php index 6172d17a1..1e16f9d14 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -170,14 +170,28 @@ function salmon_post(&$a) { * */ - $r = q("SELECT * FROM `contact` WHERE `network` = 'stat' AND ( `url` = '%s' OR `alias` = '%s') + $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s' ) AND `uid` = %d LIMIT 1", + dbesc(NETWORK_OSTATUS), dbesc($author_link), dbesc($author_link), intval($importer['uid']) ); if(! count($r)) { logger('mod-salmon: Author unknown to us.'); + if(get_pconfig($importer['uid'],'system','ostatus_autofriend')) { + require_once('include/follow.php'); + $result = new_contact($importer['uid'],$author_link); + if($result['success']) { + $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s' ) + AND `uid` = %d LIMIT 1", + dbesc(NETWORK_OSTATUS), + dbesc($author_link), + dbesc($author_link), + intval($importer['uid']) + ); + } + } } // is this a follower? Or have we ignored the person? diff --git a/mod/wall_upload.php b/mod/wall_upload.php index fa66561e8..4b81f8d1c 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -57,17 +57,20 @@ function wall_upload_post(&$a) { if(! x($_FILES,'userfile') && ! x($_FILES,'media')) killme(); - if(x($_FILES,'userfile')) { - $src = $_FILES['userfile']['tmp_name']; - $filename = basename($_FILES['userfile']['name']); - $filesize = intval($_FILES['userfile']['size']); - } - elseif(x($_FILES,'media')) { - $src = $_FILES['media']['tmp_name']; - $filename = basename($_FILES['media']['name']); - $filesize = intval($_FILES['media']['size']); - } - + if(x($_FILES,'userfile')) { + $src = $_FILES['userfile']['tmp_name']; + $filename = basename($_FILES['userfile']['name']); + $filesize = intval($_FILES['userfile']['size']); + $filetype = $_FILES['userfile']['type']; + } + elseif(x($_FILES,'media')) { + $src = $_FILES['media']['tmp_name']; + $filename = basename($_FILES['media']['name']); + $filesize = intval($_FILES['media']['size']); + $filetype = $_FILES['media']['type']; + } + + if ($filetype=="") $filetype=guess_image_type($filename); $maximagesize = get_config('system','maximagesize'); if(($maximagesize) && ($filesize > $maximagesize)) { @@ -77,7 +80,7 @@ function wall_upload_post(&$a) { } $imagedata = @file_get_contents($src); - $ph = new Photo($imagedata); + $ph = new Photo($imagedata, $filetype); if(! $ph->is_valid()) { echo ( t('Unable to process image.') . EOL); @@ -123,19 +126,19 @@ function wall_upload_post(&$a) { /* mod Waitman Gobble NO WARRANTY */ //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) - if ($_REQUEST['hush']!='yeah') { + if ($_REQUEST['hush']!='yeah') { /*existing code*/ if(local_user() && intval(get_pconfig(local_user(),'system','plaintext'))) - 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"; + echo "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n"; else - 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 />"; + echo '<br /><br /><a href="' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '" ><img src="' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."\" alt=\"$basename\" /></a><br /><br />"; /*existing code*/ } else { - $m = '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.jpg[/img][/url]"; + $m = '[url=' . $a->get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . $a->get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]"; return($m); - } + } /* mod Waitman Gobble NO WARRANTY */ killme(); |