aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php85
1 files changed, 48 insertions, 37 deletions
diff --git a/include/text.php b/include/text.php
index 7101d76da..377c1c46f 100644
--- a/include/text.php
+++ b/include/text.php
@@ -579,9 +579,9 @@ function attribute_contains($attr, $s) {
}
/**
- * @brief Logging function for RedMatrix.
+ * @brief Logging function for Hubzilla.
*
- * Logging output is configured through RedMatrix's system config. The log file
+ * Logging output is configured through Hubzilla's system config. The log file
* is set in system logfile, log level in system loglevel and to enable logging
* set system debugging.
*
@@ -747,7 +747,7 @@ function get_tags($s) {
// make sure the longer tags are returned first so that if two or more have common substrings
// we'll replace the longest ones first. Otherwise the common substring would be found in
// both strings and the string replacement would link both to the shorter strings and
- // fail to link the longer string. RedMatrix github issue #378
+ // fail to link the longer string. Hubzilla github issue #378
usort($ret,'tag_sort_length');
@@ -812,20 +812,21 @@ function contact_block() {
return;
$is_owner = ((local_channel() && local_channel() == $a->profile['uid']) ? true : false);
+ $sql_extra = '';
+
+ $abook_flags = " and abook_pending = 0 and abook_self = 0 ";
- $abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF;
- $xchan_flags = XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED;
if(! $is_owner) {
- $abook_flags = $abook_flags | ABOOK_FLAG_HIDDEN;
- $xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN;
+ $abook_flags .= " and abook_hidden = 0 ";
+ $sql_extra = " and xchan_hidden = 0 ";
}
if((! is_array($a->profile)) || ($a->profile['hide_friends']))
return $o;
- $r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and ( abook_flags & %d ) = 0 and ( xchan_flags & %d ) = 0",
- intval($a->profile['uid']),
- intval($abook_flags),
- intval($xchan_flags)
+
+ $r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d
+ $abook_flags and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra",
+ intval($a->profile['uid'])
);
if(count($r)) {
$total = intval($r[0]['total']);
@@ -834,21 +835,19 @@ function contact_block() {
$contacts = t('No connections');
$micropro = null;
} else {
-
+
$randfunc = db_getfunc('RAND');
-
- $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND ( abook_flags & %d ) = 0 and ( xchan_flags & %d ) = 0 ORDER BY $randfunc LIMIT %d",
- intval($a->profile['uid']),
- intval($abook_flags|ABOOK_FLAG_ARCHIVED),
- intval($xchan_flags),
- intval($shown)
+
+ $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d $abook_flags and abook_archived = 0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ORDER BY $randfunc LIMIT %d",
+ intval($a->profile['uid']),
+ intval($shown)
);
if(count($r)) {
$contacts = sprintf( tt('%d Connection','%d Connections', $total),$total);
$micropro = Array();
foreach($r as $rr) {
- $rr['archived'] = (($rr['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? true : false);
+ $rr['archived'] = (intval($rr['abook_archived']) ? true : false);
$micropro[] = micropro($rr,true,'mpfriend');
}
}
@@ -1245,7 +1244,7 @@ function link_compare($a, $b) {
function unobscure(&$item) {
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
$key = get_config('system','prvkey');
if($item['title'])
$item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
@@ -1264,11 +1263,10 @@ function unobscure(&$item) {
function unobscure_mail(&$item) {
if(array_key_exists('mail_flags',$item) && ($item['mail_flags'] & MAIL_OBSCURED)) {
- $key = get_config('system','prvkey');
if($item['title'])
- $item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
+ $item['title'] = base64url_decode(str_rot47($item['title']));
if($item['body'])
- $item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
+ $item['body'] = base64url_decode(str_rot47($item['body']));
}
}
@@ -1445,16 +1443,24 @@ function generate_named_map($location) {
function prepare_body(&$item,$attach = false) {
- call_hooks('prepare_body_init', $item);
-
- unobscure($item);
-
- $s = prepare_text($item['body'],$item['mimetype']);
+ if($item['html']) {
+ $s = bb_observer($item['html']);
+ }
+ else {
+ call_hooks('prepare_body_init', $item);
+ unobscure($item);
+ $s = prepare_text($item['body'],$item['mimetype'], true);
+ }
$prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body', $prep_arr);
$s = $prep_arr['html'];
+ q("update item set html = '%s' where id = %d",
+ dbesc($s),
+ intval($item['id'])
+ );
+
if(! $attach) {
return $s;
}
@@ -1513,7 +1519,6 @@ function prepare_body(&$item,$attach = false) {
$prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body_final', $prep_arr);
-
return $prep_arr['html'];
}
@@ -1524,7 +1529,7 @@ function prepare_body(&$item,$attach = false) {
* @param sting $content_type
* @return string
*/
-function prepare_text($text, $content_type = 'text/bbcode') {
+function prepare_text($text, $content_type = 'text/bbcode', $cache = false) {
switch($content_type) {
case 'text/plain':
@@ -1562,9 +1567,9 @@ function prepare_text($text, $content_type = 'text/bbcode') {
require_once('include/bbcode.php');
if(stristr($text,'[nosmile]'))
- $s = bbcode($text);
+ $s = bbcode($text,false,true,$cache);
else
- $s = smilies(bbcode($text));
+ $s = smilies(bbcode($text,false,true,$cache));
$s = zidify_links($s);
break;
}
@@ -1676,9 +1681,9 @@ function unamp($s) {
}
function layout_select($channel_id, $current = '') {
- $r = q("select mid,sid from item left join item_id on iid = item.id where service = 'PDL' and item.uid = item_id.uid and item_id.uid = %d and (item_restrict & %d)>0",
+ $r = q("select mid,sid from item left join item_id on iid = item.id where service = 'PDL' and item.uid = item_id.uid and item_id.uid = %d and item_type = %d ",
intval($channel_id),
- intval(ITEM_PDL)
+ intval(ITEM_TYPE_PDL)
);
if($r) {
@@ -2031,13 +2036,13 @@ function xchan_query(&$items,$abook = true,$effective_uid = 0) {
if(count($arr)) {
if($abook) {
$chans = q("select * from xchan left join hubloc on hubloc_hash = xchan_hash left join abook on abook_xchan = xchan_hash and abook_channel = %d
- where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0",
+ where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1",
intval($item['uid'])
);
}
else {
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash
- where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0");
+ where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1");
}
$xchans = q("select * from xchan where xchan_hash in (" . implode(',',$arr) . ") and xchan_network in ('rss','unknown')");
if(! $chans)
@@ -2065,7 +2070,7 @@ function xchan_mail_query(&$item) {
if(count($arr)) {
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash
- where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0");
+ where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1");
}
if($chans) {
$item['from'] = find_xchan_in_array($item['from_xchan'],$chans);
@@ -2614,3 +2619,9 @@ function userReadableSize($size) {
return $ret;
}
+
+function str_rot47($str) {
+ return strtr($str,
+ '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~',
+ 'PQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO');
+}