aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rwxr-xr-x[-rw-r--r--]mod/events.php4
-rw-r--r--mod/fbrowser.php18
-rw-r--r--mod/msearch.php2
-rw-r--r--mod/network.php162
-rw-r--r--mod/parse_url.php5
-rw-r--r--mod/photo.php20
-rw-r--r--mod/photos.php51
-rw-r--r--mod/profile.php37
-rw-r--r--mod/profile_photo.php13
-rw-r--r--mod/pubsub.php16
-rw-r--r--mod/salmon.php16
-rw-r--r--mod/wall_upload.php37
12 files changed, 271 insertions, 110 deletions
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/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..45983053c 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,80 @@ 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) {
+
+ require_once('include/conversation.php');
- if($all_active && x($_GET,'order') && $_GET['order'] !== 'comment') {
- $all_active = '';
- $postord_active = 'active';
+ if(! local_user()) {
+ $_SESSION['return_url'] = $a->query_string;
+ return login(false);
}
-
+
+ $arr = array('query' => $a->query_string);
+
+ call_hooks('network_content_init', $arr);
+
+
+ $datequery = $datequery2 = '';
+
+ if($a->argc > 1) {
+ for($x = 1; $x < $a->argc; $x ++) {
+ if(is_a_date_arg($a->argv[$x])) {
+ if($datequery)
+ $datequery2 = escape_tags($a->argv[$x]);
+ else {
+ $datequery = escape_tags($a->argv[$x]);
+ $_GET['order'] = 'post';
+ }
+ }
+ elseif($a->argv[$x] === 'new') {
+ $nouveau = true;
+ }
+ elseif(intval($a->argv[$x])) {
+ $group = intval($a->argv[$x]);
+ $def_acl = array('allow_gid' => '<' . $group . '>');
+ }
+ }
+ }
+
+
+ $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 +289,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);
@@ -248,17 +326,7 @@ function network_content(&$a, $update = 0) {
$cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99);
$file = ((x($_GET,'file')) ? $_GET['file'] : '');
- if(($a->argc > 2) && $a->argv[2] === 'new')
- $nouveau = true;
- if($a->argc > 1) {
- if($a->argv[1] === 'new')
- $nouveau = true;
- else {
- $group = intval($a->argv[1]);
- $def_acl = array('allow_gid' => '<' . $group . '>');
- }
- }
if(x($_GET,'search') || x($_GET,'file'))
$nouveau = true;
@@ -398,7 +466,17 @@ function network_content(&$a, $update = 0) {
. "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
}
+ $sql_extra3 = '';
+
+ if($datequery) {
+ $sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert('','',$datequery))));
+ }
+ if($datequery2) {
+ $sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert('','',$datequery2))));
+ }
+
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
+ $sql_extra3 = (($nouveau) ? '' : $sql_extra3);
if(x($_GET,'search')) {
$search = escape_tags($_GET['search']);
@@ -454,7 +532,7 @@ function network_content(&$a, $update = 0) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- $sql_extra2
+ $sql_extra2 $sql_extra3
$sql_extra $sql_nets ",
intval($_SESSION['uid'])
);
@@ -506,7 +584,7 @@ function network_content(&$a, $update = 0) {
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`moderated` = 0 and `item`.`unseen` = 1
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- $sql_extra $sql_nets ",
+ $sql_extra3 $sql_extra $sql_nets ",
intval(local_user())
);
}
@@ -516,7 +594,7 @@ function network_content(&$a, $update = 0) {
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`parent` = `item`.`id`
- $sql_extra $sql_nets
+ $sql_extra3 $sql_extra $sql_nets
ORDER BY `item`.$ordering DESC $pager_sql ",
intval(local_user())
);
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.php b/mod/profile.php
index 7658a9647..2ac8fe586 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -67,11 +67,23 @@ function profile_init(&$a) {
function profile_content(&$a, $update = 0) {
- if (x($a->category)) {
- $category = $a->category;
+ $category = $datequery = $datequery2 = '';
+
+ if($a->argc > 2) {
+ for($x = 2; $x < $a->argc; $x ++) {
+ if(is_a_date_arg($a->argv[$x])) {
+ if($datequery)
+ $datequery2 = escape_tags($a->argv[$x]);
+ else
+ $datequery = escape_tags($a->argv[$x]);
+ }
+ else
+ $category = $a->argv[$x];
+ }
}
- else {
- $category = ((x($_GET,'category')) ? $_GET['category'] : '');
+
+ if(! x($category)) {
+ $category = ((x($_GET,'category')) ? $_GET['category'] : '');
}
if(get_config('system','block_public') && (! local_user()) && (! remote_user())) {
@@ -97,6 +109,7 @@ function profile_content(&$a, $update = 0) {
}
}
+
$contact = null;
$remote_contact = false;
@@ -200,16 +213,24 @@ function profile_content(&$a, $update = 0) {
}
else {
- if(x($category)) {
- $sql_extra .= file_tag_file_query('item',$category,'category');
+ if(x($category)) {
+ $sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category'));
}
+ if($datequery) {
+ $sql_extra2 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert('','',$datequery))));
+ }
+ if($datequery2) {
+ $sql_extra2 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert('','',$datequery2))));
+ }
+
+
$r = q("SELECT COUNT(*) AS `total`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
- $sql_extra ",
+ $sql_extra $sql_extra2 ",
intval($a->profile['profile_uid'])
);
@@ -225,7 +246,7 @@ function profile_content(&$a, $update = 0) {
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
- $sql_extra
+ $sql_extra $sql_extra2
ORDER BY `item`.`created` DESC $pager_sql ",
intval($a->profile['profile_uid'])
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();