aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/bbcode.php6
-rwxr-xr-xinclude/conversation.php35
-rwxr-xr-xinclude/items.php4
-rwxr-xr-xinclude/notifier.php2
-rwxr-xr-xinclude/security.php79
-rw-r--r--[-rwxr-xr-x]include/text.php79
6 files changed, 171 insertions, 34 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index cff26f5c8..d69cb263f 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -216,6 +216,9 @@ function bbcode($Text,$preserve_nl = false) {
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
+ $Text = preg_replace("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4))\[\/video\]/ism", '<video src="$1" controls="controls" width="425" height="350"><a href="$1">$1</a></video>', $Text);
+
+ $Text = preg_replace("/\[audio\](.*?\.(ogg|ogv|oga|ogm|webm|mp4|mp3))\[\/audio\]/ism", '<audio src="$1" controls="controls"><a href="$1">$1</a></audio>', $Text);
// Try to Oembed
$Text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", 'tryoembed', $Text);
@@ -224,9 +227,6 @@ function bbcode($Text,$preserve_nl = false) {
// html5 video and audio
- $Text = preg_replace("/\[video\](.*?)\[\/video\]/ism", '<video src="$1" controls="controls" width="425" height="350"><a href="$1">$1</a></video>', $Text);
-
- $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/ism", '<audio src="$1" controls="controls"><a href="$1">$1</a></audio>', $Text);
$Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text);
diff --git a/include/conversation.php b/include/conversation.php
index f4740688c..526c6ea00 100755
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -179,9 +179,11 @@ function localize_item(&$item){
* that are based on unique features of the calling module.
*
*/
- if(!function_exists('conversation')){
+
+if(!function_exists('conversation')) {
function conversation(&$a, $items, $mode, $update, $preview = false) {
+
require_once('bbcode.php');
$profile_owner = 0;
@@ -217,7 +219,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if($update)
$return_url = $_SESSION['return_url'];
else
- $return_url = $_SESSION['return_url'] = $a->cmd;
+ $return_url = $_SESSION['return_url'] = $a->query_string;
load_contact_links(local_user());
@@ -418,26 +420,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$toplevelprivate = (($toplevelpost && $item['private']) ? true : false);
$item_writeable = (($item['writable'] || $item['self']) ? true : false);
- // DISABLED
- /*
- if($blowhard == $item['cid'] && (! $item['self']) && ($mode != 'profile') && ($mode != 'notes')) {
- $blowhard_count ++;
- if($blowhard_count == 3) {
- $o .= '<div class="icollapse-wrapper fakelink" id="icollapse-wrapper-' . $item['parent']
- . '" onclick="openClose(' . '\'icollapse-' . $item['parent'] . '\'); $(\'#icollapse-wrapper-' . $item['parent'] . '\').hide();" >'
- . t('See more posts like this') . '</div>' . '<div class="icollapse" id="icollapse-'
- . $item['parent'] . '" style="display: none;" >';
- }
- }
- else {
- $blowhard = $item['cid'];
- if($blowhard_count >= 3)
- $o .= '</div>';
- $blowhard_count = 0;
- }
- // END DISABLED
- */
-
$comments_seen = 0;
$comments_collapsed = false;
$comment_lastcollapsed = false;
@@ -445,13 +427,16 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$threadsid++;
$threads[$threadsid]['id'] = $item['item_id'];
+ $threads[$threadsid]['private'] = $item['private'];
$threads[$threadsid]['items'] = array();
}
else {
- // prevent private email from leaking into public conversation
- if((! $toplevelpost) && (! $toplevelprivate) && ($item['private']) && ($profile_owner != local_user()))
+
+ // prevent private email reply to public conversation from leaking.
+ if($item['private'] && ! $threads[$threadsid]['private'])
continue;
+
$comments_seen ++;
$comment_lastcollapsed = false;
$comment_firstcollapsed = false;
@@ -502,7 +487,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$template = $wallwall;
$commentww = 'ww';
}
- if((! $item['wall']) && (strlen($item['owner-link'])) && ($item['owner-link'] != $item['author-link'])) {
+ if((! $item['wall']) && (strlen($item['owner-link'])) && (! link_compare($item['owner-link'],$item['author-link']))) {
// Could be anybody.
diff --git a/include/items.php b/include/items.php
index fdff6b642..1a7aa6c46 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1756,7 +1756,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
- if(x($datarray,'owner-link') && strlen($datarray['owner-link']) && (! link_compare($datarray['owner-link'],$contact['url']))) {
+ if(! link_compare($datarray['owner-link'],$contact['url'])) {
// The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery,
// 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,
@@ -2477,7 +2477,7 @@ function local_delivery($importer,$data) {
$datarray['uid'] = $importer['importer_uid'];
$datarray['contact-id'] = $importer['id'];
- if(x($datarray,'owner-link') && strlen($datarray['owner-link']) && (! link_compare($datarray['owner-link'],$importer['url']))) {
+ if(! link_compare($datarray['owner-link'],$contact['url'])) {
// The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery,
// 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,
diff --git a/include/notifier.php b/include/notifier.php
index 4765cca06..5b23406fc 100755
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -201,7 +201,7 @@ function notifier_run($argv, $argc){
// by stringing togther an array of retractions and sending them onward.
- $localhost = $a->get_hostname();
+ $localhost = str_replace('www.','',$a->get_hostname());
if(strpos($localhost,':'))
$localhost = substr($localhost,0,strpos($localhost,':'));
diff --git a/include/security.php b/include/security.php
index 6b8128bdd..8c536b656 100755
--- a/include/security.php
+++ b/include/security.php
@@ -202,7 +202,7 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) {
" AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' )
AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' )
AND ( allow_gid = '' OR allow_gid REGEXP '%s' )
- AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s')
+ AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s')
",
intval($remote_user),
intval($remote_user),
@@ -212,4 +212,79 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) {
}
}
return $sql;
-} \ No newline at end of file
+}
+
+
+function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) {
+
+ $local_user = local_user();
+ $remote_user = remote_user();
+
+ /**
+ * Construct permissions
+ *
+ * default permissions - anonymous user
+ */
+
+ $sql = " AND allow_cid = ''
+ AND allow_gid = ''
+ AND deny_cid = ''
+ AND deny_gid = ''
+ AND private = 0
+ ";
+
+ /**
+ * Profile owner - everything is visible
+ */
+
+ if(($local_user) && ($local_user == $owner_id)) {
+ $sql = '';
+ }
+
+ /**
+ * Authenticated visitor. Unless pre-verified,
+ * check that the contact belongs to this $owner_id
+ * and load the groups the visitor belongs to.
+ * If pre-verified, the caller is expected to have already
+ * done this and passed the groups into this function.
+ */
+
+ elseif($remote_user) {
+
+ if(! $remote_verified) {
+ $r = q("SELECT id FROM contact WHERE id = %d AND uid = %d AND blocked = 0 LIMIT 1",
+ intval($remote_user),
+ intval($owner_id)
+ );
+ if(count($r)) {
+ $remote_verified = true;
+ $groups = init_groups_visitor($remote_user);
+ }
+ }
+ if($remote_verified) {
+
+ $gs = '<<>>'; // should be impossible to match
+
+ if(is_array($groups) && count($groups)) {
+ foreach($groups as $g)
+ $gs .= '|<' . intval($g) . '>';
+ }
+
+ $sql = sprintf(
+ " AND ( private = 0 OR ( private = 1 AND wall = 1 AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' )
+ AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' )
+ AND ( allow_gid = '' OR allow_gid REGEXP '%s' )
+ AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s')))
+ ",
+ intval($remote_user),
+ intval($remote_user),
+ dbesc($gs),
+ dbesc($gs)
+ );
+ }
+ }
+
+ return $sql;
+}
+
+
diff --git a/include/text.php b/include/text.php
index c8c03174e..011006b76 100755..100644
--- a/include/text.php
+++ b/include/text.php
@@ -738,6 +738,9 @@ function smilies($s, $sample = false) {
'~friendika',
'~friendica',
// 'Diaspora*'
+ ':beard',
+ ':whitebeard'
+
);
$icons = array(
@@ -779,7 +782,8 @@ function smilies($s, $sample = false) {
'<a href="http://project.friendika.com">~friendika <img src="' . $a->get_baseurl() . '/images/friendika-16.png" alt="~friendika" /></a>',
'<a href="http://friendica.com">~friendica <img src="' . $a->get_baseurl() . '/images/friendica-16.png" alt="~friendica" /></a>',
// '<a href="http://diasporafoundation.org">Diaspora<img src="' . $a->get_baseurl() . '/images/diaspora.png" alt="Diaspora*" /></a>',
-
+ '<img src="' . $a->get_baseurl() . '/images/smiley-beard.png" alt=":beard" />',
+ '<img src="' . $a->get_baseurl() . '/images/smiley-whitebeard.png" alt=":whitebeard" />'
);
$params = array('texts' => $texts, 'icons' => $icons, 'string' => $s);
@@ -1231,4 +1235,77 @@ function item_post_type($item) {
return t('post');
}
+// post categories and "save to file" use the same item.file table for storage.
+// We will differentiate the different uses by wrapping categories in angle brackets
+// and save to file categories in square brackets.
+// To do this we need to escape these characters if they appear in our tag.
+
+function file_tag_encode($s) {
+ return str_replace(array('<','>','[',']'),array('%3c','%3e','%5b','%5d'),$s);
+}
+
+function file_tag_decode($s) {
+ return str_replace(array('%3c','%3e','%5b','%5d'),array('<','>','[',']'),$s);
+}
+
+function file_tag_file_query($table,$s,$type = 'file') {
+ if($type == 'file')
+ $str = preg_quote( '[' . file_tag_encode($s) . ']' );
+ else
+ $str = preg_quote( '<' . file_tag_encode($s) . '>' );
+ return " AND " . (($table) ? dbesc($table) . '.' : '') . "file regexp '" . dbesc($str) . "' ";
+}
+
+function file_tag_save_file($uid,$item,$file) {
+ $result = false;
+ if(! intval($uid))
+ return false;
+ $r = q("select file from item where id = %d and uid = %d limit 1",
+ intval($item),
+ intval($uid)
+ );
+ if(count($r)) {
+ if(! stristr($r[0]['file'],'[' . file_tag_encode($file) . ']'))
+ q("update item set file = '%s' where id = %d and uid = %d limit 1",
+ dbesc($r[0]['file'] . '[' . $file_tag_encode($file) . ']'),
+ intval($item),
+ intval($uid)
+ );
+ $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) . ']');
+ }
+ return true;
+}
+
+function file_tag_unsave_file($uid,$item,$file) {
+ $result = false;
+ if(! intval($uid))
+ return false;
+
+ $pattern = '[' . file_tag_encode($file) . ']' ;
+
+ $r = q("select file from item where id = %d and uid = %d limit 1",
+ intval($item),
+ intval($uid)
+ );
+ if(! count($r))
+ return false;
+
+ q("update item set file = '%s' where id = %d and uid = %d limit 1",
+ dbesc(str_replace($pattern,'',$r[0]['file'])),
+ intval($item),
+ intval($uid)
+ );
+
+ $r = q("select file from item where uid = %d " . file_tag_file_query('item',$file),
+ intval($uid)
+ );
+
+ if(! count($r)) {
+ $saved = get_pconfig($uid,'system','filetags');
+ set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved));
+ }
+ return true;
+}