aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Apps.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-07-27 13:59:27 -0700
committerzotlabs <mike@macgirvin.com>2018-07-27 13:59:27 -0700
commite28dab17d6b958d6ef76181d23f784d17bc70b5e (patch)
treea39ff562a3bca958d914731b2b39ab203d22792e /Zotlabs/Lib/Apps.php
parenta94c9d270906136f69156c0e7c0bd2c8a2e63d1a (diff)
downloadvolse-hubzilla-e28dab17d6b958d6ef76181d23f784d17bc70b5e.tar.gz
volse-hubzilla-e28dab17d6b958d6ef76181d23f784d17bc70b5e.tar.bz2
volse-hubzilla-e28dab17d6b958d6ef76181d23f784d17bc70b5e.zip
app update and ownership issues
Diffstat (limited to 'Zotlabs/Lib/Apps.php')
-rw-r--r--Zotlabs/Lib/Apps.php57
1 files changed, 50 insertions, 7 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index 82f0b57b8..b337a3bcd 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -140,10 +140,15 @@ class Apps {
foreach(self::$available_apps as $iapp) {
if($iapp['app_id'] == hash('whirlpool',$app['name'])) {
$notfound = false;
- if(($iapp['app_version'] != $app['version'])
+ if(($iapp['app_version'] !== $app['version'])
|| ($app['plugin'] && (! $iapp['app_plugin']))) {
return intval($iapp['app_id']);
}
+
+ if(($iapp['app_url'] !== $app['url'])
+ || ($iapp['app_photo'] !== $app['photo'])) {
+ return intval($iapp['app_id']);
+ }
}
}
@@ -198,12 +203,11 @@ class Apps {
if($lines) {
foreach($lines as $x) {
if(preg_match('/^([a-zA-Z].*?):(.*?)$/ism',$x,$matches)) {
- $ret[$matches[1]] = trim(str_replace(array('$baseurl','$nick'),array($baseurl,$address),$matches[2]));
+ $ret[$matches[1]] = trim($matches[2]);
}
}
}
-
if(! $ret['photo'])
$ret['photo'] = $baseurl . '/' . get_default_profile_photo(80);
@@ -372,9 +376,24 @@ class Apps {
$papp['papp'] = self::papp_encode($papp);
+ // This will catch somebody clicking on a system "available" app that hasn't had the path macros replaced
+ // and they are allowed to see the app
+
+
+ if(strstr($papp['url'],'$baseurl') || strstr($papp['url'],'$nick') || strstr($papp['photo'],'$baseurl') || strstr($pap['photo'],'$nick')) {
+ $view_channel = local_channel();
+ if(! $view_channel) {
+ $sys = get_sys_channel();
+ $view_channel = $sys['channel_id'];
+ }
+ self::app_macros($view_channel,$papp);
+ }
+
if(! strstr($papp['url'],'://'))
$papp['url'] = z_root() . ((strpos($papp['url'],'/') === 0) ? '' : '/') . $papp['url'];
+
+
foreach($papp as $k => $v) {
if(strpos($v,'http') === 0 && $k != 'papp') {
if(! (local_channel() && strpos($v,z_root()) === 0)) {
@@ -811,6 +830,29 @@ class Apps {
}
+ static public function app_macros($uid,&$arr) {
+
+ if(! intval($uid))
+ return;
+
+ $baseurl = z_root();
+ $channel = channelx_by_n($uid);
+ $address = (($channel) ? $channel['channel_address'] : '');
+
+ //future expansion
+
+ $observer = \App::get_observer();
+
+ $arr['url'] = str_replace(array('$baseurl','$nick'),array($baseurl,$address),$arr['url']);
+ $arr['photo'] = str_replace(array('$baseurl','$nick'),array($baseurl,$address),$arr['photo']);
+
+ }
+
+
+
+
+
+
static public function app_store($arr) {
//logger('app_store: ' . print_r($arr,true));
@@ -820,6 +862,7 @@ class Apps {
$sys = get_sys_channel();
+ self::app_macros($arr['uid'],$arr);
$darray['app_url'] = ((x($arr,'url')) ? $arr['url'] : '');
$darray['app_channel'] = ((x($arr,'uid')) ? $arr['uid'] : 0);
@@ -905,11 +948,14 @@ class Apps {
$darray = array();
$ret = array('success' => false);
+ self::app_macros($arr['uid'],$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['app_url']) || (! $darray['app_channel']) || (! $darray['app_id']))
+ if((! $darray['app_url']) || (! $darray['app_id']))
return $ret;
if($arr['photo'] && (strpos($arr['photo'],'icon:') !== 0) && (! strstr($arr['photo'],z_root()))) {
@@ -999,9 +1045,6 @@ class Apps {
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'];