diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 957b859af..fa2368a92 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -640,7 +640,21 @@ class Notifier { } else { $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : ''); - $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + + // currently zot6 delivery is only performed on normal items and not sync items or mail or anything else + // Eventually we will do this for all deliveries, but for now ensure this is precisely what we are dealing + // with before switching to zot6 as the primary zot6 handler checks for the existence of a message delivery report + // to trigger dequeue'ing + + $z6 = (($encoded_item && $encoded_item['type'] === 'activity' && (! array_key_exists('allow_cid',$encoded_item))) ? true : false); + if($z6) { + $packet = zot6_build_packet($channel,'notify',$env, json_encode($encoded_item), (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + } + else { + $packet = zot_build_packet($channel,'notify',$env, (($private) ? $hub['hubloc_sitekey'] : null), $hub['site_crypto'],$hash); + + } + queue_insert( [ 'hash' => $hash, diff --git a/Zotlabs/Identity/OAuth2Server.php b/Zotlabs/Identity/OAuth2Server.php index 3d7d5efb2..cbb4748fe 100644 --- a/Zotlabs/Identity/OAuth2Server.php +++ b/Zotlabs/Identity/OAuth2Server.php @@ -2,42 +2,33 @@ namespace Zotlabs\Identity; -class OAuth2Server { +class OAuth2Server extends \OAuth2\Server { - public $server; + public function __construct(OAuth2Storage $storage, $config = []) { - public function __construct() { + if(! is_array($config)) { + $config = [ + 'use_openid_connect' => true, + 'issuer' => \Zotlabs\Lib\System::get_site_name() + ]; + } - $storage = new OAuth2Storage(\DBA::$dba->db); - - $config = [ - 'use_openid_connect' => true, - 'issuer' => \Zotlabs\Lib\System::get_site_name() - ]; - - // Pass a storage object or array of storage objects to the OAuth2 server class - $this->server = new \OAuth2\Server($storage,$config); + parent::__construct($storage, $config); // Add the "Client Credentials" grant type (it is the simplest of the grant types) - $this->server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage)); + $this->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage)); // Add the "Authorization Code" grant type (this is where the oauth magic happens) - $this->server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage)); + $this->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage)); - $keyStorage = new \OAuth2\Storage\Memory( [ - 'keys' => [ - 'public_key' => get_config('system','pubkey'), - 'private_key' => get_config('system','prvkey') + $keyStorage = new \OAuth2\Storage\Memory( [ + 'keys' => [ + 'public_key' => get_config('system', 'pubkey'), + 'private_key' => get_config('system', 'prvkey') ] ]); - $this->server->addStorage($keyStorage,'public_key'); - + $this->addStorage($keyStorage, 'public_key'); } - public function get_server() { - return $this->server; - } - - -} \ No newline at end of file +} diff --git a/Zotlabs/Lib/DB_Upgrade.php b/Zotlabs/Lib/DB_Upgrade.php index 8f0488f6f..4038a2d53 100644 --- a/Zotlabs/Lib/DB_Upgrade.php +++ b/Zotlabs/Lib/DB_Upgrade.php @@ -10,22 +10,12 @@ class DB_Upgrade { function __construct($db_revision) { - $platform_name = System::get_platform_name(); + $this->config_name = 'db_version'; + $this->func_prefix = '_'; - $update_file = 'install/' . $platform_name . '/update.php'; - if(! file_exists($update_file)) { - $update_file = 'install/update.php'; - $this->config_name = 'db_version'; - $this->func_prefix = 'update_r'; - } - else { - $this->config_name = $platform_name . '_db_version'; - $this->func_prefix = $platform_name . '_update_'; - } - - $build = get_config('system', $this->config_name, 0); + $build = get_config('system', 'db_version', 0); if(! intval($build)) - $build = set_config('system', $this->config_name, $db_revision); + $build = set_config('system', 'db_version', $db_revision); if($build == $db_revision) { // Nothing to be done. @@ -40,82 +30,78 @@ class DB_Upgrade { $current = intval($db_revision); - if(($stored < $current) && file_exists($update_file)) { + if($stored < $current) { - Config::Load('database'); + // The last update we performed was $stored. + // Start at $stored + 1 and continue until we have completed $current - // We're reporting a different version than what is currently installed. - // Run any existing update scripts to bring the database up to current. - - require_once($update_file); - - // make sure that boot.php and update.php are the same release, we might be - // updating from git right this very second and the correct version of the update.php - // file may not be here yet. This can happen on a very busy site. - - if($db_revision == UPDATE_VERSION) { - for($x = $stored; $x < $current; $x ++) { - $func = $this->func_prefix . $x; - if(function_exists($func)) { - // There could be a lot of processes running or about to run. - // We want exactly one process to run the update command. - // So store the fact that we're taking responsibility - // after first checking to see if somebody else already has. - - // If the update fails or times-out completely you may need to - // delete the config entry to try again. - - if(get_config('database', $func)) - break; - set_config('database',$func, '1'); - // call the specific update - - $retval = $func(); - if($retval) { - - // Prevent sending hundreds of thousands of emails by creating - // a lockfile. - - $lockfile = 'store/[data]/mailsent'; - - if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400))) - return; - @unlink($lockfile); - //send the administrator an e-mail - file_put_contents($lockfile, $x); - - $r = q("select account_language from account where account_email = '%s' limit 1", - dbesc(\App::$config['system']['admin_email']) - ); - push_lang(($r) ? $r[0]['account_language'] : 'en'); - - z_mail( - [ - 'toEmail' => \App::$config['system']['admin_email'], - 'messageSubject' => sprintf( t('Update Error at %s'), z_root()), - 'textVersion' => replace_macros(get_intltext_template('update_fail_eml.tpl'), - [ - '$sitename' => \App::$config['system']['sitename'], - '$siteurl' => z_root(), - '$update' => $x, - '$error' => sprintf( t('Update %s failed. See error logs.'), $x) - ] - ) - ] - ); - - //try the logger - logger('CRITICAL: Update Failed: ' . $x); - pop_lang(); - } - else { - set_config('database',$func, 'success'); - } - } + for($x = $stored + 1; $x <= $current; $x ++) { + $s = '_' . $x; + $cls = '\\Zotlabs\Update\\' . $s ; + if(! class_exists($cls)) { + return; + } + + // There could be a lot of processes running or about to run. + // We want exactly one process to run the update command. + // So store the fact that we're taking responsibility + // after first checking to see if somebody else already has. + + // If the update fails or times-out completely you may need to + // delete the config entry to try again. + + Config::Load('database'); + + if(get_config('database', $s)) + break; + set_config('database',$s, '1'); + + + $c = new $cls(); + $retval = $c->run(); + + if($retval != UPDATE_SUCCESS) { + + // Prevent sending hundreds of thousands of emails by creating + // a lockfile. + + $lockfile = 'store/[data]/mailsent'; + + if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400))) + return; + @unlink($lockfile); + //send the administrator an e-mail + file_put_contents($lockfile, $x); + + $r = q("select account_language from account where account_email = '%s' limit 1", + dbesc(\App::$config['system']['admin_email']) + ); + push_lang(($r) ? $r[0]['account_language'] : 'en'); + z_mail( + [ + 'toEmail' => \App::$config['system']['admin_email'], + 'messageSubject' => sprintf( t('Update Error at %s'), z_root()), + 'textVersion' => replace_macros(get_intltext_template('update_fail_eml.tpl'), + [ + '$sitename' => \App::$config['system']['sitename'], + '$siteurl' => z_root(), + '$update' => $x, + '$error' => sprintf( t('Update %s failed. See error logs.'), $x) + ] + ) + ] + ); + + //try the logger + logger('CRITICAL: Update Failed: ' . $x); + pop_lang(); + } + else { + set_config('database',$s, 'success'); } - set_config('system', $this->config_name, $db_revision); } } + set_config('system', 'db_version', $db_revision); } } } \ No newline at end of file diff --git a/Zotlabs/Module/Admin/Dbsync.php b/Zotlabs/Module/Admin/Dbsync.php index cff8a2484..469af2aa5 100644 --- a/Zotlabs/Module/Admin/Dbsync.php +++ b/Zotlabs/Module/Admin/Dbsync.php @@ -7,36 +7,38 @@ namespace Zotlabs\Module\Admin; class Dbsync { - - function get() { $o = ''; if(argc() > 3 && intval(argv(3)) && argv(2) === 'mark') { - set_config('database', 'update_r' . intval(argv(3)), 'success'); - if(intval(get_config('system','db_version')) <= intval(argv(3))) - set_config('system','db_version',intval(argv(3)) + 1); + // remove the old style config if it exists + del_config('database', 'update_r' . intval(argv(3))); + set_config('database', '_' . intval(argv(3)), 'success'); + if(intval(get_config('system','db_version')) < intval(argv(3))) + set_config('system','db_version',intval(argv(3))); info( t('Update has been marked successful') . EOL); goaway(z_root() . '/admin/dbsync'); } if(argc() > 2 && intval(argv(2))) { - require_once('install/update.php'); - $func = 'update_r' . intval(argv(2)); - if(function_exists($func)) { - $retval = $func(); + $x = intval(argv(2)); + $s = '_' . $x; + $cls = '\\Zotlabs\Update\\' . $s ; + if(class_exists($cls)) { + $c = new $cls(); + $retval = $c->run(); if($retval === UPDATE_FAILED) { - $o .= sprintf( t('Executing %s failed. Check system logs.'), $func); + $o .= sprintf( t('Executing %s failed. Check system logs.'), $s); } elseif($retval === UPDATE_SUCCESS) { - $o .= sprintf( t('Update %s was successfully applied.'), $func); - set_config('database',$func, 'success'); + $o .= sprintf( t('Update %s was successfully applied.'), $s); + set_config('database',$s, 'success'); } else - $o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $func); + $o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $s); } else - $o .= sprintf( t('Update function %s could not be found.'), $func); + $o .= sprintf( t('Update function %s could not be found.'), $s); return $o; } @@ -45,23 +47,25 @@ class Dbsync { $r = q("select * from config where cat = 'database' "); if(count($r)) { foreach($r as $rr) { - $upd = intval(substr($rr['k'],8)); + $upd = intval(substr($rr['k'],-4)); if($rr['v'] === 'success') continue; $failed[] = $upd; } } - if(! count($failed)) - return '

' . t('No failed updates.') . '

'; - - $o = replace_macros(get_markup_template('failed_updates.tpl'),array( - '$base' => z_root(), - '$banner' => t('Failed Updates'), - '$desc' => '', - '$mark' => t('Mark success (if update was manually applied)'), - '$apply' => t('Attempt to execute this update step automatically'), - '$failed' => $failed + if(count($failed)) { + $o = replace_macros(get_markup_template('failed_updates.tpl'),array( + '$base' => z_root(), + '$banner' => t('Failed Updates'), + '$desc' => '', + '$mark' => t('Mark success (if update was manually applied)'), + '$apply' => t('Attempt to execute this update step automatically'), + '$failed' => $failed )); + } + else { + return '

' . t('No failed updates.') . '

'; + } return $o; } diff --git a/Zotlabs/Module/Authorize.php b/Zotlabs/Module/Authorize.php index 7676b0855..254700b4e 100644 --- a/Zotlabs/Module/Authorize.php +++ b/Zotlabs/Module/Authorize.php @@ -2,13 +2,13 @@ namespace Zotlabs\Module; +use Zotlabs\Identity\OAuth2Storage; + class Authorize extends \Zotlabs\Web\Controller { - function init() { - // workaround for HTTP-auth in CGI mode if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; @@ -28,41 +28,40 @@ class Authorize extends \Zotlabs\Web\Controller { } } - $s = new \Zotlabs\Identity\OAuth2Server(); + $s = new \Zotlabs\Identity\OAuth2Server(new OAuth2Storage(\DBA::$dba->db)); $request = \OAuth2\Request::createFromGlobals(); $response = new \OAuth2\Response(); // validate the authorize request - if (! $s->server->validateAuthorizeRequest($request, $response)) { - $response->send(); - killme(); + if (! $s->validateAuthorizeRequest($request, $response)) { + $response->send(); + killme(); } - // display an authorization form - if (empty($_POST)) { + // display an authorization form + if (empty($_POST)) { - return ' + return '

'; + } + + // print the authorization code if the user has authorized your client + $is_authorized = ($_POST['authorized'] === 'yes'); + $s->handleAuthorizeRequest($request, $response, $is_authorized, local_channel()); + if ($is_authorized) { + // this is only here so that you get to see your code in the cURL request. Otherwise, + // we'd redirect back to the client + $code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=')+5, 40); + echo("SUCCESS! Authorization Code: $code"); + } + + $response->send(); + killme(); } - // print the authorization code if the user has authorized your client - $is_authorized = ($_POST['authorized'] === 'yes'); - $s->server->handleAuthorizeRequest($request, $response, $is_authorized, local_channel()); - if ($is_authorized) { - // this is only here so that you get to see your code in the cURL request. Otherwise, - // we'd redirect back to the client - $code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=')+5, 40); - echo("SUCCESS! Authorization Code: $code"); - - } - - $response->send(); - killme(); - } - -} \ No newline at end of file +} diff --git a/Zotlabs/Module/Token.php b/Zotlabs/Module/Token.php index 5cde58895..f7c074233 100644 --- a/Zotlabs/Module/Token.php +++ b/Zotlabs/Module/Token.php @@ -2,6 +2,8 @@ namespace Zotlabs\Module; +use Zotlabs\Identity\OAuth2Storage; + class Token extends \Zotlabs\Web\Controller { @@ -26,11 +28,10 @@ class Token extends \Zotlabs\Web\Controller { } } - - $s = new \Zotlabs\Identity\OAuth2Server(); - $s->server->handleTokenRequest(\OAuth2\Request::createFromGlobals())->send(); + $s = new \Zotlabs\Identity\OAuth2Server(new OAuth2Storage(\DBA::$dba->db)); + $s->handleTokenRequest(\OAuth2\Request::createFromGlobals())->send(); killme(); } -} \ No newline at end of file +} diff --git a/Zotlabs/Update/_1000.php b/Zotlabs/Update/_1000.php new file mode 100644 index 000000000..02787db38 --- /dev/null +++ b/Zotlabs/Update/_1000.php @@ -0,0 +1,15 @@ + 0 "); + + if($r1 && $r2 && $r3) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +} \ No newline at end of file diff --git a/Zotlabs/Update/_1137.php b/Zotlabs/Update/_1137.php new file mode 100644 index 000000000..ab11fe3db --- /dev/null +++ b/Zotlabs/Update/_1137.php @@ -0,0 +1,16 @@ +' . $match[2] . ''; + return $match[1] . '
' . $match[2] . '
' . t('View article') . '
'; } diff --git a/include/crypto.php b/include/crypto.php index 105c1c54f..ab33ba096 100644 --- a/include/crypto.php +++ b/include/crypto.php @@ -122,7 +122,18 @@ function other_encapsulate($data,$pubkey,$alg) { if(! $pubkey) logger('no key. data: ' . $data); - $fn = strtoupper($alg) . '_encrypt'; + $oaep = false; + + if(strpos($alg,'.oaep')) { + $oaep = true; + $subalg = substr($alg,0,-5); + } + else { + $subalg = $alg; + } + + + $fn = strtoupper($subalg) . '_encrypt'; if(function_exists($fn)) { // A bit hesitant to use openssl_random_pseudo_bytes() as we know @@ -140,14 +151,14 @@ function other_encapsulate($data,$pubkey,$alg) { $iv = openssl_random_pseudo_bytes(256); $result['data'] = base64url_encode($fn($data,$key,$iv),true); // log the offending call so we can track it down - if(! openssl_public_encrypt($key,$k,$pubkey)) { + if(! openssl_public_encrypt($key,$k,$pubkey,(($oaep) ? OPENSSL_PKCS1_OAEP_PADDING : OPENSSL_PKCS1_PADDING))) { $x = debug_backtrace(); logger('RSA failed. ' . print_r($x[0],true)); } $result['alg'] = $alg; $result['key'] = base64url_encode($k,true); - openssl_public_encrypt($iv,$i,$pubkey); + openssl_public_encrypt($iv,$i,$pubkey,(($oaep) ? OPENSSL_PKCS1_OAEP_PADDING : OPENSSL_PKCS1_PADDING)); $result['iv'] = base64url_encode($i,true); return $result; } @@ -166,7 +177,7 @@ function crypto_methods() { // The actual methods are responsible for deriving the actual key/iv from the provided parameters; // possibly by truncation or segmentation - though many other methods could be used. - $r = [ 'aes256ctr', 'camellia256cfb', 'cast5cfb', 'aes256cbc', 'aes128cbc', 'cast5cbc' ]; + $r = [ 'aes256ctr.oaep', 'camellia256cfb.oaep', 'cast5cfb.oaep', 'aes256ctr', 'camellia256cfb', 'cast5cfb', 'aes256cbc', 'aes128cbc', 'cast5cbc' ]; call_hooks('crypto_methods',$r); return $r; @@ -207,6 +218,7 @@ function aes_encapsulate($data,$pubkey) { function crypto_unencapsulate($data,$prvkey) { if(! $data) return; + $alg = ((array_key_exists('alg',$data)) ? $data['alg'] : 'aes256cbc'); if($alg === 'aes256cbc') return aes_unencapsulate($data,$prvkey); @@ -216,10 +228,21 @@ function crypto_unencapsulate($data,$prvkey) { } function other_unencapsulate($data,$prvkey,$alg) { - $fn = strtoupper($alg) . '_decrypt'; + + $oaep = false; + + if(strpos($alg,'.oaep')) { + $oaep = true; + $subalg = substr($alg,0,-5); + } + else { + $subalg = $alg; + } + + $fn = strtoupper($subalg) . '_decrypt'; if(function_exists($fn)) { - openssl_private_decrypt(base64url_decode($data['key']),$k,$prvkey); - openssl_private_decrypt(base64url_decode($data['iv']),$i,$prvkey); + openssl_private_decrypt(base64url_decode($data['key']),$k,$prvkey,(($oaep) ? OPENSSL_PKCS1_OAEP_PADDING : OPENSSL_PKCS1_PADDING)); + openssl_private_decrypt(base64url_decode($data['iv']),$i,$prvkey,(($oaep) ? OPENSSL_PKCS1_OAEP_PADDING : OPENSSL_PKCS1_PADDING)); return $fn(base64url_decode($data['data']),$k,$i); } else { diff --git a/include/feedutils.php b/include/feedutils.php index c4e9790de..369193fce 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -436,6 +436,9 @@ function get_atom_elements($feed, $item) { $summary = unxmlify($item->get_description(true)); + if($summary === $res['body']) + $summary = ''; + if(($summary) && ((strpos($summary,'<') !== false) || (strpos($summary,'>') !== false))) { $summary = purify_html($summary); $summary = html2bbcode($summary); diff --git a/include/items.php b/include/items.php index 04962ec76..68fa4c3b2 100755 --- a/include/items.php +++ b/include/items.php @@ -3477,7 +3477,7 @@ function item_expire($uid,$days) { AND item_thread_top = 1 AND resource_type = '' AND item_starred = 0 - $sql_extra $item_normal ORDER BY created ASC LIMIT $expire_limit ", + $sql_extra $item_normal LIMIT $expire_limit ", intval($uid), db_utcnow(), db_quoteinterval(intval($days).' DAY') diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index 8d1c8d648..36cd2539b 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -654,6 +654,9 @@ CREATE TABLE IF NOT EXISTS `item` ( KEY `uid_item_type` (`uid`, `item_type`), KEY `uid_item_thread_top` (`uid`, `item_thread_top`), KEY `uid_item_blocked` (`uid`, `item_blocked`), + KEY `uid_item_wall` (`uid`, `item_wall`), + KEY `uid_item_starred` (`uid`, `item_starred`), + KEY `uid_item_retained` (`uid`, `item_retained`), KEY `aid` (`aid`), KEY `owner_xchan` (`owner_xchan`), KEY `author_xchan` (`author_xchan`), @@ -679,9 +682,7 @@ CREATE TABLE IF NOT EXISTS `item` ( KEY `changed` (`changed`), KEY `item_origin` (`item_origin`), KEY `item_unseen` (`item_unseen`), - KEY `item_starred` (`item_starred`), KEY `item_uplink` (`item_uplink`), - KEY `item_wall` (`item_wall`), KEY `item_notshown` (`item_notshown`), KEY `item_nsfw` (`item_nsfw`), KEY `item_relay` (`item_relay`), @@ -689,7 +690,6 @@ CREATE TABLE IF NOT EXISTS `item` ( KEY `item_nocomment` (`item_nocomment`), KEY `item_obscured` (`item_obscured`), KEY `item_verified` (`item_verified`), - KEY `item_retained` (`item_retained`), KEY `item_rss` (`item_rss`), KEY `item_consensus` (`item_consensus`), KEY `item_deleted_pending_remove_changed` (`item_deleted`, `item_pending_remove`, `changed`) diff --git a/install/update.php b/install/update.php deleted file mode 100644 index 56cf3d608..000000000 --- a/install/update.php +++ /dev/null @@ -1,3131 +0,0 @@ - 0 "); - - if($r1 && $r2 && $r3) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1137() { - $r1 = q("alter table site add site_valid smallint not null default '0' "); - $r2 = q("create index site_valid on site ( site_valid ) "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - - -function update_r1138() { - $r1 = q("alter table outq add outq_priority smallint not null default '0' "); - $r2 = q("create index outq_priority on outq ( outq_priority ) "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1139() { - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("ALTER TABLE channel ADD channel_lastpost timestamp NOT NULL DEFAULT '0001-01-01 00:00:00'"); - $r2 = q("create index channel_lastpost on channel ( channel_lastpost ) "); - $r = $r1 && $r2; - } - else - $r = q("ALTER TABLE `channel` ADD `channel_lastpost` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `channel_dirdate` , ADD INDEX ( `channel_lastpost` ) "); - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1140() { - $r = q("select * from clients where true"); - $x = false; - if($r) { - foreach($r as $rr) { - $m = q("INSERT INTO xperm (xp_client, xp_channel, xp_perm) VALUES ('%s', %d, '%s') ", - dbesc($rr['client_id']), - intval($rr['uid']), - dbesc('all') - ); - if(! $m) - $x = true; - } - } - if($x) - return UPDATE_FAILED; - return UPDATE_SUCCESS; -} - - -function update_r1141() { - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("ALTER TABLE menu ADD menu_created timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', ADD menu_edited timestamp NOT NULL DEFAULT '0001-01-01 00:00:00'"); - $r2 = q("create index menu_created on menu ( menu_created ) "); - $r3 = q("create index menu_edited on menu ( menu_edited ) "); - $r = $r1 && $r2; - } - else - $r = q("ALTER TABLE menu ADD menu_created DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD menu_edited DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD INDEX ( menu_created ), ADD INDEX ( menu_edited ) "); - - $t = datetime_convert(); - q("update menu set menu_created = '%s', menu_edited = '%s' where true", - dbesc($t), - dbesc($t) - ); - - - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1142() { - - $r1 = q("alter table site add site_dead smallint not null default '0' "); - $r2 = q("create index site_dead on site ( site_dead ) "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - - -} - -function update_r1143() { - - $r1 = q("ALTER TABLE abook ADD abook_incl TEXT NOT NULL DEFAULT ''"); - $r2 = q("ALTER TABLE abook ADD abook_excl TEXT NOT NULL DEFAULT '' "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1144() { - $r = q("select flags, id from attach where flags != 0"); - if($r) { - foreach($r as $rr) { - if($rr['flags'] & 1) { - q("update attach set is_dir = 1 where id = %d", - intval($rr['id']) - ); - } - if($rr['flags'] & 2) { - q("update attach set os_storage = 1 where id = %d", - intval($rr['id']) - ); - } - } - } - - return UPDATE_SUCCESS; -} - -function update_r1145() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("ALTER TABLE event ADD event_status char(255) NOT NULL DEFAULT '', - ADD event_status_date timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', - ADD event_percent SMALLINT NOT NULL DEFAULT '0', - ADD event_repeat TEXT NOT NULL DEFAULT '' "); - $r2 = q("create index event_status on event ( event_status )"); - $r = $r1 && $r2; - } - else { - $r = q("ALTER TABLE `event` ADD `event_status` CHAR( 255 ) NOT NULL DEFAULT '', - ADD `event_status_date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', - ADD `event_percent` SMALLINT NOT NULL DEFAULT '0', - ADD `event_repeat` TEXT NOT NULL DEFAULT '', - ADD INDEX ( `event_status` ) "); - } - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1146() { - - $r1 = q("alter table event add event_sequence smallint not null default '0' "); - $r2 = q("create index event_sequence on event ( event_sequence ) "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1147() { - - $r1 = q("alter table event add event_priority smallint not null default '0' "); - $r2 = q("create index event_priority on event ( event_priority ) "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1148() { - $r1 = q("alter table likes add i_mid char(255) not null default '' "); - $r2 = q("create index i_mid on likes ( i_mid ) "); - - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1149() { - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("ALTER TABLE obj ADD obj_term CHAR( 255 ) NOT NULL DEFAULT '', - ADD obj_url CHAR( 255 ) NOT NULL DEFAULT '', - ADD obj_imgurl CHAR( 255 ) NOT NULL DEFAULT '', - ADD obj_created timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', - ADD obj_edited timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' "); - } - else { - $r1 = q("ALTER TABLE obj ADD obj_term CHAR( 255 ) NOT NULL DEFAULT '', - ADD obj_url CHAR( 255 ) NOT NULL DEFAULT '', - ADD obj_imgurl CHAR( 255 ) NOT NULL DEFAULT '', - ADD obj_created DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', - ADD obj_edited DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' "); - } - - $r2 = q("create index obj_term on obj ( obj_term ) "); - $r3 = q("create index obj_url on obj ( obj_url ) "); - $r4 = q("create index obj_imgurl on obj ( obj_imgurl ) "); - $r5 = q("create index obj_created on obj ( obj_created ) "); - $r6 = q("create index obj_edited on obj ( obj_edited ) "); - $r = $r1 && $r2 && $r3 && $r4 && $r5 && $r6; - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1150() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("ALTER TABLE app ADD app_created timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', - ADD app_edited timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' "); - } - else { - $r1 = q("ALTER TABLE app ADD app_created DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', - ADD app_edited DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' "); - } - - $r2 = q("create index app_created on app ( app_created ) "); - $r3 = q("create index app_edited on app ( app_edited ) "); - - $r = $r1 && $r2 && $r3; - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1151() { - - $r3 = q("select likes.*, item.mid from likes left join item on likes.iid = item.id"); - if($r3) { - foreach($r3 as $rr) { - q("update likes set i_mid = '%s' where id = $d", - dbesc($rr['mid']), - intval($rr['id']) - ); - } - } - - - return UPDATE_SUCCESS; - -} - -function update_r1152() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - - $r1 = q("CREATE TABLE IF NOT EXISTS \"dreport\" ( - \"dreport_id\" serial NOT NULL, - \"dreport_channel\" int(11) NOT NULL DEFAULT '0', - \"dreport_mid\" char(255) NOT NULL DEFAULT '', - \"dreport_site\" char(255) NOT NULL DEFAULT '', - \"dreport_recip\" char(255) NOT NULL DEFAULT '', - \"dreport_result\" char(255) NOT NULL DEFAULT '', - \"dreport_time\" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', - \"dreport_xchan\" char(255) NOT NULL DEFAULT '', - PRIMARY KEY (\"dreport_id\") "); - - $r2 = q("create index \"dreport_mid\" on dreport (\"dreport_mid\") "); - $r3 = q("create index \"dreport_site\" on dreport (\"dreport_site\") "); - $r4 = q("create index \"dreport_time\" on dreport (\"dreport_time\") "); - $r5 = q("create index \"dreport_xchan\" on dreport (\"dreport_xchan\") "); - $r6 = q("create index \"dreport_channel\" on dreport (\"dreport_channel\") "); - - $r = $r1 && $r2 && $r3 && $r4 && $r5 && $r6; - - } - else { - $r = q("CREATE TABLE IF NOT EXISTS `dreport` ( - `dreport_id` int(11) NOT NULL AUTO_INCREMENT, - `dreport_channel` int(11) NOT NULL DEFAULT '0', - `dreport_mid` char(255) NOT NULL DEFAULT '', - `dreport_site` char(255) NOT NULL DEFAULT '', - `dreport_recip` char(255) NOT NULL DEFAULT '', - `dreport_result` char(255) NOT NULL DEFAULT '', - `dreport_time` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', - `dreport_xchan` char(255) NOT NULL DEFAULT '', - PRIMARY KEY (`dreport_id`), - KEY `dreport_mid` (`dreport_mid`), - KEY `dreport_site` (`dreport_site`), - KEY `dreport_time` (`dreport_time`), - KEY `dreport_xchan` (`dreport_xchan`), - KEY `dreport_channel` (`dreport_channel`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); - - } - - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1153() { - - $r1 = q("ALTER TABLE dreport ADD dreport_queue CHAR( 255 ) NOT NULL DEFAULT '' "); - $r2 = q("create index dreport_queue on dreport ( dreport_queue) "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - - -} - -function update_r1154() { - - $r = q("ALTER TABLE event ADD event_vdata text NOT NULL "); - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - - -function update_r1155() { - - $r1 = q("alter table site add site_type smallint not null default '0' "); - $r2 = q("create index site_type on site ( site_type ) "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - - -function update_r1156() { - $r1 = q("ALTER TABLE mail ADD conv_guid CHAR( 255 ) NOT NULL DEFAULT '' "); - $r2 = q("create index conv_guid on mail ( conv_guid ) "); - - $r3 = q("select mail.id, mail.convid, conv.guid from mail left join conv on mail.convid = conv.id where true"); - if($r3) { - foreach($r3 as $rr) { - if($rr['convid']) { - q("update mail set conv_guid = '%s' where id = %d", - dbesc($rr['guid']), - intval($rr['id']) - ); - } - } - } - - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1157() { - $r1 = q("alter table site add site_project char(255) not null default '' "); - $r2 = q("create index site_project on site ( site_project ) "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - - -function update_r1158() { - $r = q("select attach.id, attach.data, channel_address from attach left join channel on attach.uid = channel_id where os_storage = 1 and not attach.data like '%%store%%' "); - if($r) { - foreach($r as $rr) { - $has_slash = ((substr($rr['data'],0,1) === '/') ? true : false); - q("update attach set data = '%s' where id = %d", - dbesc('store/' . $rr['channel_address']. (($has_slash) ? '' : '/' . $rr['data'])), - dbesc($rr['id']) - ); - } - } - return UPDATE_SUCCESS; -} - - -function update_r1159() { - $r = q("select attach.id, attach.data, attach.hash, channel_address from attach left join channel on attach.uid = channel_id where os_storage = 1 "); - if($r) { - foreach($r as $rr) { - $x = dbunescbin($rr['data']); - $has_slash = (($x === 'store/' . $rr['channel_address'] . '/') ? true : false); - if(($x === 'store/' . $rr['channel_address']) || ($has_slash)) { - q("update attach set data = '%s' where id = %d", - dbesc('store/' . $rr['channel_address']. (($has_slash) ? '' : '/' . $rr['hash'])), - dbesc($rr['id']) - ); - } - } - } - return UPDATE_SUCCESS; -} - - -function update_r1160() { - $r = q("alter table abook add abook_instance text not null default '' "); - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1161() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("CREATE TABLE \"iconfig\" ( - \"id\" serial NOT NULL, - \"iid\" bigint NOT NULL DEFAULT '0', - \"cat\" text NOT NULL DEFAULT '', - \"k\" text NOT NULL DEFAULT '', - \"v\" text NOT NULL DEFAULT '', - PRIMARY_KEY(\"id\") -) "); -$r2 = q("create index \"iconfig_iid\" on iconfig (\"iid\") ");; -$r3 = q("create index \"iconfig_cat\" on iconfig (\"cat\") "); -$r4 = q("create index \"iconfig_k\" on iconfig (\"k\") "); - $r = $r1 && $r2 && $r3 && $r4; - } - else { - $r = q("CREATE TABLE IF NOT EXISTS `iconfig` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `iid` int(11) NOT NULL DEFAULT '0', - `cat` char(255) NOT NULL DEFAULT '', - `k` char(255) NOT NULL DEFAULT '', - `v` mediumtext NOT NULL, - PRIMARY KEY (`id`), - KEY `iid` (`iid`), - KEY `cat` (`cat`), - KEY `k` (`k`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); - - } - - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1162() { - $r1 = q("alter table iconfig add sharing int not null default '0' "); - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) - $r2 = q("create index \"iconfig_sharing\" on iconfig (\"sharing\") "); - else - $r2 = q("alter table iconfig add index ( sharing ) "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1163() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("alter table channel add channel_moved text not null default '' "); - $r2 = q("create index \"channel_channel_moved\" on channel (\"channel_moved\") "); - } - else { - $r1 = q("alter table channel add channel_moved char(255) not null default '' "); - $r2 = q("alter table channel add index ( channel_moved ) "); - } - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1164() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("CREATE TABLE \"abconfig\" ( - \"id\" serial NOT NULL, - \"chan\" text NOT NULL, - \"xchan\" text NOT NULL, - \"cat\" text NOT NULL, - \"k\" text NOT NULL, - \"v\" text NOT NULL, - PRIMARY KEY (\"id\") "); - $r2 = q("create index \"abconfig_chan\" on abconfig (\"chan\") "); - $r3 = q("create index \"abconfig_xchan\" on abconfig (\"xchan\") "); - $r4 = q("create index \"abconfig_cat\" on abconfig (\"cat\") "); - $r5 = q("create index \"abconfig_k\" on abconfig (\"k\") "); - $r = $r1 && $r2 && $r3 && $r4 && $r5; - } - else { - $r = q("CREATE TABLE IF NOT EXISTS `abconfig` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `chan` char(255) NOT NULL DEFAULT '', - `xchan` char(255) NOT NULL DEFAULT '', - `cat` char(255) NOT NULL DEFAULT '', - `k` char(255) NOT NULL DEFAULT '', - `v` mediumtext NOT NULL, - PRIMARY KEY (`id`), - KEY `chan` (`chan`), - KEY `xchan` (`xchan`), - KEY `cat` (`cat`), - KEY `k` (`k`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); - - } - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1165() { - - $r1 = q("alter table hook add hook_version int not null default '0' "); - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) - $r2 = q("create index \"hook_version_idx\" on hook (\"hook_version\") "); - else - $r2 = q("alter table hook add index ( hook_version ) "); - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1166() { - - $r = q("alter table source add src_tag text not null default '' "); - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1167() { - - $r1 = q("alter table app add app_deleted int not null default '0' "); - $r2 = q("alter table app add app_system int not null default '0' "); - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r3 = q("create index \"app_deleted_idx\" on app (\"app_deleted\") "); - $r4 = q("create index \"app_system_idx\" on app (\"app_system\") "); - } - else { - $r3 = q("alter table app add index ( app_deleted ) "); - $r4 = q("alter table app add index ( app_system ) "); - } - - if($r1 && $r2 && $r3 && $r4) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1168() { - - $r1 = q("alter table obj add obj_quantity int not null default '0' "); - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r2 = q("create index \"obj_quantity_idx\" on obj (\"obj_quantity\") "); - } - else { - $r2 = q("alter table obj add index ( obj_quantity ) "); - } - - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1169() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("ALTER TABLE `addon` CHANGE `timestamp` `tstamp` numeric( 20 ) UNSIGNED NOT NULL DEFAULT '0' "); - $r2 = q("ALTER TABLE `addon` CHANGE `name` `aname` text NOT NULL DEFAULT '' "); - $r3 = q("ALTER TABLE `hook` CHANGE `function` `fn` text NOT NULL DEFAULT '' "); - - } - else { - $r1 = q("ALTER TABLE `addon` CHANGE `timestamp` `tstamp` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0' "); - $r2 = q("ALTER TABLE `addon` CHANGE `name` `aname` CHAR(255) NOT NULL DEFAULT '' "); - $r3 = q("ALTER TABLE `hook` CHANGE `function` `fn` CHAR(255) NOT NULL DEFAULT '' "); - } - - if($r1 && $r2 && $r3) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - - -function update_r1170() { - - $r1 = q("drop table fcontact"); - $r2 = q("drop table ffinder"); - $r3 = q("drop table fserver"); - $r4 = q("drop table fsuggest"); - $r5 = q("drop table spam"); - - if($r1 && $r2 && $r3 && $r4 && $r5) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1171() { - - $r1 = q("ALTER TABLE verify CHANGE `type` `vtype` varchar(32) NOT NULL DEFAULT '' "); - $r2 = q("ALTER TABLE tokens CHANGE `scope` `auth_scope` varchar(512) NOT NULL DEFAULT '' "); - $r3 = q("ALTER TABLE auth_codes CHANGE `scope` `auth_scope` varchar(512) NOT NULL DEFAULT '' "); - $r4 = q("ALTER TABLE clients CHANGE `name` `clname` TEXT "); - $r5 = q("ALTER TABLE session CHANGE `data` `sess_data` TEXT NOT NULL "); - $r6 = q("ALTER TABLE register CHANGE `language` `lang` varchar(16) NOT NULL DEFAULT '' "); - - if($r1 && $r2 && $r3 && $r4 && $r5 && $r6) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - - - -} - -function update_r1172() { - - $r1 = q("ALTER TABLE term CHANGE `type` `ttype` int(3) NOT NULL DEFAULT '0' "); - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r2 = q("ALTER TABLE groups CHANGE `name` `gname` TEXT NOT NULL "); - $r3 = q("ALTER TABLE profile CHANGE `name` `fullname` TEXT NOT NULL "); - $r4 = q("ALTER TABLE profile CHANGE `with` `partner` TEXT NOT NULL "); - $r5 = q("ALTER TABLE profile CHANGE `work` `employment` TEXT NOT NULL "); - } - else { - $r2 = q("ALTER TABLE groups CHANGE `name` `gname` char(255) NOT NULL DEFAULT '' "); - $r3 = q("ALTER TABLE profile CHANGE `name` `fullname` char(255) NOT NULL DEFAULT '' "); - $r4 = q("ALTER TABLE profile CHANGE `with` `partner` char(255) NOT NULL DEFAULT '' "); - $r5 = q("ALTER TABLE profile CHANGE `work` `employment` TEXT NOT NULL "); - } - if($r1 && $r2 && $r3 && $r4 && $r5) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1173() { - - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("ALTER TABLE notify CHANGE `name` `xname` TEXT NOT NULL "); - $r2 = q("ALTER TABLE notify CHANGE `date` `created` timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' "); - $r3 = q("ALTER TABLE notify CHANGE `type` `ntype` numeric(3) NOT NULL DEFAULT '0' "); - } - else { - $r1 = q("ALTER TABLE notify CHANGE `name` `xname` char(255) NOT NULL DEFAULT '' "); - $r2 = q("ALTER TABLE notify CHANGE `date` `created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' "); - $r3 = q("ALTER TABLE notify CHANGE `type` `ntype` smallint(3) NOT NULL DEFAULT '0' "); - } - - if($r1 && $r2 && $r3) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1174() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("ALTER TABLE event CHANGE `type` `etype` varchar(255) NOT NULL DEFAULT '' "); - $r2 = q("ALTER TABLE event CHANGE `start` `dtstart` timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' "); - $r3 = q("ALTER TABLE event CHANGE `finish` `dtend` timestamp NOT NULL DEFAULT '0001-01-01 00:00:00' "); - $r4 = q("ALTER TABLE event CHANGE `ignore` `dismissed` numeric(1) NOT NULL DEFAULT '0' "); - $r5 = q("ALTER TABLE attach CHANGE `data` `content` bytea NOT NULL "); - $r6 = q("ALTER TABLE photo CHANGE `data` `content` bytea NOT NULL "); - } - else { - $r1 = q("ALTER TABLE event CHANGE `type` `etype` char(255) NOT NULL DEFAULT '' "); - $r2 = q("ALTER TABLE event CHANGE `start` `dtstart` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' "); - $r3 = q("ALTER TABLE event CHANGE `finish` `dtend` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' "); - $r4 = q("ALTER TABLE event CHANGE `ignore` `dismissed` tinyint(1) NOT NULL DEFAULT '0' "); - $r5 = q("ALTER TABLE attach CHANGE `data` `content` longblob NOT NULL "); - $r6 = q("ALTER TABLE photo CHANGE `data` `content` mediumblob NOT NULL "); - } - - if($r1 && $r2 && $r3 && $r4 && $r5 && $r6) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1175() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("ALTER TABLE item CHANGE `object` `obj` text NOT NULL"); - $r2 = q("ALTER TABLE photo CHANGE `size` `filesize` bigint NOT NULL DEFAULT '0' "); - $r3 = q("ALTER TABLE photo CHANGE `scale` `imgscale` numeric(3) NOT NULL DEFAULT '0' "); - $r4 = q("ALTER TABLE photo CHANGE `type` `mimetype` varchar(128) NOT NULL DEFAULT 'image/jpeg' "); - - } - else { - $r1 = q("ALTER TABLE item CHANGE `object` `obj` text NOT NULL"); - $r2 = q("ALTER TABLE photo CHANGE `size` `filesize` int(10) unsigned NOT NULL DEFAULT '0' "); - $r3 = q("ALTER TABLE photo CHANGE `scale` `imgscale` tinyint(3) unsigned NOT NULL DEFAULT '0' "); - $r4 = q("ALTER TABLE photo CHANGE `type` `mimetype` char(128) NOT NULL DEFAULT 'image/jpeg' "); - - } - - if($r1 && $r2 && $r3 && $r4) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - - -function update_r1176() { - - $r = q("select * from item_id where true"); - if($r) { - foreach($r as $rr) { - \Zotlabs\Lib\IConfig::Set($rr['iid'],'system',$rr['service'],$rr['sid'],true); - } - } - return UPDATE_SUCCESS; - -} - -function update_r1177() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("alter table event add cal_id bigint NOT NULL DEFAULT '0'"); - $r2 = q("create index \"event_cal_idx\" on event (\"cal_id\") "); - - $r3 = q("CREATE TABLE \"cal\" ( - \"cal_id\" serial NOT NULL, - \"cal_aid\" bigint NOT NULL DEFAULT '0', - \"cal_uid\" bigint NOT NULL DEFAULT '0', - \"cal_hash\" text NOT NULL, - \"cal_name\" text NOT NULL, - \"uri\" text NOT NULL, - \"logname\" text NOT NULL, - \"pass\" text NOT NULL, - \"ctag\" text NOT NULL, - \"synctoken\" text NOT NULL, - \"cal_types\" text NOT NULL, - PRIMARY KEY (\"cal_id\") "); - $r4 = q("create index \"cal_hash_idx\" on cal (\"cal_hash\") "); - $r5 = q("create index \"cal_name_idx\" on cal (\"cal_name\") "); - $r6 = q("create index \"cal_types_idx\" on cal (\"cal_types\") "); - $r7 = q("create index \"cal_aid_idx\" on cal (\"cal_aid\") "); - $r8 = q("create index \"cal_uid_idx\" on cal (\"cal_uid\") "); - $r = $r1 && $r2 && $r3 && $r4 && $r5 && $r6 && $r7 && $r8; - } - else { - $r1 = q("alter table event add cal_id int(10) unsigned NOT NULL DEFAULT '0', - add index ( cal_id ) "); - - $r2 = q("CREATE TABLE IF NOT EXISTS `cal` ( - `cal_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `cal_aid` int(10) unsigned NOT NULL DEFAULT '0', - `cal_uid` int(10) unsigned NOT NULL DEFAULT '0', - `cal_hash` varchar(255) NOT NULL DEFAULT '', - `cal_name` varchar(255) NOT NULL DEFAULT '', - `uri` varchar(255) NOT NULL DEFAULT '', - `logname` varchar(255) NOT NULL DEFAULT '', - `pass` varchar(255) NOT NULL DEFAULT '', - `ctag` varchar(255) NOT NULL DEFAULT '', - `synctoken` varchar(255) NOT NULL DEFAULT '', - `cal_types` varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (`cal_id`), - KEY `cal_aid` (`cal_aid`), - KEY `cal_uid` (`cal_uid`), - KEY `cal_hash` (`cal_hash`), - KEY `cal_name` (`cal_name`), - KEY `cal_types` (`cal_types`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); - - $r = $r1 && $r2; - } - - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - - -function update_r1178() { - - $c2 = null; - - $c1 = q("SELECT channel_id, channel_hash from channel where true"); - if($c1) { - $c2 = q("SELECT id, chan from abconfig where true"); - if($c2) { - for($x = 0; $x < count($c2); $x ++) { - foreach($c1 as $c) { - if($c['channel_hash'] == $c2[$x]['chan']) { - $c2[$x]['chan'] = $c['channel_id']; - break; - } - } - } - } - } - - $r1 = q("ALTER TABLE abconfig CHANGE chan chan int(10) unsigned NOT NULL DEFAULT '0' "); - - if($c2) { - foreach($c2 as $c) { - q("UPDATE abconfig SET chan = %d where id = %d", - intval($c['chan']), - intval($c['id']) - ); - } - } - - if($r1) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1179() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("CREATE TABLE atoken ( - atoken_id serial NOT NULL, - atoken_aid bigint NOT NULL DEFAULT 0, - atoken_uid bigint NOT NULL DEFAULT 0, - atoken_name varchar(255) NOT NULL DEFAULT '', - atoken_token varchar(255) NOT NULL DEFAULT '', - atoken_expires timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', - PRIMARY KEY (atoken_id)) "); - $r2 = q("create index atoken_aid on atoken (atoken_aid)"); - $r3 = q("create index atoken_uid on atoken (atoken_uid)"); - $r4 = q("create index atoken_name on atoken (atoken_name)"); - $r5 = q("create index atoken_token on atoken (atoken_token)"); - $r6 = q("create index atoken_expires on atoken (atoken_expires)"); - - $r = $r1 && $r2 && $r3 && $r4 && $r5 && $r6; - - } - else { - $r = q("CREATE TABLE IF NOT EXISTS `atoken` ( - `atoken_id` int(11) NOT NULL AUTO_INCREMENT, - `atoken_aid` int(11) NOT NULL DEFAULT 0, - `atoken_uid` int(11) NOT NULL DEFAULT 0, - `atoken_name` char(255) NOT NULL DEFAULT '', - `atoken_token` char(255) NOT NULL DEFAULT '', - `atoken_expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', - PRIMARY KEY (`atoken_id`), - KEY `atoken_aid` (`atoken_aid`), - KEY `atoken_uid` (`atoken_uid`), - KEY `atoken_name` (`atoken_name`), - KEY `atoken_token` (`atoken_token`), - KEY `atoken_expires` (`atoken_expires`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); - } - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1180() { - - require_once('include/perm_upgrade.php'); - - $r1 = q("select * from channel where true"); - if($r1) { - foreach($r1 as $rr) { - perm_limits_upgrade($rr); - autoperms_upgrade($rr); - } - } - - $r2 = q("select * from abook where true"); - if($r2) { - foreach($r2 as $rr) { - perm_abook_upgrade($rr); - } - } - - $r = $r1 && $r2; - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1181() { - if(\Zotlabs\Lib\System::get_server_role() == 'pro') { - q("update account set account_level = 5 where true"); - } - return UPDATE_SUCCESS; -} - -function update_r1182() { - - $r1 = q("alter table site add site_version varchar(32) not null default '' "); - - if($r1) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - - -function update_r1183() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("alter table hook ALTER COLUMN priority TYPE smallint"); - $r2 = q("alter table hook ALTER COLUMN priority SET NOT NULL"); - $r3 = q("alter table hook ALTER COLUMN priority SET DEFAULT '0'"); - $r1 = $r1 && $r2 && $r3; - } - else { - $r1 = q("alter table hook CHANGE priority priority smallint NOT NULL DEFAULT '0' "); - } - $r2 = q("create index priority_idx on hook (priority)"); - - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1184() { - - $r1 = q("alter table site add site_crypto text not null default '' "); - - if($r1) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1185() { - - $r1 = q("alter table app add app_plugin text not null default '' "); - - if($r1) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1186() { - - $r1 = q("alter table profile add profile_vcard text not null"); - - if($r1) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - - -} - -function update_r1187() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("alter table outq add outq_scheduled timestamp not null default '0001-01-01 00:00:00' "); - } - else { - $r1 = q("alter table outq add outq_scheduled datetime not null default '0001-01-01 00:00:00' "); - } - $r2 = q("create index outq_scheduled_idx on outq (outq_scheduled)"); - - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - - -} - -function update_r1188() { - - $r1 = q("alter table channel add channel_password varchar(255) not null default '' "); - $r2 = q("alter table channel add channel_salt varchar(255) not null default '' "); - - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1189() { - - $r1 = q("alter table mail add mail_mimetype varchar(64) not null default 'text/bbcode' "); - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r2 = q("alter table mail add mail_raw smallint not null default 0 "); - } - else { - $r2 = q("alter table mail add mail_raw tinyint(4) not null default 0 "); - } - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - -} - -function update_r1190() { - $r1 = q("alter table abook add abook_not_here smallint not null default 0 "); - - $r2 = q("create index abook_not_here on abook (abook_not_here)"); - - if($r1 && $r2) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1191() { - - $r = q("SELECT 1 FROM principals LIMIT 1"); - - if($r !== false) { - return UPDATE_SUCCESS; - } - else { - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("CREATE TABLE addressbooks ( - id SERIAL NOT NULL, - principaluri VARCHAR(255), - displayname VARCHAR(255), - uri VARCHAR(200), - description TEXT, - synctoken INTEGER NOT NULL DEFAULT 1 - );" - ); - - $r2 = q("ALTER TABLE ONLY addressbooks ADD CONSTRAINT addressbooks_pkey PRIMARY KEY (id);"); - - $r3 = q("CREATE UNIQUE INDEX addressbooks_ukey ON addressbooks USING btree (principaluri, uri);"); - - $r4 = q("CREATE TABLE cards ( - id SERIAL NOT NULL, - addressbookid INTEGER NOT NULL, - carddata BYTEA, - uri VARCHAR(200), - lastmodified INTEGER, - etag VARCHAR(32), - size INTEGER NOT NULL - );" - ); - - $r5 = q("ALTER TABLE ONLY cards ADD CONSTRAINT cards_pkey PRIMARY KEY (id);"); - - $r6 = q("CREATE UNIQUE INDEX cards_ukey ON cards USING btree (addressbookid, uri);"); - - $r7 = q("CREATE TABLE addressbookchanges ( - id SERIAL NOT NULL, - uri VARCHAR(200) NOT NULL, - synctoken INTEGER NOT NULL, - addressbookid INTEGER NOT NULL, - operation SMALLINT NOT NULL - );" - ); - - $r8 = q("ALTER TABLE ONLY addressbookchanges ADD CONSTRAINT addressbookchanges_pkey PRIMARY KEY (id);"); - - $r9 = q("CREATE INDEX addressbookchanges_addressbookid_synctoken_ix ON addressbookchanges USING btree (addressbookid, synctoken);"); - - $r10 = q("CREATE TABLE calendarobjects ( - id SERIAL NOT NULL, - calendardata BYTEA, - uri VARCHAR(200), - calendarid INTEGER NOT NULL, - lastmodified INTEGER, - etag VARCHAR(32), - size INTEGER NOT NULL, - componenttype VARCHAR(8), - firstoccurence INTEGER, - lastoccurence INTEGER, - uid VARCHAR(200) - );" - ); - - $r11 = q("ALTER TABLE ONLY calendarobjects ADD CONSTRAINT calendarobjects_pkey PRIMARY KEY (id);"); - - $r12 = q("CREATE UNIQUE INDEX calendarobjects_ukey ON calendarobjects USING btree (calendarid, uri);"); - - $r13 = q("CREATE TABLE calendars ( - id SERIAL NOT NULL, - synctoken INTEGER NOT NULL DEFAULT 1, - components VARCHAR(21) - );" - ); - - $r14 = q("ALTER TABLE ONLY calendars ADD CONSTRAINT calendars_pkey PRIMARY KEY (id);"); - - $r15 = q("CREATE TABLE calendarinstances ( - id SERIAL NOT NULL, - calendarid INTEGER NOT NULL, - principaluri VARCHAR(100), - access SMALLINT NOT NULL DEFAULT '1', -- '1 = owner, 2 = read, 3 = readwrite' - displayname VARCHAR(100), - uri VARCHAR(200), - description TEXT, - calendarorder INTEGER NOT NULL DEFAULT 0, - calendarcolor VARCHAR(10), - timezone TEXT, - transparent SMALLINT NOT NULL DEFAULT '0', - share_href VARCHAR(100), - share_displayname VARCHAR(100), - share_invitestatus SMALLINT NOT NULL DEFAULT '2' -- '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid' - );" - ); - - $r16 = q("ALTER TABLE ONLY calendarinstances ADD CONSTRAINT calendarinstances_pkey PRIMARY KEY (id);"); - - $r17 = q("CREATE UNIQUE INDEX calendarinstances_principaluri_uri ON calendarinstances USING btree (principaluri, uri);"); - - $r18 = q("CREATE UNIQUE INDEX calendarinstances_principaluri_calendarid ON calendarinstances USING btree (principaluri, calendarid);"); - - $r19 = q("CREATE UNIQUE INDEX calendarinstances_principaluri_share_href ON calendarinstances USING btree (principaluri, share_href);"); - - $r20 = q("CREATE TABLE calendarsubscriptions ( - id SERIAL NOT NULL, - uri VARCHAR(200) NOT NULL, - principaluri VARCHAR(100) NOT NULL, - source TEXT, - displayname VARCHAR(100), - refreshrate VARCHAR(10), - calendarorder INTEGER NOT NULL DEFAULT 0, - calendarcolor VARCHAR(10), - striptodos SMALLINT NULL, - stripalarms SMALLINT NULL, - stripattachments SMALLINT NULL, - lastmodified INTEGER - );" - ); - - $r21 = q("ALTER TABLE ONLY calendarsubscriptions ADD CONSTRAINT calendarsubscriptions_pkey PRIMARY KEY (id);"); - - $r22 = q("CREATE UNIQUE INDEX calendarsubscriptions_ukey ON calendarsubscriptions USING btree (principaluri, uri);"); - - $r23 = q("CREATE TABLE calendarchanges ( - id SERIAL NOT NULL, - uri VARCHAR(200) NOT NULL, - synctoken INTEGER NOT NULL, - calendarid INTEGER NOT NULL, - operation SMALLINT NOT NULL DEFAULT 0 - );" - ); - - $r24 = q("ALTER TABLE ONLY calendarchanges ADD CONSTRAINT calendarchanges_pkey PRIMARY KEY (id);"); - - $r25 = q("CREATE INDEX calendarchanges_calendarid_synctoken_ix ON calendarchanges USING btree (calendarid, synctoken);"); - - $r26 = q("CREATE TABLE schedulingobjects ( - id SERIAL NOT NULL, - principaluri VARCHAR(255), - calendardata BYTEA, - uri VARCHAR(200), - lastmodified INTEGER, - etag VARCHAR(32), - size INTEGER NOT NULL - );" - ); - - $r27 = q("CREATE TABLE locks ( - id SERIAL NOT NULL, - owner VARCHAR(100), - timeout INTEGER, - created INTEGER, - token VARCHAR(100), - scope SMALLINT, - depth SMALLINT, - uri TEXT - );" - ); - - $r28 = q("ALTER TABLE ONLY locks ADD CONSTRAINT locks_pkey PRIMARY KEY (id);"); - - $r29 = q("CREATE INDEX locks_token_ix ON locks USING btree (token);"); - - $r30 = q("CREATE INDEX locks_uri_ix ON locks USING btree (uri);"); - - $r31 = q("CREATE TABLE principals ( - id SERIAL NOT NULL, - uri VARCHAR(200) NOT NULL, - email VARCHAR(80), - displayname VARCHAR(80) - );" - ); - - $r32 = q("ALTER TABLE ONLY principals ADD CONSTRAINT principals_pkey PRIMARY KEY (id);"); - - $r33 = q("CREATE UNIQUE INDEX principals_ukey ON principals USING btree (uri);"); - - $r34 = q("CREATE TABLE groupmembers ( - id SERIAL NOT NULL, - principal_id INTEGER NOT NULL, - member_id INTEGER NOT NULL - );" - ); - - $r35 = q("ALTER TABLE ONLY groupmembers ADD CONSTRAINT groupmembers_pkey PRIMARY KEY (id);"); - - $r36 = q("CREATE UNIQUE INDEX groupmembers_ukey ON groupmembers USING btree (principal_id, member_id);"); - - $r37 = q("CREATE TABLE propertystorage ( - id SERIAL NOT NULL, - path VARCHAR(1024) NOT NULL, - name VARCHAR(100) NOT NULL, - valuetype INT, - value BYTEA - );" - ); - - $r38 = q("ALTER TABLE ONLY propertystorage ADD CONSTRAINT propertystorage_pkey PRIMARY KEY (id);"); - - $r39 = q("CREATE UNIQUE INDEX propertystorage_ukey ON propertystorage (path, name);"); - - $r40 = q("CREATE TABLE users ( - id SERIAL NOT NULL, - username VARCHAR(50), - digesta1 VARCHAR(32) - );" - ); - - $r41 = q("ALTER TABLE ONLY users ADD CONSTRAINT users_pkey PRIMARY KEY (id);"); - - $r42 = q("CREATE UNIQUE INDEX users_ukey ON users USING btree (username);"); - - if( - $r1 && $r2 && $r3 && $r4 && $r5 && $r6 && $r7 && $r8 && $r9 && $r10 - && $r11 && $r12 && $r13 && $r14 && $r15 && $r16 && $r17 && $r18 && $r19 && $r20 - && $r21 && $r22 && $r23 && $r24 && $r25 && $r26 && $r27 && $r28 && $r29 && $r30 - && $r31 && $r32 && $r33 && $r34 && $r35 && $r36 && $r37 && $r38 && $r39 && $r40 - && $r41 && $r42 - ) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - } - else { - $r1 = q("CREATE TABLE if not exists addressbooks ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - principaluri VARBINARY(255), - displayname VARCHAR(255), - uri VARBINARY(200), - description TEXT, - synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1', - UNIQUE(principaluri(100), uri(100)) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r2 = q("CREATE TABLE if not exists cards ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - addressbookid INT(11) UNSIGNED NOT NULL, - carddata MEDIUMBLOB, - uri VARBINARY(200), - lastmodified INT(11) UNSIGNED, - etag VARBINARY(32), - size INT(11) UNSIGNED NOT NULL - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r3 = q("CREATE TABLE if not exists addressbookchanges ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - uri VARBINARY(200) NOT NULL, - synctoken INT(11) UNSIGNED NOT NULL, - addressbookid INT(11) UNSIGNED NOT NULL, - operation TINYINT(1) NOT NULL, - INDEX addressbookid_synctoken (addressbookid, synctoken) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r4 = q("CREATE TABLE if not exists calendarobjects ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - calendardata MEDIUMBLOB, - uri VARBINARY(200), - calendarid INTEGER UNSIGNED NOT NULL, - lastmodified INT(11) UNSIGNED, - etag VARBINARY(32), - size INT(11) UNSIGNED NOT NULL, - componenttype VARBINARY(8), - firstoccurence INT(11) UNSIGNED, - lastoccurence INT(11) UNSIGNED, - uid VARBINARY(200), - UNIQUE(calendarid, uri), - INDEX calendarid_time (calendarid, firstoccurence) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r5 = q("CREATE TABLE if not exists calendars ( - id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - synctoken INTEGER UNSIGNED NOT NULL DEFAULT '1', - components VARBINARY(21) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r6 = q("CREATE TABLE if not exists calendarinstances ( - id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - calendarid INTEGER UNSIGNED NOT NULL, - principaluri VARBINARY(100), - access TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1 = owner, 2 = read, 3 = readwrite', - displayname VARCHAR(100), - uri VARBINARY(200), - description TEXT, - calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0', - calendarcolor VARBINARY(10), - timezone TEXT, - transparent TINYINT(1) NOT NULL DEFAULT '0', - share_href VARBINARY(100), - share_displayname VARCHAR(100), - share_invitestatus TINYINT(1) NOT NULL DEFAULT '2' COMMENT '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid', - UNIQUE(principaluri, uri), - UNIQUE(calendarid, principaluri), - UNIQUE(calendarid, share_href) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r7 = q("CREATE TABLE if not exists calendarchanges ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - uri VARBINARY(200) NOT NULL, - synctoken INT(11) UNSIGNED NOT NULL, - calendarid INT(11) UNSIGNED NOT NULL, - operation TINYINT(1) NOT NULL, - INDEX calendarid_synctoken (calendarid, synctoken) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r8 = q("CREATE TABLE if not exists calendarsubscriptions ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - uri VARBINARY(200) NOT NULL, - principaluri VARBINARY(100) NOT NULL, - source TEXT, - displayname VARCHAR(100), - refreshrate VARCHAR(10), - calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0', - calendarcolor VARBINARY(10), - striptodos TINYINT(1) NULL, - stripalarms TINYINT(1) NULL, - stripattachments TINYINT(1) NULL, - lastmodified INT(11) UNSIGNED, - UNIQUE(principaluri, uri) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r9 = q("CREATE TABLE if not exists schedulingobjects ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - principaluri VARBINARY(255), - calendardata MEDIUMBLOB, - uri VARBINARY(200), - lastmodified INT(11) UNSIGNED, - etag VARBINARY(32), - size INT(11) UNSIGNED NOT NULL - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r10 = q("CREATE TABLE if not exists locks ( - id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - owner VARCHAR(100), - timeout INTEGER UNSIGNED, - created INTEGER, - token VARBINARY(100), - scope TINYINT, - depth TINYINT, - uri VARBINARY(1000), - INDEX(token), - INDEX(uri(100)) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r11 = q("CREATE TABLE if not exists principals ( - id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - uri VARBINARY(200) NOT NULL, - email VARBINARY(80), - displayname VARCHAR(80), - UNIQUE(uri) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r12 = q("CREATE TABLE if not exists groupmembers ( - id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - principal_id INTEGER UNSIGNED NOT NULL, - member_id INTEGER UNSIGNED NOT NULL, - UNIQUE(principal_id, member_id) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r13 = q("CREATE TABLE if not exists propertystorage ( - id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - path VARBINARY(1024) NOT NULL, - name VARBINARY(100) NOT NULL, - valuetype INT UNSIGNED, - value MEDIUMBLOB - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r14 = q("CREATE UNIQUE INDEX path_property ON propertystorage (path(600), name(100));"); - - $r15 = q("CREATE TABLE if not exists users ( - id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - username VARBINARY(50), - digesta1 VARBINARY(32), - UNIQUE(username) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - $r16 = q("CREATE TABLE if not exists calendarinstances ( - id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - calendarid INTEGER UNSIGNED NOT NULL, - principaluri VARBINARY(100), - access TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1 = owner, 2 = read, 3 = readwrite', - displayname VARCHAR(100), - uri VARBINARY(200), - description TEXT, - calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0', - calendarcolor VARBINARY(10), - timezone TEXT, - transparent TINYINT(1) NOT NULL DEFAULT '0', - share_href VARBINARY(100), - share_displayname VARCHAR(100), - share_invitestatus TINYINT(1) NOT NULL DEFAULT '2' COMMENT '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid', - UNIQUE(principaluri, uri), - UNIQUE(calendarid, principaluri), - UNIQUE(calendarid, share_href) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;" - ); - - if($r1 && $r2 && $r3 && $r4 && $r5 && $r6 && $r7 && $r8 && $r9 && $r10 && $r11 && $r12 && $r13 && $r14 && $r15 && $r16) - return UPDATE_SUCCESS; - return UPDATE_FAILED; - } - } -} - -function update_r1192() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("CREATE INDEX item_obj_type ON item (obj_type)"); - } - else { - $r1 = q("ALTER TABLE item ADD INDEX (obj_type)"); - } - - if($r1) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1193() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("CREATE INDEX item_uid_unseen ON item (uid, item_unseen)"); - } - else { - $r1 = q("ALTER TABLE item ADD INDEX uid_item_unseen (uid, item_unseen)"); - } - - if($r1) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - - -function update_r1194() { - $r = q("select id, resource_id from item where resource_type = 'nwiki'"); - if($r) { - foreach($r as $rv) { - $mimetype = get_iconfig($rv['id'],'wiki','mimeType'); - q("update item set mimetype = '%s' where resource_type = 'nwikipage' and resource_id = '%s'", - dbesc($mimetype), - dbesc($rv['resource_id']) - ); - } - } - - return UPDATE_SUCCESS; -} - -function update_r1195() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("CREATE INDEX item_resource_id ON item (resource_id)"); - } - else { - $r1 = q("ALTER TABLE item ADD INDEX (resource_id)"); - } - - if($r1) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1196() { - - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r1 = q("CREATE TABLE \"pchan\" ( - \"pchan_id\" serial NOT NULL, - \"pchan_guid\" text NOT NULL, - \"pchan_hash\" text NOT NULL, - \"pchan_pubkey\" text NOT NULL, - \"pchan_prvkey\" text NOT NULL, - PRIMARY KEY (\"pchan_id\") -)"); - - $r2 = q("create index \"pchan_guid\" on pchan (\"pchan_guid\")"); - $r3 = q("create index \"pchan_hash\" on pchan (\"pchan_hash\")"); - - if($r1 && $r2 && $r3) { - return UPDATE_SUCCESS; - } - } - else { - $r1 = q("CREATE TABLE IF NOT EXISTS pchan ( - pchan_id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, - pchan_guid char(191) NOT NULL DEFAULT '', - pchan_hash char(191) NOT NULL DEFAULT '', - pchan_pubkey text NOT NULL, - pchan_prvkey text NOT NULL, - PRIMARY KEY (pchan_id), - KEY pchan_guid (pchan_guid), - KEY pchan_hash (pchan_hash) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"); - if($r1) { - return UPDATE_SUCCESS; - } - } - - return UPDATE_FAILED; -} - -function update_r1197() { - - $r = q("select diaspora_meta from item where true limit 1"); - if($r) { - $r = q("ALTER TABLE item DROP diaspora_meta"); - } - - return UPDATE_SUCCESS; -} - -function update_r1198() { - - if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { - $r = q("ALTER TABLE item - DROP INDEX item_blocked, - DROP INDEX item_unpublished, - DROP INDEX item_deleted, - DROP INDEX item_delayed, - DROP INDEX item_hidden, - DROP INDEX item_pending_remove, - DROP INDEX item_type - "); - } - - return UPDATE_SUCCESS; -} - -function update_r1199() { - - if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { - $r = q("ALTER TABLE item - DROP INDEX uid, - ADD INDEX (item_type) - "); - } - - return UPDATE_SUCCESS; -} - -function update_r1200() { - - if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { - $r = q("ALTER TABLE item - DROP INDEX item_type, - ADD INDEX uid_item_type (uid, item_type) - "); - } - - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} - -function update_r1201() { - - if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { - $r = q("ALTER TABLE item - DROP INDEX item_thread_top, - ADD INDEX uid_item_thread_top (uid, item_thread_top), - ADD INDEX uid_item_blocked (uid, item_blocked), - ADD INDEX item_deleted_pending_remove_changed (item_deleted, item_pending_remove, changed) - "); - } - - if($r) - return UPDATE_SUCCESS; - return UPDATE_FAILED; -} diff --git a/view/css/conversation.css b/view/css/conversation.css index 77a600deb..f7ab3dcdd 100644 --- a/view/css/conversation.css +++ b/view/css/conversation.css @@ -286,7 +286,6 @@ img.smiley.emoji:hover { height: 32px; } - .checklist input { margin: 0px; vertical-align: middle; @@ -296,6 +295,15 @@ img.smiley.emoji:hover { padding: 15px; } +.view-summary { + margin-bottom: 1rem; +} + +.view-article { + margin-top: 1rem; +} + + #filer_save { margin-left: 15px; } diff --git a/view/js/main.js b/view/js/main.js index 4a2bae802..f6fe475d8 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -357,7 +357,9 @@ function closeMenu(theID) { function markRead(notifType) { $.get('ping?f=&markRead='+notifType); $('.' + notifType + '-button').hide(); + $('#nav-' + notifType + '-sub').removeClass('show'); sessionStorage.removeItem(notifType + '_notifications_cache'); + sessionStorage.removeItem('notification_open'); if(timer) clearTimeout(timer); timer = setTimeout(updateInit,2000); }