aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlexander Kampmann <programmer@nurfuerspam.de>2012-04-05 13:39:15 +0200
committerAlexander Kampmann <programmer@nurfuerspam.de>2012-04-05 13:39:15 +0200
commit355c42cb309eb1313097411067ca999b699aa620 (patch)
treed00d1af9dceecdf114cadff924c5ba4a864fbf43 /include
parentcbf4544887c7f496f2b2312727fe7bcb64a6d6c8 (diff)
parent9b6e91086b29554fd04362f6c87ea148718e8b1c (diff)
downloadvolse-hubzilla-355c42cb309eb1313097411067ca999b699aa620.tar.gz
volse-hubzilla-355c42cb309eb1313097411067ca999b699aa620.tar.bz2
volse-hubzilla-355c42cb309eb1313097411067ca999b699aa620.zip
Merge branch 'master' of https://github.com/friendica/friendica
Conflicts: include/config.php update.php
Diffstat (limited to 'include')
-rw-r--r--[-rwxr-xr-x]include/Contact.php0
-rw-r--r--[-rwxr-xr-x]include/EmailNotification.php0
-rw-r--r--[-rwxr-xr-x]include/Photo.php0
-rw-r--r--[-rwxr-xr-x]include/Scrape.php0
-rw-r--r--[-rwxr-xr-x]include/acl_selectors.php0
-rw-r--r--[-rwxr-xr-x]include/api.php232
-rw-r--r--[-rwxr-xr-x]include/attach.php0
-rw-r--r--[-rwxr-xr-x]include/auth.php6
-rw-r--r--[-rwxr-xr-x]include/bb2diaspora.php0
-rw-r--r--include/bbcode.php23
-rw-r--r--[-rwxr-xr-x]include/cache.php0
-rw-r--r--include/config.php11
-rw-r--r--[-rwxr-xr-x]include/contact_selectors.php0
-rw-r--r--[-rwxr-xr-x]include/contact_widgets.php38
-rw-r--r--[-rwxr-xr-x]include/conversation.php65
-rw-r--r--[-rwxr-xr-x]include/cronhooks.php0
-rw-r--r--[-rwxr-xr-x]include/crypto.php0
-rw-r--r--[-rwxr-xr-x]include/datetime.php0
-rw-r--r--[-rwxr-xr-x]include/dba.php6
-rw-r--r--[-rwxr-xr-x]include/delivery.php8
-rw-r--r--[-rwxr-xr-x]include/diaspora.php39
-rw-r--r--[-rwxr-xr-x]include/directory.php0
-rw-r--r--[-rwxr-xr-x]include/email.php6
-rw-r--r--[-rwxr-xr-x]include/enotify.php41
-rw-r--r--[-rwxr-xr-x]include/event.php0
-rw-r--r--[-rwxr-xr-x]include/expire.php0
-rw-r--r--[-rwxr-xr-x]include/fcontact.php0
-rw-r--r--[-rwxr-xr-x]include/group.php0
-rw-r--r--[-rwxr-xr-x]include/html2bbcode.php0
-rw-r--r--include/html2plain.php86
-rw-r--r--[-rwxr-xr-x]include/items.php67
-rw-r--r--[-rwxr-xr-x]include/message.php85
-rw-r--r--include/msgclean.php2
-rw-r--r--[-rwxr-xr-x]include/nav.php4
-rw-r--r--[-rwxr-xr-x]include/network.php48
-rw-r--r--[-rwxr-xr-x]include/notifier.php11
-rw-r--r--[-rwxr-xr-x]include/oauth.php0
-rw-r--r--[-rwxr-xr-x]include/oembed.php5
-rw-r--r--[-rwxr-xr-x]include/pgettext.php0
-rw-r--r--[-rwxr-xr-x]include/plugin.php11
-rw-r--r--[-rwxr-xr-x]include/poller.php7
-rw-r--r--[-rwxr-xr-x]include/profile_advanced.php0
-rw-r--r--[-rwxr-xr-x]include/profile_selectors.php0
-rw-r--r--[-rwxr-xr-x]include/profile_update.php0
-rw-r--r--[-rwxr-xr-x]include/queue.php0
-rw-r--r--[-rwxr-xr-x]include/queue_fn.php0
-rw-r--r--include/quoteconvert.php2
-rw-r--r--[-rwxr-xr-x]include/remoteupdate.php0
-rw-r--r--[-rwxr-xr-x]include/salmon.php0
-rw-r--r--[-rwxr-xr-x]include/security.php1
-rw-r--r--[-rwxr-xr-x]include/session.php0
-rw-r--r--[-rwxr-xr-x]include/socgraph.php8
-rw-r--r--[-rwxr-xr-x]include/system_unavailable.php0
-rw-r--r--[-rwxr-xr-x]include/template_processor.php0
-rw-r--r--include/text.php175
55 files changed, 837 insertions, 150 deletions
diff --git a/include/Contact.php b/include/Contact.php
index d9949b1ef..d9949b1ef 100755..100644
--- a/include/Contact.php
+++ b/include/Contact.php
diff --git a/include/EmailNotification.php b/include/EmailNotification.php
index 8861e8f5d..8861e8f5d 100755..100644
--- a/include/EmailNotification.php
+++ b/include/EmailNotification.php
diff --git a/include/Photo.php b/include/Photo.php
index 4d02b5c65..4d02b5c65 100755..100644
--- a/include/Photo.php
+++ b/include/Photo.php
diff --git a/include/Scrape.php b/include/Scrape.php
index 9c237916b..9c237916b 100755..100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index a5f5aff53..a5f5aff53 100755..100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
diff --git a/include/api.php b/include/api.php
index 013f4b97a..065f14cff 100755..100644
--- a/include/api.php
+++ b/include/api.php
@@ -3,6 +3,7 @@
require_once("datetime.php");
require_once("conversation.php");
require_once("oauth.php");
+ require_once("html2plain.php");
/*
* Twitter-Like API
*
@@ -82,7 +83,7 @@
$record = $r[0];
} else {
logger('API_login failure: ' . print_r($_SERVER,true), LOGGER_DEBUG);
- header('WWW-Authenticate: Basic realm="Friendika"');
+ header('WWW-Authenticate: Basic realm="Friendica"');
header('HTTP/1.0 401 Unauthorized');
die('This api requires login');
}
@@ -306,10 +307,10 @@
}
$ret = Array(
+ 'id' => intval($uinfo[0]['cid']),
'self' => intval($uinfo[0]['self']),
'uid' => intval($uinfo[0]['uid']),
- 'id' => intval($uinfo[0]['cid']),
- 'name' => $uinfo[0]['name'],
+ 'name' => (($uinfo[0]['name']) ? $uinfo[0]['name'] : $uinfo[0]['nick']),
'screen_name' => (($uinfo[0]['nick']) ? $uinfo[0]['nick'] : $uinfo[0]['name']),
'location' => ($usr) ? $usr[0]['default-location'] : '',
'profile_image_url' => $uinfo[0]['micro'],
@@ -347,6 +348,8 @@
}
function api_item_get_user(&$a, $item) {
+ global $usercache;
+
// The author is our direct contact, in a conversation with us.
if(link_compare($item['url'],$item['author-link'])) {
return api_get_user($a,$item['cid']);
@@ -362,27 +365,40 @@
list($nick, $name) = array_map("trim",explode("(",$item['author-name']));
$name=str_replace(")","",$name);
-
+
+ if ($name == '')
+ $name = $nick;
+
+ if ($nick == '')
+ $nick = $name;
+
+ // Generating a random ID
+ if (!array_key_exists($nick, $usercache))
+ $usercache[$nick] = mt_rand(2000000, 2100000);
+
$ret = array(
- 'uid' => 0,
- 'id' => 0,
+ 'id' => $usercache[$nick],
'name' => $name,
'screen_name' => $nick,
'location' => '', //$uinfo[0]['default-location'],
+ 'description' => '',
'profile_image_url' => $item['author-avatar'],
'url' => $item['author-link'],
- 'contact_url' => 0,
'protected' => false, #
+ 'followers_count' => 0,
'friends_count' => 0,
'created_at' => '',
+ 'favourites_count' => 0,
'utc_offset' => 0, #XXX: fix me
'time_zone' => '', //$uinfo[0]['timezone'],
- 'geo_enabled' => false,
'statuses_count' => 0,
+ 'following' => 1,
+ 'statusnet_blocking' => false,
+ 'notifications' => false,
+ 'uid' => 0,
+ 'contact_url' => 0,
+ 'geo_enabled' => false,
'lang' => 'en', #XXX: fix me
- 'description' => '',
- 'followers_count' => 0,
- 'favourites_count' => 0,
'contributors_enabled' => false,
'follow_request_sent' => false,
'profile_background_color' => 'cfe8f6',
@@ -393,7 +409,6 @@
'profile_background_image_url' => '',
'profile_background_tile' => false,
'profile_use_background_image' => false,
- 'notifications' => false,
'verified' => true, #XXX: fix me
'followers' => '', #XXX: fix me
'status' => array()
@@ -591,16 +606,16 @@
$in_reply_to_screen_name = $lastwall['reply_author'];
}
$status_info = array(
- 'created_at' => api_date($lastwall['created']),
- 'id' => $lastwall['contact-id'],
- 'text' => strip_tags(bbcode($lastwall['body'])),
- 'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
+ 'text' => html2plain(bbcode($lastwall['body']), 0),
'truncated' => false,
+ 'created_at' => api_date($lastwall['created']),
'in_reply_to_status_id' => $in_reply_to_status_id,
+ 'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
+ 'id' => $lastwall['contact-id'],
'in_reply_to_user_id' => $in_reply_to_user_id,
- 'favorited' => false,
'in_reply_to_screen_name' => $in_reply_to_screen_name,
'geo' => '',
+ 'favorited' => false,
'coordinates' => $lastwall['coord'],
'place' => $lastwall['location'],
'contributors' => ''
@@ -650,7 +665,7 @@
$user_info['status'] = array(
'created_at' => api_date($lastwall['created']),
'id' => $lastwall['contact-id'],
- 'text' => strip_tags(bbcode($lastwall['body'])),
+ 'text' => html2plain(bbcode($lastwall['body']), 0),
'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
'truncated' => false,
'in_reply_to_status_id' => $in_reply_to_status_id,
@@ -686,10 +701,17 @@
$count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
if ($page<0) $page=0;
- $since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+ $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+ $max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
+ //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
$start = $page*$count;
+ //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
+
+ if ($max_id > 0)
+ $sql_extra = 'AND `item`.`id` <= '.intval($max_id);
+
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
@@ -722,6 +744,48 @@
api_register_func('api/statuses/home_timeline','api_statuses_home_timeline', true);
api_register_func('api/statuses/friends_timeline','api_statuses_home_timeline', true);
+ /**
+ *
+ */
+ function api_statuses_show(&$a, $type){
+ if (local_user()===false) return false;
+
+ $user_info = api_get_user($a);
+
+ // params
+ $id = intval($a->argv[3]);
+
+ logger('API: api_statuses_show: '.$id);
+
+ //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
+
+ $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
+ `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
+ `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
+ `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ FROM `item`, `contact`
+ WHERE `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
+ AND `contact`.`id` = `item`.`contact-id`
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ $sql_extra
+ AND `item`.`id`=%d",
+ intval($id)
+ );
+
+ $ret = api_format_items($r,$user_info);
+
+ $data = array('$status' => $ret[0]);
+ /*switch($type){
+ case "atom":
+ case "rss":
+ $data = api_rss_extra($a, $data, $user_info);
+ }*/
+ return api_apply_template("status", $type, $data);
+ }
+ api_register_func('api/statuses/show','api_statuses_show', true);
+
+ //api_register_func('api/statuses/mentions','api_statuses_mentions', true);
+ //api_register_func('api/statuses/replies','api_statuses_mentions', true);
function api_statuses_user_timeline(&$a, $type){
@@ -740,7 +804,8 @@
$count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
if ($page<0) $page=0;
- $since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+ $since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+ //$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
$start = $page*$count;
@@ -846,33 +911,64 @@
foreach($r as $item) {
localize_item($item);
$status_user = (($item['cid']==$user_info['id'])?$user_info: api_item_get_user($a,$item));
+
+ if ($item['parent']!=$item['id']) {
+ $r = q("select id from item where parent=%s and id<%s order by id desc limit 1",
+ intval($item['parent']), intval($item['id']));
+ if ($r)
+ $in_reply_to_status_id = $r[0]['id'];
+ else
+ $in_reply_to_status_id = $item['parent'];
+
+ $r = q("select `item`.`contact-id`, `contact`.nick, `item`.`author-name` from item, contact
+ where `contact`.`id` = `item`.`contact-id` and `item`.id=%d", intval($in_reply_to_status_id));
+
+ $in_reply_to_screen_name = $r[0]['author-name'];
+ $in_reply_to_user_id = $r[0]['contact-id'];
+
+ } else {
+ $in_reply_to_screen_name = '';
+ $in_reply_to_user_id = 0;
+ $in_reply_to_status_id = 0;
+ }
+
$status = array(
+ 'text' => trim($item['title']." \n".html2plain(bbcode($item['body']), 0)),
+ 'truncated' => False,
'created_at'=> api_date($item['created']),
- 'published' => api_date($item['created']),
- 'updated' => api_date($item['edited']),
- 'id' => intval($item['id']),
- 'message_id' => $item['uri'],
- 'text' => strip_tags(bbcode($item['body'])),
- 'statusnet_html' => bbcode($item['body']),
+ 'in_reply_to_status_id' => $in_reply_to_status_id,
'source' => (($item['app']) ? $item['app'] : 'web'),
- 'url' => ($item['plink']!=''?$item['plink']:$item['author-link']),
- 'truncated' => False,
- 'in_reply_to_status_id' => ($item['parent']!=$item['id']? intval($item['parent']):''),
- 'in_reply_to_user_id' => '',
- 'favorited' => $item['starred'] ? true : false,
- 'in_reply_to_screen_name' => '',
+ 'id' => intval($item['id']),
+ 'in_reply_to_user_id' => $in_reply_to_user_id,
+ 'in_reply_to_screen_name' => $in_reply_to_screen_name,
'geo' => '',
- 'coordinates' => $item['coord'],
- 'place' => $item['location'],
- 'contributors' => '',
- 'annotations' => '',
- 'entities' => '',
+ 'favorited' => $item['starred'] ? true : false,
'user' => $status_user ,
- 'objecttype' => (($item['object-type']) ? $item['object-type'] : ACTIVITY_OBJ_NOTE),
- 'verb' => (($item['verb']) ? $item['verb'] : ACTIVITY_POST),
- 'self' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
- 'edit' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
+ 'statusnet_html' => bbcode($item['body']),
+ 'statusnet_conversation_id' => 0,
);
+
+ // Seesmic doesn't like the following content
+ if ($_SERVER['HTTP_USER_AGENT'] != 'Seesmic') {
+ $status2 = array(
+ 'updated' => api_date($item['edited']),
+ 'published' => api_date($item['created']),
+ 'message_id' => $item['uri'],
+ 'url' => ($item['plink']!=''?$item['plink']:$item['author-link']),
+ 'coordinates' => $item['coord'],
+ 'place' => $item['location'],
+ 'contributors' => '',
+ 'annotations' => '',
+ 'entities' => '',
+ 'objecttype' => (($item['object-type']) ? $item['object-type'] : ACTIVITY_OBJ_NOTE),
+ 'verb' => (($item['verb']) ? $item['verb'] : ACTIVITY_POST),
+ 'self' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
+ 'edit' => $a->get_baseurl()."/api/statuses/show/".$item['id'].".".$type,
+ );
+
+ $status = array_merge($status, $status2);
+ }
+
$ret[]=$status;
};
return $ret;
@@ -882,17 +978,31 @@
function api_account_rate_limit_status(&$a,$type) {
$hash = array(
+ 'reset_time_in_seconds' => strtotime('now + 1 hour'),
'remaining_hits' => (string) 150,
'hourly_limit' => (string) 150,
'reset_time' => datetime_convert('UTC','UTC','now + 1 hour',ATOM_TIME),
- 'reset_time_in_seconds' => strtotime('now + 1 hour')
);
+ if ($type == "xml")
+ $hash['resettime_in_seconds'] = $hash['reset_time_in_seconds'];
return api_apply_template('ratelimit', $type, array('$hash' => $hash));
}
api_register_func('api/account/rate_limit_status','api_account_rate_limit_status',true);
+ function api_help_test(&$a,$type) {
+
+ if ($type == 'xml')
+ $ok = "true";
+ else
+ $ok = "ok";
+
+ return api_apply_template('test', $type, array('$ok' => $ok));
+
+ }
+ api_register_func('api/help/test','api_help_test',true);
+
/**
* https://dev.twitter.com/docs/api/1/get/statuses/friends
* This function is deprecated by Twitter
@@ -1075,7 +1185,7 @@
'recipient_screen_name'=> $recipient['screen_name'],
'recipient'=> $recipient,
- 'text'=> $item['title']."\n".strip_tags(bbcode($item['body'])) ,
+ 'text'=> $item['title']."\n".html2plain(bbcode($item['body']), 0) ,
);
@@ -1144,7 +1254,7 @@
'recipient_screen_name'=> $recipient['screen_name'],
'recipient'=> $recipient,
- 'text'=> $item['title']."\n".strip_tags(bbcode($item['body'])) ,
+ 'text'=> $item['title']."\n".html2plain(bbcode($item['body']), 0) ,
);
@@ -1197,4 +1307,36 @@
api_register_func('api/oauth/request_token', 'api_oauth_request_token', false);
api_register_func('api/oauth/access_token', 'api_oauth_access_token', false);
-
+/*
+Not implemented by now:
+statuses/public_timeline
+statuses/mentions
+statuses/replies
+statuses/retweets_of_me
+statuses/destroy
+statuses/retweet
+friendships/create
+friendships/destroy
+friendships/exists
+friendships/show
+account/update_location
+account/update_profile_background_image
+account/update_profile_image
+favorites
+favorites/create
+favorites/destroy
+blocks/create
+blocks/destroy
+oauth/authorize
+
+Not implemented in status.net:
+statuses/retweeted_to_me
+statuses/retweeted_by_me
+direct_messages/destroy
+account/end_session
+account/update_delivery_device
+notifications/follow
+notifications/leave
+blocks/exists
+blocks/blocking
+*/
diff --git a/include/attach.php b/include/attach.php
index 6d611cec0..6d611cec0 100755..100644
--- a/include/attach.php
+++ b/include/attach.php
diff --git a/include/auth.php b/include/auth.php
index 835616a82..1341f3bb8 100755..100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -94,13 +94,17 @@ else {
// Otherwise it's probably an openid.
+ try {
require_once('library/openid.php');
$openid = new LightOpenID;
$openid->identity = $openid_url;
$_SESSION['openid'] = $openid_url;
$a = get_app();
$openid->returnUrl = $a->get_baseurl(true) . '/openid';
- goaway($openid->authUrl());
+ goaway($openid->authUrl());
+ } catch (Exception $e) {
+ notice( t('We encountered a problem while logging in with the OpenID you provided. Please check the correct spelling of the ID.').'<br /><br >'. t('The error message was:').' '.$e->getMessage());
+ }
// NOTREACHED
}
}
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 8487f845a..8487f845a 100755..100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
diff --git a/include/bbcode.php b/include/bbcode.php
index d69cb263f..9befbd0f7 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -189,8 +189,29 @@ function bbcode($Text,$preserve_nl = false) {
// Check for [code] text
$Text = preg_replace("/\[code\](.*?)\[\/code\]/ism","$CodeLayout", $Text);
+ // Declare the format for [spoiler] layout
+ $SpoilerLayout = '<blockquote class="spoiler">$1</blockquote>';
+
+ // Check for [spoiler] text
+ // handle nested quotes
+ $endlessloop = 0;
+ while ((strpos($Text, "[/spoiler]") !== false) and (strpos($Text, "[spoiler]") !== false) and (++$endlessloop < 20))
+ $Text = preg_replace("/\[spoiler\](.*?)\[\/spoiler\]/ism","$SpoilerLayout", $Text);
+
+ // Check for [spoiler=Author] text
+
+ $t_wrote = t('$1 wrote:');
+
+ // handle nested quotes
+ $endlessloop = 0;
+ while ((strpos($Text, "[/spoiler]")!== false) and (strpos($Text, "[spoiler=") !== false) and (++$endlessloop < 20))
+ $Text = preg_replace("/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism",
+ "<br /><strong class=".'"spoiler"'.">" . $t_wrote . "</strong><blockquote class=".'"spoiler"'.">$2</blockquote>",
+ $Text);
+
// Declare the format for [quote] layout
$QuoteLayout = '<blockquote>$1</blockquote>';
+
// Check for [quote] text
// handle nested quotes
$endlessloop = 0;
@@ -205,7 +226,7 @@ function bbcode($Text,$preserve_nl = false) {
$endlessloop = 0;
while ((strpos($Text, "[/quote]")!== false) and (strpos($Text, "[quote=") !== false) and (++$endlessloop < 20))
$Text = preg_replace("/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
- "<blockquote><strong>" . $t_wrote . "</strong> $2</blockquote>",
+ "<br /><strong class=".'"author"'.">" . $t_wrote . "</strong><blockquote class=".'"author"'.">$2</blockquote>",
$Text);
// [img=widthxheight]image source[/img]
diff --git a/include/cache.php b/include/cache.php
index 3c8a3f713..3c8a3f713 100755..100644
--- a/include/cache.php
+++ b/include/cache.php
diff --git a/include/config.php b/include/config.php
index f93cb52c9..c999b76f2 100644
--- a/include/config.php
+++ b/include/config.php
@@ -81,11 +81,13 @@ if(! function_exists('get_config')) {
* Return the value, or false if the database update failed
*/
if(! function_exists('set_config')) {
- function set_config($family,$key,$value) {
- global $a;
- // manage array value
- $dbvalue = (is_array($value)?serialize($value):$value);
+function set_config($family,$key,$value) {
+ global $a;
+
+ // manage array value
+ $dbvalue = (is_array($value)?serialize($value):$value);
+ $dbvalue = (is_bool($value) ? intval($value) : $value);
$a->config[$family][$key] = $value;
$ret = q("REPLACE INTO `config` ( `cat`, `k`, `v` ) VALUES ( '%s', '%s', '%s' ) ",
@@ -191,6 +193,7 @@ if(! function_exists('set_pconfig')) {
// manage array value
$dbvalue = (is_array($value)?serialize($value):$value);
+ $dbvalue = (is_bool($value)?serialize($value):$value);
$a->config[$uid][$family][$key] = $value;
diff --git a/include/contact_selectors.php b/include/contact_selectors.php
index 4b3ca987a..4b3ca987a 100755..100644
--- a/include/contact_selectors.php
+++ b/include/contact_selectors.php
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index 605a3eb78..e0f37f078 100755..100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -15,8 +15,6 @@ function findpeople_widget() {
$a = get_app();
- $inv = (($a->config['register_policy'] != REGISTER_CLOSED) ? t('Invite Friends') : '');
-
if(get_config('system','invitation_only')) {
$x = get_pconfig(local_user(),'system','invites_remaining');
if($x || is_site_admin()) {
@@ -34,7 +32,7 @@ function findpeople_widget() {
'$findthem' => t('Find'),
'$suggest' => t('Friend Suggestions'),
'$similar' => t('Similar Interests'),
- '$inv' => $inv
+ '$inv' => t('Invite Friends')
));
}
@@ -48,7 +46,7 @@ function networks_widget($baseurl,$selected = '') {
return '';
- $r = q("select distinct(network) from contact where uid = %d",
+ $r = q("select distinct(network) from contact where uid = %d and self = 0",
intval(local_user())
);
@@ -89,13 +87,41 @@ function fileas_widget($baseurl,$selected = '') {
$cnt = preg_match_all('/\[(.*?)\]/',$saved,$matches,PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
- $unescaped = file_tag_decode($mtch[1]);
+ $unescaped = xmlify(file_tag_decode($mtch[1]));
$terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : ''));
}
}
return replace_macros(get_markup_template('fileas_widget.tpl'),array(
- '$title' => t('File Selections'),
+ '$title' => t('Saved Folders'),
+ '$desc' => '',
+ '$sel_all' => (($selected == '') ? 'selected' : ''),
+ '$all' => t('Everything'),
+ '$terms' => $terms,
+ '$base' => $baseurl,
+
+ ));
+}
+
+function categories_widget($baseurl,$selected = '') {
+ $a = get_app();
+
+ $saved = get_pconfig($a->profile['profile_uid'],'system','filetags');
+ if(! strlen($saved))
+ return;
+
+ $matches = false;
+ $terms = array();
+ $cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ $unescaped = xmlify(file_tag_decode($mtch[1]));
+ $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : ''));
+ }
+ }
+
+ return replace_macros(get_markup_template('categories_widget.tpl'),array(
+ '$title' => t('Categories'),
'$desc' => '',
'$sel_all' => (($selected == '') ? 'selected' : ''),
'$all' => t('Everything'),
diff --git a/include/conversation.php b/include/conversation.php
index 5de4fcb51..df92a40ed 100755..100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -94,9 +94,9 @@ function localize_item(&$item){
}
- $A = '[url=' . $Alink . ']' . $Aname . '[/url]';
- $B = '[url=' . $Blink . ']' . $Bname . '[/url]';
- if ($Bphoto!="") $Bphoto = '[url=' . $Blink . '][img]' . $Bphoto . '[/img][/url]';
+ $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
+ $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
+ if ($Bphoto!="") $Bphoto = '[url=' . zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]';
$item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto;
@@ -108,8 +108,8 @@ function localize_item(&$item){
if(count($r)==0) return;
$obj=$r[0];
- $author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
- $objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]';
+ $author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
+ $objauthor = '[url=' . zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]';
switch($obj['verb']){
case ACTIVITY_POST:
@@ -158,14 +158,21 @@ function localize_item(&$item){
$target = $r[0];
$Bname = $target['author-name'];
$Blink = $target['author-link'];
- $A = '[url=' . $Alink . ']' . $Aname . '[/url]';
- $B = '[url=' . $Blink . ']' . $Bname . '[/url]';
+ $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
+ $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
$P = '[url=' . $target['plink'] . ']' . t('post/item') . '[/url]';
$item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n";
}
}
}
+ $matches = null;
+ if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
+ foreach($matches as $mtch) {
+ if(! strpos($mtch[1],'zrl='))
+ $item['body'] = str_replace($mtch[0],'@[url=' . zrl($mtch[1]). ']',$item['body']);
+ }
+ }
}
@@ -243,7 +250,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$threads = array();
$threadsid = -1;
- if(count($items)) {
+ if($items && count($items)) {
if($mode === 'network-new' || $mode === 'search' || $mode === 'community') {
@@ -276,13 +283,16 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link'];
+
+
$sp = false;
$profile_link = best_link_url($item,$sp);
- if($sp)
- $sparkle = ' sparkle';
if($profile_link === 'mailbox')
$profile_link = '';
-
+ if($sp)
+ $sparkle = ' sparkle';
+ else
+ $profile_link = zrl($profile_link);
$normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
if(($normalised != 'mailbox') && (x($a->contacts[$normalised])))
@@ -484,7 +494,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
// This will have been stored in $a->page_contact by our calling page.
// Put this person on the left of the wall-to-wall notice.
- $owner_url = $a->page_contact['url'];
+ $owner_url = zrl($a->page_contact['url']);
$owner_photo = $a->page_contact['thumb'];
$owner_name = $a->page_contact['name'];
$template = $wallwall;
@@ -501,10 +511,12 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$commentww = 'ww';
// If it is our contact, use a friendly redirect link
if((link_compare($item['owner-link'],$item['url']))
- && ($item['network'] === 'dfrn')) {
+ && ($item['network'] === NETWORK_DFRN)) {
$owner_url = $redirect_url;
$osparkle = ' sparkle';
}
+ else
+ $owner_url = zrl($owner_url);
}
}
@@ -520,9 +532,12 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share'));
}
+ $qc = $qcomment = null;
- $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
- $qcomment = (($qc) ? explode("\n",$qc) : null);
+ if(in_array('qcomment',$a->plugins)) {
+ $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null);
+ $qcomment = (($qc) ? explode("\n",$qc) : null);
+ }
if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) {
$comment = replace_macros($cmnt_tpl,array(
@@ -580,7 +595,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'classtagger' => "",
);
}
- $filer = t("file as");
+ $filer = t("save to folder");
}
@@ -596,14 +611,14 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link'];
-
$sp = false;
$profile_link = best_link_url($item,$sp);
- if($sp)
- $sparkle = ' sparkle';
-
if($profile_link === 'mailbox')
$profile_link = '';
+ if($sp)
+ $sparkle = ' sparkle';
+ else
+ $profile_link = zrl($profile_link);
$normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
@@ -767,8 +782,10 @@ function item_photo_menu($item){
$photos_link = $profile_link . "?url=photos";
$profile_link = $profile_link . "?url=profile";
$pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid;
+ $zurl = '';
}
else {
+ $profile_link = zrl($profile_link);
if(local_user() && local_user() == $item['uid'] && link_compare($item['url'],$item['author-link'])) {
$cid = $item['contact-id'];
}
@@ -795,7 +812,7 @@ function item_photo_menu($item){
$menu = Array(
t("View status") => $status_link,
t("View profile") => $profile_link,
- t("View photos") => $photos_link,
+ t("View photos") => $photos_link,
t("View recent") => $posts_link,
t("Edit contact") => $contact_url,
t("Send PM") => $pm_url,
@@ -828,6 +845,8 @@ function like_puller($a,$item,&$arr,$mode) {
$url = $a->get_baseurl(true) . '/redir/' . $item['contact-id'];
$sparkle = ' class="sparkle" ';
}
+ else
+ $url = zrl($url);
if(! ((isset($arr[$item['parent'] . '-l'])) && (is_array($arr[$item['parent'] . '-l']))))
$arr[$item['parent'] . '-l'] = array();
if(! isset($arr[$item['parent']]))
@@ -896,7 +915,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
'$vidurl' => t("Please enter a video link/URL:"),
'$audurl' => t("Please enter an audio link/URL:"),
'$term' => t('Tag term:'),
- '$fileas' => t('File as:'),
+ '$fileas' => t('Save to Folder:'),
'$whereareu' => t('Where are you right now?')
));
@@ -955,6 +974,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
'$shortnoloc' => t('clear location'),
'$title' => "",
'$placeholdertitle' => t('Set title'),
+ '$category' => "",
+ '$placeholdercategory' => t('Categories (comma-separated list)'),
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
'$shortpermset' => t('permissions'),
diff --git a/include/cronhooks.php b/include/cronhooks.php
index 37541f013..37541f013 100755..100644
--- a/include/cronhooks.php
+++ b/include/cronhooks.php
diff --git a/include/crypto.php b/include/crypto.php
index 0feb45c24..0feb45c24 100755..100644
--- a/include/crypto.php
+++ b/include/crypto.php
diff --git a/include/datetime.php b/include/datetime.php
index 6d395fe3f..6d395fe3f 100755..100644
--- a/include/datetime.php
+++ b/include/datetime.php
diff --git a/include/dba.php b/include/dba.php
index 5beea7a3a..76cc0bc7b 100755..100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -207,8 +207,10 @@ function q($sql) {
unset($args[0]);
if($db && $db->connected) {
- $ret = $db->q(vsprintf($sql,$args));
- return $ret;
+ $stmt = vsprintf($sql,$args);
+ if($stmt === false)
+ logger('dba: vsprintf error: ' . print_r(debug_backtrace(),true));
+ return $db->q($stmt);
}
/**
diff --git a/include/delivery.php b/include/delivery.php
index 532dcd699..794b8f27a 100755..100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -321,6 +321,14 @@ function delivery_run($argv, $argc){
$x[0]['writable'] = 1;
}
+ $ssl_policy = get_config('system','ssl_policy');
+ fix_contact_ssl_policy($x[0],$ssl_policy);
+
+ // If we are setup as a soapbox we aren't accepting input from this person
+
+ if($x[0]['page-flags'] == PAGE_SOAPBOX)
+ break;
+
require_once('library/simplepie/simplepie.inc');
logger('mod-delivery: local delivery');
local_delivery($x[0],$atom);
diff --git a/include/diaspora.php b/include/diaspora.php
index 1b5af42cd..06df9c24a 100755..100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -9,6 +9,12 @@ require_once('include/queue_fn.php');
function diaspora_dispatch_public($msg) {
+ $enabled = intval(get_config('system','diaspora_enabled'));
+ if(! $enabled) {
+ logger('mod-diaspora: disabled');
+ return;
+ }
+
$r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN ( SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s' ) AND `account_expired` = 0 ",
dbesc(NETWORK_DIASPORA),
dbesc($msg['author'])
@@ -29,6 +35,12 @@ function diaspora_dispatch($importer,$msg) {
$ret = 0;
+ $enabled = intval(get_config('system','diaspora_enabled'));
+ if(! $enabled) {
+ logger('mod-diaspora: disabled');
+ return;
+ }
+
// php doesn't like dashes in variable names
$msg['message'] = str_replace(
@@ -688,9 +700,9 @@ function diaspora_post($importer,$xml) {
// don't link tags that are already embedded in links
- if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body))
+ if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body))
continue;
- if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body))
+ if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
continue;
$basetag = str_replace('_',' ',substr($tag,1));
@@ -853,9 +865,9 @@ function diaspora_reshare($importer,$xml) {
// don't link tags that are already embedded in links
- if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body))
+ if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body))
continue;
- if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body))
+ if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
continue;
@@ -1094,9 +1106,9 @@ function diaspora_comment($importer,$xml,$msg) {
// don't link tags that are already embedded in links
- if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body))
+ if(preg_match('/\[(.*?)' . preg_quote($tag,'/') . '(.*?)\]/',$body))
continue;
- if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body))
+ if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
continue;
@@ -1737,7 +1749,7 @@ function diaspora_retraction($importer,$xml) {
contact_remove($contact['id']);
}
elseif($type === 'Post') {
- $r = q("select * from item where guid = '%s' and uid = %d limit 1",
+ $r = q("select * from item where guid = '%s' and uid = %d and not file like '%%[%%' limit 1",
dbesc('guid'),
intval($importer['uid'])
);
@@ -1785,7 +1797,7 @@ function diaspora_signed_retraction($importer,$xml,$msg) {
}
if($type === 'StatusMessage') {
- $r = q("select * from item where guid = '%s' and uid = %d limit 1",
+ $r = q("select * from item where guid = '%s' and uid = %d and not file like '%%[%%' limit 1",
dbesc($guid),
intval($importer['uid'])
);
@@ -1920,6 +1932,7 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
$images = array();
+ $title = $item['title'];
$body = $item['body'];
/*
@@ -1944,9 +1957,12 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
}
}
*/
-
$body = xmlify(html_entity_decode(bb2diaspora($body)));
+ if(strlen($title))
+ $body = xmlify('**' . html_entity_decode($title) . '**' . "\n") . $body;
+
+
if($item['attach']) {
$cnt = preg_match_all('/href=\"(.*?)\"(.*?)title=\"(.*?)\"/ism',$item['attach'],$matches,PREG_SET_ORDER);
if(cnt) {
@@ -2267,6 +2283,11 @@ function diaspora_send_mail($item,$owner,$contact) {
function diaspora_transmit($owner,$contact,$slap,$public_batch) {
+ $enabled = intval(get_config('system','diaspora_enabled'));
+ if(! $enabled) {
+ return 200;
+ }
+
$a = get_app();
$logid = random_string(4);
$dest_url = (($public_batch) ? $contact['batch'] : $contact['notify']);
diff --git a/include/directory.php b/include/directory.php
index cae78adb4..cae78adb4 100755..100644
--- a/include/directory.php
+++ b/include/directory.php
diff --git a/include/email.php b/include/email.php
index 8ea8145fb..b43ae0dc1 100755..100644
--- a/include/email.php
+++ b/include/email.php
@@ -74,7 +74,7 @@ function email_msg_headers($mbox,$uid) {
}
-function email_get_msg($mbox,$uid) {
+function email_get_msg($mbox,$uid, $reply) {
$ret = array();
$struc = (($mbox && $uid) ? @imap_fetchstructure($mbox,$uid,FT_UID) : null);
@@ -114,7 +114,7 @@ function email_get_msg($mbox,$uid) {
$ret['body'] = removegpg($ret['body']);
$msg = removesig($ret['body']);
$ret['body'] = $msg['body'];
- $ret['body'] = convertquote($ret['body'], false);
+ $ret['body'] = convertquote($ret['body'], $reply);
if (trim($html) != '')
$ret['body'] = removelinebreak($ret['body']);
@@ -250,7 +250,7 @@ function email_header_encode($in_str, $charset) {
// remove trailing spacer and
// add start and end delimiters
- $spacer = preg_quote($spacer);
+ $spacer = preg_quote($spacer,'/');
$out_str = preg_replace("/" . $spacer . "$/", "", $out_str);
$out_str = $start . $out_str . $end;
}
diff --git a/include/enotify.php b/include/enotify.php
index a505f1f04..8385bdec5 100755..100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -5,6 +5,12 @@ function notification($params) {
logger('notification: entry', LOGGER_DEBUG);
$a = get_app();
+
+ // from here on everything is in the recipients language
+
+ push_lang($params['language']);
+
+
$banner = t('Friendica Notification');
$product = FRIENDICA_PLATFORM;
$siteurl = z_path();
@@ -153,9 +159,33 @@ function notification($params) {
}
- // from here on everything is in the recipients language
+ if($params['type'] == NOTIFY_SYSTEM) {
+
+ }
+
+ $h = array(
+ 'params' => $params,
+ 'subject' => $subject,
+ 'preamble' => $preamble,
+ 'epreamble' => $epreamble,
+ 'body' => $body,
+ 'sitelink' => $sitelink,
+ 'tsitelink' => $tsitelink,
+ 'hsitelink' => $hsitelink,
+ 'itemlink' => $itemlink
+ );
+
+ call_hooks('enotify',$h);
+
+ $subject = $h['subject'];
+ $preamble = $h['preamble'];
+ $epreamble = $h['epreamble'];
+ $body = $h['body'];
+ $sitelink = $h['sitelink'];
+ $tsitelink = $h['tsitelink'];
+ $hsitelink = $h['hsitelink'];
+ $itemlink = $h['itemlink'];
- push_lang($params['language']);
require_once('include/html2bbcode.php');
@@ -207,8 +237,10 @@ function notification($params) {
);
if($r)
$notify_id = $r[0]['id'];
- else
+ else {
+ pop_lang();
return;
+ }
$itemlink = $a->get_baseurl() . '/notify/view/' . $notify_id;
$msg = replace_macros($epreamble,array('$itemlink' => $itemlink));
@@ -219,11 +251,10 @@ function notification($params) {
);
-
// send email notification if notification preferences permit
require_once('bbcode.php');
- if(intval($params['notify_flags']) & intval($params['type'])) {
+ if((intval($params['notify_flags']) & intval($params['type'])) || $params['type'] == NOTIFY_SYSTEM) {
logger('notification: sending notification email');
diff --git a/include/event.php b/include/event.php
index 29202badd..29202badd 100755..100644
--- a/include/event.php
+++ b/include/event.php
diff --git a/include/expire.php b/include/expire.php
index 5fa0ec758..5fa0ec758 100755..100644
--- a/include/expire.php
+++ b/include/expire.php
diff --git a/include/fcontact.php b/include/fcontact.php
index 8821a985f..8821a985f 100755..100644
--- a/include/fcontact.php
+++ b/include/fcontact.php
diff --git a/include/group.php b/include/group.php
index 4a35912e5..4a35912e5 100755..100644
--- a/include/group.php
+++ b/include/group.php
diff --git a/include/html2bbcode.php b/include/html2bbcode.php
index 69ccf41b7..69ccf41b7 100755..100644
--- a/include/html2bbcode.php
+++ b/include/html2bbcode.php
diff --git a/include/html2plain.php b/include/html2plain.php
index 2a4cf6639..fe0e3326e 100644
--- a/include/html2plain.php
+++ b/include/html2plain.php
@@ -1,9 +1,15 @@
<?php
require_once "html2bbcode.php";
-function breaklines($line, $level)
+function breaklines($line, $level, $wraplength = 75)
{
- $wraplen = 75-$level;
+
+ if ($wraplength == 0)
+ $wraplength = 2000000;
+
+ // return($line);
+
+ $wraplen = $wraplength-$level;
$newlines = array();
@@ -37,7 +43,7 @@ function breaklines($line, $level)
return(implode($newlines, "\n"));
}
-function quotelevel($message)
+function quotelevel($message, $wraplength = 75)
{
$lines = explode("\n", $message);
@@ -65,12 +71,31 @@ function quotelevel($message)
}
if (!$startquote or ($line != ''))
- $newlines[] = breaklines($line, $currlevel);
+ $newlines[] = breaklines($line, $currlevel, $wraplength);
}
return(implode($newlines, "\n"));
}
-function html2plain($html)
+function collecturls($message) {
+ $pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
+ preg_match_all($pattern, $message, $result, PREG_SET_ORDER);
+
+ $urls = array();
+ foreach ($result as $treffer) {
+ // A list of some links that should be ignored
+ $list = array("/user/", "/tag/", "/profile/", "/search?search=", "mailto:", "/u/", "/node/",
+ "//facebook.com/profile.php?id=", "//plus.google.com/");
+ foreach ($list as $listitem)
+ if (strpos($treffer[1], $listitem) !== false)
+ $ignore = true;
+
+ if (!$ignore)
+ $urls[$treffer[1]] = $treffer[1];
+ }
+ return($urls);
+}
+
+function html2plain($html, $wraplength = 75, $compact = false)
{
global $lang;
@@ -93,22 +118,16 @@ function html2plain($html)
$message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "<br>", " ", ""), $message);
$message = preg_replace('= [\s]*=i', " ", $message);
- // nach <a href="...">...</a> suchen, die ... miteinander vergleichen und bei Gleichheit durch ein einzelnes ... ersetzen.
- $pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
- preg_match_all($pattern, $message, $result, PREG_SET_ORDER);
+ // Collecting all links
+ $urls = collecturls($message);
- foreach ($result as $treffer) {
- if ($treffer[1] == $treffer[2]) {
- $search = '<a href="'.$treffer[1].'" target="_blank">'.$treffer[1].'</a>';
- $message = str_replace($search, $treffer[1], $message);
- }
- }
@$doc->loadHTML($message);
node2bbcode($doc, 'html', array(), '', '');
node2bbcode($doc, 'body', array(), '', '');
// MyBB-Auszeichnungen
+ /*
node2bbcode($doc, 'span', array('style'=>'text-decoration: underline;'), '_', '_');
node2bbcode($doc, 'span', array('style'=>'font-style: italic;'), '/', '/');
node2bbcode($doc, 'span', array('style'=>'font-weight: bold;'), '*', '*');
@@ -117,8 +136,12 @@ function html2plain($html)
node2bbcode($doc, 'b', array(), '*', '*');
node2bbcode($doc, 'i', array(), '/', '/');
node2bbcode($doc, 'u', array(), '_', '_');
+ */
- node2bbcode($doc, 'blockquote', array(), '[quote]', "[/quote]\n");
+ if ($compact)
+ node2bbcode($doc, 'blockquote', array(), "»", "«");
+ else
+ node2bbcode($doc, 'blockquote', array(), '[quote]', "[/quote]\n");
node2bbcode($doc, 'br', array(), "\n", '');
@@ -143,16 +166,25 @@ function html2plain($html)
node2bbcode($doc, 'h5', array(), "\n\n*", "*\n");
node2bbcode($doc, 'h6', array(), "\n\n*", "*\n");
- node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1', '', true);
- node2bbcode($doc, 'img', array('alt'=>'/(.+)/'), '$1', '');
- node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', '');
- node2bbcode($doc, 'img', array(), '', '');
- node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '[img]$1', '[/img]');
+ // Problem: there is no reliable way to detect if it is a link to a tag or profile
+ //node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', '', true);
+ node2bbcode($doc, 'a', array('href'=>'/(.+)/', 'rel'=>'oembed'), ' $1 ', '', true);
+ //node2bbcode($doc, 'img', array('alt'=>'/(.+)/'), '$1', '');
+ //node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', '');
+ //node2bbcode($doc, 'img', array(), '', '');
+ if (!$compact)
+ node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '[img]$1', '[/img]');
+ else
+ node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '', '');
+
+ node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), ' $1 ', '', true);
$message = $doc->saveHTML();
- $message = str_replace("[img]", "", $message);
- $message = str_replace("[/img]", "", $message);
+ if (!$compact) {
+ $message = str_replace("[img]", "", $message);
+ $message = str_replace("[/img]", "", $message);
+ }
// was ersetze ich da?
// Irgendein stoerrisches UTF-Zeug
@@ -168,12 +200,20 @@ function html2plain($html)
$message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
+ if (!$compact) {
+ $counter = 1;
+ foreach ($urls as $id=>$url)
+ if (strpos($message, $url) == false)
+ $message .= "\n".$url." ";
+ //$message .= "\n[".($counter++)."] ".$url;
+ }
+
do {
$oldmessage = $message;
$message = str_replace("\n\n\n", "\n\n", $message);
} while ($oldmessage != $message);
- $message = quotelevel(trim($message));
+ $message = quotelevel(trim($message), $wraplength);
return(trim($message));
}
diff --git a/include/items.php b/include/items.php
index 5a297c83e..ee6960534 100755..100644
--- a/include/items.php
+++ b/include/items.php
@@ -7,14 +7,11 @@ require_once('include/crypto.php');
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
- // default permissions - anonymous user
-
- if(! strlen($owner_nick))
- killme();
+ $sitefeed = ((strlen($owner_nick)) ? false : true); // not yet implemented, need to rewrite huge chunks of following logic
$public_feed = (($dfrn_id) ? false : true);
- $starred = false;
- $converse = false;
+ $starred = false; // not yet implemented, possible security issues
+ $converse = false;
if($public_feed && $a->argc > 2) {
for($x = 2; $x < $a->argc; $x++) {
@@ -25,6 +22,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
}
}
+ // default permissions - anonymous user
$sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
@@ -418,7 +416,7 @@ function get_atom_elements($feed,$item) {
// the wild, by sanitising it and converting supported tags to bbcode before we rip out any remaining
// html.
- if((strpos($res['body'],'<') !== false) || (strpos($res['body'],'>') !== false)) {
+ if((strpos($res['body'],'<') !== false) && (strpos($res['body'],'>') !== false)) {
$res['body'] = reltoabs($res['body'],$base_url);
@@ -431,14 +429,22 @@ function get_atom_elements($feed,$item) {
// we shouldn't need a whitelist, because the bbcode converter
// will strip out any unsupported tags.
- // $config->set('HTML.Allowed', 'p,b,a[href],i');
$purifier = new HTMLPurifier($config);
$res['body'] = $purifier->purify($res['body']);
- $res['body'] = html2bbcode($res['body']);
+ $res['body'] = @html2bbcode($res['body']);
+ }
+ elseif(! $have_real_body) {
+
+ // it's not one of our messages and it has no tags
+ // so it's probably just text. We'll escape it just to be safe.
+
+ $res['body'] = escape_tags($res['body']);
}
+ // this tag is obsolete but we keep it for really old sites
+
$allow = $item->get_item_tags(NAMESPACE_DFRN,'comment-allow');
if($allow && $allow[0]['data'] == 1)
$res['last-child'] = 1;
@@ -1092,12 +1098,23 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$postvars = array();
$sent_dfrn_id = hex2bin((string) $res->dfrn_id);
$challenge = hex2bin((string) $res->challenge);
+ $perm = (($res->perm) ? $res->perm : null);
$dfrn_version = (float) (($res->dfrn_version) ? $res->dfrn_version : 2.0);
$rino_allowed = ((intval($res->rino) === 1) ? 1 : 0);
$page = (($owner['page-flags'] == PAGE_COMMUNITY) ? 1 : 0);
$final_dfrn_id = '';
+ if($perm) {
+ if((($perm == 'rw') && (! intval($contact['writable'])))
+ || (($perm == 'r') && (intval($contact['writable'])))) {
+ q("update contact set writable = %d where id = %d limit 1",
+ intval(($perm == 'rw') ? 1 : 0),
+ intval($contact['id'])
+ );
+ $contact['writable'] = (string) 1 - intval($contact['writable']);
+ }
+ }
if(($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
@@ -1437,7 +1454,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
}
if($deleted && is_array($contact)) {
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.`id`
- WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d LIMIT 1",
+ WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1",
dbesc($uri),
intval($importer['uid']),
intval($contact['id'])
@@ -1582,9 +1599,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(count($r)) {
if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
- $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($datarray['title']),
dbesc($datarray['body']),
+ dbesc($datarray['tag']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc($item_id),
intval($importer['uid'])
@@ -1727,9 +1745,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(count($r)) {
if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
- $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($datarray['title']),
dbesc($datarray['body']),
+ dbesc($datarray['tag']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc($item_id),
intval($importer['uid'])
@@ -1800,7 +1819,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
// but otherwise there's a possible data mixup on the sender's system.
// the tgroup delivery code called from item_store will correct it if it's a forum,
// but we're going to unconditionally correct it here so that the post will always be owned by our contact.
- logger('local_delivery: Correcting item owner.', LOGGER_DEBUG);
+ logger('consume_feed: Correcting item owner.', LOGGER_DEBUG);
$datarray['owner-name'] = $contact['name'];
$datarray['owner-link'] = $contact['url'];
$datarray['owner-avatar'] = $contact['thumb'];
@@ -1896,6 +1915,14 @@ function local_delivery($importer,$data) {
);
if(count($r)) {
$fid = $r[0]['id'];
+
+ // OK, we do. Do we already have an introduction for this person ?
+ $r = q("select id from intro where uid = %d and fid = %d limit 1",
+ intval($fsugg['uid']),
+ intval($fid)
+ );
+ if(count($r))
+ return 0;
}
if(! $fid)
$r = q("INSERT INTO `fcontact` ( `name`,`url`,`photo`,`request` ) VALUES ( '%s', '%s', '%s', '%s' ) ",
@@ -1916,6 +1943,7 @@ function local_delivery($importer,$data) {
else
return 0;
+
$hash = random_string();
$r = q("INSERT INTO `intro` ( `uid`, `fid`, `contact-id`, `note`, `hash`, `datetime`, `blocked` )
@@ -2036,7 +2064,7 @@ function local_delivery($importer,$data) {
if($deleted) {
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join contact on `item`.`contact-id` = `contact`.`id`
- WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d LIMIT 1",
+ WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1",
dbesc($uri),
intval($importer['importer_uid']),
intval($importer['id'])
@@ -2332,9 +2360,10 @@ function local_delivery($importer,$data) {
if(count($r)) {
if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
- $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($datarray['title']),
dbesc($datarray['body']),
+ dbesc($datarray['tag']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc($item_id),
intval($importer['importer_uid'])
@@ -2497,9 +2526,10 @@ function local_delivery($importer,$data) {
if(count($r)) {
if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
- $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($datarray['title']),
dbesc($datarray['body']),
+ dbesc($datarray['tag']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
dbesc($item_id),
intval($importer['importer_uid'])
@@ -2925,6 +2955,11 @@ function item_expire($uid,$days) {
foreach($r as $item) {
+ // don't expire filed items
+
+ if(strpos($item['file'],'[') !== false)
+ continue;
+
// Only expire posts, not photos and photo comments
if($expire_photos==0 && strlen($item['resource-id']))
diff --git a/include/message.php b/include/message.php
index 7ad80ae9c..377d7c715 100755..100644
--- a/include/message.php
+++ b/include/message.php
@@ -1,4 +1,5 @@
<?php
+
// send a private message
@@ -155,3 +156,87 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
}
}
+
+
+
+
+
+function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){
+
+ $a = get_app();
+
+ if(! $recipient) return -1;
+
+ if(! strlen($subject))
+ $subject = t('[no subject]');
+
+ $hash = random_string();
+ $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $hash ;
+
+ $convid = 0;
+ $reply = false;
+
+ require_once('include/Scrape.php');
+
+ $me = probe_url($replyto);
+
+ if(! $me['name'])
+ return -2;
+
+ $conv_guid = get_guid();
+
+ $recip_handle = $recipient['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+
+ $sender_nick = basename($replyto);
+ $sender_host = substr($replyto,strpos($replyto,'://')+3);
+ $sender_host = substr($sender_host,0,strpos($sender_host,'/'));
+ $sender_handle = $sender_nick . '@' . $sender_host;
+
+ $handles = $recip_handle . ';' . $sender_handle;
+
+ $r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ",
+ intval(local_user()),
+ dbesc($conv_guid),
+ dbesc($sender_handle),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc($subject),
+ dbesc($handles)
+ );
+
+ $r = q("select * from conv where guid = '%s' and uid = %d limit 1",
+ dbesc($conv_guid),
+ intval($recipient['uid'])
+ );
+ if(count($r))
+ $convid = $r[0]['id'];
+
+ if(! $convid) {
+ logger('send message: conversation not found.');
+ return -4;
+ }
+
+ $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
+ `contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`)
+ VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )",
+ intval($recipient['uid']),
+ dbesc(get_guid()),
+ intval($convid),
+ dbesc($me['name']),
+ dbesc($me['photo']),
+ dbesc($me['url']),
+ 0,
+ dbesc($subject),
+ dbesc($body),
+ 0,
+ 0,
+ 0,
+ dbesc($uri),
+ dbesc($replyto),
+ datetime_convert(),
+ 1
+ );
+
+ return 0;
+
+}
diff --git a/include/msgclean.php b/include/msgclean.php
index 284ad1ce4..eabb47788 100644
--- a/include/msgclean.php
+++ b/include/msgclean.php
@@ -13,7 +13,7 @@ function savereplace($pattern, $replace, $text)
function unifyattributionline($message)
{
- $quotestr = array('quote', 'collapsed');
+ $quotestr = array('quote', 'spoiler');
foreach ($quotestr as $quote) {
$message = savereplace('/----- Original Message -----\s.*?From: "([^<"].*?)" <(.*?)>\s.*?To: (.*?)\s*?Cc: (.*?)\s*?Sent: (.*?)\s.*?Subject: ([^\n].*)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
diff --git a/include/nav.php b/include/nav.php
index f40e92dbc..2c9c643a9 100755..100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -69,7 +69,9 @@ function nav(&$a) {
* "Home" should also take you home from an authenticated remote profile connection
*/
- $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
+ $homelink = get_my_url();
+ if(! $homelink)
+ $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
if(($a->module != 'home') && (! (local_user())))
$nav['home'] = array($homelink, t('Home'), "", t('Home Page'));
diff --git a/include/network.php b/include/network.php
index 22157ff18..38d0980d5 100755..100644
--- a/include/network.php
+++ b/include/network.php
@@ -364,6 +364,9 @@ function lrdd($uri, $debug = false) {
logger('lrdd: host_meta: ' . $xml, LOGGER_DATA);
+ if(! stristr($xml,'<xrd'))
+ return array();
+
$h = parse_xml_string($xml);
if(! $h)
return array();
@@ -821,3 +824,48 @@ function scale_external_images($s,$include_link = true) {
}
return $s;
}
+
+
+function fix_contact_ssl_policy(&$contact,$new_policy) {
+
+ $ssl_changed = false;
+ if((intval($new_policy) == SSL_POLICY_SELFSIGN || $new_policy === 'self') && strstr($contact['url'],'https:')) {
+ $ssl_changed = true;
+ $contact['url'] = str_replace('https:','http:',$contact['url']);
+ $contact['request'] = str_replace('https:','http:',$contact['request']);
+ $contact['notify'] = str_replace('https:','http:',$contact['notify']);
+ $contact['poll'] = str_replace('https:','http:',$contact['poll']);
+ $contact['confirm'] = str_replace('https:','http:',$contact['confirm']);
+ $contact['poco'] = str_replace('https:','http:',$contact['poco']);
+ }
+
+ if((intval($new_policy) == SSL_POLICY_FULL || $new_policy === 'full') && strstr($contact['url'],'http:')) {
+ $ssl_changed = true;
+ $contact['url'] = str_replace('http:','https:',$contact['url']);
+ $contact['request'] = str_replace('http:','https:',$contact['request']);
+ $contact['notify'] = str_replace('http:','https:',$contact['notify']);
+ $contact['poll'] = str_replace('http:','https:',$contact['poll']);
+ $contact['confirm'] = str_replace('http:','https:',$contact['confirm']);
+ $contact['poco'] = str_replace('http:','https:',$contact['poco']);
+ }
+
+ if($ssl_changed) {
+ q("update contact set
+ url = '%s',
+ request = '%s',
+ notify = '%s',
+ poll = '%s',
+ confirm = '%s',
+ poco = '%s'
+ where id = %d limit 1",
+ dbesc($contact['url']),
+ dbesc($contact['request']),
+ dbesc($contact['notify']),
+ dbesc($contact['poll']),
+ dbesc($contact['confirm']),
+ dbesc($contact['poco']),
+ intval($contact['id'])
+ );
+ }
+}
+
diff --git a/include/notifier.php b/include/notifier.php
index d63ad7ae7..ca7c7b92e 100755..100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -537,6 +537,17 @@ function notifier_run($argv, $argc){
$x[0]['writable'] = 1;
}
+ // if contact's ssl policy changed, which we just determined
+ // is on our own server, update our contact links
+
+ $ssl_policy = get_config('system','ssl_policy');
+ fix_contact_ssl_policy($x[0],$ssl_policy);
+
+ // If we are setup as a soapbox we aren't accepting input from this person
+
+ if($x[0]['page-flags'] == PAGE_SOAPBOX)
+ break;
+
require_once('library/simplepie/simplepie.inc');
logger('mod-delivery: local delivery');
local_delivery($x[0],$atom);
diff --git a/include/oauth.php b/include/oauth.php
index 2724dcf7c..2724dcf7c 100755..100644
--- a/include/oauth.php
+++ b/include/oauth.php
diff --git a/include/oembed.php b/include/oembed.php
index cc71f9757..1f45d2814 100755..100644
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -38,7 +38,8 @@ function oembed_fetch_url($embedurl){
$entries = $xpath->query("//link[@type='application/json+oembed']");
foreach($entries as $e){
$href = $e->getAttributeNode("href")->nodeValue;
- $txt = fetch_url($href);
+ $txt = fetch_url($href . '&maxwidth=425');
+ break;
}
}
}
@@ -46,7 +47,7 @@ function oembed_fetch_url($embedurl){
if ($txt==false || $txt==""){
// try oohembed service
- $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl);
+ $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl).'&maxwidth=425';
$txt = fetch_url($ourl);
}
diff --git a/include/pgettext.php b/include/pgettext.php
index 83e76ba9d..83e76ba9d 100755..100644
--- a/include/pgettext.php
+++ b/include/pgettext.php
diff --git a/include/plugin.php b/include/plugin.php
index 8280b1022..e37ae8435 100755..100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -249,6 +249,7 @@ function get_theme_info($theme){
list($k,$v) = array_map("trim", explode(":",$l,2));
$k= strtolower($k);
if ($k=="author"){
+
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
if ($r) {
$info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
@@ -276,3 +277,13 @@ function get_theme_info($theme){
return $info;
}}
+
+function get_theme_screenshot($theme) {
+ $a = get_app();
+ $exts = array('.png','.jpg');
+ foreach($exts as $ext) {
+ if(file_exists('view/theme/' . $theme . '/screenshot' . $ext))
+ return($a->get_baseurl() . '/view/theme/' . $theme . '/screenshot' . $ext);
+ }
+ return($a->get_baseurl() . '/images/blank.png');
+}
diff --git a/include/poller.php b/include/poller.php
index 8262c1d60..90a97867c 100755..100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -504,7 +504,12 @@ function poller_run($argv, $argc){
//$datarray['title'] = notags(trim($meta->subject));
$datarray['created'] = datetime_convert('UTC','UTC',$meta->date);
- $r = email_get_msg($mbox,$msg_uid);
+ // Is it reply?
+ $reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") or
+ (substr(strtolower($datarray['title']), 0, 3) == "re-") or
+ (raw_refs != ""));
+
+ $r = email_get_msg($mbox,$msg_uid, $reply);
if(! $r) {
logger("Mail: can't fetch msg ".$msg_uid);
continue;
diff --git a/include/profile_advanced.php b/include/profile_advanced.php
index 004a58524..004a58524 100755..100644
--- a/include/profile_advanced.php
+++ b/include/profile_advanced.php
diff --git a/include/profile_selectors.php b/include/profile_selectors.php
index 92579f64a..92579f64a 100755..100644
--- a/include/profile_selectors.php
+++ b/include/profile_selectors.php
diff --git a/include/profile_update.php b/include/profile_update.php
index 61eaee75d..61eaee75d 100755..100644
--- a/include/profile_update.php
+++ b/include/profile_update.php
diff --git a/include/queue.php b/include/queue.php
index 7e92705be..7e92705be 100755..100644
--- a/include/queue.php
+++ b/include/queue.php
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 3c1087f4e..3c1087f4e 100755..100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
diff --git a/include/quoteconvert.php b/include/quoteconvert.php
index 3aee93234..2a6d28370 100644
--- a/include/quoteconvert.php
+++ b/include/quoteconvert.php
@@ -124,7 +124,7 @@ function removetofu($message)
}
if ($quotestart != 0) {
- $message = trim(substr($message, 0, $quotestart))."\n[collapsed]\n".substr($message, $quotestart+7, -8).'[/collapsed]';
+ $message = trim(substr($message, 0, $quotestart))."\n[spoiler]".substr($message, $quotestart+7, -8).'[/spoiler]';
}
return($message);
diff --git a/include/remoteupdate.php b/include/remoteupdate.php
index 9effc9b6e..9effc9b6e 100755..100644
--- a/include/remoteupdate.php
+++ b/include/remoteupdate.php
diff --git a/include/salmon.php b/include/salmon.php
index 3d525f51a..3d525f51a 100755..100644
--- a/include/salmon.php
+++ b/include/salmon.php
diff --git a/include/security.php b/include/security.php
index 19e91eb63..66622fd33 100755..100644
--- a/include/security.php
+++ b/include/security.php
@@ -9,6 +9,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$_SESSION['authenticated'] = 1;
$_SESSION['page_flags'] = $user_record['page-flags'];
$_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname'];
+ $_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
$a->user = $user_record;
diff --git a/include/session.php b/include/session.php
index 6c32e299f..6c32e299f 100755..100644
--- a/include/session.php
+++ b/include/session.php
diff --git a/include/socgraph.php b/include/socgraph.php
index b2f545509..3f5194049 100755..100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -237,12 +237,14 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
$r = q("SELECT count(glink.gcid) as `total`, gcontact.* from gcontact
left join glink on glink.gcid = gcontact.id
- where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d)
+ where uid = %d and not gcontact.nurl in ( select nurl from contact where uid = %d )
+ and not gcontact.name in ( select name from contact where uid = %d )
and not gcontact.id in ( select gcid from gcign where uid = %d )
group by glink.gcid order by total desc limit %d, %d ",
intval($uid),
intval($uid),
intval($uid),
+ intval($uid),
intval($start),
intval($limit)
);
@@ -252,11 +254,13 @@ function suggestion_query($uid, $start = 0, $limit = 80) {
$r2 = q("SELECT gcontact.* from gcontact
left join glink on glink.gcid = gcontact.id
- where glink.uid = 0 and glink.cid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d)
+ where glink.uid = 0 and glink.cid = 0 and not gcontact.nurl in ( select nurl from contact where uid = %d )
+ and not gcontact.name in ( select name from contact where uid = %d )
and not gcontact.id in ( select gcid from gcign where uid = %d )
order by rand() limit %d, %d ",
intval($uid),
intval($uid),
+ intval($uid),
intval($start),
intval($limit)
);
diff --git a/include/system_unavailable.php b/include/system_unavailable.php
index bd7196cdf..bd7196cdf 100755..100644
--- a/include/system_unavailable.php
+++ b/include/system_unavailable.php
diff --git a/include/template_processor.php b/include/template_processor.php
index 4c317efe1..4c317efe1 100755..100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
diff --git a/include/text.php b/include/text.php
index 92a74eb49..5456b5ad3 100644
--- a/include/text.php
+++ b/include/text.php
@@ -205,7 +205,6 @@ function hex2bin($s) {
return '';
if(! ctype_xdigit($s)) {
- logger('hex2bin: illegal input: ' . print_r(debug_backtrace(), true));
return($s);
}
@@ -226,6 +225,9 @@ if(! function_exists('paginate')) {
function paginate(&$a) {
$o = '';
$stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string);
+
+// $stripped = preg_replace('/&zrl=(.*?)([\?&]|$)/ism','',$stripped);
+
$stripped = str_replace('q=','',$stripped);
$stripped = trim($stripped,'/');
$pagenum = $a->pager['page'];
@@ -610,6 +612,8 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
$url = $redirect_url;
$sparkle = ' sparkle';
}
+ else
+ $url = zrl($url);
}
$click = ((x($contact,'click')) ? ' onclick="' . $contact['click'] . '" ' : '');
if($click)
@@ -724,6 +728,8 @@ function smilies($s, $sample = false) {
'\\o/',
'o.O',
'O.o',
+ 'o_O',
+ 'O_o',
":'(",
":-!",
":-/",
@@ -758,6 +764,8 @@ function smilies($s, $sample = false) {
'<img src="' . $a->get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="o_O" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-Oo.gif" alt="O_o" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" />',
'<img src="' . $a->get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" />',
@@ -919,7 +927,7 @@ function prepare_body($item,$attach = false) {
foreach($matches as $mtch) {
if(strlen($x))
$x .= ',';
- $x .= file_tag_decode($mtch[1]);
+ $x .= xmlify(file_tag_decode($mtch[1]));
}
if(strlen($x))
$s .= '<div class="categorytags"><span>' . t('Categories:') . ' </span>' . $x . '</div>';
@@ -934,12 +942,42 @@ function prepare_body($item,$attach = false) {
foreach($matches as $mtch) {
if(strlen($x))
$x .= '&nbsp;&nbsp;&nbsp;';
- $x .= file_tag_decode($mtch[1]). ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . file_tag_decode($mtch[1]) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>';
+ $x .= xmlify(file_tag_decode($mtch[1])) . ' <a href="' . $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])) . '" title="' . t('remove') . '" >' . t('[remove]') . '</a>';
}
if(strlen($x) && (local_user() == $item['uid']))
$s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>';
}
+ // Look for spoiler
+ $spoilersearch = '<blockquote class="spoiler">';
+
+ // Remove line breaks before the spoiler
+ while ((strpos($s, "\n".$spoilersearch) !== false))
+ $s = str_replace("\n".$spoilersearch, $spoilersearch, $s);
+ while ((strpos($s, "<br />".$spoilersearch) !== false))
+ $s = str_replace("<br />".$spoilersearch, $spoilersearch, $s);
+
+ while ((strpos($s, $spoilersearch) !== false)) {
+
+ $pos = strpos($s, $spoilersearch);
+ $rnd = random_string(8);
+ $spoilerreplace = '<br /> <span id="spoiler-wrap-'.$rnd.'" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-'.$rnd.'\');">'.sprintf(t('Click to open/close')).'</span>'.
+ '<blockquote class="spoiler" id="spoiler-'.$rnd.'" style="display: none;">';
+ $s = substr($s, 0, $pos).$spoilerreplace.substr($s, $pos+strlen($spoilersearch));
+ }
+
+ // Look for quote with author
+ $authorsearch = '<blockquote class="author">';
+
+ while ((strpos($s, $authorsearch) !== false)) {
+
+ $pos = strpos($s, $authorsearch);
+ $rnd = random_string(8);
+ $authorreplace = '<br /> <span id="author-wrap-'.$rnd.'" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'author-'.$rnd.'\');">'.sprintf(t('Click to open/close')).'</span>'.
+ '<blockquote class="author" id="author-'.$rnd.'" style="display: block;">';
+ $s = substr($s, 0, $pos).$authorreplace.substr($s, $pos+strlen($authorsearch));
+ }
+
$prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body_final', $prep_arr);
@@ -1275,13 +1313,126 @@ function file_tag_decode($s) {
}
function file_tag_file_query($table,$s,$type = 'file') {
+
if($type == 'file')
- $str = preg_quote( '[' . file_tag_encode($s) . ']' );
+ $str = preg_quote( '[' . str_replace('%','%%',file_tag_encode($s)) . ']' );
else
- $str = preg_quote( '<' . file_tag_encode($s) . '>' );
+ $str = preg_quote( '<' . str_replace('%','%%',file_tag_encode($s)) . '>' );
return " AND " . (($table) ? dbesc($table) . '.' : '') . "file regexp '" . dbesc($str) . "' ";
}
+// ex. given music,video return <music><video> or [music][video]
+function file_tag_list_to_file($list,$type = 'file') {
+ $tag_list = '';
+ if(strlen($list)) {
+ $list_array = explode(",",$list);
+ if($type == 'file') {
+ $lbracket = '[';
+ $rbracket = ']';
+ }
+ else {
+ $lbracket = '<';
+ $rbracket = '>';
+ }
+
+ foreach($list_array as $item) {
+ if(strlen($item)) {
+ $tag_list .= $lbracket . file_tag_encode(trim($item)) . $rbracket;
+ }
+ }
+ }
+ return $tag_list;
+}
+
+// ex. given <music><video>[friends], return music,video or friends
+function file_tag_file_to_list($file,$type = 'file') {
+ $matches = false;
+ $list = '';
+ if($type == 'file') {
+ $cnt = preg_match_all('/\[(.*?)\]/',$file,$matches,PREG_SET_ORDER);
+ }
+ else {
+ $cnt = preg_match_all('/<(.*?)>/',$file,$matches,PREG_SET_ORDER);
+ }
+ if($cnt) {
+ foreach($matches as $mtch) {
+ if(strlen($list))
+ $list .= ',';
+ $list .= file_tag_decode($mtch[1]);
+ }
+ }
+
+ return $list;
+}
+
+function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
+ // $file_old - categories previously associated with an item
+ // $file_new - new list of categories for an item
+
+ if(! intval($uid))
+ return false;
+
+ if($file_old == $file_new)
+ return true;
+
+ $saved = get_pconfig($uid,'system','filetags');
+ if(strlen($saved)) {
+ if($type == 'file') {
+ $lbracket = '[';
+ $rbracket = ']';
+ }
+ else {
+ $lbracket = '<';
+ $rbracket = '>';
+ }
+
+ $filetags_updated = $saved;
+
+ // check for new tags to be added as filetags in pconfig
+ $new_tags = array();
+ $check_new_tags = explode(",",file_tag_file_to_list($file_new,$type));
+
+ foreach($check_new_tags as $tag) {
+ if(! stristr($saved,$lbracket . file_tag_encode($tag) . $rbracket))
+ $new_tags[] = $tag;
+ }
+
+ $filetags_updated .= file_tag_list_to_file(implode(",",$new_tags),$type);
+
+ // check for deleted tags to be removed from filetags in pconfig
+ $deleted_tags = array();
+ $check_deleted_tags = explode(",",file_tag_file_to_list($file_old,$type));
+
+ foreach($check_deleted_tags as $tag) {
+ if(! stristr($file_new,$lbracket . file_tag_encode($tag) . $rbracket))
+ $deleted_tags[] = $tag;
+ }
+
+ foreach($deleted_tags as $key => $tag) {
+ $r = q("select file from item where uid = %d " . file_tag_file_query('item',$tag,$type),
+ intval($uid)
+ );
+
+ if(count($r)) {
+ unset($deleted_tags[$key]);
+ }
+ else {
+ $filetags_updated = str_replace($lbracket . file_tag_encode($tag) . $rbracket,'',$filetags_updated);
+ }
+ }
+
+ if($saved != $filetags_updated) {
+ set_pconfig($uid,'system','filetags', $filetags_updated);
+ }
+ return true;
+ }
+ else
+ if(strlen($file_new)) {
+ set_pconfig($uid,'system','filetags', $file_new);
+ }
+ return true;
+}
+
function file_tag_save_file($uid,$item,$file) {
$result = false;
if(! intval($uid))
@@ -1300,6 +1451,7 @@ function file_tag_save_file($uid,$item,$file) {
$saved = get_pconfig($uid,'system','filetags');
if((! strlen($saved)) || (! stristr($saved,'[' . file_tag_encode($file) . ']')))
set_pconfig($uid,'system','filetags',$saved . '[' . file_tag_encode($file) . ']');
+ info( t('Item filed') );
}
return true;
}
@@ -1338,3 +1490,16 @@ function file_tag_unsave_file($uid,$item,$file) {
function normalise_openid($s) {
return trim(str_replace(array('http://','https://'),array('',''),$s),'/');
}
+
+
+function undo_post_tagging($s) {
+ $matches = null;
+ $cnt = preg_match_all('/([@#])\[url=(.*?)\](.*?)\[\/url\]/ism',$s,$matches,PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ $s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s);
+ }
+ }
+ return $s;
+}
+