From 711719ce0ce340fbcda7559bf20582e85e4b1e3d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 7 May 2014 12:01:12 -0700 Subject: Made some changes to img tags to enforce max-width everywhere, and to the page headers to allow user scaling. --- include/bbcode.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 326676b72..92d979638 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -606,24 +606,24 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // Images // [img]pathtoimage[/img] if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } // [img float={left, right}]pathtoimage[/img] if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } // [img=widthxheight]pathtoimage[/img] -- cgit v1.2.3 From 1a4c99ec0232899ac791fdac7d9a509048f94ec5 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 7 May 2014 22:28:19 -0700 Subject: fix events until the new event subscription mechanism goes in, as shared events have been broken --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index ea439a603..9e69aea96 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1457,7 +1457,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false) { if((x($arr,'obj_type')) && (activity_match($arr['obj_type'],ACTIVITY_OBJ_EVENT))) { require_once('include/event.php'); $ev = bbtoevent($arr['body']); - if(x($ev,'desc') && x($ev,'start')) { + if(x($ev,'description') && x($ev,'start')) { $ev['event_xchan'] = $arr['author_xchan']; $ev['uid'] = $channel['channel_id']; $ev['account'] = $channel['channel_account_id']; -- cgit v1.2.3 From 8144498803a589f9179dea556acc8332381a93af Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 8 May 2014 13:44:43 +0200 Subject: like indicator rewrite --- include/ItemObject.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index 2922ee473..36070335d 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -123,6 +123,14 @@ class Item extends BaseObject { $location = format_location($item); + $like_count = ((x($alike,$item['mid'])) ? $alike[$item['mid']] : ''); + $like_list = ((x($alike,$item['mid'])) ? $alike[$item['mid'] . '-l'] : ''); + $like_button_label = ((x($alike,$item['mid'])) && ($alike[$item['mid']] < 2 ) ? t('like') : t('likes')); + if (feature_enabled($conv->get_profile_owner(),'dislike')) { + $dislike_count = ((x($dlike,$item['mid'])) ? $dlike[$item['mid']] : ''); + $dislike_list = ((x($dlike,$item['mid'])) ? $dlike[$item['mid'] . '-l'] : ''); + $dislike_button_label = ((x($dlike,$item['mid'])) && ($dlike[$item['mid']] < 2) ? t('dislike') : t('dislikes')); + } $showlike = ((x($alike,$item['mid'])) ? format_like($alike[$item['mid']],$alike[$item['mid'] . '-l'],'like',$item['mid']) : ''); $showdislike = ((x($dlike,$item['mid']) && feature_enabled($conv->get_profile_owner(),'dislike')) @@ -251,7 +259,12 @@ class Item extends BaseObject { 'drop' => $drop, 'multidrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $multidrop : ''), // end toolbar buttons - + 'like_count' => $like_count, + 'like_list' => $like_list, + 'like_button_label' => $like_button_label, + 'dislike_count' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_count : ''), + 'dislike_list' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list : ''), + 'dislike_button_label' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_button_label : ''), 'showlike' => $showlike, 'showdislike' => $showdislike, 'comment' => $this->get_comment_box($indent), -- cgit v1.2.3 From 2fe8bae7a59ae61b2b0708a480d250e46dab7673 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 8 May 2014 17:08:34 -0700 Subject: show hidden connections in contact block if and only if the observer is the profile owner --- include/text.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index b36e550f9..0e136fe8e 100755 --- a/include/text.php +++ b/include/text.php @@ -705,12 +705,22 @@ function contact_block() { if($shown == 0) return; + + $is_owner = ((local_user() && local_user() == $a->profile['uid']) ? true : false); + + $abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF; + $xchan_flags = XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED; + if(! $is_owner) { + $abook_flags = $abook_flags | ABOOK_FLAGS_HIDDEN; + $xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN; + } + 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 not ( abook_flags & %d ) and not (xchan_flags & %d)", intval($a->profile['uid']), - intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF), - intval(XCHAN_FLAGS_HIDDEN|XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED) + intval($abook_flags), + intval($xchan_flags) ); if(count($r)) { $total = intval($r[0]['total']); @@ -723,8 +733,8 @@ function contact_block() { $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND not ( abook_flags & %d) and not (xchan_flags & %d ) ORDER BY RAND() LIMIT %d", intval($a->profile['uid']), - intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF), - intval(XCHAN_FLAGS_HIDDEN|XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED), + intval($abook_flags), + intval($xchan_flags), intval($shown) ); -- cgit v1.2.3 From 0e336fc09258e255d8bc01daad703cde11dbcad2 Mon Sep 17 00:00:00 2001 From: Michael Johnston Date: Sat, 10 May 2014 00:54:59 -0400 Subject: add support for h1, h2, etc. to bbcode --- include/bbcode.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 326676b72..17b25c206 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -507,6 +507,30 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism","$2",$Text); $Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","$2",$Text); } + // Check for h1 + if (strpos($Text,'[h1]') !== false) { + $Text = preg_replace("(\[h1\](.*?)\[\/h1\])ism",'

$1

',$Text); + } + // Check for h2 + if (strpos($Text,'[h2]') !== false) { + $Text = preg_replace("(\[h2\](.*?)\[\/h2\])ism",'

$1

',$Text); + } + // Check for h3 + if (strpos($Text,'[h3]') !== false) { + $Text = preg_replace("(\[h3\](.*?)\[\/h3\])ism",'

$1

',$Text); + } + // Check for h4 + if (strpos($Text,'[h4]') !== false) { + $Text = preg_replace("(\[h4\](.*?)\[\/h4\])ism",'

$1

',$Text); + } + // Check for h5 + if (strpos($Text,'[h5]') !== false) { + $Text = preg_replace("(\[h5\](.*?)\[\/h5\])ism",'
$1
',$Text); + } + // Check for h6 + if (strpos($Text,'[h6]') !== false) { + $Text = preg_replace("(\[h6\](.*?)\[\/h6\])ism",'
$1
',$Text); + } // Check for centered text if (strpos($Text,'[/center]') !== false) { $Text = preg_replace("(\[center\](.*?)\[\/center\])ism","
$1
",$Text); -- cgit v1.2.3 From 3f5852c30e9db9c1b62688db61a1756ffd7db1a7 Mon Sep 17 00:00:00 2001 From: Charles Date: Sat, 10 May 2014 12:50:20 -0700 Subject: correct minor typo --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 96242fdac..526007306 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -63,7 +63,7 @@ function bb_spacefy($st) { } // The previously spacefied [noparse][ i ]italic[ /i ][/noparse], -// now turns back and the [noparse] tags are trimed +// now turns back and the [noparse] tags are trimmed // returning [i]italic[/i] function bb_unspacefy_and_trim($st) { -- cgit v1.2.3 From ef5ffad69073ca047beeed23c508def4e1843922 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 11 May 2014 22:01:53 -0700 Subject: log IP mis-matches even if paranoia isn't set. --- include/auth.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/auth.php b/include/auth.php index c21705c99..e8f13d0fb 100644 --- a/include/auth.php +++ b/include/auth.php @@ -117,13 +117,14 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p // first check if we're enforcing that sessions can't change IP address - $check = get_config('system','paranoia'); - // extra paranoia - if the IP changed, log them out - if($check && ($_SESSION['addr'] != $_SERVER['REMOTE_ADDR'])) { - logger('Session address changed. Paranoid setting in effect, blocking session. ' - . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']); - nuke_session(); - goaway(z_root()); + if($_SESSION['addr'] != $_SERVER['REMOTE_ADDR']) { + logger('SECURITY: Session IP address changed: ' . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']); + if(get_config('system','paranoia')) { + logger('Session address changed. Paranoid setting in effect, blocking session. ' + . $_SESSION['addr'] . ' != ' . $_SERVER['REMOTE_ADDR']); + nuke_session(); + goaway(z_root()); + } } $r = q("select * from account where account_id = %d limit 1", -- cgit v1.2.3 From c7a0891bbeb6a072f95668fb7d6c8fd5a0f701fc Mon Sep 17 00:00:00 2001 From: marijus Date: Mon, 12 May 2014 11:27:53 +0200 Subject: Typo --- include/ItemObject.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index 36070335d..475642787 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -125,11 +125,11 @@ class Item extends BaseObject { $like_count = ((x($alike,$item['mid'])) ? $alike[$item['mid']] : ''); $like_list = ((x($alike,$item['mid'])) ? $alike[$item['mid'] . '-l'] : ''); - $like_button_label = ((x($alike,$item['mid'])) && ($alike[$item['mid']] < 2 ) ? t('like') : t('likes')); + $like_button_label = ((x($alike,$item['mid'])) && ($alike[$item['mid']] < 2 ) ? t('Like') : t('Likes')); if (feature_enabled($conv->get_profile_owner(),'dislike')) { $dislike_count = ((x($dlike,$item['mid'])) ? $dlike[$item['mid']] : ''); $dislike_list = ((x($dlike,$item['mid'])) ? $dlike[$item['mid'] . '-l'] : ''); - $dislike_button_label = ((x($dlike,$item['mid'])) && ($dlike[$item['mid']] < 2) ? t('dislike') : t('dislikes')); + $dislike_button_label = ((x($dlike,$item['mid'])) && ($dlike[$item['mid']] < 2) ? t('Dislike') : t('Dislikes')); } $showlike = ((x($alike,$item['mid'])) ? format_like($alike[$item['mid']],$alike[$item['mid'] . '-l'],'like',$item['mid']) : ''); -- cgit v1.2.3 From b3cc05c41dd11e245d262ede40b1ba8635953fb9 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 May 2014 17:04:03 -0700 Subject: try to fix random logouts --- include/session.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/session.php b/include/session.php index be1ec5ee7..b531688e2 100644 --- a/include/session.php +++ b/include/session.php @@ -11,7 +11,11 @@ $session_expire = 180000; function new_cookie($time) { $old_sid = session_id(); - session_set_cookie_params("$time"); + +// ??? This shouldn't have any effect if called after session_start() +// We probably need to set the session expiration and change the PHPSESSID cookie. + + session_set_cookie_params($time); session_regenerate_id(false); q("UPDATE session SET sid = '%s' WHERE sid = '%s'", dbesc(session_id()), dbesc($old_sid)); -- cgit v1.2.3 From a4869394f45886a9a6945c3ec0354dee42c1afda Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 May 2014 17:59:47 -0700 Subject: allow jgrowl 'close all' message to be translated --- include/js_strings.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/js_strings.php b/include/js_strings.php index fef84077e..1b62266d6 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -14,6 +14,7 @@ function js_strings() { '$passphrase' => t('Secret Passphrase'), '$passhint' => t('Passphrase hint'), '$permschange' => t('Notice: Permissions have changed but have not yet been submitted.'), + '$closeAll' => t('close all'), '$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : ''), '$t02' => ((t('timeago.prefixFromNow') != 'timeago.prefixFromNow') ? t('timeago.prefixFromNow') : ''), -- cgit v1.2.3 From 2c27ba66a5a05a52a6f0144ebd3e65562edba14b Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 May 2014 20:17:52 -0700 Subject: zrlify (turn into zmg) any relevant img tags in a post. --- include/items.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 7a94336be..5aaeb55c0 100755 --- a/include/items.php +++ b/include/items.php @@ -239,6 +239,31 @@ function red_unescape_codeblock($m) { } +function red_zrlify_img_callback($matches) { + $m = @parse_url($matches[2]); + $zrl = false; + if($m['host']) { + $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1", + dbesc($m['host']) + ); + if($r) + $zrl = true; + } + + $t = strip_zids($matches[2]); + if($t !== $matches[2]) { + $zrl = true; + $matches[2] = $t; + } + + if($zrl) + return '[zmg' . $matches[1] . ']' . $matches[2] . '[/zmg]'; + return $matches[0]; +} + + + + /** * @function post_activity_item($arr) * -- cgit v1.2.3 From 2f5bd7e1b3b6df368d3c030828c53a9354ff97cd Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 May 2014 20:58:55 -0700 Subject: add activity_received hook --- include/zot.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 9e69aea96..869943a24 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1501,6 +1501,9 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false) { $arr['uid'] = $channel['channel_id']; $item_result = item_store($arr); $item_id = $item_result['item_id']; + $parr = array('item_id' => $item_id,'item' => $arr,'sender' => $sender,'channel' => $channel); + call_hooks('activity_received',$parr); + add_source_route($item_id,$sender['hash']); $result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed:' . $item_result['message']),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); -- cgit v1.2.3 From b0dc3d3b4cc6c4c4151b2d7882062b6658637955 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 May 2014 21:33:39 -0700 Subject: add photo widget --- include/widgets.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 1b0e140c0..0f6d70ff7 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -719,4 +719,46 @@ $(document).ready(function() { EOT; return $o; -} \ No newline at end of file +} + + +/** + * @function widget_photo($arr) + * widget to display a single photo. + * @param array $arr; + * 'src' => URL of photo + * 'zrl' => true or false, use zid in url + * 'style' => CSS string + * URL must be an http or https URL + */ + + +function widget_photo($arr) { + + $style = $zrl = false; + $params = ''; + if(array_key_exists('src',$arr) && isset($arr['src'])) + $url = $arr['src']; + + if(strpos($url,'http') !== 0) + return ''; + + if(array_key_exists('style',$arr) && isset($arr['style'])) + $style = $arr['style']; + + if(array_key_exists('zrl',$arr) && isset($arr['zrl'])) + $zrl = (($arr['zrl']) ? true : false); + + if($zrl) + $url = zid($url); + + $o = '
'; + + $o .= ''; + + $o .= '
'; + + return $o; +} -- cgit v1.2.3 From 2f1e4a6370da6892433b6d8d57362a5a6565e07c Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 14 May 2014 00:55:32 -0700 Subject: xss prevention --- include/widgets.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 0f6d70ff7..0ed79f1eb 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -746,6 +746,11 @@ function widget_photo($arr) { if(array_key_exists('style',$arr) && isset($arr['style'])) $style = $arr['style']; + // ensure they can't sneak in an eval(js) function + + if(strpos($style,'(') !== false) + return ''; + if(array_key_exists('zrl',$arr) && isset($arr['zrl'])) $zrl = (($arr['zrl']) ? true : false); -- cgit v1.2.3 From e68bb132a701d170ef1e13752a8f64107eac7353 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 15 May 2014 16:43:42 -0700 Subject: some backend stuff for apps --- include/apps.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/plugin.php | 11 +++++++++++ 2 files changed, 64 insertions(+) create mode 100644 include/apps.php (limited to 'include') diff --git a/include/apps.php b/include/apps.php new file mode 100644 index 000000000..38812ef83 --- /dev/null +++ b/include/apps.php @@ -0,0 +1,53 @@ + Date: Thu, 15 May 2014 17:15:22 -0700 Subject: apps: provide a default photo if none was set. For now it's the default profile photo until we have a default app photo --- include/apps.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 38812ef83..244c2adb7 100644 --- a/include/apps.php +++ b/include/apps.php @@ -40,14 +40,27 @@ function get_system_apps() { function parse_app_description($f) { $ret = array(); + $baseurl = z_root(); + $channel = get_app()->get_channel(); + $address = (($channel) ? $channel['channel_address'] : ''); + + //future expansion + + $observer = get_observer(); + + + $lines = @file($f); if($lines) { foreach($lines as $x) { if(preg_match('/^([a-zA-Z].*?):(.*?)$/ism',$x,$matches)) { - $ret[$matches[1]] = trim($matches[2]); + $ret[$matches[1]] = trim(str_replace(array('$baseurl','$nick'),array($baseurl,$address),$matches[2])); } } } + if(! $ret['photo']) + $ret['photo'] = $baseurl . '/' . get_default_profile_photo(80); + return $ret; } -- cgit v1.2.3 From 077b97eac46989cfc7aadc14f3c4974fb31473b3 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 15 May 2014 19:54:37 -0700 Subject: the app menu takes form --- include/apps.php | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 244c2adb7..f6c09d803 100644 --- a/include/apps.php +++ b/include/apps.php @@ -46,10 +46,9 @@ function parse_app_description($f) { //future expansion - $observer = get_observer(); + $observer = get_app()->get_observer(); - $lines = @file($f); if($lines) { foreach($lines as $x) { @@ -62,5 +61,46 @@ function parse_app_description($f) { if(! $ret['photo']) $ret['photo'] = $baseurl . '/' . get_default_profile_photo(80); - return $ret; + + foreach($ret as $k => $v) { + if(strpos($v,'http') === 0) + $ret[$k] = zid($v); + } + + if(array_key_exists('requires',$ret)) { + $require = trim(strtolower($ret['requires'])); + switch($require) { + case 'local_user': + if(! local_user()) + unset($ret); + break; + case 'observer': + if(! $observer) + unset($ret); + break; + default: + if(! local_user() && feature_enabled(local_user(),$require)) + unset($ret); + break; + + } + logger('require: ' . print_r($ret,true)); + } + if($ret) { + translate_system_apps($ret); + return $ret; + } + return false; } + + +function translate_system_apps(&$arr) { + $apps = array( 'Matrix' => t('Matrix'), 'Channel Home' => t('Channel Home'), 'Profile' => t('Profile'), + 'Photos' => t('Photos') + + ); + + if(array_key_exists($arr['name'],$apps)) + $arr['name'] = $apps[$arr['name']]; + +} \ No newline at end of file -- cgit v1.2.3 From 2dee303d92e4dc5d176483b2af3791b7c5f546cb Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 15 May 2014 20:09:28 -0700 Subject: more base apps --- include/apps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index f6c09d803..ced337e71 100644 --- a/include/apps.php +++ b/include/apps.php @@ -96,7 +96,7 @@ function parse_app_description($f) { function translate_system_apps(&$arr) { $apps = array( 'Matrix' => t('Matrix'), 'Channel Home' => t('Channel Home'), 'Profile' => t('Profile'), - 'Photos' => t('Photos') + 'Photos' => t('Photos'), 'Events' => t('Events') ); -- cgit v1.2.3 From 2fdc13e91d3b0ccd514a13fd7f475f045656b23f Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 15 May 2014 20:20:20 -0700 Subject: some sidebar content (doesn't yet do anything) --- include/widgets.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 0ed79f1eb..37a079bc7 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -74,6 +74,18 @@ function widget_collections($args) { } +function widget_appselect($arr) { + return replace_macros(get_markup_template('app_select.tpl'),array( + '$title' => t('App Category'), + '$system' => t('System'), + '$personal' => t('Personal'), + '$featured' => t('Featured'), + '$new' => t('New') + )); +} + + + function widget_suggestions($arr) { if((! local_user()) || (! feature_enabled(local_user(),'suggest'))) -- cgit v1.2.3 From a2b4187a083a16df788fa6feb196d64ec970d3c4 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 15 May 2014 20:36:09 -0700 Subject: add directory --- include/apps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index ced337e71..80fc0299b 100644 --- a/include/apps.php +++ b/include/apps.php @@ -96,7 +96,7 @@ function parse_app_description($f) { function translate_system_apps(&$arr) { $apps = array( 'Matrix' => t('Matrix'), 'Channel Home' => t('Channel Home'), 'Profile' => t('Profile'), - 'Photos' => t('Photos'), 'Events' => t('Events') + 'Photos' => t('Photos'), 'Events' => t('Events'), 'Directory' => t('Directory') ); -- cgit v1.2.3 From 420540fc9444ec3273338ea7663e7903e9933414 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 15 May 2014 20:39:49 -0700 Subject: login app --- include/apps.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 80fc0299b..733cb30cf 100644 --- a/include/apps.php +++ b/include/apps.php @@ -70,6 +70,10 @@ function parse_app_description($f) { if(array_key_exists('requires',$ret)) { $require = trim(strtolower($ret['requires'])); switch($require) { + case 'nologin': + if(local_user()) + unset($ret); + break; case 'local_user': if(! local_user()) unset($ret); -- cgit v1.2.3 From 659714956ccce13b7055d5bf265be07cf4b79cfa Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 15 May 2014 20:58:26 -0700 Subject: add hover tips - except we need a way to translate the things --- include/apps.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 733cb30cf..1896b938b 100644 --- a/include/apps.php +++ b/include/apps.php @@ -58,6 +58,8 @@ function parse_app_description($f) { } } + + if(! $ret['photo']) $ret['photo'] = $baseurl . '/' . get_default_profile_photo(80); @@ -67,6 +69,9 @@ function parse_app_description($f) { $ret[$k] = zid($v); } + if(array_key_exists('hover',$ret)) + $ret['hover'] = str_replace(array('\'','"'),array(''','&dquot;'),$ret['hover']); + if(array_key_exists('requires',$ret)) { $require = trim(strtolower($ret['requires'])); switch($require) { -- cgit v1.2.3 From 9e95458ea5fd1cc24df59c70d0bf1d315fe6a3a3 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 16 May 2014 02:54:52 -0700 Subject: the help app --- include/apps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 1896b938b..181079f2f 100644 --- a/include/apps.php +++ b/include/apps.php @@ -105,7 +105,7 @@ function parse_app_description($f) { function translate_system_apps(&$arr) { $apps = array( 'Matrix' => t('Matrix'), 'Channel Home' => t('Channel Home'), 'Profile' => t('Profile'), - 'Photos' => t('Photos'), 'Events' => t('Events'), 'Directory' => t('Directory') + 'Photos' => t('Photos'), 'Events' => t('Events'), 'Directory' => t('Directory'), 'Help' => t('Help') ); -- cgit v1.2.3 From 89b8bc07ac7178b8ea722f8d1faa2f649faa8c1b Mon Sep 17 00:00:00 2001 From: marijus Date: Sun, 18 May 2014 09:14:21 +0200 Subject: implement modal for more then 10 likes/dislikes --- include/ItemObject.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index 475642787..cdb09ecf1 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -125,11 +125,24 @@ class Item extends BaseObject { $like_count = ((x($alike,$item['mid'])) ? $alike[$item['mid']] : ''); $like_list = ((x($alike,$item['mid'])) ? $alike[$item['mid'] . '-l'] : ''); + if (count($like_list) > MAX_LIKERS) { + $like_list_part = array_slice($like_list, 0, MAX_LIKERS); + array_push($like_list_part, '' . t('View all') . ''); + } else { + $like_list_part = ''; + } $like_button_label = ((x($alike,$item['mid'])) && ($alike[$item['mid']] < 2 ) ? t('Like') : t('Likes')); + if (feature_enabled($conv->get_profile_owner(),'dislike')) { $dislike_count = ((x($dlike,$item['mid'])) ? $dlike[$item['mid']] : ''); $dislike_list = ((x($dlike,$item['mid'])) ? $dlike[$item['mid'] . '-l'] : ''); $dislike_button_label = ((x($dlike,$item['mid'])) && ($dlike[$item['mid']] < 2) ? t('Dislike') : t('Dislikes')); + if (count($dislike_list) > MAX_LIKERS) { + $dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS); + array_push($dislike_list_part, '' . t('View all') . ''); + } else { + $dislike_list_part = ''; + } } $showlike = ((x($alike,$item['mid'])) ? format_like($alike[$item['mid']],$alike[$item['mid'] . '-l'],'like',$item['mid']) : ''); @@ -261,10 +274,15 @@ class Item extends BaseObject { // end toolbar buttons 'like_count' => $like_count, 'like_list' => $like_list, + 'like_list_part' => $like_list_part, 'like_button_label' => $like_button_label, + 'like_modal_title' => t('Likes'), + 'dislike_modal_title' => t('Dislikes'), 'dislike_count' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_count : ''), 'dislike_list' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list : ''), + 'dislike_list_part' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list_part : ''), 'dislike_button_label' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_button_label : ''), + 'modal_dismiss' => t('Close'), 'showlike' => $showlike, 'showdislike' => $showdislike, 'comment' => $this->get_comment_box($indent), -- cgit v1.2.3 From 070e7cc376ec6465d61a63aa4954969cf9cb9e6e Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 18 May 2014 00:44:42 -0700 Subject: more app infrastructure --- include/apps.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 181079f2f..58af045f1 100644 --- a/include/apps.php +++ b/include/apps.php @@ -104,12 +104,57 @@ function parse_app_description($f) { function translate_system_apps(&$arr) { - $apps = array( 'Matrix' => t('Matrix'), 'Channel Home' => t('Channel Home'), 'Profile' => t('Profile'), - 'Photos' => t('Photos'), 'Events' => t('Events'), 'Directory' => t('Directory'), 'Help' => t('Help') - + $apps = array( 'Matrix' => t('Matrix'), + 'Channel Home' => t('Channel Home'), + 'Profile' => t('Profile'), + 'Photos' => t('Photos'), + 'Events' => t('Events'), + 'Directory' => t('Directory'), + 'Help' => t('Help') ); if(array_key_exists($arr['name'],$apps)) $arr['name'] = $apps[$arr['name']]; -} \ No newline at end of file +} + +function app_render($app) { + + + + + +} + + +function app_install($uid,$app) { + + + +} + + +function app_installed($uid,$app) { + + $r = q("select id from app where app_id = '%s' and app_version = '%s' and app_channel = %d limit 1", + dbesc((array_key_exists('guid',$app)) ? $app['guid'] : ''), + dbesc((array_key_exists('version',$app)) ? $app['version'] : ''), + intval($uid) + ); + return(($r) ? true : false); + +} + + +function app_list($uid) { + $r = q("select * from app where app_channel = %d order by app_name asc", + intval($uid) + ); + return($r); +} + + +function app_decode($s) { + $x = base64_decode($s); + return json_decode($x,true); +} -- cgit v1.2.3 From 2b44af445515a5e1beea14d3d47025a411d39e7b Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 18 May 2014 02:00:06 -0700 Subject: more app work --- include/apps.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 58af045f1..09aee0389 100644 --- a/include/apps.php +++ b/include/apps.php @@ -158,3 +158,47 @@ function app_decode($s) { $x = base64_decode($s); return json_decode($x,true); } + + +function app_store($arr) { + + $darray = array(); + $ret = array('success' => false); + + $darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : ''); + $darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0); + if((! $darray['url']) || (! $darray['app_channel'])) + return $ret; + + $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string()); + $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); + $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); + $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown')); + $darray['app_desc'] = ((x($arr,'desc')) ? escape_tags($arr['desc']) : ''); + $darray['app_photo'] = ((x($arr,'photo')) ? $arr['photo'] : z_root() . '/' . get_default_profile_photo(80)); + $darray['app_version'] = ((x($arr,'version')) ? escape_tags($arr['version']) : ''); + + $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )", + dbesc($darray['app_id']), + dbesc($darray['app_sig']), + dbesc($darray['app_author']), + dbesc($darray['app_name']), + dbesc($darray['app_desc']), + dbesc($darray['app_url']), + dbesc($darray['app_photo']), + dbesc($darray['app_version']), + intval($darray['app_channel']) + ); + if($r) + $ret['success'] = true; + + return $ret; +} + + +function app_update($arr) { + + + + +} \ No newline at end of file -- cgit v1.2.3 From 466fe725bc056ad7ed2c3bf24783b65565293472 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 18 May 2014 18:21:20 -0700 Subject: start to build out the apps --- include/apps.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++------ include/bbcode.php | 14 ++++++++++++ 2 files changed, 70 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 09aee0389..ac6f34ee5 100644 --- a/include/apps.php +++ b/include/apps.php @@ -119,10 +119,8 @@ function translate_system_apps(&$arr) { } function app_render($app) { - - - - +//debugging + return print_r($app,true); } @@ -177,8 +175,11 @@ function app_store($arr) { $darray['app_desc'] = ((x($arr,'desc')) ? escape_tags($arr['desc']) : ''); $darray['app_photo'] = ((x($arr,'photo')) ? $arr['photo'] : z_root() . '/' . get_default_profile_photo(80)); $darray['app_version'] = ((x($arr,'version')) ? escape_tags($arr['version']) : ''); + $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); + $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); + $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); - $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )", + $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s' )", dbesc($darray['app_id']), dbesc($darray['app_sig']), dbesc($darray['app_author']), @@ -187,7 +188,10 @@ function app_store($arr) { dbesc($darray['app_url']), dbesc($darray['app_photo']), dbesc($darray['app_version']), - intval($darray['app_channel']) + intval($darray['app_channel']), + dbesc($darray['app_addr']), + dbesc($darray['app_price']), + dbesc($darray['app_page']) ); if($r) $ret['success'] = true; @@ -201,4 +205,50 @@ function app_update($arr) { +} + + +function app_encode($app) { + + $ret = array(); + + if($app['app_id']) + $ret['guid'] = $app['app_id']; + + if($app['app_id']) + $ret['guid'] = $app['app_id']; + + if($app['app_sig']) + $ret['sig'] = $app['app_sig']; + + if($app['app_author']) + $ret['author'] = $app['app_author']; + + if($app['app_name']) + $ret['name'] = $app['app_name']; + + if($app['app_desc']) + $ret['desc'] = $app['app_desc']; + + if($app['app_url']) + $ret['url'] = $app['app_url']; + + if($app['app_photo']) + $ret['photo'] = $app['app_photo']; + + if($app['app_version']) + $ret['version'] = $app['app_version']; + + if($app['app_addr']) + $ret['addr'] = $app['app_addr']; + + if($app['app_price']) + $ret['price'] = $app['app_price']; + + if($app['app_page']) + $ret['page'] = $app['app_page']; + + $j = json_encode($ret); + return '[app]' . base64_encode($j) . '[/app]'; + } \ No newline at end of file diff --git a/include/bbcode.php b/include/bbcode.php index a4e7560d6..674b5f45a 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -166,6 +166,15 @@ function bb_parse_crypt($match) { } +function bb_parse_app($match) { + require_once('include/apps.php'); + + $app = app_decode($match[1]); + if($app) + return app_render($app); + +} + function bb_qr($match) { return '' . t('QR code') . ''; } @@ -684,6 +693,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = preg_replace_callback("/\[crypt (.*?)\](.*?)\[\/crypt\]/ism", 'bb_parse_crypt', $Text); } + if(strpos($Text,'[/app]') !== false) { + $Text = preg_replace_callback("/\[app\](.*?)\[\/app\]/ism",'bb_parse_app', $Text); + } + + // html5 video and audio if (strpos($Text,'[/video]') !== false) { $Text = preg_replace_callback("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4))\[\/video\]/ism", 'tryzrlvideo', $Text); -- cgit v1.2.3 From ea67b9bda895d30d3115b04ba78db35e6a8b0a74 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 18 May 2014 20:00:30 -0700 Subject: apps: fix encoding/decoding and chunk splitting --- include/apps.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index ac6f34ee5..109da2454 100644 --- a/include/apps.php +++ b/include/apps.php @@ -153,7 +153,7 @@ function app_list($uid) { function app_decode($s) { - $x = base64_decode($s); + $x = base64_decode(str_replace(array('
',"\r","\n",' '),array('','','',''),$s)); return json_decode($x,true); } @@ -249,6 +249,6 @@ function app_encode($app) { $ret['page'] = $app['app_page']; $j = json_encode($ret); - return '[app]' . base64_encode($j) . '[/app]'; + return '[app]' . chunk_split(base64_encode($j),72,"\n") . '[/app]'; } \ No newline at end of file -- cgit v1.2.3 From 6d01707a724504a34b8e84e87c6601a046de9739 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 19 May 2014 16:49:11 -0700 Subject: more app backend work --- include/apps.php | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 109da2454..a1469b400 100644 --- a/include/apps.php +++ b/include/apps.php @@ -126,9 +126,11 @@ function app_render($app) { function app_install($uid,$app) { - - - + $app['uid'] = $uid; + if(app_installed($uid,$app)) + app_update($app); + else + app_store($app); } @@ -168,7 +170,7 @@ function app_store($arr) { if((! $darray['url']) || (! $darray['app_channel'])) return $ret; - $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string()); + $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string(). '.' . get_app()->get_hostname()); $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown')); @@ -202,8 +204,43 @@ function app_store($arr) { function app_update($arr) { + $darray = array(); + $ret = array('success' => false); + $darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : ''); + $darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0); + $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : 0); + if((! $darray['url']) || (! $darray['app_channel']) || (! $darray['app_id'])) + return $ret; + $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); + $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); + $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown')); + $darray['app_desc'] = ((x($arr,'desc')) ? escape_tags($arr['desc']) : ''); + $darray['app_photo'] = ((x($arr,'photo')) ? $arr['photo'] : z_root() . '/' . get_default_profile_photo(80)); + $darray['app_version'] = ((x($arr,'version')) ? escape_tags($arr['version']) : ''); + $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); + $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); + $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); + + $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s' where app_id = '%s' and app_channel = %d limit 1", + dbesc($darray['app_sig']), + dbesc($darray['app_author']), + dbesc($darray['app_name']), + dbesc($darray['app_desc']), + dbesc($darray['app_url']), + dbesc($darray['app_photo']), + dbesc($darray['app_version']), + dbesc($darray['app_addr']), + dbesc($darray['app_price']), + dbesc($darray['app_page']), + dbesc($darray['app_id']), + intval($darray['app_channel']) + ); + if($r) + $ret['success'] = true; + + return $ret; } -- cgit v1.2.3 From fc0967b84b5e1301c0ce3a9a41c00985ce16bc82 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 20 May 2014 18:08:49 -0700 Subject: most of the remaining apps basic infrastructure except a form to create the things. Don't let this fool you - there is still a lot of work, but there isn't a whole lot of work to create a demo; in fact you can demo it now. --- include/apps.php | 54 +++++++++++++++++++++++++++++++++++++++++++++++++---- include/widgets.php | 6 +++--- 2 files changed, 53 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index a1469b400..536a40f01 100644 --- a/include/apps.php +++ b/include/apps.php @@ -118,10 +118,38 @@ function translate_system_apps(&$arr) { } -function app_render($app) { -//debugging - return print_r($app,true); +// papp is a portable app + +function app_render($papp,$mode = 'view') { + + /** + * modes: + * view: normal mode for viewing an app via bbcode from a conversation or page + * provides install/update button if you're logged in locally + * list: normal mode for viewing an app on the app page + * no buttons are shown + * edit: viewing the app page in editing mode provides a delete button + */ + + $installed = false; + + if(! $papp['photo']) + $papp['photo'] = z_root() . '/' . get_default_profile_photo(80); + + $papp['papp'] = papp_encode($papp); + + if(local_user()) { + $installed = app_installed(local_user(),$papp); + } + + $install_action = (($installed) ? t('Update') : t('Install')); + + return replace_macros(get_markup_template('app.tpl'),array( + '$app' => $papp, + '$install' => ((local_user() && $mode == 'view') ? $install_action : ''), + '$delete' => ((local_user() && $installed && $mode == 'edit') ? t('Delete') : '') + )); } @@ -133,6 +161,15 @@ function app_install($uid,$app) { app_store($app); } +function app_destroy($uid,$app) { + if($uid && $app['guid']) { + $r = q("delete from app where app_id = '%s' and app_channel = %d limit 1", + dbesc($app['guid']), + intval($uid) + ); + } +} + function app_installed($uid,$app) { @@ -245,7 +282,7 @@ function app_update($arr) { } -function app_encode($app) { +function app_encode($app,$embed = false) { $ret = array(); @@ -285,7 +322,16 @@ function app_encode($app) { if($app['app_page']) $ret['page'] = $app['app_page']; + if(! $embed) + return $ret; + $j = json_encode($ret); return '[app]' . chunk_split(base64_encode($j),72,"\n") . '[/app]'; +} + + +function papp_encode($papp) { + return chunk_split(base64_encode(json_encode($papp)),72,"\n"); + } \ No newline at end of file diff --git a/include/widgets.php b/include/widgets.php index 37a079bc7..8cd2287a7 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -78,9 +78,9 @@ function widget_appselect($arr) { return replace_macros(get_markup_template('app_select.tpl'),array( '$title' => t('App Category'), '$system' => t('System'), - '$personal' => t('Personal'), - '$featured' => t('Featured'), - '$new' => t('New') + '$personal' => t('Personal') +// '$featured' => t('Featured'), +// '$new' => t('New') )); } -- cgit v1.2.3 From 71f5908e216c71e7ab379bc15902ddf59b2884ba Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 20 May 2014 20:22:38 -0700 Subject: add optional context to translations --- include/language.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/language.php b/include/language.php index b43f5aacc..f4c7d1524 100644 --- a/include/language.php +++ b/include/language.php @@ -145,10 +145,12 @@ function load_translation_table($lang, $install = false) { /** * @brief translate string if translation exists. * - * @param s string that should get translated + * @param $s string that should get translated + * @param $ctx optional context to appear in po file * @return translated string if exsists, otherwise s + * */ -function t($s) { +function t($s,$ctx = '') { global $a; if(x($a->strings,$s)) { -- cgit v1.2.3 From 5d9f924642872e30c83ac0de4807e0beb2c15011 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 20 May 2014 22:25:36 -0700 Subject: more app work --- include/apps.php | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 536a40f01..910d1c84d 100644 --- a/include/apps.php +++ b/include/apps.php @@ -93,7 +93,7 @@ function parse_app_description($f) { break; } - logger('require: ' . print_r($ret,true)); +// logger('require: ' . print_r($ret,true)); } if($ret) { translate_system_apps($ret); @@ -156,9 +156,14 @@ function app_render($papp,$mode = 'view') { function app_install($uid,$app) { $app['uid'] = $uid; if(app_installed($uid,$app)) - app_update($app); + $x = app_update($app); else - app_store($app); + $x = app_store($app); + + if($x['success']) + return $x['app_id']; + + return false; } function app_destroy($uid,$app) { @@ -199,14 +204,22 @@ function app_decode($s) { function app_store($arr) { + // logger('app_store: ' . print_r($arr,true)); + $darray = array(); $ret = array('success' => false); $darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : ''); $darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0); - if((! $darray['url']) || (! $darray['app_channel'])) + if((! $darray['app_url']) || (! $darray['app_channel'])) return $ret; + if($arr['photo'] && ! strstr($arr['photo'],z_root())) { + $x = import_profile_photo($arr['photo'],get_observer_hash(),true); + $arr['photo'] = $x[1]; + } + + $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string(). '.' . get_app()->get_hostname()); $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); @@ -232,9 +245,10 @@ function app_store($arr) { dbesc($darray['app_price']), dbesc($darray['app_page']) ); - if($r) + if($r) { $ret['success'] = true; - + $ret['app_id'] = $darray['app_id']; + } return $ret; } @@ -247,9 +261,14 @@ function app_update($arr) { $darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : ''); $darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0); $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : 0); - if((! $darray['url']) || (! $darray['app_channel']) || (! $darray['app_id'])) + if((! $darray['app_url']) || (! $darray['app_channel']) || (! $darray['app_id'])) return $ret; + if($arr['photo'] && ! strstr($arr['photo'],z_root())) { + $x = import_profile_photo($arr['photo'],get_observer_hash(),true); + $arr['photo'] = $x[1]; + } + $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown')); @@ -274,8 +293,10 @@ function app_update($arr) { dbesc($darray['app_id']), intval($darray['app_channel']) ); - if($r) + if($r) { $ret['success'] = true; + $ret['app_id'] = $darray['app_id']; + } return $ret; -- cgit v1.2.3 From c6de9096fabf913e5e8b4acbde75cd58bb8c9959 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 20 May 2014 22:59:58 -0700 Subject: add zids to all the personal app links --- include/apps.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 910d1c84d..2b5903329 100644 --- a/include/apps.php +++ b/include/apps.php @@ -139,6 +139,11 @@ function app_render($papp,$mode = 'view') { $papp['papp'] = papp_encode($papp); + foreach($papp as $k => $v) { + if(strpos($v,'http') === 0 && $k != 'papp') + $papp[$k] = zid($v); + } + if(local_user()) { $installed = app_installed(local_user(),$papp); } -- cgit v1.2.3 From 72a633dc51b98b25c740a9cb392acfaad77148d8 Mon Sep 17 00:00:00 2001 From: Alexandre Hannud Abdo Date: Wed, 21 May 2014 04:48:22 -0300 Subject: Make translation contexts effective. --- include/language.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/language.php b/include/language.php index f4c7d1524..ba14c33be 100644 --- a/include/language.php +++ b/include/language.php @@ -153,8 +153,9 @@ function load_translation_table($lang, $install = false) { function t($s,$ctx = '') { global $a; - if(x($a->strings,$s)) { - $t = $a->strings[$s]; + $cs = $ctx?"__ctx:".$ctx."__ ".$s:$s; + if(x($a->strings,$cs)) { + $t = $a->strings[$cs]; return is_array($t) ? $t[0] : $t; } return $s; -- cgit v1.2.3 From d15e3776f3ec5476b1614f0488e8e81e0f0ebb70 Mon Sep 17 00:00:00 2001 From: Alexandre Hannud Abdo Date: Wed, 21 May 2014 05:32:46 -0300 Subject: Allow translation context with plural. Use that in Likes/Dislikes. --- include/ItemObject.php | 8 ++++---- include/language.php | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index cdb09ecf1..19283c317 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -131,12 +131,12 @@ class Item extends BaseObject { } else { $like_list_part = ''; } - $like_button_label = ((x($alike,$item['mid'])) && ($alike[$item['mid']] < 2 ) ? t('Like') : t('Likes')); + $like_button_label = tt('Like','Likes',$like_count,'noun'); if (feature_enabled($conv->get_profile_owner(),'dislike')) { $dislike_count = ((x($dlike,$item['mid'])) ? $dlike[$item['mid']] : ''); $dislike_list = ((x($dlike,$item['mid'])) ? $dlike[$item['mid'] . '-l'] : ''); - $dislike_button_label = ((x($dlike,$item['mid'])) && ($dlike[$item['mid']] < 2) ? t('Dislike') : t('Dislikes')); + $dislike_button_label = tt('Dislike','Dislikes',$dislike_count,'noun'); if (count($dislike_list) > MAX_LIKERS) { $dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS); array_push($dislike_list_part, '' . t('View all') . ''); @@ -276,8 +276,8 @@ class Item extends BaseObject { 'like_list' => $like_list, 'like_list_part' => $like_list_part, 'like_button_label' => $like_button_label, - 'like_modal_title' => t('Likes'), - 'dislike_modal_title' => t('Dislikes'), + 'like_modal_title' => t('Likes','noun'), + 'dislike_modal_title' => t('Dislikes','noun'), 'dislike_count' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_count : ''), 'dislike_list' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list : ''), 'dislike_list_part' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list_part : ''), diff --git a/include/language.php b/include/language.php index ba14c33be..780dfadba 100644 --- a/include/language.php +++ b/include/language.php @@ -162,11 +162,12 @@ function t($s,$ctx = '') { } -function tt($singular, $plural, $count){ +function tt($singular, $plural, $count, $ctx = ''){ $a = get_app(); - if(x($a->strings,$singular)) { - $t = $a->strings[$singular]; + $cs = $ctx?"__ctx:".$ctx."__ ".$singular:$singular; + if(x($a->strings,$cs)) { + $t = $a->strings[$cs]; $f = 'string_plural_select_' . str_replace('-', '_', $a->language); if(! function_exists($f)) $f = 'string_plural_select_default'; -- cgit v1.2.3 From 77ca117218382b57e2d0590466d9fc38dc016e80 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 21 May 2014 01:55:32 -0700 Subject: make it possible to edit/delete apps via /apps/personal/edit --- include/apps.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 2b5903329..b5aad2456 100644 --- a/include/apps.php +++ b/include/apps.php @@ -348,6 +348,9 @@ function app_encode($app,$embed = false) { if($app['app_page']) $ret['page'] = $app['app_page']; + if($app['alt_url']) + $ret['alt_url'] = $app['alt_url']; + if(! $embed) return $ret; -- cgit v1.2.3 From 6fb8cd4d24902af1c861c1ee242ea2e86b1eee68 Mon Sep 17 00:00:00 2001 From: Alexandre Hannud Abdo Date: Wed, 21 May 2014 17:23:18 -0300 Subject: Make tag delivery work when channel name differs from profile name --- include/items.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 5aaeb55c0..1c44b7df5 100755 --- a/include/items.php +++ b/include/items.php @@ -2438,7 +2438,7 @@ function tag_deliver($uid,$item_id) { if($terms) { foreach($terms as $term) { - if((strcasecmp($term['term'],$u[0]['channel_name']) == 0) && link_compare($term['url'],$link)) { + if(link_compare($term['url'],$link)) { $mention = true; break; } @@ -2474,11 +2474,11 @@ function tag_deliver($uid,$item_id) { $tagged = false; $plustagged = false; - $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($u[0]['channel_name'],'/') . '\[\/zrl\]/'; + $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'],'/') . '\[\/zrl\]/'; if(preg_match($pattern,$body,$matches)) $tagged = true; - $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($u[0]['channel_name'] . '+','/') . '\[\/zrl\]/'; + $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/'; if(preg_match($pattern,$body,$matches)) $plustagged = true; @@ -2607,7 +2607,7 @@ function tgroup_check($uid,$item) { if($terms) { foreach($terms as $term) { - if(($term['term'] == $u[0]['channel_name']) && link_compare($term['url'],$link)) { + if(link_compare($term['url'],$link)) { $mention = true; break; } @@ -2625,7 +2625,7 @@ function tgroup_check($uid,$item) { $body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']); - $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($u[0]['channel_name'] . '+','/') . '\[\/zrl\]/'; + $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/'; if(! preg_match($pattern,$body,$matches)) { logger('tgroup_check: mention was in a reshare - ignoring'); -- cgit v1.2.3 From d17768d4e7b7f07dfd2f4326f79fa8b1f9a74582 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 21 May 2014 17:23:34 -0700 Subject: change app dropdown to point to apps module (changes nav template). Important: Plugins using the app-menu hook will no longer be accessible from there and may require re-writing to plug into the system apps page. Also filter apps in items from the language detector to avoid false triggers from the base64 content. --- include/language.php | 4 +++- include/nav.php | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/language.php b/include/language.php index 780dfadba..cfaa855dd 100644 --- a/include/language.php +++ b/include/language.php @@ -214,8 +214,10 @@ function detect_language($s) { if($min_confidence === false) $min_confidence = LANGUAGE_DETECT_MIN_CONFIDENCE; + // embedded apps have long base64 strings which will trip up the detector. + $naked_body = preg_replace('/\[app\](.*?)\[\/app\]/','',$s); // strip off bbcode - $naked_body = preg_replace('/\[(.+?)\]/', '', $s); + $naked_body = preg_replace('/\[(.+?)\]/', '', $naked_body); if(mb_strlen($naked_body) < intval($min_length)) { logger('detect language: string length less than ' . intval($min_length), LOGGER_DATA); return ''; diff --git a/include/nav.php b/include/nav.php index a97b434bc..2d0d43d5a 100644 --- a/include/nav.php +++ b/include/nav.php @@ -138,8 +138,8 @@ EOT; if(! get_config('system','hide_help')) $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation')); - if(count($a->get_apps()) > 0) - $nav['apps'] = array('apps', t('Apps'), "", t('Addon applications, utilities, games')); + + $nav['apps'] = array('apps', t('Apps'), "", t('Applications, utilities, links, games')); $nav['search'] = array('search', t('Search'), "", t('Search site content')); @@ -221,7 +221,6 @@ EOT; '$userinfo' => $x['usermenu'], '$localuser' => local_user(), '$sel' => $a->nav_sel, - '$apps' => $a->get_apps(), '$pleasewait' => t('Please wait...') )); -- cgit v1.2.3 From 751fda97045ad4e399e9a01cc14d8eb058b361a8 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 21 May 2014 20:54:09 -0700 Subject: more app work --- include/apps.php | 19 ++++++++++++++++--- include/widgets.php | 8 ++++---- 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index b5aad2456..e632ae3d6 100644 --- a/include/apps.php +++ b/include/apps.php @@ -104,7 +104,15 @@ function parse_app_description($f) { function translate_system_apps(&$arr) { - $apps = array( 'Matrix' => t('Matrix'), + $apps = array( + 'Bookmarks' => t('Bookmarks'), + 'Address Book' => t('Address Book'), + 'Login' => t('Login'), + 'Channel Select' => t('Channel Select'), + 'Matrix' => t('Matrix'), + 'Settings' => t('Settings'), + 'Files' => t('Files'), + 'Webpages' => t('Webpages'), 'Channel Home' => t('Channel Home'), 'Profile' => t('Profile'), 'Photos' => t('Photos'), @@ -142,6 +150,9 @@ function app_render($papp,$mode = 'view') { foreach($papp as $k => $v) { if(strpos($v,'http') === 0 && $k != 'papp') $papp[$k] = zid($v); + if($k === 'desc') + $papp['desc'] = str_replace(array('\'','"'),array(''','&dquot;'),$papp['desc']); + } if(local_user()) { @@ -152,7 +163,9 @@ function app_render($papp,$mode = 'view') { return replace_macros(get_markup_template('app.tpl'),array( '$app' => $papp, + '$purchase' => (($papp['page'] && (! $installed)) ? t('Purchase') : ''), '$install' => ((local_user() && $mode == 'view') ? $install_action : ''), + '$edit' => ((local_user() && $installed && $mode == 'edit') ? t('Edit') : ''), '$delete' => ((local_user() && $installed && $mode == 'edit') ? t('Delete') : '') )); } @@ -348,8 +361,8 @@ function app_encode($app,$embed = false) { if($app['app_page']) $ret['page'] = $app['app_page']; - if($app['alt_url']) - $ret['alt_url'] = $app['alt_url']; +// if($app['alt_url']) +// $ret['alt_url'] = $app['alt_url']; if(! $embed) return $ret; diff --git a/include/widgets.php b/include/widgets.php index 8cd2287a7..1043acce0 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -76,11 +76,11 @@ function widget_collections($args) { function widget_appselect($arr) { return replace_macros(get_markup_template('app_select.tpl'),array( - '$title' => t('App Category'), + '$title' => t('Apps'), '$system' => t('System'), - '$personal' => t('Personal') -// '$featured' => t('Featured'), -// '$new' => t('New') + '$personal' => t('Personal'), + '$new' => t('Create Personal App'), + '$edit' => t('Edit Personal App') )); } -- cgit v1.2.3 From 4d7fc304ea9dd9b756aba406601739652c54f72d Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 21 May 2014 21:47:09 -0700 Subject: Add the admin app --- include/apps.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index e632ae3d6..bf5b292d0 100644 --- a/include/apps.php +++ b/include/apps.php @@ -79,6 +79,10 @@ function parse_app_description($f) { if(local_user()) unset($ret); break; + case 'admin': + if(! is_site_admin()) + unset($ret); + break; case 'local_user': if(! local_user()) unset($ret); @@ -105,6 +109,7 @@ function parse_app_description($f) { function translate_system_apps(&$arr) { $apps = array( + 'Site Admin' => t('Site Admin'), 'Bookmarks' => t('Bookmarks'), 'Address Book' => t('Address Book'), 'Login' => t('Login'), -- cgit v1.2.3 From 6f7fb7a2ac3a8462b8f642436d191ccca720cd9e Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 May 2014 02:13:33 -0700 Subject: sort by app name and not by apd filename --- include/apps.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index bf5b292d0..9eb54af00 100644 --- a/include/apps.php +++ b/include/apps.php @@ -31,11 +31,14 @@ function get_system_apps() { } } } - + usort($ret,'app_name_compare'); return $ret; } +function app_name_compare($a,$b) { + return strcmp($a['name'],$b['name']); +} function parse_app_description($f) { $ret = array(); -- cgit v1.2.3 From bcac633085d9383ad32f3608f07f83df31cc7635 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 May 2014 19:19:04 -0700 Subject: implement 'requires' on personal apps --- include/apps.php | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 9eb54af00..37deb0bbc 100644 --- a/include/apps.php +++ b/include/apps.php @@ -126,7 +126,9 @@ function translate_system_apps(&$arr) { 'Photos' => t('Photos'), 'Events' => t('Events'), 'Directory' => t('Directory'), - 'Help' => t('Help') + 'Help' => t('Help'), + 'Mail' => t('Mail'), + 'Mood' => t('Mood'), ); if(array_key_exists($arr['name'],$apps)) @@ -153,6 +155,9 @@ function app_render($papp,$mode = 'view') { if(! $papp['photo']) $papp['photo'] = z_root() . '/' . get_default_profile_photo(80); + if(! $papp) + return; + $papp['papp'] = papp_encode($papp); foreach($papp as $k => $v) { @@ -161,6 +166,34 @@ function app_render($papp,$mode = 'view') { if($k === 'desc') $papp['desc'] = str_replace(array('\'','"'),array(''','&dquot;'),$papp['desc']); + if($k === 'requires') { + $require = trim(strtolower($v)); + switch($require) { + case 'nologin': + if(local_user()) + return ''; + break; + case 'admin': + if(! is_site_admin()) + return ''; + break; + case 'local_user': + if(! local_user()) + return ''; + break; + case 'observer': + $observer = get_app()->get_observer(); + if(! $observer) + return ''; + break; + default: + if(! local_user() && feature_enabled(local_user(),$require)) + return ''; + break; + + } + + } } if(local_user()) { @@ -256,8 +289,9 @@ function app_store($arr) { $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); + $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); - $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s' )", + $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page, app_requires ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s' )", dbesc($darray['app_id']), dbesc($darray['app_sig']), dbesc($darray['app_author']), @@ -269,7 +303,8 @@ function app_store($arr) { intval($darray['app_channel']), dbesc($darray['app_addr']), dbesc($darray['app_price']), - dbesc($darray['app_page']) + dbesc($darray['app_page']), + dbesc($darray['app_requires']) ); if($r) { $ret['success'] = true; @@ -304,8 +339,9 @@ function app_update($arr) { $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); + $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); - $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s' where app_id = '%s' and app_channel = %d limit 1", + $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s', app_requires = '%s' where app_id = '%s' and app_channel = %d limit 1", dbesc($darray['app_sig']), dbesc($darray['app_author']), dbesc($darray['app_name']), @@ -316,6 +352,7 @@ function app_update($arr) { dbesc($darray['app_addr']), dbesc($darray['app_price']), dbesc($darray['app_page']), + dbesc($darray['app_requires']), dbesc($darray['app_id']), intval($darray['app_channel']) ); @@ -369,8 +406,8 @@ function app_encode($app,$embed = false) { if($app['app_page']) $ret['page'] = $app['app_page']; -// if($app['alt_url']) -// $ret['alt_url'] = $app['alt_url']; + if($app['app_requires']) + $ret['requires'] = $app['app_requires']; if(! $embed) return $ret; -- cgit v1.2.3 From 39d5f2abcfbeabb2e7d1483dfb753eda8882b35b Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 May 2014 20:39:42 -0700 Subject: more apps --- include/apps.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 37deb0bbc..ab09ff531 100644 --- a/include/apps.php +++ b/include/apps.php @@ -129,6 +129,8 @@ function translate_system_apps(&$arr) { 'Help' => t('Help'), 'Mail' => t('Mail'), 'Mood' => t('Mood'), + 'Poke' => t('Poke'), + 'Chat' => t('Chat') ); if(array_key_exists($arr['name'],$apps)) -- cgit v1.2.3 From 345f784f670ed8f41bf0435f1cba8a634597b92d Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 May 2014 21:24:41 -0700 Subject: fix search to use in app --- include/apps.php | 3 ++- include/text.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index ab09ff531..6897669d6 100644 --- a/include/apps.php +++ b/include/apps.php @@ -130,7 +130,8 @@ function translate_system_apps(&$arr) { 'Mail' => t('Mail'), 'Mood' => t('Mood'), 'Poke' => t('Poke'), - 'Chat' => t('Chat') + 'Chat' => t('Chat'), + 'Search' => t('Search') ); if(array_key_exists($arr['name'],$apps)) diff --git a/include/text.php b/include/text.php index 0e136fe8e..b249c9767 100755 --- a/include/text.php +++ b/include/text.php @@ -810,9 +810,9 @@ function search($s,$id='search-box',$url='/search',$save = false) { $o = '
'; $o .= '
'; $o .= ''; - $o .= ''; + $o .= ''; if(feature_enabled(local_user(),'savedsearch')) - $o .= ''; + $o .= ''; $o .= '
'; return $o; } -- cgit v1.2.3 From bc389ff9341d8efec367b2b07c2d1b55be11b8d0 Mon Sep 17 00:00:00 2001 From: Alexandre Hannud Abdo Date: Fri, 23 May 2014 10:16:03 -0300 Subject: Language selection: case-insensitive and system language Fixed ignoring HTTP_ACCEPT_LANGUAGE tags that had uppercase characters. Fixed defining a->language too soon to ever get the system lang --- include/language.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/language.php b/include/language.php index cfaa855dd..855d94505 100644 --- a/include/language.php +++ b/include/language.php @@ -43,8 +43,6 @@ function get_browser_language() { arsort($langs, SORT_NUMERIC); } } - else - $langs['en'] = 1; return $langs; } @@ -65,6 +63,7 @@ function get_best_language() { if(isset($langs) && count($langs)) { foreach ($langs as $lang => $v) { + $lang = strtolower($lang); if(file_exists("view/$lang") && is_dir("view/$lang")) { $preferred = $lang; break; -- cgit v1.2.3 From 9fa929fab5c4c547951a0b42e7d56a94aea17564 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 25 May 2014 23:00:06 -0700 Subject: filter randprof results to avoid channels that are known to be deceased. --- include/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 540e1169d..0cd4be72c 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -510,7 +510,7 @@ function unmark_for_death($contact) { }} function random_profile() { - $r = q("select xchan_url from xchan where 1 order by rand() limit 1"); + $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > UTC_TIMESTAMP() - interval 30 day order by rand() limit 1"); if($r) return $r[0]['xchan_url']; return ''; -- cgit v1.2.3 From b17f923abbfcc79ed80b8a8779681a77a77f0ecc Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 May 2014 16:49:47 -0700 Subject: give the cloud file list a bit of padding --- include/apps.php | 46 ++++++++++++++++++++++++---------------------- include/reddav.php | 2 +- 2 files changed, 25 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/apps.php b/include/apps.php index 6897669d6..a24d8e503 100644 --- a/include/apps.php +++ b/include/apps.php @@ -271,8 +271,9 @@ function app_store($arr) { $darray = array(); $ret = array('success' => false); - $darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : ''); + $darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : ''); $darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0); + if((! $darray['app_url']) || (! $darray['app_channel'])) return $ret; @@ -282,16 +283,16 @@ function app_store($arr) { } - $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string(). '.' . get_app()->get_hostname()); - $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); - $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); - $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown')); - $darray['app_desc'] = ((x($arr,'desc')) ? escape_tags($arr['desc']) : ''); - $darray['app_photo'] = ((x($arr,'photo')) ? $arr['photo'] : z_root() . '/' . get_default_profile_photo(80)); - $darray['app_version'] = ((x($arr,'version')) ? escape_tags($arr['version']) : ''); - $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); - $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); - $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); + $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : random_string(). '.' . get_app()->get_hostname()); + $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); + $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); + $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown')); + $darray['app_desc'] = ((x($arr,'desc')) ? escape_tags($arr['desc']) : ''); + $darray['app_photo'] = ((x($arr,'photo')) ? $arr['photo'] : z_root() . '/' . get_default_profile_photo(80)); + $darray['app_version'] = ((x($arr,'version')) ? escape_tags($arr['version']) : ''); + $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); + $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); + $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); $r = q("insert into app ( app_id, app_sig, app_author, app_name, app_desc, app_url, app_photo, app_version, app_channel, app_addr, app_price, app_page, app_requires ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s' )", @@ -322,9 +323,10 @@ function app_update($arr) { $darray = array(); $ret = array('success' => false); - $darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : ''); + $darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : ''); $darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0); - $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : 0); + $darray['app_id'] = ((x($arr,'guid')) ? $arr['guid'] : 0); + if((! $darray['app_url']) || (! $darray['app_channel']) || (! $darray['app_id'])) return $ret; @@ -333,15 +335,15 @@ function app_update($arr) { $arr['photo'] = $x[1]; } - $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); - $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); - $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown')); - $darray['app_desc'] = ((x($arr,'desc')) ? escape_tags($arr['desc']) : ''); - $darray['app_photo'] = ((x($arr,'photo')) ? $arr['photo'] : z_root() . '/' . get_default_profile_photo(80)); - $darray['app_version'] = ((x($arr,'version')) ? escape_tags($arr['version']) : ''); - $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); - $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); - $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); + $darray['app_sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); + $darray['app_author'] = ((x($arr,'author')) ? $arr['author'] : get_observer_hash()); + $darray['app_name'] = ((x($arr,'name')) ? escape_tags($arr['name']) : t('Unknown')); + $darray['app_desc'] = ((x($arr,'desc')) ? escape_tags($arr['desc']) : ''); + $darray['app_photo'] = ((x($arr,'photo')) ? $arr['photo'] : z_root() . '/' . get_default_profile_photo(80)); + $darray['app_version'] = ((x($arr,'version')) ? escape_tags($arr['version']) : ''); + $darray['app_addr'] = ((x($arr,'addr')) ? escape_tags($arr['addr']) : ''); + $darray['app_price'] = ((x($arr,'price')) ? escape_tags($arr['price']) : ''); + $darray['app_page'] = ((x($arr,'page')) ? escape_tags($arr['page']) : ''); $darray['app_requires'] = ((x($arr,'requires')) ? escape_tags($arr['requires']) : ''); $r = q("update app set app_sig = '%s', app_author = '%s', app_name = '%s', app_desc = '%s', app_url = '%s', app_photo = '%s', app_version = '%s', app_addr = '%s', app_price = '%s', app_page = '%s', app_requires = '%s' where app_id = '%s' and app_channel = %d limit 1", diff --git a/include/reddav.php b/include/reddav.php index 0650531dd..3c2801e89 100644 --- a/include/reddav.php +++ b/include/reddav.php @@ -892,7 +892,7 @@ class RedBrowser extends DAV\Browser\Plugin { $html .= "

Index for " . $this->escapeHTML($path) . "/

- +
"; -- cgit v1.2.3 From f6de9c09fb34ed9eba9210e08097e1aecfaa5dad Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 May 2014 21:21:38 -0700 Subject: logging: include target url when reporting z_fetch_url and z_post_url errors. --- include/network.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index 9f68328b7..03faf9957 100644 --- a/include/network.php +++ b/include/network.php @@ -121,8 +121,8 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { if(! $ret['success']) { $ret['error'] = curl_error($ch); $ret['debug'] = $curl_info; - logger('z_fetch_url: error:' . $ret['error'], LOGGER_DEBUG); - logger('z_fetch_url: debug:' . print_r($curl_info,true), LOGGER_DATA); + logger('z_fetch_url: error: ' . $url . ': ' . $ret['error'], LOGGER_DEBUG); + logger('z_fetch_url: debug: ' . print_r($curl_info,true), LOGGER_DATA); } $ret['body'] = substr($s,strlen($header)); $ret['header'] = $header; @@ -229,8 +229,8 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) { if(! $ret['success']) { $ret['error'] = curl_error($ch); $ret['debug'] = $curl_info; - logger('z_post_url: error:' . $ret['error'], LOGGER_DEBUG); - logger('z_post_url: debug:' . print_r($curl_info,true), LOGGER_DATA); + logger('z_post_url: error: ' . $url . ': ' . $ret['error'], LOGGER_DEBUG); + logger('z_post_url: debug: ' . print_r($curl_info,true), LOGGER_DATA); } $ret['body'] = substr($s,strlen($header)); -- cgit v1.2.3 From 30eb1b494a403acf0bcad461907ece77c707d574 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 May 2014 17:58:49 -0700 Subject: moods: simplify 'xyz is tired' rather than 'xyz is currently tired'. This is possible now that we have translation contexts, as before '$1 is $2' was ambiguous without a context - in this case 'mood'. --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 2d72f3489..21ce3bb66 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -255,7 +255,7 @@ function localize_item(&$item){ $A = '[zrl=' . chanlink_url($Alink) . ']' . $Aname . '[/zrl]'; - $txt = t('%1$s is currently %2$s'); + $txt = t('%1$s is %2$s','mood'); $item['body'] = sprintf($txt, $A, t($verb)); } -- cgit v1.2.3 From 2a6d7b6a079a565afc0200fe160cb2402ed7c0a3 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 May 2014 21:42:46 -0700 Subject: cleanup dead directory entries. This was a real b#tch, so keep your eye out for issues - which you shouldn't see until next weekend when this is scheduled to run. We're only setting flags, so if anything goes wrong we should be able to recover without too much pain. --- include/Contact.php | 84 +++++++++++++++++++++++++++++++++++++++++------------ include/poller.php | 3 +- include/zot.php | 18 ++++++++++++ 3 files changed, 86 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 0cd4be72c..6e12652a5 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -141,24 +141,6 @@ function abook_toggle_flag($abook,$flag) { } - - - - - - - - - - - - - - - - - - // Included here for completeness, but this is a very dangerous operation. // It is the caller's responsibility to confirm the requestor's intent and // authorisation to do this. @@ -305,6 +287,72 @@ function channel_remove($channel_id, $local = true) { } +/** + * mark any hubs "offline" that haven't been heard from in more than 30 days + * Allow them to redeem themselves if they come back later. + * Then go through all those that are newly marked and see if any other hubs + * are attached to the controlling xchan that are still alive. + * If not, they're dead (although they could come back some day). + */ + + +function mark_orphan_hubsxchans() { + + $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where not (hubloc_status & %d) + and hubloc_connected < utc_timestamp() - interval 30 day", + intval(HUBLOC_OFFLINE), + intval(HUBLOC_OFFLINE) + ); + + $r = q("select hubloc_id, hubloc_hash from hubloc where (hubloc_status & %d) and not (hubloc_flags & %d)", + intval(HUBLOC_OFFLINE), + intval(HUBLOC_FLAGS_ORPHANCHECK) + ); + + if($r) { + foreach($r as $rr) { + + // see if any other hublocs are still alive for this channel + + $x = q("select * from hubloc where hubloc_hash = '%s' and not (hubloc_status & %d)", + dbesc($rr['hubloc_hash']), + intval(HUBLOC_OFFLINE) + ); + if($x) { + + // yes - if the xchan was marked as an orphan, undo it + + $y = q("update xchan set xchan_flags = (xchan_flags ^ %d) where (xchan_flags & %d) and xchan_hash = '%s' limit 1", + intval(XCHAN_FLAGS_ORPHAN), + intval(XCHAN_FLAGS_ORPHAN), + dbesc($rr['hubloc_hash']) + ); + + } + else { + + // nope - mark the xchan as an orphan + + $y = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s' limit 1", + intval(XCHAN_FLAGS_ORPHAN), + dbesc($rr['hubloc_hash']) + ); + } + + // mark that we've checked this entry so we don't need to do it again + + $y = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d limit 1", + intval(HUBLOC_FLAGS_ORPHANCHECK), + dbesc($rr['hubloc_id']) + ); + } + } + +} + + + + function remove_all_xchan_resources($xchan, $channel_id = 0) { if(intval($channel_id)) { diff --git a/include/poller.php b/include/poller.php index 9592c29e4..35844e666 100644 --- a/include/poller.php +++ b/include/poller.php @@ -118,10 +118,11 @@ function poller_run($argv, $argc){ require_once('include/hubloc.php'); prune_hub_reinstalls(); + require_once('include/Contact.php'); + mark_orphan_hubsxchans(); } - // expire any read notifications over a month old q("delete from notify where seen = 1 and date < UTC_TIMESTAMP() - INTERVAL 30 DAY"); diff --git a/include/zot.php b/include/zot.php index 869943a24..303f4f4a7 100644 --- a/include/zot.php +++ b/include/zot.php @@ -840,6 +840,24 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED) { intval($r[0]['hubloc_id']) ); } + if($r[0]['hubloc_status'] & HUBLOC_OFFLINE) { + q("update hubloc set hubloc_status = (hubloc_status ^ %d) where hubloc_id = %d limit 1", + intval(HUBLOC_OFFLINE), + intval($r[0]['hubloc_id']) + ); + if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { + q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where hubloc_id = %d limit 1", + intval(HUBLOC_FLAGS_ORPHANCHECK), + intval($r[0]['hubloc_id']) + ); + } + q("update xchan set xchan_flags = (xchan_flags ^ %d) where (xchan_flags & %d) and xchan_hash = '%s' limit 1", + intval(XCHAN_FLAGS_ORPHAN), + intval(XCHAN_FLAGS_ORPHAN), + dbesc($xchan_hash) + ); + + } // Remove pure duplicates if(count($r) > 1) { -- cgit v1.2.3 From 1a58777daa0ab9394f38737a806a7a185ebceeb0 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 29 May 2014 00:55:34 -0700 Subject: this is an important bit - only mark dead hubs on directory servers. They shouldn't matter anywhere else. --- include/Contact.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 6e12652a5..b4583c358 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -298,6 +298,10 @@ function channel_remove($channel_id, $local = true) { function mark_orphan_hubsxchans() { + $dirmode = intval(get_config('system','directory_mode')); + if($dirmode == DIRECTORY_MODE_NORMAL) + return; + $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where not (hubloc_status & %d) and hubloc_connected < utc_timestamp() - interval 30 day", intval(HUBLOC_OFFLINE), -- cgit v1.2.3
NameTypeSizeLast modified