aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/account.php2
-rw-r--r--include/channel.php9
-rw-r--r--include/feedutils.php14
-rw-r--r--include/items.php33
-rw-r--r--include/menu.php24
-rw-r--r--include/network.php4
-rw-r--r--include/opengraph.php2
-rw-r--r--include/zid.php53
8 files changed, 100 insertions, 41 deletions
diff --git a/include/account.php b/include/account.php
index d138dab41..98d7f00a8 100644
--- a/include/account.php
+++ b/include/account.php
@@ -48,7 +48,7 @@ function check_account_email($email) {
$result['message'] = t('The provided email address is already registered at this site');
}
- $register = q("select reg_did2 from register where reg_vital = 1 and reg_did2 = '%s' limit 1",
+ $register = q("select reg_did2 from register where reg_vital = 1 and reg_did2 = '%s' and reg_didx = 'e' limit 1",
dbesc($email)
);
if ($register) {
diff --git a/include/channel.php b/include/channel.php
index bc9f686e7..5684f7a6b 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -1407,7 +1407,7 @@ function profile_load($nickname, $profile = '') {
if(! $user) {
logger('profile error: ' . App::$query_string, LOGGER_DEBUG);
- notice( t('Requested channel is not available.') . EOL );
+ notice( t('Requested channel is not available') . EOL );
App::$error = 404;
return;
}
@@ -1516,8 +1516,11 @@ function profile_load($nickname, $profile = '') {
if($p[0]['keywords']) {
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$p[0]['keywords']);
- if(strlen($keywords) && $can_view_profile)
+ if(strlen($keywords) && $can_view_profile) {
+ if(! isset(App::$page['htmlhead']))
+ App::$page['htmlhead'] = '';
App::$page['htmlhead'] .= '<meta name="keywords" content="' . htmlentities($keywords,ENT_COMPAT,'UTF-8') . '" />' . "\r\n" ;
+ }
}
App::$profile = $p[0];
@@ -2534,7 +2537,7 @@ function channelx_by_nick($nick) {
return App::$channel;
}
- $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and channel_removed = 0 LIMIT 1",
+ $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and channel_removed = 0 LIMIT 1",
dbesc($nick)
);
diff --git a/include/feedutils.php b/include/feedutils.php
index e827bde98..f489030b6 100644
--- a/include/feedutils.php
+++ b/include/feedutils.php
@@ -296,7 +296,7 @@ function get_atom_author($feed, $item) {
$rawauthor = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'author');
- if($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) {
+ if($rawauthor && isset($rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])) {
$base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
foreach($base as $link) {
if(!x($author, 'author_photo') || ! $author['author_photo']) {
@@ -336,7 +336,7 @@ function get_atom_author($feed, $item) {
if(! x($author,'author_link') || ! x($author,'author_photo')) {
$rawauthor = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'author');
- if($rawauthor && $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) {
+ if($rawauthor && isset($rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])) {
$base = $rawauthor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
foreach($base as $link) {
if($link['attribs']['']['rel'] === 'alternate' && (! $author['author_link'])) {
@@ -372,16 +372,16 @@ function get_atom_author($feed, $item) {
if(! $rawowner)
$rawowner = $item->get_item_tags(NAMESPACE_ZOT, 'owner');
- if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])
+ if(isset($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
$author['owner_name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']);
- elseif($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data'])
+ elseif(isset($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data']))
$author['owner_name'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['name'][0]['data']);
- if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])
+ if(isset($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']))
$author['owner_link'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data']);
- elseif($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data'])
+ elseif(isset($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data']))
$author['owner_link'] = unxmlify($rawowner[0]['child'][NAMESPACE_DFRN]['uri'][0]['data']);
- if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']) {
+ if(isset($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'])) {
$base = $rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'];
foreach($base as $link) {
diff --git a/include/items.php b/include/items.php
index 29160c01d..d6dd517ba 100644
--- a/include/items.php
+++ b/include/items.php
@@ -702,7 +702,6 @@ function get_item_elements($x,$allow_code = false) {
$arr['mid'] = (($x['message_id']) ? htmlspecialchars($x['message_id'], ENT_COMPAT,'UTF-8',false) : '');
$arr['parent_mid'] = (($x['message_top']) ? htmlspecialchars($x['message_top'], ENT_COMPAT,'UTF-8',false) : '');
$arr['thr_parent'] = (($x['message_parent']) ? htmlspecialchars($x['message_parent'], ENT_COMPAT,'UTF-8',false) : '');
-
$arr['plink'] = (($x['permalink']) ? htmlspecialchars($x['permalink'], ENT_COMPAT,'UTF-8',false) : '');
$arr['location'] = (($x['location']) ? htmlspecialchars($x['location'], ENT_COMPAT,'UTF-8',false) : '');
$arr['coord'] = (($x['longlat']) ? htmlspecialchars($x['longlat'], ENT_COMPAT,'UTF-8',false) : '');
@@ -718,17 +717,12 @@ function get_item_elements($x,$allow_code = false) {
$arr['comment_policy'] = (($x['comment_scope']) ? htmlspecialchars($x['comment_scope'], ENT_COMPAT,'UTF-8',false) : 'contacts');
$arr['sig'] = (($x['signature']) ? htmlspecialchars($x['signature'], ENT_COMPAT,'UTF-8',false) : '');
-
$arr['obj'] = activity_sanitise($x['object']);
$arr['target'] = activity_sanitise($x['target']);
-
$arr['attach'] = activity_sanitise($x['attach']);
$arr['term'] = decode_tags($x['tags']);
$arr['iconfig'] = decode_item_meta($x['meta']);
-
- $arr['item_private'] = ((array_key_exists('flags',$x) && is_array($x['flags']) && in_array('private',$x['flags'])) ? 1 : 0);
-
- $arr['item_flags'] = 0;
+ $arr['item_flags'] = 0;
if(array_key_exists('flags',$x)) {
@@ -749,6 +743,12 @@ function get_item_elements($x,$allow_code = false) {
if(in_array('hidden',$x['flags']))
$arr['item_hidden'] = 1;
+ if(in_array('private', $x['flags']))
+ $arr['item_private'] = 1;
+
+ if(in_array('private', $x['flags']) && in_array('direct', $x['flags']))
+ $arr['item_private'] = 2;
+
}
// Here's the deal - the site might be down or whatever but if there's a new person you've never
@@ -971,7 +971,7 @@ function import_author_xchan($x) {
if($y)
return $y;
- if(!$y && !isset($x['network']) || $x['network'] === 'zot') {
+ if(!isset($x['network']) || $x['network'] === 'zot') {
$y = import_author_zot($x);
}
@@ -981,11 +981,14 @@ function import_author_xchan($x) {
$r = q("SELECT xchan_hash FROM xchan WHERE xchan_url = '%s' AND xchan_network = 'zot6'",
dbesc($x['url'])
);
- if(! $r)
+ // TODO: fix dupplicate with line 960
+ if(!$r)
discover_by_webbie($x['url'], 'zot6');
}
- return $y;
+ if($y)
+ return $y;
+
}
// perform zot6 discovery
@@ -1336,7 +1339,13 @@ function encode_item_xchan($xchan) {
$ret['id_sig'] = $xchan['xchan_guid_sig'];
$ret['key'] = $xchan['xchan_pubkey'];
- return $ret;
+ $hookdata = [
+ 'encoded_xchan' => $ret
+ ];
+
+ call_hooks('encode_item_xchan', $hookdata);
+
+ return $hookdata['encoded_xchan'];
}
function encode_item_terms($terms,$mirror = false) {
@@ -1551,6 +1560,8 @@ function encode_item_flags($item) {
$ret[] = 'obscured';
if(intval($item['item_private']))
$ret[] = 'private';
+ if(intval($item['item_private']) === 2)
+ $ret[] = 'direct';
return $ret;
}
diff --git a/include/menu.php b/include/menu.php
index 02b05a36e..1f65f987d 100644
--- a/include/menu.php
+++ b/include/menu.php
@@ -16,7 +16,7 @@ function menu_fetch($name,$uid,$observer_xchan) {
);
if($r) {
$x = q("select * from menu_item where mitem_menu_id = %d and mitem_channel_id = %d
- $sql_options
+ $sql_options
order by mitem_order asc, mitem_desc asc",
intval($r[0]['menu_id']),
intval($uid)
@@ -26,7 +26,7 @@ function menu_fetch($name,$uid,$observer_xchan) {
return null;
}
-
+
function menu_element($channel,$menu) {
$arr = array();
@@ -67,7 +67,7 @@ function menu_element($channel,$menu) {
}
$arr['items'][] = $entry;
}
- }
+ }
return $arr;
}
@@ -111,7 +111,7 @@ function menu_render($menu, $class='', $edit = false, $var = array()) {
$menu['items'][$x]['mitem_desc'] = zidify_links(smilies(bbcode($menu['items'][$x]['mitem_desc'])));
}
- $wrap = (! x($var, 'wrap') || $var['wrap'] === 'none' ? false : true);
+ $wrap = ((isset($var['wrap']) && $var['wrap'] === 'none') ? false : true);
$ret = replace_macros(get_markup_template('usermenu.tpl'),array(
'$menu' => $menu['menu'],
@@ -168,7 +168,7 @@ function menu_create($arr) {
$t = datetime_convert();
- $r = q("insert into menu ( menu_name, menu_desc, menu_flags, menu_channel_id, menu_created, menu_edited )
+ $r = q("insert into menu ( menu_name, menu_desc, menu_flags, menu_channel_id, menu_created, menu_edited )
values( '%s', '%s', %d, %d, '%s', '%s' )",
dbesc($menu_name),
dbesc($menu_desc),
@@ -260,7 +260,7 @@ function menu_edit($arr) {
}
return q("update menu set menu_name = '%s', menu_desc = '%s', menu_flags = %d, menu_edited = '%s'
- where menu_id = %d and menu_channel_id = %d",
+ where menu_id = %d and menu_channel_id = %d",
dbesc($menu_name),
dbesc($menu_desc),
intval($menu_flags),
@@ -295,7 +295,7 @@ function menu_delete_id($menu_id, $uid) {
intval($menu_id),
intval($uid)
);
- }
+ }
return false;
}
@@ -304,11 +304,11 @@ function menu_add_item($menu_id, $uid, $arr) {
$mitem_link = escape_tags($arr['mitem_link']);
$mitem_desc = escape_tags($arr['mitem_desc']);
- $mitem_order = intval($arr['mitem_order']);
+ $mitem_order = intval($arr['mitem_order']);
$mitem_flags = intval($arr['mitem_flags']);
if(local_channel() == $uid) {
- $channel = App::get_channel();
+ $channel = App::get_channel();
}
$acl = new Zotlabs\Access\AccessList($channel);
@@ -344,12 +344,12 @@ function menu_edit_item($menu_id, $uid, $arr) {
$mitem_id = intval($arr['mitem_id']);
$mitem_link = escape_tags($arr['mitem_link']);
$mitem_desc = escape_tags($arr['mitem_desc']);
- $mitem_order = intval($arr['mitem_order']);
+ $mitem_order = intval($arr['mitem_order']);
$mitem_flags = intval($arr['mitem_flags']);
if(local_channel() == $uid) {
- $channel = App::get_channel();
+ $channel = App::get_channel();
}
$acl = new Zotlabs\Access\AccessList($channel);
@@ -403,7 +403,7 @@ function menu_sync_packet($uid,$observer_hash,$menu_id,$delete = false) {
$r = menu_fetch_id($menu_id,$uid);
$c = channelx_by_n($uid);
if($r) {
- $m = menu_fetch($r['menu_name'],$uid,$observer_hash);
+ $m = menu_fetch($r['menu_name'],$uid,$observer_hash);
if($m) {
if($delete)
$m['menu_delete'] = 1;
diff --git a/include/network.php b/include/network.php
index fcc7b4289..77b7c49d6 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1118,9 +1118,9 @@ function discover_by_url($url, $arr = null) {
/**
* @brief
*
- * @param string $webbie
+ * @param string $webbie (TODO: explain)
* @param string $protocol (optional) default empty
- * @return boolean
+ * @return boolean|string (TODO: explain)
*/
function discover_by_webbie($webbie, $protocol = '') {
diff --git a/include/opengraph.php b/include/opengraph.php
index 4c88570d3..465acbd39 100644
--- a/include/opengraph.php
+++ b/include/opengraph.php
@@ -62,6 +62,8 @@
$ogimagetype = $channel['xchan_photo_mimetype'];
}
+ if (! isset(App::$page['htmlhead']))
+ App::$page['htmlhead'] = '';
App::$page['htmlhead'] .= '<meta property="og:title" content="' . htmlspecialchars((isset($ogtitle) ? $ogtitle : $channel['channel_name'])) . '">' . "\r\n";
App::$page['htmlhead'] .= '<meta property="og:image" content="' . $ogimage . '">' . "\r\n";
App::$page['htmlhead'] .= '<meta property="og:image:type" content="' . $ogimagetype . '">' . "\r\n";
diff --git a/include/zid.php b/include/zid.php
index 75414a691..0a33280ee 100644
--- a/include/zid.php
+++ b/include/zid.php
@@ -89,20 +89,24 @@ function zid($s, $address = '') {
}
-function strip_query_param($s,$param) {
- return preg_replace('/[\?&]' . $param . '=(.*?)(&|$)/ism','$2',$s);
+function strip_query_param($s, $param) {
+ return drop_query_params($s, [$param]);
+ //return preg_replace('/[\?&]' . $param . '=(.*?)(&|$)/ism','$2',$s);
}
function strip_zids($s) {
- return preg_replace('/[\?&]zid=(.*?)(&|$)/ism','$2',$s);
+ return drop_query_params($s, ['zid']);
+ //return preg_replace('/[\?&]zid=(.*?)(&|$)/ism','$2',$s);
}
function strip_owt($s) {
- return preg_replace('/[\?&]owt=(.*?)(&|$)/ism','$2',$s);
+ return drop_query_params($s, ['owt']);
+ //return preg_replace('/[\?&]owt=(.*?)(&|$)/ism','$2',$s);
}
function strip_zats($s) {
- return preg_replace('/[\?&]zat=(.*?)(&|$)/ism','$2',$s);
+ return drop_query_params($s, ['zat']);
+ //return preg_replace('/[\?&]zat=(.*?)(&|$)/ism','$2',$s);
}
function strip_escaped_zids($s) {
@@ -112,12 +116,51 @@ function strip_escaped_zids($s) {
function clean_query_string($s = '') {
+
+ $x = (($s) ? $s : \App::$query_string);
+ return drop_query_params($x, ['zid', 'owt', 'zat', 'sort', 'f']);
+
+/*
$x = strip_zids(($s) ? $s : \App::$query_string);
$x = strip_owt($x);
$x = strip_zats($x);
$x = strip_query_param($x,'sort');
return strip_query_param($x,'f');
+*/
+}
+
+/**
+ * @brief Remove parameters from query string.
+ *
+ * @param string $s
+ * The query string
+ * @param array $p
+ * $p array of parameters to remove
+ * @return string
+ */
+
+function drop_query_params($s, $p) {
+ $parsed = parse_url($s);
+
+ $query = '';
+ $query_args = null;
+ if(isset($parsed['query'])) {
+ parse_str($parsed['query'], $query_args);
+ }
+
+ if(is_array($query_args)) {
+ foreach($query_args as $k => $v) {
+ if(in_array($k, $p))
+ continue;
+ $query .= (($query) ? '&' : '') . urlencode($k) . '=' . urlencode($v);
+ }
+ }
+
+ if($query)
+ $parsed['query'] = $query;
+
+ return unparse_url($parsed);
}