aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Willingham <founder@kakste.com>2012-04-24 02:18:51 +0100
committerThomas Willingham <founder@kakste.com>2012-04-24 02:18:51 +0100
commit8a80ea24d1d8039be6dc532c9db23c60e71eb467 (patch)
tree7f94f8d1e2336bbb7e69a327a003b6880f0610c0 /include
parentc4f4715a541ad89dfd348f14c4e25a83006e74e7 (diff)
parentaf7abcea2715824cbd6460a7323c8bb64bd5b829 (diff)
downloadvolse-hubzilla-8a80ea24d1d8039be6dc532c9db23c60e71eb467.tar.gz
volse-hubzilla-8a80ea24d1d8039be6dc532c9db23c60e71eb467.tar.bz2
volse-hubzilla-8a80ea24d1d8039be6dc532c9db23c60e71eb467.zip
Merge remote-tracking branch 'upstream/master'
Merge upstream
Diffstat (limited to 'include')
-rw-r--r--[-rwxr-xr-x]include/Contact.php53
-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.php6
-rw-r--r--[-rwxr-xr-x]include/acl_selectors.php0
-rw-r--r--[-rwxr-xr-x]include/api.php342
-rw-r--r--[-rwxr-xr-x]include/attach.php0
-rw-r--r--[-rwxr-xr-x]include/auth.php0
-rw-r--r--[-rwxr-xr-x]include/bb2diaspora.php0
-rw-r--r--include/bbcode.php6
-rw-r--r--[-rwxr-xr-x]include/cache.php0
-rw-r--r--[-rwxr-xr-x]include/config.php1
-rw-r--r--[-rwxr-xr-x]include/contact_selectors.php0
-rw-r--r--[-rwxr-xr-x]include/contact_widgets.php30
-rw-r--r--[-rwxr-xr-x]include/conversation.php30
-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.php10
-rw-r--r--[-rwxr-xr-x]include/dba.php4
-rw-r--r--[-rwxr-xr-x]include/delivery.php8
-rw-r--r--[-rwxr-xr-x]include/diaspora.php25
-rw-r--r--[-rwxr-xr-x]include/directory.php0
-rw-r--r--[-rwxr-xr-x]include/email.php0
-rw-r--r--[-rwxr-xr-x]include/enotify.php0
-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.php1
-rw-r--r--[-rwxr-xr-x]include/html2bbcode.php0
-rw-r--r--include/html2plain.php7
-rw-r--r--[-rwxr-xr-x]include/items.php111
-rw-r--r--[-rwxr-xr-x]include/message.php0
-rw-r--r--[-rwxr-xr-x]include/nav.php0
-rw-r--r--[-rwxr-xr-x]include/network.php84
-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.php0
-rw-r--r--[-rwxr-xr-x]include/pgettext.php1
-rw-r--r--include/pidfile.php32
-rw-r--r--[-rwxr-xr-x]include/plugin.php9
-rw-r--r--[-rwxr-xr-x]include/poller.php10
-rw-r--r--[-rwxr-xr-x]include/profile_advanced.php15
-rw-r--r--[-rwxr-xr-x]include/profile_selectors.php2
-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--[-rwxr-xr-x]include/remoteupdate.php0
-rw-r--r--[-rwxr-xr-x]include/salmon.php0
-rwxr-xr-xinclude/security.php5
-rw-r--r--[-rwxr-xr-x]include/session.php0
-rw-r--r--[-rwxr-xr-x]include/socgraph.php0
-rw-r--r--[-rwxr-xr-x]include/system_unavailable.php0
-rw-r--r--[-rwxr-xr-x]include/template_processor.php4
-rw-r--r--include/text.php150
54 files changed, 843 insertions, 114 deletions
diff --git a/include/Contact.php b/include/Contact.php
index d9949b1ef..9ba1e8ae5 100755..100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -23,16 +23,24 @@ function user_remove($uid) {
);
q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid));
+ q("DELETE FROM `gcign` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `group` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `group_member` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `intro` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `event` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `item` WHERE `uid` = %d", intval($uid));
+ q("DELETE FROM `item_id` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `mail` WHERE `uid` = %d", intval($uid));
+ q("DELETE FROM `mailacct` WHERE `uid` = %d", intval($uid));
+ q("DELETE FROM `manage` WHERE `uid` = %d", intval($uid));
+ q("DELETE FROM `notify` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `photo` WHERE `uid` = %d", intval($uid));
+ q("DELETE FROM `attach` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `profile` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `profile_check` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($uid));
+ q("DELETE FROM `search` WHERE `uid` = %d", intval($uid));
+ q("DELETE FROM `spam` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `user` WHERE `uid` = %d", intval($uid));
if($uid == local_user()) {
unset($_SESSION['authenticated']);
@@ -134,11 +142,11 @@ function contact_photo_menu($contact) {
$posts_link = $a->get_baseurl() . '/network/?cid=' . $contact['id'];
$menu = Array(
- t("View status") => $status_link,
- t("View profile") => $profile_link,
- t("View photos") => $photos_link,
- t("View recent") => $posts_link,
- t("Edit contact") => $contact_url,
+ t("View Status") => $status_link,
+ t("View Profile") => $profile_link,
+ t("View Photos") => $photos_link,
+ t("Network Posts") => $posts_link,
+ t("Edit Contact") => $contact_url,
t("Send PM") => $pm_url,
);
@@ -150,7 +158,7 @@ function contact_photo_menu($contact) {
$o = "";
foreach($menu as $k=>$v){
if ($v!="") {
- if(($k !== t("View recent")) && ($k !== t("Send PM")))
+ if(($k !== t("Network Posts")) && ($k !== t("Send PM")) && ($k !== t('Edit Contact')))
$o .= "<li><a target=\"redir\" href=\"$v\">$k</a></li>\n";
else
$o .= "<li><a href=\"$v\">$k</a></li>\n";
@@ -158,3 +166,36 @@ function contact_photo_menu($contact) {
}
return $o;
}}
+
+
+function random_profile() {
+ $r = q("select url from gcontact where url like '%%://%%/profile/%%' order by rand() limit 1");
+ if(count($r))
+ return dirname($r[0]['url']);
+ return '';
+}
+
+
+function contacts_not_grouped($uid,$start = 0,$count = 0) {
+
+ if(! $count) {
+ $r = q("select count(*) as total from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) ",
+ intval($uid),
+ intval($uid)
+ );
+
+ return $r;
+
+
+ }
+
+ $r = q("select * from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) and blocked = 0 and pending = 0 limit %d, %d",
+ intval($uid),
+ intval($uid),
+ intval($start),
+ intval($count)
+ );
+
+ return $r;
+}
+
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..b20d7d604 100755..100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
@@ -446,7 +446,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$phost = substr($url,strpos($url,'@')+1);
$profile = 'http://' . $phost;
// fix nick character range
- $vcard = array('fn' => $name, 'nick' => $name, 'photo' => gravatar_img($url));
+ $vcard = array('fn' => $name, 'nick' => $name, 'photo' => avatar_img($url));
$notify = 'smtp ' . random_string();
$poll = 'email ' . random_string();
$priority = 0;
@@ -593,7 +593,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA);
$a = get_app();
- logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), $LOGGER_DATA);
+ logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), LOGGER_DATA);
$feed->set_raw_data($xml);
@@ -655,7 +655,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
}
if((! $vcard['photo']) && strlen($email))
- $vcard['photo'] = gravatar_img($email);
+ $vcard['photo'] = avatar_img($email);
if($poll === $profile)
$lnk = $feed->get_permalink();
if(isset($lnk) && strlen($lnk))
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 065f14cff..f9be68c3d 100755..100644
--- a/include/api.php
+++ b/include/api.php
@@ -121,6 +121,7 @@
if (strpos($a->query_string, ".json")>0) $type="json";
if (strpos($a->query_string, ".rss")>0) $type="rss";
if (strpos($a->query_string, ".atom")>0) $type="atom";
+ if (strpos($a->query_string, ".as")>0) $type="as";
$r = call_user_func($info['func'], $a, $type);
if ($r===false) return;
@@ -144,6 +145,12 @@
header ("Content-Type: application/atom+xml");
return '<?xml version="1.0" encoding="UTF-8"?>'."\n".$r;
break;
+ case "as":
+ //header ("Content-Type: application/json");
+ //foreach($r as $rr)
+ // return json_encode($rr);
+ return json_encode($r);
+ break;
}
//echo "<pre>"; var_dump($r); die();
@@ -560,8 +567,17 @@
$_REQUEST['profile_uid'] = local_user();
if(requestdata('parent'))
$_REQUEST['type'] = 'net-comment';
- else
+ else {
$_REQUEST['type'] = 'wall';
+ if(x($_FILES,'media')) {
+ // upload the image if we have one
+ $_REQUEST['hush']='yeah'; //tell wall_upload function to return img info instead of echo
+ require_once('mod/wall_upload.php');
+ $media = wall_upload_post($a);
+ if(strlen($media)>0)
+ $_REQUEST['body'] .= "\n\n".$media;
+ }
+ }
// set this so that the item_post() function is quiet and doesn't redirect or emit json
@@ -737,6 +753,13 @@
case "atom":
case "rss":
$data = api_rss_extra($a, $data, $user_info);
+ break;
+ case "as":
+ $as = api_format_as($a, $ret, $user_info);
+ $as['title'] = $a->config['sitename']." Home Timeline";
+ $as['link']['url'] = $a->get_baseurl()."/".$user_info["screen_name"]."/all";
+ return($as);
+ break;
}
return api_apply_template("timeline", $type, $data);
@@ -744,6 +767,85 @@
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_public_timeline(&$a, $type){
+ if (local_user()===false) return false;
+
+ $user_info = api_get_user($a);
+ // get last newtork messages
+
+
+ // params
+ $count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
+ $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
+ if ($page<0) $page=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`,
+ `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 `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
+ AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
+ AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
+ AND `contact`.`id` = `item`.`contact-id`
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ $sql_extra
+ AND `item`.`id`>%d
+ ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
+ intval($since_id),
+ intval($start), intval($count)
+ );*/
+ $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
+ `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
+ `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
+ `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
+ `user`.`nickname`, `user`.`hidewall`
+ FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+ LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
+ WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
+ AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
+ AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
+ AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ $sql_extra
+ AND `item`.`id`>%d
+ ORDER BY `received` DESC LIMIT %d, %d ",
+ intval($since_id),
+ intval($start),
+ intval($count));
+
+ $ret = api_format_items($r,$user_info);
+
+
+ $data = array('$statuses' => $ret);
+ switch($type){
+ case "atom":
+ case "rss":
+ $data = api_rss_extra($a, $data, $user_info);
+ break;
+ case "as":
+ $as = api_format_as($a, $ret, $user_info);
+ $as['title'] = $a->config['sitename']." Public Timeline";
+ $as['link']['url'] = $a->get_baseurl()."/";
+ return($as);
+ break;
+ }
+
+ return api_apply_template("timeline", $type, $data);
+ }
+ api_register_func('api/statuses/public_timeline','api_statuses_public_timeline', true);
+
/**
*
*/
@@ -784,8 +886,152 @@
}
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_repeat(&$a, $type){
+ if (local_user()===false) return false;
+
+ $user_info = api_get_user($a);
+
+ // params
+ $id = intval($a->argv[3]);
+
+ logger('API: api_statuses_repeat: '.$id);
+
+ //$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
+
+ $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`nick` as `reply_author`,
+ `contact`.`name`, `contact`.`photo`, `contact`.`url` as `reply_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)
+ );
+
+ $_REQUEST['body'] = html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8')."[url=".$r[0]['reply_url']."]".$r[0]['reply_author']."[/url] \n".$r[0]['body'];
+ $_REQUEST['profile_uid'] = local_user();
+ $_REQUEST['type'] = 'wall';
+ $_REQUEST['api_source'] = true;
+
+ require_once('mod/item.php');
+ item_post($a);
+
+ if ($type == 'xml')
+ $ok = "true";
+ else
+ $ok = "ok";
+
+ return api_apply_template('test', $type, array('$ok' => $ok));
+ }
+ api_register_func('api/statuses/retweet','api_statuses_repeat', true);
+
+ /**
+ *
+ */
+ function api_statuses_destroy(&$a, $type){
+ if (local_user()===false) return false;
+
+ $user_info = api_get_user($a);
+
+ // params
+ $id = intval($a->argv[3]);
+
+ logger('API: api_statuses_destroy: '.$id);
+
+ require_once('include/items.php');
+ drop_item($id, false);
+
+ if ($type == 'xml')
+ $ok = "true";
+ else
+ $ok = "ok";
+
+ return api_apply_template('test', $type, array('$ok' => $ok));
+ }
+ api_register_func('api/statuses/destroy','api_statuses_destroy', true);
+
+ /**
+ *
+ * http://developer.twitter.com/doc/get/statuses/mentions
+ *
+ */
+ function api_statuses_mentions(&$a, $type){
+ if (local_user()===false) return false;
+
+ $user_info = api_get_user($a);
+ // get last newtork messages
+
+
+ // params
+ $count = (x($_REQUEST,'count')?$_REQUEST['count']:20);
+ $page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
+ if ($page<0) $page=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);
+
+ $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
+ $myurl = substr($myurl,strpos($myurl,'://')+3);
+ $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
+ $diasp_url = str_replace('/profile/','/u/',$myurl);
+ $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` regexp '%s' or `tag` regexp '%s' or tag regexp '%s' )) ",
+ dbesc($myurl . '$'),
+ dbesc($myurl . '\\]'),
+ dbesc($diasp_url . '\\]')
+ );
+
+ 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`,
+ `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ FROM `item`, `contact`
+ WHERE `item`.`uid` = %d
+ AND `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
+ ORDER BY `item`.`received` DESC LIMIT %d ,%d ",
+ intval($user_info['uid']),
+ intval($since_id),
+ intval($start), intval($count)
+ );
+
+ $ret = api_format_items($r,$user_info);
+
+
+ $data = array('$statuses' => $ret);
+ switch($type){
+ case "atom":
+ case "rss":
+ $data = api_rss_extra($a, $data, $user_info);
+ break;
+ case "as":
+ $as = api_format_as($a, $ret, $user_info);
+ $as["title"] = $a->config['sitename']." Mentions";
+ $as['link']['url'] = $a->get_baseurl()."/";
+ return($as);
+ break;
+ }
+
+ return api_apply_template("timeline", $type, $data);
+ }
+ 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){
@@ -898,6 +1144,70 @@
api_register_func('api/favorites','api_favorites', true);
+ function api_format_as($a, $ret, $user_info) {
+
+ $as = array();
+ $as['title'] = $a->config['sitename']." Public Timeline";
+ $items = array();
+ foreach ($ret as $item) {
+ $singleitem["actor"]["displayName"] = $item["user"]["name"];
+ $singleitem["actor"]["id"] = $item["user"]["contact_url"];
+ $avatar[0]["url"] = $item["user"]["profile_image_url"];
+ $avatar[0]["rel"] = "avatar";
+ $avatar[0]["type"] = "";
+ $avatar[0]["width"] = 96;
+ $avatar[0]["height"] = 96;
+ $avatar[1]["url"] = $item["user"]["profile_image_url"];
+ $avatar[1]["rel"] = "avatar";
+ $avatar[1]["type"] = "";
+ $avatar[1]["width"] = 48;
+ $avatar[1]["height"] = 48;
+ $avatar[2]["url"] = $item["user"]["profile_image_url"];
+ $avatar[2]["rel"] = "avatar";
+ $avatar[2]["type"] = "";
+ $avatar[2]["width"] = 24;
+ $avatar[2]["height"] = 24;
+ $singleitem["actor"]["avatarLinks"] = $avatar;
+
+ $singleitem["actor"]["image"]["url"] = $item["user"]["profile_image_url"];
+ $singleitem["actor"]["image"]["rel"] = "avatar";
+ $singleitem["actor"]["image"]["type"] = "";
+ $singleitem["actor"]["image"]["width"] = 96;
+ $singleitem["actor"]["image"]["height"] = 96;
+ $singleitem["actor"]["type"] = "person";
+ $singleitem["actor"]["url"] = $item["person"]["contact_url"];
+ $singleitem["actor"]["statusnet:profile_info"]["local_id"] = $item["user"]["id"];
+ $singleitem["actor"]["statusnet:profile_info"]["following"] = $item["user"]["following"] ? "true" : "false";
+ $singleitem["actor"]["statusnet:profile_info"]["blocking"] = "false";
+ $singleitem["actor"]["contact"]["preferredUsername"] = $item["user"]["screen_name"];
+ $singleitem["actor"]["contact"]["displayName"] = $item["user"]["name"];
+ $singleitem["actor"]["contact"]["addresses"] = "";
+
+ $singleitem["body"] = $item["text"];
+ $singleitem["object"]["displayName"] = $item["text"];
+ $singleitem["object"]["id"] = $item["url"];
+ $singleitem["object"]["type"] = "note";
+ $singleitem["object"]["url"] = $item["url"];
+ //$singleitem["context"] =;
+ $singleitem["postedTime"] = date("c", strtotime($item["published"]));
+ $singleitem["provider"]["objectType"] = "service";
+ $singleitem["provider"]["displayName"] = "Test";
+ $singleitem["provider"]["url"] = "http://test.tld";
+ $singleitem["title"] = $item["text"];
+ $singleitem["verb"] = "post";
+ $singleitem["statusnet:notice_info"]["local_id"] = $item["id"];
+ $singleitem["statusnet:notice_info"]["source"] = $item["source"];
+ $singleitem["statusnet:notice_info"]["favorite"] = "false";
+ $singleitem["statusnet:notice_info"]["repeated"] = "false";
+ //$singleitem["original"] = $item;
+ $items[] = $singleitem;
+ }
+ $as['items'] = $items;
+ $as['link']['url'] = $a->get_baseurl()."/".$user_info["screen_name"]."/all";
+ $as['link']['rel'] = "alternate";
+ $as['link']['type'] = "text/html";
+ return($as);
+ }
function api_format_items($r,$user_info) {
@@ -932,8 +1242,17 @@
$in_reply_to_status_id = 0;
}
+ // Workaround for ostatus messages where the title is identically to the body
+ $statusbody = trim(html2plain(bbcode($item['body']), 0));
+ $statustitle = trim($item['title']);
+
+ if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false))
+ $statustext = trim($statusbody);
+ else
+ $statustext = trim($statustitle."\n\n".$statusbody);
+
$status = array(
- 'text' => trim($item['title']." \n".html2plain(bbcode($item['body']), 0)),
+ 'text' => $statustext,
'truncated' => False,
'created_at'=> api_date($item['created']),
'in_reply_to_status_id' => $in_reply_to_status_id,
@@ -944,8 +1263,8 @@
'geo' => '',
'favorited' => $item['starred'] ? true : false,
'user' => $status_user ,
- 'statusnet_html' => bbcode($item['body']),
- 'statusnet_conversation_id' => 0,
+ 'statusnet_html' => trim(bbcode($item['body'])),
+ 'statusnet_conversation_id' => $item['parent'],
);
// Seesmic doesn't like the following content
@@ -1309,12 +1628,10 @@
/*
Not implemented by now:
-statuses/public_timeline
-statuses/mentions
-statuses/replies
+favorites
+favorites/create
+favorites/destroy
statuses/retweets_of_me
-statuses/destroy
-statuses/retweet
friendships/create
friendships/destroy
friendships/exists
@@ -1322,9 +1639,6 @@ 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
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 1341f3bb8..1341f3bb8 100755..100644
--- a/include/auth.php
+++ b/include/auth.php
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 9befbd0f7..85d310b75 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -230,7 +230,8 @@ function bbcode($Text,$preserve_nl = false) {
$Text);
// [img=widthxheight]image source[/img]
- $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
+ //$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
+ $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="width: $1px;" >', $Text);
// Images
// [img]pathtoimage[/img]
@@ -297,6 +298,9 @@ function bbcode($Text,$preserve_nl = false) {
$Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_unspacefy_and_trim',$Text);
$Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_unspacefy_and_trim',$Text);
+
+ $Text = preg_replace('/\[\&amp\;([#a-z0-9]+)\;\]/','&$1;',$Text);
+
// fix any escaped ampersands that may have been converted into links
$Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
if(strlen($saved_image))
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 2cddda0b8..4cff38090 100755..100644
--- a/include/config.php
+++ b/include/config.php
@@ -80,6 +80,7 @@ function set_config($family,$key,$value) {
// manage array value
$dbvalue = (is_array($value)?serialize($value):$value);
+ $dbvalue = (is_bool($value) ? intval($value) : $value);
if(get_config($family,$key,true) === false) {
$a->config[$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 7346b95af..96b02f293 100755..100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -12,6 +12,7 @@ function follow_widget() {
}
function findpeople_widget() {
+ require_once('include/Contact.php');
$a = get_app();
@@ -32,6 +33,7 @@ function findpeople_widget() {
'$findthem' => t('Find'),
'$suggest' => t('Friend Suggestions'),
'$similar' => t('Similar Interests'),
+ '$random' => t('Random Profile'),
'$inv' => t('Invite Friends')
));
@@ -103,3 +105,31 @@ function fileas_widget($baseurl,$selected = '') {
));
}
+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'),
+ '$terms' => $terms,
+ '$base' => $baseurl,
+
+ ));
+}
+
diff --git a/include/conversation.php b/include/conversation.php
index 5a922b2b5..1b869b91e 100755..100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -342,7 +342,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'body' => template_escape($body),
'text' => strip_tags(template_escape($body)),
'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
- 'lock' => $lock,
'location' => template_escape($location),
'indent' => '',
'owner_name' => template_escape($owner_name),
@@ -400,6 +399,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
}
$comments_collapsed = false;
+ $comments_seen = 0;
$comment_lastcollapsed = false;
$comment_firstcollapsed = false;
$blowhard = 0;
@@ -559,10 +559,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
}
}
- $edpost = (((($profile_owner == local_user()) && ($toplevelpost) && (intval($item['wall']) == 1)) || ($mode === 'notes'))
- ? array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"))
- : False);
-
+ if(local_user() && link_compare($a->contact['url'],$item['author-link']))
+ $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
+ else
+ $edpost = false;
$drop = '';
$dropping = false;
@@ -626,10 +626,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
else
$profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb);
-
-
-
-
$like = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
$dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
@@ -713,7 +709,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
}
$page_template = get_markup_template("conversation.tpl");
- $o .= replace_macros($page_template, array(
+ $o = replace_macros($page_template, array(
'$baseurl' => $a->get_baseurl($ssl_state),
'$mode' => $mode,
'$user' => $a->user,
@@ -810,11 +806,11 @@ function item_photo_menu($item){
}
$menu = Array(
- t("View status") => $status_link,
- t("View profile") => $profile_link,
- t("View photos") => $photos_link,
- t("View recent") => $posts_link,
- t("Edit contact") => $contact_url,
+ t("View Status") => $status_link,
+ t("View Profile") => $profile_link,
+ t("View Photos") => $photos_link,
+ t("Network Posts") => $posts_link,
+ t("Edit Contact") => $contact_url,
t("Send PM") => $pm_url,
);
@@ -974,6 +970,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'),
@@ -1076,7 +1074,6 @@ function find_thread_parent_index($arr,$x) {
}
function render_location_google($item) {
- $location = '';
$location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
$coord = (($item['coord']) ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
if($coord) {
@@ -1087,4 +1084,3 @@ function render_location_google($item) {
}
return $location;
}
-
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..f4dcfce62 100755..100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -80,6 +80,16 @@ function field_timezone($name='timezone', $label='', $current = 'America/Los_Ang
if(! function_exists('datetime_convert')) {
function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") {
+ // Defaults to UTC if nothing is set, but throws an exception if set to empty string.
+ // Provide some sane defaults regardless.
+
+ if($from === '')
+ $from = 'UTC';
+ if($to === '')
+ $to = 'UTC';
+ if($s === '')
+ $s = 'now';
+
// Slight hackish adjustment so that 'zero' datetime actually returns what is intended
// otherwise we end up with -0001-11-30 ...
// add 32 days so that we at least get year 00, and then hack around the fact that
diff --git a/include/dba.php b/include/dba.php
index 76cc0bc7b..44a663eac 100755..100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -260,6 +260,4 @@ function dbesc_array(&$arr) {
if(is_array($arr) && count($arr)) {
array_walk($arr,'dbesc_array_cb');
}
-}}
-
-
+}}
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 104ccadf2..afd86957b 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(
@@ -1160,7 +1172,7 @@ function diaspora_comment($importer,$xml,$msg) {
proc_run('php','include/notifier.php','comment',$message_id);
}
- $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 ",
+ $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0 ",
dbesc($parent_item['uri']),
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 b43ae0dc1..b43ae0dc1 100755..100644
--- a/include/email.php
+++ b/include/email.php
diff --git a/include/enotify.php b/include/enotify.php
index 8385bdec5..8385bdec5 100755..100644
--- a/include/enotify.php
+++ b/include/enotify.php
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..edb547de6 100755..100644
--- a/include/group.php
+++ b/include/group.php
@@ -212,6 +212,7 @@ function group_side($every="contacts",$each="group",$edit = false, $group_id = 0
'$title' => t('Groups'),
'$edittext' => t('Edit group'),
'$createtext' => t('Create a new group'),
+ '$ungrouped' => (($every === 'contacts') ? t('Contacts not in any group') : ''),
'$groups' => $groups,
'$add' => t('add'),
));
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 fe0e3326e..21261327d 100644
--- a/include/html2plain.php
+++ b/include/html2plain.php
@@ -83,12 +83,15 @@ function collecturls($message) {
$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/",
+ $list = array("/user/", "/tag/", "/group/", "/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 ((strpos($treffer[1], "//plus.google.com/") !== false) and (strpos($treffer[1], "/posts") !== false))
+ $ignore = false;
+
if (!$ignore)
$urls[$treffer[1]] = $treffer[1];
}
@@ -154,7 +157,7 @@ function html2plain($html, $wraplength = 75, $compact = false)
//node2bbcode($doc, 'ol', array(), "\n[list=1]", "[/list]\n");
node2bbcode($doc, 'li', array(), "\n* ", "\n");
- node2bbcode($doc, 'hr', array(), str_repeat("-", 70), "");
+ node2bbcode($doc, 'hr', array(), "\n".str_repeat("-", 70)."\n", "");
node2bbcode($doc, 'tr', array(), "\n", "");
node2bbcode($doc, 'td', array(), "\t", "");
diff --git a/include/items.php b/include/items.php
index ee6960534..07f62ece5 100755..100644
--- a/include/items.php
+++ b/include/items.php
@@ -19,9 +19,15 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
$converse = true;
if($a->argv[$x] == 'starred')
$starred = true;
+ if($a->argv[$x] === 'category' && $a->argc > ($x + 1) && strlen($a->argv[$x+1]))
+ $category = $a->argv[$x+1];
}
+
+
}
+
+
// default permissions - anonymous user
$sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
@@ -101,6 +107,10 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
if(! strlen($last_update))
$last_update = 'now -30 days';
+ if(isset($category)) {
+ $sql_extra .= file_tag_file_query('item',$category,'category');
+ }
+
if($public_feed) {
if(! $converse)
$sql_extra .= " AND `contact`.`self` = 1 ";
@@ -578,20 +588,21 @@ function get_atom_elements($feed,$item) {
if($rawobj) {
$res['object'] = '<object>' . "\n";
- if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
- $res['object-type'] = $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'];
- $res['object'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
+ $child = $rawobj[0]['child'];
+ if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
+ $res['object-type'] = $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'];
+ $res['object'] .= '<type>' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
}
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
- $res['object'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
- $res['object'] .= '<link>' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
- $res['object'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
- $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
+ $res['object'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
+ $res['object'] .= '<link>' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'title') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
+ $res['object'] .= '<title>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'content') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
+ $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
if(! $body)
- $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
+ $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
// preserve a copy of the original body content in case we later need to parse out any microformat information, e.g. events
$res['object'] .= '<orig>' . xmlify($body) . '</orig>' . "\n";
if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
@@ -616,20 +627,20 @@ function get_atom_elements($feed,$item) {
if($rawobj) {
$res['target'] = '<target>' . "\n";
- if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
- $res['target'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
+ $child = $rawobj[0]['child'];
+ if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
+ $res['target'] .= '<type>' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
}
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
- $res['target'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
-
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
- $res['target'] .= '<link>' . encode_rel_links($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
- $res['target'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
- if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
- $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
+ $res['target'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
+ $res['target'] .= '<link>' . encode_rel_links($child[SIMPLEPIE_NAMESPACE_ATOM_10]['link']) . '</link>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'data') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
+ $res['target'] .= '<title>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
+ if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'data') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
+ $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
if(! $body)
- $body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
+ $body = $child[SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
// preserve a copy of the original body content in case we later need to parse out any microformat information, e.g. events
$res['target'] .= '<orig>' . xmlify($body) . '</orig>' . "\n";
if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
@@ -1465,7 +1476,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(! $item['deleted'])
logger('consume_feed: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
- if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTVITY_OBJ_TAGTERM)) {
+ if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item['object'],false);
$xt = parse_xml_string($item['target'],false);
if($xt->type === ACTIVITY_OBJ_NOTE) {
@@ -1856,6 +1867,8 @@ function local_delivery($importer,$data) {
$feed->enable_order_by_date(false);
$feed->init();
+/*
+ // Currently unsupported - needs a lot of work
$reloc = $feed->get_feed_tags( NAMESPACE_DFRN, 'relocate' );
if(isset($reloc[0]['child'][NAMESPACE_DFRN])) {
$base = $reloc[0]['child'][NAMESPACE_DFRN];
@@ -1880,6 +1893,7 @@ function local_delivery($importer,$data) {
// schedule a scan?
}
+*/
// handle friend suggestion notification
@@ -2078,7 +2092,7 @@ function local_delivery($importer,$data) {
logger('local_delivery: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
- if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTVITY_OBJ_TAGTERM)) {
+ if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item['object'],false);
$xt = parse_xml_string($item['target'],false);
@@ -2216,6 +2230,34 @@ function local_delivery($importer,$data) {
$datarray = get_atom_elements($feed,$item);
+ $r = q("SELECT `id`, `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($item_id),
+ intval($importer['importer_uid'])
+ );
+
+ // Update content if 'updated' changes
+
+ if(count($r)) {
+ $iid = $r[0]['id'];
+ if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
+ logger('received updated comment' , LOGGER_DEBUG);
+ $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'])
+ );
+
+ proc_run('php',"include/notifier.php","comment-import",$iid);
+
+ }
+
+ continue;
+ }
+
+
// TODO: make this next part work against both delivery threads of a community post
// if((! link_compare($datarray['author-link'],$importer['url'])) && (! $community)) {
@@ -2435,9 +2477,9 @@ function local_delivery($importer,$data) {
// find out if our user is involved in this conversation and wants to be notified.
- if($datarray['type'] != 'activity') {
+ if(!x($datarray['type']) || $datarray['type'] != 'activity') {
- $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 ",
+ $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0",
dbesc($parent_uri),
intval($importer['importer_uid'])
);
@@ -2971,12 +3013,23 @@ function item_expire($uid,$days) {
if($expire_items==0 && $item['type']!='note')
continue;
+
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
);
+ $r = q("DELETE FROM item_id where iid in (select id from item where parent = %d) and uid = %d",
+ intval($item['id']),
+ intval($uid)
+ );
+
+ $r = q("DELETE FROM sign where iid in (select id from item where parent = %d) and uid = %d",
+ intval($item['id']),
+ intval($uid)
+ );
+
// kill the kids
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
@@ -2996,7 +3049,7 @@ function item_expire($uid,$days) {
function drop_items($items) {
$uid = 0;
- if((! local_user()) && (! $remote_user()))
+ if(! local_user() && ! remote_user())
return;
if(count($items)) {
diff --git a/include/message.php b/include/message.php
index 377d7c715..377d7c715 100755..100644
--- a/include/message.php
+++ b/include/message.php
diff --git a/include/nav.php b/include/nav.php
index 2c9c643a9..2c9c643a9 100755..100644
--- a/include/nav.php
+++ b/include/nav.php
diff --git a/include/network.php b/include/network.php
index 9e1ed2091..4bec4a172 100755..100644
--- a/include/network.php
+++ b/include/network.php
@@ -172,7 +172,7 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
$url_parsed = @parse_url($newurl);
if (isset($url_parsed)) {
$redirects++;
- return fetch_url($newurl,$binary,$redirects,$timeout);
+ return fetch_url($newurl,false,$redirects,$timeout);
}
}
$a->set_curl_code($http_code);
@@ -206,6 +206,7 @@ function xml_status($st, $message = '') {
if(! function_exists('http_status_exit')) {
function http_status_exit($val) {
+ $err = '';
if($val >= 400)
$err = 'Error';
if($val >= 200 && $val < 300)
@@ -452,7 +453,7 @@ function lrdd($uri, $debug = false) {
logger('lrdd: parse error: ' . $e);
}
- if($dom) {
+ if(isset($dom) && $dom) {
$items = $dom->getElementsByTagName('link');
foreach($items as $item) {
$x = $item->getAttribute('rel');
@@ -587,13 +588,14 @@ function fetch_xrd_links($url) {
if(! function_exists('validate_url')) {
function validate_url(&$url) {
- // no naked subdomains
- if(strpos($url,'.') === false)
+
+ // no naked subdomains (allow localhost for tests)
+ if(strpos($url,'.') === false && strpos($url,'/localhost/') === false)
return false;
if(substr($url,0,4) != 'http')
$url = 'http://' . $url;
$h = @parse_url($url);
-
+
if(($h) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR))) {
return true;
}
@@ -692,18 +694,23 @@ function allowed_email($email) {
}}
-if(! function_exists('gravatar_img')) {
-function gravatar_img($email) {
- $size = 175;
- $opt = 'identicon'; // psuedo-random geometric pattern if not found
- $rating = 'pg';
- $hash = md5(trim(strtolower($email)));
-
- $url = 'http://www.gravatar.com/avatar/' . $hash . '.jpg'
- . '?s=' . $size . '&d=' . $opt . '&r=' . $rating;
+if(! function_exists('avatar_img')) {
+function avatar_img($email) {
+
+ $a = get_app();
+
+ $avatar['size'] = 175;
+ $avatar['email'] = $email;
+ $avatar['url'] = '';
+ $avatar['success'] = false;
- logger('gravatar: ' . $email . ' ' . $url);
- return $url;
+ call_hooks('avatar_lookup', $avatar);
+
+ if(! $avatar['success'])
+ $avatar['url'] = $a->get_baseurl() . '/images/person-175.jpg';
+
+ logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url'], LOGGER_DEBUG);
+ return $avatar['url'];
}}
@@ -824,3 +831,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 1f45d2814..1f45d2814 100755..100644
--- a/include/oembed.php
+++ b/include/oembed.php
diff --git a/include/pgettext.php b/include/pgettext.php
index 83e76ba9d..a079a4687 100755..100644
--- a/include/pgettext.php
+++ b/include/pgettext.php
@@ -49,6 +49,7 @@ function get_language() {
if(isset($preferred))
return $preferred;
+ $a = get_app();
return ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
}}
diff --git a/include/pidfile.php b/include/pidfile.php
new file mode 100644
index 000000000..47df8d1f4
--- /dev/null
+++ b/include/pidfile.php
@@ -0,0 +1,32 @@
+<?php
+class pidfile {
+ private $_file;
+ private $_running;
+
+ public function __construct($dir, $name) {
+ $this->_file = "$dir/$name.pid";
+
+ if (file_exists($this->_file)) {
+ $pid = trim(file_get_contents($this->_file));
+ if (posix_kill($pid, 0)) {
+ $this->_running = true;
+ }
+ }
+
+ if (! $this->_running) {
+ $pid = getmypid();
+ file_put_contents($this->_file, $pid);
+ }
+ }
+
+ public function __destruct() {
+ if ((! $this->_running) && file_exists($this->_file)) {
+ unlink($this->_file);
+ }
+ }
+
+ public function is_already_running() {
+ return $this->_running;
+ }
+}
+?>
diff --git a/include/plugin.php b/include/plugin.php
index e37ae8435..8196e8756 100755..100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -17,7 +17,12 @@ function uninstall_plugin($plugin){
}}
if (! function_exists('install_plugin')){
-function install_plugin($plugin){
+function install_plugin($plugin) {
+
+ // silently fail if plugin was removed
+
+ if(! file_exists('addon/' . $plugin . '/' . $plugin . '.php'))
+ return false;
logger("Addons: installing " . $plugin);
$t = @filemtime('addon/' . $plugin . '/' . $plugin . '.php');
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
@@ -32,9 +37,11 @@ function install_plugin($plugin){
intval($t),
$plugin_admin
);
+ return true;
}
else {
logger("Addons: FAILED installing " . $plugin);
+ return false;
}
}}
diff --git a/include/poller.php b/include/poller.php
index 90a97867c..499483d00 100755..100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -25,10 +25,20 @@ function poller_run($argv, $argc){
require_once('include/Contact.php');
require_once('include/email.php');
require_once('include/socgraph.php');
+ require_once('include/pidfile.php');
load_config('config');
load_config('system');
+ $lockpath = get_config('system','lockpath');
+ if ($lockpath != '') {
+ $pidfile = new pidfile($lockpath, 'poller.lck');
+ if($pidfile->is_already_running()) {
+ logger("poller: Already running");
+ exit;
+ }
+ }
+
$a->set_baseurl(get_config('system','url'));
load_hooks();
diff --git a/include/profile_advanced.php b/include/profile_advanced.php
index 004a58524..bb9850cd0 100755..100644
--- a/include/profile_advanced.php
+++ b/include/profile_advanced.php
@@ -2,7 +2,7 @@
function advanced_profile(&$a) {
- $o .= '';
+ $o = '';
$o .= '<h2>' . t('Profile') . '</h2>';
@@ -69,13 +69,12 @@ function advanced_profile(&$a) {
if($txt = prepare_text($a->profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt);
if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
- }
-
-
- return replace_macros($tpl, array(
- '$title' => t('Profile'),
- '$profile' => $profile,
- ));
+ return replace_macros($tpl, array(
+ '$title' => t('Profile'),
+ '$profile' => $profile,
+ ));
+ }
+ return '';
}
diff --git a/include/profile_selectors.php b/include/profile_selectors.php
index 92579f64a..a2cef959d 100755..100644
--- a/include/profile_selectors.php
+++ b/include/profile_selectors.php
@@ -30,7 +30,7 @@ function sexpref_selector($current="",$suffix="") {
function marital_selector($current="",$suffix="") {
$o = '';
- $select = array('', t('Single'), t('Lonely'), t('Available'), t('Unavailable'), t('Dating'), t('Unfaithful'), t('Sex Addict'), t('Friends'), t('Friends/Benefits'), t('Casual'), t('Engaged'), t('Married'), t('Partners'), t('Cohabiting'), t('Happy'), t('Not Looking'), t('Swinger'), t('Betrayed'), t('Separated'), t('Unstable'), t('Divorced'), t('Widowed'), t('Uncertain'), t('Complicated'), t('Don\'t care'), t('Ask me') );
+ $select = array('', t('Single'), t('Lonely'), t('Available'), t('Unavailable'), t('Has crush'), t('Infatuated'), t('Dating'), t('Unfaithful'), t('Sex Addict'), t('Friends'), t('Friends/Benefits'), t('Casual'), t('Engaged'), t('Married'), t('Imaginarily married'), t('Partners'), t('Cohabiting'), t('Common law'), t('Happy'), t('Not looking'), t('Swinger'), t('Betrayed'), t('Separated'), t('Unstable'), t('Divorced'), t('Imaginarily divorced'), t('Widowed'), t('Uncertain'), t('It\'s complicated'), t('Don\'t care'), t('Ask me') );
$o .= "<select name=\"marital\" id=\"marital-select\" size=\"1\" >";
foreach($select as $selection) {
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/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 66622fd33..a92400b5c 100755
--- a/include/security.php
+++ b/include/security.php
@@ -326,7 +326,7 @@ function check_form_security_token($typename = '', $formname = 'form_security_to
}
function check_form_security_std_err_msg() {
- return t('The form security token was not correct. This probably happened because the form has been opened for too long (>3 hours) before subitting it.') . EOL;
+ return t('The form security token was not correct. This probably happened because the form has been opened for too long (>3 hours) before submitting it.') . EOL;
}
function check_form_security_token_redirectOnErr($err_redirect, $typename = '', $formname = 'form_security_token') {
if (!check_form_security_token($typename, $formname)) {
@@ -339,9 +339,10 @@ function check_form_security_token_redirectOnErr($err_redirect, $typename = '',
}
function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'form_security_token') {
if (!check_form_security_token($typename, $formname)) {
+ $a = get_app();
logger('check_form_security_token failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
logger('check_form_security_token failed: _REQUEST data: ' . print_r($_REQUEST, true), LOGGER_DATA);
header('HTTP/1.1 403 Forbidden');
killme();
}
-} \ No newline at end of file
+}
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 3f5194049..3f5194049 100755..100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
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..46252c355 100755..100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -13,12 +13,14 @@
var $debug=false;
private function _preg_error(){
+
switch(preg_last_error()){
case PREG_INTERNAL_ERROR: echo('PREG_INTERNAL_ERROR'); break;
case PREG_BACKTRACK_LIMIT_ERROR: echo('PREG_BACKTRACK_LIMIT_ERROR'); break;
case PREG_RECURSION_LIMIT_ERROR: echo('PREG_RECURSION_LIMIT_ERROR'); break;
case PREG_BAD_UTF8_ERROR: echo('PREG_BAD_UTF8_ERROR'); break;
- case PREG_BAD_UTF8_OFFSET_ERROR: echo('PREG_BAD_UTF8_OFFSET_ERROR'); break;
+// This is only valid for php > 5.3, not certain how to code around it for unit tests
+// case PREG_BAD_UTF8_OFFSET_ERROR: echo('PREG_BAD_UTF8_OFFSET_ERROR'); break;
default:
//die("Unknown preg error.");
return;
diff --git a/include/text.php b/include/text.php
index 191f4fca8..8c8db66a9 100644
--- a/include/text.php
+++ b/include/text.php
@@ -80,6 +80,9 @@ function escape_tags($string) {
if(! function_exists('autoname')) {
function autoname($len) {
+ if($len <= 0)
+ return '';
+
$vowels = array('a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u');
if(mt_rand(0,5) == 4)
$vowels[] = 'y';
@@ -225,6 +228,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'];
@@ -725,6 +731,8 @@ function smilies($s, $sample = false) {
'\\o/',
'o.O',
'O.o',
+ 'o_O',
+ 'O_o',
":'(",
":-!",
":-/",
@@ -759,6 +767,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=":-/" />',
@@ -1058,10 +1068,12 @@ function unamp($s) {
if(! function_exists('lang_selector')) {
function lang_selector() {
global $lang;
- $o = '<div id="lang-select-icon" class="icon language" title="' . t('Select an alternate language') . '" onclick="openClose(\'language-selector\');" ></div>';
- $o .= '<div id="language-selector" style="display: none;" >';
- $o .= '<form action="#" method="post" ><select name="system_language" onchange="this.form.submit();" >';
+
$langs = glob('view/*/strings.php');
+
+ $lang_options = array();
+ $selected = "";
+
if(is_array($langs) && count($langs)) {
$langs[] = '';
if(! in_array('view/en/strings.php',$langs))
@@ -1069,17 +1081,22 @@ function lang_selector() {
asort($langs);
foreach($langs as $l) {
if($l == '') {
- $default_selected = ((! x($_SESSION,'language')) ? ' selected="selected" ' : '');
- $o .= '<option value="" ' . $default_selected . '>' . t('default') . '</option>';
+ $lang_options[""] = t('default');
continue;
}
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
- $selected = (($ll === $lang && (x($_SESSION, 'language'))) ? ' selected="selected" ' : '');
- $o .= '<option value="' . $ll . '"' . $selected . '>' . $ll . '</option>';
+ $selected = (($ll === $lang && (x($_SESSION, 'language'))) ? $ll : $selected);
+ $lang_options[$ll]=$ll;
}
}
- $o .= '</select></form></div>';
+
+ $tpl = get_markup_template("lang_selector.tpl");
+ $o = replace_macros($tpl, array(
+ '$title' => t('Select an alternate language'),
+ '$langs' => array($lang_options, $selected),
+
+ ));
return $o;
}}
@@ -1314,6 +1331,118 @@ function file_tag_file_query($table,$s,$type = 'file') {
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))
@@ -1384,3 +1513,8 @@ function undo_post_tagging($s) {
return $s;
}
+function fix_mce_lf($s) {
+ $s = str_replace("\r\n","\n",$s);
+ $s = str_replace("\n\n","\n",$s);
+ return $s;
+}