diff --git a/boot.php b/boot.php
index 24f7d5532..2eb55caac 100755
--- a/boot.php
+++ b/boot.php
@@ -47,7 +47,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
-define ( 'DB_UPDATE_VERSION', 1109 );
+define ( 'DB_UPDATE_VERSION', 1110 );
define ( 'EOL', '
' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
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;
}
diff --git a/install/database.sql b/install/database.sql
index 0de5879a2..d03cebd4b 100644
--- a/install/database.sql
+++ b/install/database.sql
@@ -85,7 +85,7 @@ CREATE TABLE IF NOT EXISTS `addon` (
CREATE TABLE IF NOT EXISTS `app` (
`id` int(11) NOT NULL AUTO_INCREMENT,
- `app_id` char(64) NOT NULL DEFAULT '',
+ `app_id` char(255) NOT NULL DEFAULT '',
`app_sig` char(255) NOT NULL DEFAULT '',
`app_author` char(255) NOT NULL DEFAULT '',
`app_name` char(255) NOT NULL DEFAULT '',
diff --git a/install/update.php b/install/update.php
index 561070ba4..b91589c28 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
+
+{{$ap.name}}
+
+
+