diff options
author | Mario <mario@mariovavti.com> | 2018-03-09 11:12:18 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2018-03-09 11:12:18 +0100 |
commit | 4baf5eab16d809977a44e7911ddcab0ff8383897 (patch) | |
tree | 393f618c4cfc20f53264ecd8a26a08de0823d35d /Zotlabs | |
parent | 577da0eb9eb1f90a4cf7a70cfb3582cfb49007ac (diff) | |
parent | 7361af85b5488fc8bd1744389a3a332dc74276b0 (diff) | |
download | volse-hubzilla-4baf5eab16d809977a44e7911ddcab0ff8383897.tar.gz volse-hubzilla-4baf5eab16d809977a44e7911ddcab0ff8383897.tar.bz2 volse-hubzilla-4baf5eab16d809977a44e7911ddcab0ff8383897.zip |
Merge branch '3.2RC'3.2
Diffstat (limited to 'Zotlabs')
290 files changed, 6352 insertions, 770 deletions
diff --git a/Zotlabs/Access/AccessList.php b/Zotlabs/Access/AccessList.php index 6471b0b1d..7cf7b5587 100644 --- a/Zotlabs/Access/AccessList.php +++ b/Zotlabs/Access/AccessList.php @@ -3,10 +3,14 @@ namespace Zotlabs\Access; /** - * @brief AccessList class. + * @brief AccessList class which represents individual content ACLs. * * A class to hold an AccessList object with allowed and denied contacts and * groups. + * + * After evaluating @ref ::Zotlabs::Access::PermissionLimits "PermissionLimits" + * and @ref ::Zotlabs::Lib::Permcat "Permcat"s individual content ACLs are evaluated. + * These answer the question "Can Joe view *this* album/photo?". */ class AccessList { /** @@ -103,7 +107,7 @@ class AccessList { * @brief Return an array consisting of the current access list components * where the elements are directly storable. * - * @return Associative array with: + * @return array An associative array with: * * \e string \b allow_cid => string of allowed cids * * \e string \b allow_gid => string of allowed gids * * \e string \b deny_cid => string of denied cids diff --git a/Zotlabs/Access/PermissionLimits.php b/Zotlabs/Access/PermissionLimits.php index 8caeedb91..1d15098fc 100644 --- a/Zotlabs/Access/PermissionLimits.php +++ b/Zotlabs/Access/PermissionLimits.php @@ -2,35 +2,92 @@ namespace Zotlabs\Access; -use \Zotlabs\Lib as ZLib; +use Zotlabs\Lib\PConfig; +/** + * @brief Permission limits. + * + * Permission limits are a very high level permission setting. They are hard + * limits by design. + * "Who can view my photos (at all)?" + * "Who can post photos in my albums (at all)?" + * + * For viewing permissions we generally set these to 'anybody' and for write + * permissions we generally set them to 'those I allow', though many people + * restrict the viewing permissions further for things like 'Can view my connections'. + * + * People get confused enough by permissions that we wanted a place to set their + * privacy expectations once and be done with it. + * + * Connection related permissions like "Can Joe view my photos?" are handled by + * @ref ::Zotlabs::Lib::Permcat "Permcat" and inherit from the channel's Permission + * limits. + * + * @see Permissions + */ class PermissionLimits { + /** + * @brief Get standard permission limits. + * + * Viewing permissions and post_comments permission are set to 'anybody', + * other permissions are set to 'those I allow'. + * + * The list of permissions comes from Permissions::Perms(). + * + * @return array + */ static public function Std_Limits() { + $limits = []; $perms = Permissions::Perms(); - $limits = array(); + + $anon_comments = get_config('system','anonymous_comments',true); + foreach($perms as $k => $v) { - if(strstr($k,'view') || $k === 'post_comments') + if(strstr($k, 'view') || ($k === 'post_comments' && $anon_comments)) $limits[$k] = PERMS_PUBLIC; else $limits[$k] = PERMS_SPECIFIC; } + return $limits; } - static public function Set($channel_id,$perm,$perm_limit) { - ZLib\PConfig::Set($channel_id,'perm_limits',$perm,$perm_limit); + /** + * @brief Sets a permission limit for a channel. + * + * @param int $channel_id + * @param string $perm + * @param int $perm_limit one of PERMS_* constants + */ + static public function Set($channel_id, $perm, $perm_limit) { + PConfig::Set($channel_id, 'perm_limits', $perm, $perm_limit); } - static public function Get($channel_id,$perm = '') { + /** + * @brief Get a channel's permission limits. + * + * Return a channel's permission limits from PConfig. If $perm is set just + * return this permission limit, if not set, return an array with all + * permission limits. + * + * @param int $channel_id + * @param string $perm (optional) + * @return + * * \b boolean false if no perm_limits set for this channel + * * \b int if $perm is set, return one of PERMS_* constants for this permission + * * \b array with all permission limits, if $perm is not set + */ + static public function Get($channel_id, $perm = '') { if($perm) { - return Zlib\PConfig::Get($channel_id,'perm_limits',$perm); - } - else { - Zlib\PConfig::Load($channel_id); - if(array_key_exists($channel_id,\App::$config) && array_key_exists('perm_limits',\App::$config[$channel_id])) - return \App::$config[$channel_id]['perm_limits']; - return false; + return PConfig::Get($channel_id, 'perm_limits', $perm); } - } + + PConfig::Load($channel_id); + if(array_key_exists($channel_id, \App::$config) + && array_key_exists('perm_limits', \App::$config[$channel_id])) + return \App::$config[$channel_id]['perm_limits']; + + return false; + } }
\ No newline at end of file diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index ca6a7c08a..fa2368a92 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -90,8 +90,6 @@ class Notifier { $item_id = $argv[2]; - $extra = (($argc > 3) ? $argv[3] : null); - if(! $item_id) return; @@ -315,7 +313,7 @@ class Notifier { } - if($target_item['id'] == $target_item['parent']) { + if($target_item['mid'] === $target_item['parent_mid']) { $parent_item = $target_item; $top_level_post = true; } @@ -620,8 +618,8 @@ class Notifier { $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); } if($packet_type === 'keychange') { - $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); $pmsg = get_pconfig($channel['channel_id'],'system','keychange'); + $packet = zot_build_packet($channel,$packet_type,(($packet_recips) ? $packet_recips : null)); } elseif($packet_type === 'request') { $env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : ''); @@ -642,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 = zot_build_packet($channel,'notify',$env,(($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/Daemon/Queue.php b/Zotlabs/Daemon/Queue.php index 17d150250..8f529ff13 100644 --- a/Zotlabs/Daemon/Queue.php +++ b/Zotlabs/Daemon/Queue.php @@ -13,10 +13,10 @@ class Queue { require_once('include/bbcode.php'); - if(argc() > 1) - $queue_id = argv(1); + if($argc > 1) + $queue_id = $argv[1]; else - $queue_id = 0; + $queue_id = EMPTY_STR; logger('queue: start'); diff --git a/Zotlabs/Identity/OAuth2Server.php b/Zotlabs/Identity/OAuth2Server.php new file mode 100644 index 000000000..cbb4748fe --- /dev/null +++ b/Zotlabs/Identity/OAuth2Server.php @@ -0,0 +1,34 @@ +<?php + +namespace Zotlabs\Identity; + +class OAuth2Server extends \OAuth2\Server { + + public function __construct(OAuth2Storage $storage, $config = []) { + + if(! is_array($config)) { + $config = [ + 'use_openid_connect' => true, + 'issuer' => \Zotlabs\Lib\System::get_site_name() + ]; + } + + parent::__construct($storage, $config); + + // Add the "Client Credentials" grant type (it is the simplest of the grant types) + $this->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage)); + + // Add the "Authorization Code" grant type (this is where the oauth magic happens) + $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') + ] + ]); + + $this->addStorage($keyStorage, 'public_key'); + } + +} diff --git a/Zotlabs/Identity/OAuth2Storage.php b/Zotlabs/Identity/OAuth2Storage.php new file mode 100644 index 000000000..bc6db565c --- /dev/null +++ b/Zotlabs/Identity/OAuth2Storage.php @@ -0,0 +1,81 @@ +<?php + +namespace Zotlabs\Identity; + + +class OAuth2Storage extends \OAuth2\Storage\Pdo { + + /** + * @param string $username + * @param string $password + * @return bool + */ + public function checkUserCredentials($username, $password) + { + if ($user = $this->getUser($username)) { + return $this->checkPassword($user, $password); + } + + return false; + } + + /** + * @param string $username + * @return array|bool + */ + public function getUserDetails($username) + { + return $this->getUser($username); + } + + + /** + * + * @param array $user + * @param string $password + * @return bool + */ + protected function checkPassword($user, $password) + { + + $x = account_verify_password($user,$password); + return((array_key_exists('channel',$x) && ! empty($x['channel'])) ? true : false); + + } + + /** + * @param string $username + * @return array|bool + */ + public function getUser($username) + { + + $x = channelx_by_nick($username); + if(! $x) { + return false; + } + + return( [ + 'username' => $x['channel_address'], + 'user_id' => $x['channel_id'], + 'firstName' => $x['channel_name'], + 'lastName' => '', + 'password' => 'NotARealPassword' + ] ); + } + + /** + * plaintext passwords are bad! Override this for your application + * + * @param string $username + * @param string $password + * @param string $firstName + * @param string $lastName + * @return bool + */ + public function setUser($username, $password, $firstName = null, $lastName = null) + { + return true; + } + +}
\ No newline at end of file diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 457b85b62..f91dc8e49 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -119,6 +119,7 @@ class Apps { static public function parse_app_description($f,$translate = true) { + $ret = array(); $baseurl = z_root(); @@ -194,6 +195,10 @@ class Apps { if(! is_public_profile()) unset($ret); break; + case 'public_stream': + if(! can_view_public_stream()) + unset($ret); + break; case 'observer': if(! $observer) unset($ret); @@ -221,6 +226,7 @@ class Apps { static public function translate_system_apps(&$arr) { $apps = array( 'Apps' => t('Apps'), + 'Articles' => t('Articles'), 'Cards' => t('Cards'), 'Admin' => t('Site Admin'), 'Report Bug' => t('Report Bug'), @@ -345,6 +351,10 @@ class Apps { if(! is_public_profile()) return ''; break; + case 'public_stream': + if(! can_view_public_stream()) + return ''; + break; case 'observer': $observer = \App::get_observer(); if(! $observer) diff --git a/Zotlabs/Lib/Config.php b/Zotlabs/Lib/Config.php index f9f22ba3a..c00b8efb6 100644 --- a/Zotlabs/Lib/Config.php +++ b/Zotlabs/Lib/Config.php @@ -142,9 +142,9 @@ class Config { /** - * @brief Returns a value directly from the database configuration storage. + * @brief Returns a record directly from the database configuration storage. * - * This function queries directly the database and bypasses the chached storage + * This function queries directly the database and bypasses the cached storage * from get_config($family, $key). * * @param string $family 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); + for($x = $stored + 1; $x <= $current; $x ++) { + $s = '_' . $x; + $cls = '\\Zotlabs\Update\\' . $s ; + if(! class_exists($cls)) { + return; + } - // 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. + // 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($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 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', $func)) - break; - set_config('database',$func, '1'); - // call the specific update + if(get_config('database', $s)) + break; + set_config('database',$s, '1'); + - $retval = $func(); - if($retval) { + $c = new $cls(); + $retval = $c->run(); - // Prevent sending hundreds of thousands of emails by creating - // a lockfile. + if($retval != UPDATE_SUCCESS) { - $lockfile = 'store/[data]/mailsent'; + // Prevent sending hundreds of thousands of emails by creating + // a lockfile. - 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'); + $lockfile = 'store/[data]/mailsent'; - z_mail( + 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'), [ - '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) - ] - ) + '$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'); - } - } + ) + ] + ); + + //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/Zot/DReport.php b/Zotlabs/Lib/DReport.php index c90f4f670..a68d6c18f 100644 --- a/Zotlabs/Zot/DReport.php +++ b/Zotlabs/Lib/DReport.php @@ -1,5 +1,5 @@ <?php -namespace Zotlabs\Zot; +namespace Zotlabs\Lib; class DReport { diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index a7b4f28e8..61c98c881 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -63,7 +63,9 @@ class Enotify { $thanks = t('Thank You,'); $sitename = get_config('system','sitename'); $site_admin = sprintf( t('%s Administrator'), $sitename); - + $opt_out1 = sprintf( t('This email was sent by %1$s at %2$s.'), t('$Projectname'), \App::get_hostname()); + $opt_out2 = sprintf( t('To stop receiving these messages, please adjust your Notification Settings at %s'), z_root() . '/settings'); + $hopt_out2 = sprintf( t('To stop receiving these messages, please adjust your %s.'), '<a href="' . z_root() . '/settings' . '">' . t('Notification Settings') . '</a>'); $sender_name = $product; $hostname = \App::get_hostname(); if(strpos($hostname,':')) @@ -112,6 +114,8 @@ class Enotify { } + $always_show_in_notices = get_pconfig($recip['channel_id'],'system','always_show_in_notices'); + // e.g. "your post", "David's photo", etc. $possess_desc = t('%s <!item_type!>'); @@ -128,18 +132,28 @@ class Enotify { } if ($params['type'] == NOTIFY_COMMENT) { -// logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); + //logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); $moderated = (($params['item']['item_blocked'] == ITEM_MODERATED) ? true : false); $itemlink = $params['link']; - // ignore like/unlike activity on posts - they probably require a separate notification preference + $action = t('commented on'); + + if(array_key_exists('item',$params) && in_array($params['item']['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { + + if(! $always_show_in_notices) { + logger('notification: not a visible activity. Ignoring.'); + pop_lang(); + return; + } + + if(activity_match($params['verb'], ACTIVITY_LIKE)) + $action = t('liked'); + + if(activity_match($params['verb'], ACTIVITY_DISLIKE)) + $action = t('disliked'); - if (array_key_exists('item',$params) && (! visible_activity($params['item']))) { - logger('notification: not a visible activity. Ignoring.'); - pop_lang(); - return; } $parent_mid = $params['parent_mid']; @@ -181,26 +195,29 @@ class Enotify { //$possess_desc = str_replace('<!item_type!>',$possess_desc); // "a post" - $dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]a %4$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%4$s]a %5$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', + $action, $itemlink, $item_post_type); // "George Bull's post" if($p) - $dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]%4$s\'s %5$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%4$s]%5$s\'s %6$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', + $action, $itemlink, $p[0]['author']['xchan_name'], $item_post_type); // "your post" if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall'])) - $dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]your %4$s[/zrl]'), + $dest_str = sprintf(t('%1$s, %2$s %3$s [zrl=%4$s]your %5$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', + $action, $itemlink, $item_post_type); @@ -231,12 +248,12 @@ class Enotify { $itemlink = $params['link']; - // ignore like/unlike activity on posts - they probably require a separate notification preference - if (array_key_exists('item',$params) && (! activity_match($params['item']['verb'],ACTIVITY_LIKE))) { - logger('notification: not a like activity. Ignoring.'); - pop_lang(); - return; + if(! $always_show_in_notices) { + logger('notification: not a visible activity. Ignoring.'); + pop_lang(); + return; + } } $parent_mid = $params['parent_mid']; @@ -496,8 +513,6 @@ class Enotify { // Another option would be to not add them to the DB, and change how emails are handled // (probably would be better that way) - $always_show_in_notices = get_pconfig($recip['channel_id'],'system','always_show_in_notices'); - if (!$always_show_in_notices) { if (($params['type'] == NOTIFY_WALL) || ($params['type'] == NOTIFY_MAIL) || ($params['type'] == NOTIFY_INTRO)) { $seen = 1; @@ -600,6 +615,9 @@ class Enotify { $datarray['titemlink'] = $itemlink; $datarray['thanks'] = $thanks; $datarray['site_admin'] = $site_admin; + $datarray['opt_out1'] = $opt_out1; + $datarray['opt_out2'] = $opt_out2; + $datarray['hopt_out2'] = $hopt_out2; $datarray['title'] = stripslashes($title); $datarray['htmlversion'] = $htmlversion; $datarray['textversion'] = $textversion; @@ -657,6 +675,8 @@ class Enotify { '$hitemlink' => $datarray['hitemlink'], '$thanks' => $datarray['thanks'], '$site_admin' => $datarray['site_admin'], + '$opt_out1' => $datarray['opt_out1'], + '$opt_out2' => $datarray['hopt_out2'], '$title' => $datarray['title'], '$htmlversion' => $datarray['htmlversion'], )); @@ -677,6 +697,8 @@ class Enotify { '$titemlink' => $datarray['titemlink'], '$thanks' => $datarray['thanks'], '$site_admin' => $datarray['site_admin'], + '$opt_out1' => $datarray['opt_out1'], + '$opt_out2' => $datarray['opt_out2'], '$title' => $datarray['title'], '$textversion' => $datarray['textversion'], )); @@ -794,6 +816,20 @@ class Enotify { : sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name'])); } + $edit = false; + + if($item['edited'] > $item['created']) { + if($item['item_thread_top']) { + $itemem_text = sprintf( t('edited a post dated %s'), relative_date($item['created'])); + $edit = true; + } + else { + $itemem_text = sprintf( t('edited a comment dated %s'), relative_date($item['created'])); + $edit = true; + } + } + + // convert this logic into a json array just like the system notifications return array( @@ -801,7 +837,7 @@ class Enotify { 'name' => $item['author']['xchan_name'], 'url' => $item['author']['xchan_url'], 'photo' => $item['author']['xchan_photo_s'], - 'when' => relative_date($item['created']), + 'when' => relative_date(($edit)? $item['edited'] : $item['created']), 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), 'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'notify_id' => 'undefined', diff --git a/Zotlabs/Lib/Img_filesize.php b/Zotlabs/Lib/Img_filesize.php new file mode 100644 index 000000000..196697733 --- /dev/null +++ b/Zotlabs/Lib/Img_filesize.php @@ -0,0 +1,122 @@ +<?php + +namespace Zotlabs\Lib; + +class Img_filesize { + + private $url; + + function __construct($url) { + $this->url = $url; + } + + function getSize() { + $size = null; + + if(stripos($this->url,z_root() . '/photo') !== false) { + $size = self::getLocalFileSize($this->url); + } + if(! $size) { + $size = getRemoteFileSize($this->url); + } + + return $size; + } + + + static function getLocalFileSize($url) { + + $fname = basename($url); + $resolution = 0; + + if(strpos($fname,'.') !== false) + $fname = substr($fname,0,strpos($fname,'.')); + + if(substr($fname,-2,1) == '-') { + $resolution = intval(substr($fname,-1,1)); + $fname = substr($fname,0,-2); + } + + $r = q("SELECT filesize FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", + dbesc($fname), + intval($resolution) + ); + if($r) { + return $r[0]['filesize']; + } + return null; + } + +} + +/** + * Try to determine the size of a remote file by making an HTTP request for + * a byte range, or look for the content-length header in the response. + * The function aborts the transfer as soon as the size is found, or if no + * length headers are returned, it aborts the transfer. + * + * @return int|null null if size could not be determined, or length of content + */ +function getRemoteFileSize($url) +{ + $ch = curl_init($url); + + $headers = array( + 'Range: bytes=0-1', + 'Connection: close', + ); + + $in_headers = true; + $size = null; + + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2450.0 Iron/46.0.2450.0'); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($ch, CURLOPT_VERBOSE, 0); // set to 1 to debug + curl_setopt($ch, CURLOPT_STDERR, fopen('php://output', 'r')); + + curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $line) use (&$in_headers, &$size) { + $length = strlen($line); + + if (trim($line) == '') { + $in_headers = false; + } + + list($header, $content) = explode(':', $line, 2); + $header = strtolower(trim($header)); + + if ($header == 'content-range') { + // found a content-range header + list($rng, $s) = explode('/', $content, 2); + $size = (int)$s; + return 0; // aborts transfer + } else if ($header == 'content-length' && 206 != curl_getinfo($curl, CURLINFO_HTTP_CODE)) { + // found content-length header and this is not a 206 Partial Content response (range response) + $size = (int)$content; + return 0; + } else { + // continue + return $length; + } + }); + + curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($curl, $data) use ($in_headers) { + if (!$in_headers) { + // shouldn't be here unless we couldn't determine file size + // abort transfer + return 0; + } + + // write function is also called when reading headers + return strlen($data); + }); + + curl_exec($ch); + curl_getinfo($ch); + curl_close($ch); + + return $size; +}
\ No newline at end of file diff --git a/Zotlabs/Lib/MarkdownSoap.php b/Zotlabs/Lib/MarkdownSoap.php index fa279b07c..a58a5753a 100644 --- a/Zotlabs/Lib/MarkdownSoap.php +++ b/Zotlabs/Lib/MarkdownSoap.php @@ -3,51 +3,66 @@ namespace Zotlabs\Lib; /** - * MarkdownSoap + * @brief MarkdownSoap class. + * * Purify Markdown for storage + * @code{.php} * $x = new MarkdownSoap($string_to_be_cleansed); * $text = $x->clean(); - * + * @endcode * What this does: * 1. extracts code blocks and privately escapes them from processing * 2. Run html purifier on the content * 3. put back the code blocks * 4. run htmlspecialchars on the entire content for safe storage * - * At render time: + * At render time: + * @code{.php} * $markdown = \Zotlabs\Lib\MarkdownSoap::unescape($text); * $html = \Michelf\MarkdownExtra::DefaultTransform($markdown); + * @endcode */ - - - class MarkdownSoap { + /** + * @var string + */ + private $str; + /** + * @var string + */ private $token; - private $str; function __construct($s) { - $this->str = $s; + $this->str = $s; $this->token = random_string(20); } - function clean() { $x = $this->extract_code($this->str); $x = $this->purify($x); - $x = $this->putback_code($x); + $x = $this->putback_code($x); $x = $this->escape($x); - + return $x; } + /** + * @brief Extracts code blocks and privately escapes them from processing. + * + * @see encode_code() + * @see putback_code() + * + * @param string $s + * @return string + */ function extract_code($s) { - + $text = preg_replace_callback('{ (?:\n\n|\A\n?) ( # $1 = the code block -- one or more lines, starting with a space/tab @@ -62,7 +77,7 @@ class MarkdownSoap { return $text; } - + function encode_code($matches) { return $this->token . ';' . base64_encode($matches[0]) . ';' ; } @@ -71,8 +86,17 @@ class MarkdownSoap { return base64_decode($matches[1]); } + /** + * @brief Put back the code blocks. + * + * @see extract_code() + * @see decode_code() + * + * @param string $s + * @return string + */ function putback_code($s) { - $text = preg_replace_callback('{' . $this->token . '\;(.*?)\;}xm',[ $this, 'decode_code' ], $s); + $text = preg_replace_callback('{' . $this->token . '\;(.*?)\;}xm', [ $this, 'decode_code' ], $s); return $text; } @@ -84,20 +108,25 @@ class MarkdownSoap { } function protect_autolinks($s) { - $s = preg_replace('/\<(https?\:\/\/)(.*?)\>/','[$1$2]($1$2)',$s); + $s = preg_replace('/\<(https?\:\/\/)(.*?)\>/', '[$1$2]($1$2)', $s); return $s; } function unprotect_autolinks($s) { return $s; - } function escape($s) { - return htmlspecialchars($s,ENT_QUOTES,'UTF-8',false); + return htmlspecialchars($s, ENT_QUOTES, 'UTF-8', false); } + /** + * @brief Converts special HTML entities back to characters. + * + * @param string $s + * @return string + */ static public function unescape($s) { - return htmlspecialchars_decode($s,ENT_QUOTES); + return htmlspecialchars_decode($s, ENT_QUOTES); } } diff --git a/Zotlabs/Lib/Permcat.php b/Zotlabs/Lib/Permcat.php index 505ee2cfc..ca4aed9ed 100644 --- a/Zotlabs/Lib/Permcat.php +++ b/Zotlabs/Lib/Permcat.php @@ -2,12 +2,36 @@ namespace Zotlabs\Lib; -use \Zotlabs\Access as Zaccess; - +use Zotlabs\Access\PermissionRoles; +use Zotlabs\Access\Permissions; + +/** + * @brief Permission Categories. Permission rules for various classes of connections. + * + * Connection permissions answer the question "Can Joe view my photos?" + * + * Some permissions may be inherited from the channel's "privacy settings" + * (@ref ::Zotlabs::Access::PermissionLimits "PermissionLimits") "Who can view my + * photos (at all)?" which have higher priority than individual connection settings. + * We evaluate permission limits first, and then fall through to connection + * permissions if the permission limits didn't already make a definitive decision. + * + * After PermissionLimits and connection permissions are evaluated, individual + * content ACLs are evaluated (@ref ::Zotlabs::Access::AccessList "AccessList"). + * These answer the question "Can Joe view *this* album/photo?". + */ class Permcat { + /** + * @var array + */ private $permcats = []; + /** + * @brief Permcat constructor. + * + * @param int $channel_id + */ public function __construct($channel_id) { $perms = []; @@ -16,16 +40,16 @@ class Permcat { $role = get_pconfig($channel_id,'system','permissions_role'); if($role) { - $x = Zaccess\PermissionRoles::role_perms($role); + $x = PermissionRoles::role_perms($role); if($x['perms_connect']) { - $perms = Zaccess\Permissions::FilledPerms($x['perms_connect']); + $perms = Permissions::FilledPerms($x['perms_connect']); } } // if no role perms it may be a custom role, see if there any autoperms if(! $perms) { - $perms = Zaccess\Permissions::FilledAutoPerms($channel_id); + $perms = Permissions::FilledAutoPerms($channel_id); } // if no autoperms it may be a custom role with manual perms @@ -50,13 +74,13 @@ class Permcat { // nothing was found - create a filled permission array where all permissions are 0 if(! $perms) { - $perms = Zaccess\Permissions::FilledPerms([]); + $perms = Permissions::FilledPerms([]); } $this->permcats[] = [ 'name' => 'default', 'localname' => t('default','permcat'), - 'perms' => Zaccess\Permissions::Operms($perms), + 'perms' => Permissions::Operms($perms), 'system' => 1 ]; @@ -67,26 +91,39 @@ class Permcat { $this->permcats[] = [ 'name' => $p[$x][0], 'localname' => $p[$x][1], - 'perms' => Zaccess\Permissions::Operms(Zaccess\Permissions::FilledPerms($p[$x][2])), + 'perms' => Permissions::Operms(Permissions::FilledPerms($p[$x][2])), 'system' => intval($p[$x][3]) ]; } } } - + /** + * @brief Return array with permcats. + * + * @return array + */ public function listing() { return $this->permcats; } + /** + * @brief + * + * @param string $name + * @return array + * * \e array with permcats + * * \e bool \b error if $name not found in permcats true + */ public function fetch($name) { if($name && $this->permcats) { foreach($this->permcats as $permcat) { - if(strcasecmp($permcat['name'],$name) === 0) { + if(strcasecmp($permcat['name'], $name) === 0) { return $permcat; } } } + return ['error' => true]; } @@ -118,29 +155,32 @@ class Permcat { $permcats[] = [ $xv['k'], $xv['k'], $value, 0 ]; } } - } + } - call_hooks('permcats',$permcats); + /** + * @hooks permcats + * * \e array + */ + call_hooks('permcats', $permcats); return $permcats; - } - static public function find_permcat($arr,$name) { + static public function find_permcat($arr, $name) { if((! $arr) || (! $name)) return false; + foreach($arr as $p) if($p['name'] == $name) return $p['value']; } - static public function update($channel_id, $name,$permarr) { - PConfig::Set($channel_id,'permcat',$name,$permarr); + static public function update($channel_id, $name, $permarr) { + PConfig::Set($channel_id, 'permcat', $name, $permarr); } - static public function delete($channel_id,$name) { - PConfig::Delete($channel_id,'permcat',$name); + static public function delete($channel_id, $name) { + PConfig::Delete($channel_id, 'permcat', $name); } - }
\ No newline at end of file diff --git a/Zotlabs/Lib/ProtoDriver.php b/Zotlabs/Lib/ProtoDriver.php deleted file mode 100644 index daf887dbb..000000000 --- a/Zotlabs/Lib/ProtoDriver.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php /** @file */ - -namespace Zotlabs\Lib; - -/* - * Abstraction class for dealing with alternate networks (which of course do not exist, hence the abstraction) - */ - - -abstract class ProtoDriver { - abstract protected function discover($channel,$location); - abstract protected function deliver($item,$channel,$recipients); - abstract protected function collect($channel,$connection); - abstract protected function change_permissions($permissions,$channel,$recipient); - abstract protected function acknowledge_permissions($permissions,$channel,$recipient); - abstract protected function deliver_private($item,$channel,$recipients); - abstract protected function collect_private($channel,$connection); - -} diff --git a/Zotlabs/Lib/Share.php b/Zotlabs/Lib/Share.php new file mode 100644 index 000000000..b5341e662 --- /dev/null +++ b/Zotlabs/Lib/Share.php @@ -0,0 +1,141 @@ +<?php + +namespace Zotlabs\Lib; + + +class Share { + + private $item = null; + + + public function __construct($post_id) { + + if(! $post_id) + return; + + if(! (local_channel() || remote_channel())) + return; + + $r = q("SELECT * from item left join xchan on author_xchan = xchan_hash WHERE id = %d LIMIT 1", + intval($post_id) + ); + if(! $r) + return; + + if(($r[0]['item_private']) && ($r[0]['xchan_network'] !== 'rss')) + return; + + $sql_extra = item_permissions_sql($r[0]['uid']); + + $r = q("select * from item where id = %d $sql_extra", + intval($post_id) + ); + if(! $r) + return; + + if($r[0]['mimetype'] !== 'text/bbcode') + return; + + /** @FIXME eventually we want to post remotely via rpost on your home site */ + // When that works remove this next bit: + + if(! local_channel()) + return; + + xchan_query($r); + + $this->item = $r[0]; + return; + } + + public function obj() { + $obj = []; + + if(! $this->item) + return $obj; + + $obj['type'] = $this->item['obj_type']; + $obj['id'] = $this->item['mid']; + $obj['content'] = $this->item['body']; + $obj['content_type'] = $this->item['mimetype']; + $obj['title'] = $this->item['title']; + $obj['created'] = $this->item['created']; + $obj['edited'] = $this->item['edited']; + $obj['author'] = [ + 'name' => $this->item['author']['xchan_name'], + 'address' => $this->item['author']['xchan_addr'], + 'network' => $this->item['author']['xchan_network'], + 'link' => [ + [ + 'rel' => 'alternate', + 'type' => 'text/html', + 'href' => $this->item['author']['xchan_url'] + ], + [ + 'rel' => 'photo', + 'type' => $this->item['author']['xchan_photo_mimetype'], + 'href' => $this->item['author']['xchan_photo_m'] + ] + ] + ]; + + $obj['owner'] = [ + 'name' => $this->item['owner']['xchan_name'], + 'address' => $this->item['owner']['xchan_addr'], + 'network' => $this->item['owner']['xchan_network'], + 'link' => [ + [ + 'rel' => 'alternate', + 'type' => 'text/html', + 'href' => $this->item['owner']['xchan_url'] + ], + [ + 'rel' => 'photo', + 'type' => $this->item['owner']['xchan_photo_mimetype'], + 'href' => $this->item['owner']['xchan_photo_m'] + ] + ] + ]; + + $obj['link'] = [ + 'rel' => 'alternate', + 'type' => 'text/html', + 'href' => $this->item['plink'] + ]; + + return $obj; + } + + public function bbcode() { + $bb = NULL_STR; + + if(! $this->item) + return $bb; + + $is_photo = (($this->item['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false); + if($is_photo) { + $object = json_decode($this->item['obj'],true); + $photo_bb = $object['body']; + } + + if (strpos($this->item['body'], "[/share]") !== false) { + $pos = strpos($this->item['body'], "[share"); + $bb = substr($this->item['body'], $pos); + } else { + $bb = "[share author='".urlencode($this->item['author']['xchan_name']). + "' profile='".$this->item['author']['xchan_url'] . + "' avatar='".$this->item['author']['xchan_photo_s']. + "' link='".$this->item['plink']. + "' posted='".$this->item['created']. + "' message_id='".$this->item['mid']."']"; + if($this->item['title']) + $bb .= '[b]'.$this->item['title'].'[/b]'."\r\n"; + $bb .= (($is_photo) ? $photo_bb . "\r\n" . $this->item['body'] : $this->item['body']); + $bb .= "[/share]"; + } + + return $bb; + + } + +}
\ No newline at end of file diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 748edcdb7..d35d4732a 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -730,9 +730,6 @@ class ThreadItem { $observer = $conv->get_observer(); - $qc = ((local_channel()) ? get_pconfig(local_channel(),'system','qcomment') : null); - $qcomment = (($qc) ? explode("\n",$qc) : null); - $arr = array('comment_buttons' => '','id' => $this->get_id()); call_hooks('comment_buttons',$arr); $comment_buttons = $arr['comment_buttons']; @@ -744,7 +741,6 @@ class ThreadItem { '$type' => (($conv->get_mode() === 'channel') ? 'wall-comment' : 'net-comment'), '$id' => $this->get_id(), '$parent' => $this->get_id(), - '$qcomment' => $qcomment, '$comment_buttons' => $comment_buttons, '$profile_uid' => $conv->get_profile_owner(), '$mylink' => $observer['xchan_url'], diff --git a/Zotlabs/Zot/Verify.php b/Zotlabs/Lib/Verify.php index 7abe38d17..8703e29e6 100644 --- a/Zotlabs/Zot/Verify.php +++ b/Zotlabs/Lib/Verify.php @@ -1,6 +1,6 @@ <?php -namespace Zotlabs\Zot; +namespace Zotlabs\Lib; class Verify { diff --git a/Zotlabs/Lib/ZotDriver.php b/Zotlabs/Lib/ZotDriver.php deleted file mode 100644 index e14cc7f35..000000000 --- a/Zotlabs/Lib/ZotDriver.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php /** @file */ - -namespace Zotlabs\Lib; - - -class ZotDriver extends ProtoDriver { - - protected function discover($channel,$location) { - - } - protected function deliver($item,$channel,$recipients) { - - } - protected function collect($channel,$connection) { - - } - protected function change_permissions($permissions,$channel,$recipient) { - - } - protected function acknowledge_permissions($permissions,$channel,$recipient) { - - } - protected function deliver_private($item,$channel,$recipients) { - - } - protected function collect_private($channel,$connection) { - - } - -} diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index ad1c8b8cd..fae7e2e44 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -1,36 +1,39 @@ <?php + namespace Zotlabs\Module; -/* - * ACL selector json backend +require_once 'include/acl_selectors.php'; +require_once 'include/group.php'; + +/** + * @brief ACL selector json backend. + * * This module provides JSON lists of connections and local/remote channels * (xchans) to populate various tools such as the ACL (AccessControlList) popup - * and various auto-complete functions (such as email recipients, search, and + * and various auto-complete functions (such as email recipients, search, and * mention targets. + * * There are two primary output structural formats. One for the ACL widget and * the other for auto-completion. - * Many of the behaviour variations are triggered on the use of single character keys - * however this functionality has grown in an ad-hoc manner and has gotten quite messy over time. + * + * Many of the behaviour variations are triggered on the use of single character + * keys however this functionality has grown in an ad-hoc manner and has gotten + * quite messy over time. */ - -require_once("include/acl_selectors.php"); -require_once("include/group.php"); - - class Acl extends \Zotlabs\Web\Controller { function init() { - + logger('mod_acl: ' . print_r($_REQUEST,true)); - + $start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0); $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 500); $search = (x($_REQUEST,'search') ? $_REQUEST['search'] : ''); $type = (x($_REQUEST,'type') ? $_REQUEST['type'] : ''); - $noforums = (x($_REQUEST,'n') ? $_REQUEST['n'] : false); + $noforums = (x($_REQUEST,'n') ? $_REQUEST['n'] : false); - // $type = + // $type = // '' => standard ACL request // 'g' => Groups only ACL request // 'f' => forums only ACL request @@ -382,15 +385,13 @@ class Acl extends \Zotlabs\Web\Controller { 'count' => $count, 'items' => $items, ); - - - + echo json_encode($o); - + killme(); } - - + + function navbar_complete(&$a) { // logger('navbar_complete'); @@ -447,5 +448,5 @@ class Acl extends \Zotlabs\Web\Controller { } return array(); } - + } diff --git a/Zotlabs/Module/Admin/Accounts.php b/Zotlabs/Module/Admin/Accounts.php index 2043550fc..2e417edd1 100644 --- a/Zotlabs/Module/Admin/Accounts.php +++ b/Zotlabs/Module/Admin/Accounts.php @@ -16,6 +16,7 @@ class Accounts { */ function post() { + $pending = ( x($_POST, 'pending') ? $_POST['pending'] : array() ); $users = ( x($_POST, 'user') ? $_POST['user'] : array() ); $blocked = ( x($_POST, 'blocked') ? $_POST['blocked'] : array() ); @@ -24,7 +25,7 @@ class Accounts { // change to switch structure? // account block/unblock button was submitted - if (x($_POST, 'page_users_block')) { + if (x($_POST, 'page_accounts_block')) { for ($i = 0; $i < count($users); $i++) { // if account is blocked remove blocked bit-flag, otherwise add blocked bit-flag $op = ($blocked[$i]) ? '& ~' : '| '; @@ -43,13 +44,13 @@ class Accounts { notice( sprintf( tt("%s account deleted", "%s accounts deleted", count($users)), count($users)) ); } // registration approved button was submitted - if (x($_POST, 'page_users_approve')) { + if (x($_POST, 'page_accounts_approve')) { foreach ($pending as $hash) { account_allow($hash); } } // registration deny button was submitted - if (x($_POST, 'page_users_deny')) { + if (x($_POST, 'page_accounts_deny')) { foreach ($pending as $hash) { account_deny($hash); } 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 '<div class="generic-content-wrapper-styled"><h3>' . t('No failed updates.') . '</h3></div>'; - - $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 '<div class="generic-content-wrapper-styled"><h3>' . t('No failed updates.') . '</h3></div>'; + } return $o; } diff --git a/Zotlabs/Module/Admin/Profs.php b/Zotlabs/Module/Admin/Profs.php index b3da09cb7..eb2501d43 100644 --- a/Zotlabs/Module/Admin/Profs.php +++ b/Zotlabs/Module/Admin/Profs.php @@ -9,17 +9,37 @@ class Profs { if(array_key_exists('basic',$_REQUEST)) { $arr = explode(',',$_REQUEST['basic']); - for($x = 0; $x < count($arr); $x ++) - if(trim($arr[$x])) - $arr[$x] = trim($arr[$x]); - set_config('system','profile_fields_basic',$arr); - + array_walk($arr,'array_trim'); + $narr = []; + if(count($arr)) { + foreach($arr as $a) { + if(strlen($a)) { + $narr[] = $a; + } + } + } + if(! $narr) + del_config('system','profile_fields_basic'); + else + set_config('system','profile_fields_basic',$narr); + + if(array_key_exists('advanced',$_REQUEST)) { $arr = explode(',',$_REQUEST['advanced']); - for($x = 0; $x < count($arr); $x ++) - if(trim($arr[$x])) - $arr[$x] = trim($arr[$x]); - set_config('system','profile_fields_advanced',$arr); + array_walk($arr,'array_trim'); + $narr = []; + if(count($arr)) { + foreach($arr as $a) { + if(strlen($a)) { + $narr[] = $a; + } + } + } + if(! $narr) + del_config('system','profile_fields_advanced'); + else + set_config('system','profile_fields_advanced',$narr); + } goaway(z_root() . '/admin/profs'); } @@ -98,6 +118,7 @@ class Profs { $basic = ''; $barr = array(); $fields = get_profile_fields_basic(); + if(! $fields) $fields = get_profile_fields_basic(1); if($fields) { diff --git a/Zotlabs/Module/Admin/Security.php b/Zotlabs/Module/Admin/Security.php index a1e4bf537..49e1ccf42 100644 --- a/Zotlabs/Module/Admin/Security.php +++ b/Zotlabs/Module/Admin/Security.php @@ -52,24 +52,24 @@ class Security { function get() { $whitesites = get_config('system','whitelisted_sites'); - $whitesites_str = ((is_array($whitesites)) ? implode($whitesites,"\n") : ''); + $whitesites_str = ((is_array($whitesites)) ? implode("\n",$whitesites) : ''); $blacksites = get_config('system','blacklisted_sites'); - $blacksites_str = ((is_array($blacksites)) ? implode($blacksites,"\n") : ''); + $blacksites_str = ((is_array($blacksites)) ? implode("\n",$blacksites) : ''); $whitechannels = get_config('system','whitelisted_channels'); - $whitechannels_str = ((is_array($whitechannels)) ? implode($whitechannels,"\n") : ''); + $whitechannels_str = ((is_array($whitechannels)) ? implode("\n",$whitechannels) : ''); $blackchannels = get_config('system','blacklisted_channels'); - $blackchannels_str = ((is_array($blackchannels)) ? implode($blackchannels,"\n") : ''); + $blackchannels_str = ((is_array($blackchannels)) ? implode("\n",$blackchannels) : ''); $whiteembeds = get_config('system','embed_allow'); - $whiteembeds_str = ((is_array($whiteembeds)) ? implode($whiteembeds,"\n") : ''); + $whiteembeds_str = ((is_array($whiteembeds)) ? implode("\n",$whiteembeds) : ''); $blackembeds = get_config('system','embed_deny'); - $blackembeds_str = ((is_array($blackembeds)) ? implode($blackembeds,"\n") : ''); + $blackembeds_str = ((is_array($blackembeds)) ? implode("\n",$blackembeds) : ''); $embed_coop = intval(get_config('system','embed_coop')); diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php index 32417c77c..015c6535c 100644 --- a/Zotlabs/Module/Admin/Site.php +++ b/Zotlabs/Module/Admin/Site.php @@ -24,23 +24,28 @@ class Site { $siteinfo = ((x($_POST,'siteinfo')) ? trim($_POST['siteinfo']) : ''); $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : ''); $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : ''); - $theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : ''); +// $theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : ''); // $site_channel = ((x($_POST,'site_channel')) ? notags(trim($_POST['site_channel'])) : ''); $maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0); $register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0); - + $minimum_age = ((x($_POST,'minimum_age')) ? intval(trim($_POST['minimum_age'])) : 13); $access_policy = ((x($_POST,'access_policy')) ? intval(trim($_POST['access_policy'])) : 0); $invite_only = ((x($_POST,'invite_only')) ? True : False); $abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0); $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : ''); + $site_sellpage = ((x($_POST,'site_sellpage')) ? notags(trim($_POST['site_sellpage'])) : ''); + $site_location = ((x($_POST,'site_location')) ? notags(trim($_POST['site_location'])) : ''); $frontpage = ((x($_POST,'frontpage')) ? notags(trim($_POST['frontpage'])) : ''); + $firstpage = ((x(trim($_POST,'firstpage'))) ? notags(trim($_POST['firstpage'])) : 'profiles'); $mirror_frontpage = ((x($_POST,'mirror_frontpage')) ? intval(trim($_POST['mirror_frontpage'])) : 0); $directory_server = ((x($_POST,'directory_server')) ? trim($_POST['directory_server']) : ''); $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : ''); $force_publish = ((x($_POST,'publish_all')) ? True : False); $disable_discover_tab = ((x($_POST,'disable_discover_tab')) ? False : True); + $site_firehose = ((x($_POST,'site_firehose')) ? True : False); + $open_pubstream = ((x($_POST,'open_pubstream')) ? True : False); $login_on_homepage = ((x($_POST,'login_on_homepage')) ? True : False); $enable_context_help = ((x($_POST,'enable_context_help')) ? True : False); $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); @@ -76,6 +81,9 @@ class Site { set_config('system', 'poll_interval', $poll_interval); set_config('system', 'maxloadavg', $maxloadavg); set_config('system', 'frontpage', $frontpage); + set_config('system', 'sellpage', $site_sellpage); + set_config('system', 'workflow_channel_next', $firstpage); + set_config('system', 'site_location', $site_location); set_config('system', 'mirror_frontpage', $mirror_frontpage); set_config('system', 'sitename', $sitename); set_config('system', 'login_on_homepage', $login_on_homepage); @@ -114,15 +122,16 @@ class Site { set_config('system','siteinfo',$siteinfo); set_config('system', 'language', $language); set_config('system', 'theme', $theme); - if ( $theme_mobile === '---' ) { - del_config('system', 'mobile_theme'); - } else { - set_config('system', 'mobile_theme', $theme_mobile); - } +// if ( $theme_mobile === '---' ) { +// del_config('system', 'mobile_theme'); +// } else { +// set_config('system', 'mobile_theme', $theme_mobile); +// } // set_config('system','site_channel', $site_channel); set_config('system','maximagesize', $maximagesize); set_config('system','register_policy', $register_policy); + set_config('system','minimum_age', $minimum_age); set_config('system','invitation_only', $invite_only); set_config('system','access_policy', $access_policy); set_config('system','account_abandon_days', $abandon_days); @@ -130,6 +139,8 @@ class Site { set_config('system','allowed_sites', $allowed_sites); set_config('system','publish_all', $force_publish); set_config('system','disable_discover_tab', $disable_discover_tab); + set_config('system','site_firehose', $site_firehose); + set_config('system','open_pubstream', $open_pubstream); set_config('system','force_queue_threshold', $force_queue); if ($global_directory == '') { del_config('system', 'directory_submit_url'); @@ -209,9 +220,10 @@ class Site { $realm = get_directory_realm(); // directory server should not be set or settable unless we are a directory client + // avoid older redmatrix servers which don't have modern encryption if($dirmode == DIRECTORY_MODE_NORMAL) { - $x = q("select site_url from site where site_flags in (%d,%d) and site_realm = '%s' and site_dead = 0", + $x = q("select site_url from site where site_flags in (%d,%d) and site_realm = '%s' and site_dead = 0 and site_project != 'redmatrix'", intval(DIRECTORY_MODE_SECONDARY), intval(DIRECTORY_MODE_PRIMARY), dbesc($realm) @@ -288,17 +300,18 @@ class Site { '$techlock' => [ 'techlock', t('Lock the technical skill level setting'), get_config('system','techlevel_lock'), t('Members can set their own technical comfort level by default') ], - '$banner' => array('banner', t("Banner/Logo"), $banner, ""), + '$banner' => array('banner', t("Banner/Logo"), $banner, t('Unfiltered HTML/CSS/JS is allowed')), '$admininfo' => array('admininfo', t("Administrator Information"), $admininfo, t("Contact information for site administrators. Displayed on siteinfo page. BBCode can be used here")), '$siteinfo' => array('siteinfo', t('Site Information'), get_config('system','siteinfo'), t("Publicly visible description of this site. Displayed on siteinfo page. BBCode can be used here")), '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices), '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices), - '$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile_theme'), t("Theme for mobile devices"), $theme_choices_mobile), +// '$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile_theme'), t("Theme for mobile devices"), $theme_choices_mobile), // '$site_channel' => array('site_channel', t("Channel to use for this website's static pages"), get_config('system','site_channel'), t("Site Channel")), '$feed_contacts' => array('feed_contacts', t('Allow Feeds as Connections'),get_config('system','feed_contacts'),t('(Heavy system resource usage)')), '$maximagesize' => array('maximagesize', t("Maximum image size"), intval(get_config('system','maximagesize')), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")), '$register_policy' => array('register_policy', t("Does this site allow new member registration?"), get_config('system','register_policy'), "", $register_choices), '$invite_only' => array('invite_only', t("Invitation only"), get_config('system','invitation_only'), t("Only allow new member registrations with an invitation code. Above register policy must be set to Yes.")), + '$minimum_age' => array('minimum_age', t("Minimum age"), (x(get_config('system','minimum_age'))?get_config('system','minimum_age'):13), t("Minimum age (in years) for who may register on this site.")), '$access_policy' => array('access_policy', t("Which best describes the types of account offered by this hub?"), get_config('system','access_policy'), "This is displayed on the public server site list.", $access_choices), '$register_text' => array('register_text', t("Register text"), htmlspecialchars(get_config('system','register_text'), ENT_QUOTES, 'UTF-8'), t("Will be displayed prominently on the registration page.")), '$frontpage' => array('frontpage', t("Site homepage to show visitors (default: login box)"), get_config('system','frontpage'), t("example: 'public' to show public stream, 'page/sys/home' to show a system webpage called 'home' or 'include:home.html' to include a file.")), @@ -308,6 +321,8 @@ class Site { '$verify_email' => array('verify_email', t("Verify Email Addresses"), get_config('system','verify_email'), t("Check to verify email addresses used in account registration (recommended).")), '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")), '$disable_discover_tab' => array('disable_discover_tab', t('Import Public Streams'), $discover_tab, t('Import and allow access to public content pulled from other sites. Warning: this content is unmoderated.')), + '$site_firehose' => array('site_firehose', t('Site only Public Streams'), get_config('system','site_firehose'), t('Allow access to public content originating only from this site if Imported Public Streams are disabled.')), + '$open_pubstream' => array('open_pubstream', t('Allow anybody on the internet to access the Public streams'), get_config('system','open_pubstream',1), t('Disable to require authentication before viewing. Warning: this content is unmoderated.')), '$login_on_homepage' => array('login_on_homepage', t("Login on Homepage"),((intval($homelogin) || $homelogin === false) ? 1 : '') , t("Present a login box to visitors on the home page if no other content has been configured.")), '$enable_context_help' => array('enable_context_help', t("Enable context help"),((intval($enable_context_help) === 1 || $enable_context_help === false) ? 1 : 0) , t("Display contextual help for the current page when the help button is pressed.")), @@ -328,6 +343,13 @@ class Site { '$thumbnail_security' => array('thumbnail_security', t("Allow SVG thumbnails in file browser"), get_config('system','thumbnail_security',0), t("WARNING: SVG images may contain malicious code.")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), '$default_expire_days' => array('default_expire_days', t('Expiration period in days for imported (grid/network) content'), intval(get_config('system','default_expire_days')), t('0 for no expiration of imported content')), + + '$sellpage' => array('site_sellpage', t('Public servers: Optional landing (marketing) webpage for new registrants'), get_config('system','sellpage',''), sprintf( t('Create this page first. Default is %s/register'),z_root())), + '$firstpage' => array('firstpage', t('Page to display after creating a new channel'), get_config('system','workflow_channel_next','profiles'), t('Recommend: profiles, go, or settings')), + + '$location' => array('site_location', t('Optional: site location'), get_config('system','site_location',''), t('Region or country')), + + '$form_security_token' => get_form_security_token("admin_site"), )); } diff --git a/Zotlabs/Module/Api.php b/Zotlabs/Module/Api.php index a2a1aac1d..aa0fca54d 100644 --- a/Zotlabs/Module/Api.php +++ b/Zotlabs/Module/Api.php @@ -39,10 +39,12 @@ class Api extends \Zotlabs\Web\Controller { // get consumer/client from request token try { - $request = OAuth1Request::from_request(); + $request = \OAuth1Request::from_request(); } catch(\Exception $e) { - echo "<pre>"; var_dump($e); killme(); + logger('OAuth exception: ' . print_r($e,true)); + // echo "<pre>"; var_dump($e); + killme(); } @@ -52,7 +54,7 @@ class Api extends \Zotlabs\Web\Controller { if (is_null($app)) return "Invalid request. Unknown token."; - $consumer = new OAuth1Consumer($app['client_id'], $app['pw'], $app['redirect_uri']); + $consumer = new \OAuth1Consumer($app['client_id'], $app['pw'], $app['redirect_uri']); $verifier = md5($app['secret'] . local_channel()); set_config('oauth', $verifier, local_channel()); @@ -63,7 +65,7 @@ class Api extends \Zotlabs\Web\Controller { $glue = '?'; if(strstr($consumer->callback_url,$glue)) $glue = '?'; - goaway($consumer->callback_url . $glue . "oauth_token=" . OAuth1Util::urlencode_rfc3986($params['oauth_token']) . "&oauth_verifier=" . OAuth1Util::urlencode_rfc3986($verifier)); + goaway($consumer->callback_url . $glue . "oauth_token=" . \OAuth1Util::urlencode_rfc3986($params['oauth_token']) . "&oauth_verifier=" . \OAuth1Util::urlencode_rfc3986($verifier)); killme(); } diff --git a/Zotlabs/Module/Articles.php b/Zotlabs/Module/Articles.php index 25daca81d..e2e0fed5d 100644 --- a/Zotlabs/Module/Articles.php +++ b/Zotlabs/Module/Articles.php @@ -35,7 +35,7 @@ class Articles extends \Zotlabs\Web\Controller { return; } - nav_set_selected(t('Cards')); + nav_set_selected(t('Articles')); head_add_link([ 'rel' => 'alternate', @@ -102,6 +102,7 @@ class Articles extends \Zotlabs\Web\Controller { 'permissions' => $channel_acl, 'showacl' => (($is_owner) ? true : false), 'visitor' => true, + 'body' => '[summary][/summary]', 'hide_location' => false, 'hide_voting' => false, 'profile_uid' => intval($owner), diff --git a/Zotlabs/Module/Authorize.php b/Zotlabs/Module/Authorize.php index 06f66c456..254700b4e 100644 --- a/Zotlabs/Module/Authorize.php +++ b/Zotlabs/Module/Authorize.php @@ -2,70 +2,66 @@ namespace Zotlabs\Module; - -class Authorize extends \Zotlabs\Web\Controller { +use Zotlabs\Identity\OAuth2Storage; - function get() { +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)) ; - if(strlen($userpass)) { - list($name, $password) = explode(':', $userpass); - $_SERVER['PHP_AUTH_USER'] = $name; - $_SERVER['PHP_AUTH_PW'] = $password; - } + // workaround for HTTP-auth in CGI mode + if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { + $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; + if(strlen($userpass)) { + list($name, $password) = explode(':', $userpass); + $_SERVER['PHP_AUTH_USER'] = $name; + $_SERVER['PHP_AUTH_PW'] = $password; } - - if (x($_SERVER, 'HTTP_AUTHORIZATION')) { - $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; - if(strlen($userpass)) { - list($name, $password) = explode(':', $userpass); - $_SERVER['PHP_AUTH_USER'] = $name; - $_SERVER['PHP_AUTH_PW'] = $password; - } + } + + if (x($_SERVER, 'HTTP_AUTHORIZATION')) { + $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; + if(strlen($userpass)) { + list($name, $password) = explode(':', $userpass); + $_SERVER['PHP_AUTH_USER'] = $name; + $_SERVER['PHP_AUTH_PW'] = $password; } + } + $s = new \Zotlabs\Identity\OAuth2Server(new OAuth2Storage(\DBA::$dba->db)); + $request = \OAuth2\Request::createFromGlobals(); + $response = new \OAuth2\Response(); + // validate the authorize request + if (! $s->validateAuthorizeRequest($request, $response)) { + $response->send(); + killme(); + } - require_once('include/oauth2.php'); - - $request = \OAuth2\Request::createFromGlobals(); - $response = new \OAuth2\Response(); - - // validate the authorize request - if (! $oauth2_server->validateAuthorizeRequest($request, $response)) { - $response->send(); - killme(); - } - - // display an authorization form - if (empty($_POST)) { + // display an authorization form + if (empty($_POST)) { - return ' + return ' <form method="post"> <label>Do You Authorize TestClient?</label><br /> <input type="submit" name="authorized" value="yes"> <input type="submit" name="authorized" value="no"> </form>'; + } + + // 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'); - $oauth2_server->handleAuthorizeRequest($request, $response, $is_authorized); - 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/Cards.php b/Zotlabs/Module/Cards.php index 22c5d673c..f87988183 100644 --- a/Zotlabs/Module/Cards.php +++ b/Zotlabs/Module/Cards.php @@ -9,18 +9,22 @@ require_once('include/acl_selectors.php'); class Cards extends \Zotlabs\Web\Controller { function init() { - + if(argc() > 1) $which = argv(1); else return; - + profile_load($which); - + } - + + /** + * {@inheritDoc} + * @see \Zotlabs\Web\Controller::get() + */ function get($update = 0, $load = false) { - + if(observer_prohibited(true)) { return login(); } @@ -31,13 +35,13 @@ class Cards extends \Zotlabs\Web\Controller { return; } - if(! feature_enabled(\App::$profile_uid,'cards')) { + if(! feature_enabled(\App::$profile_uid, 'cards')) { return; } nav_set_selected(t('Cards')); - head_add_link([ + head_add_link([ 'rel' => 'alternate', 'type' => 'application/json+oembed', 'href' => z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . \App::$query_string), @@ -46,48 +50,48 @@ class Cards extends \Zotlabs\Web\Controller { $category = (($_REQUEST['cat']) ? escape_tags(trim($_REQUEST['cat'])) : ''); - + if($category) { - $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'],'item', $category, TERM_CATEGORY)); + $sql_extra2 .= protect_sprintf(term_item_parent_query(\App::$profile['profile_uid'], 'item', $category, TERM_CATEGORY)); } $which = argv(1); - + $selected_card = ((argc() > 2) ? argv(2) : ''); $_SESSION['return_url'] = \App::$query_string; - + $uid = local_channel(); $owner = \App::$profile_uid; $observer = \App::get_observer(); - + $ob_hash = (($observer) ? $observer['xchan_hash'] : ''); - - if(! perm_is_allowed($owner,$ob_hash,'view_pages')) { + + if(! perm_is_allowed($owner, $ob_hash, 'view_pages')) { notice( t('Permission denied.') . EOL); return; } - + $is_owner = ($uid && $uid == $owner); - + $channel = channelx_by_n($owner); if($channel) { - $channel_acl = array( + $channel_acl = [ 'allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid'] - ); + ]; } else { $channel_acl = [ 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } - - if(perm_is_allowed($owner,$ob_hash,'write_pages')) { + + if(perm_is_allowed($owner, $ob_hash, 'write_pages')) { $x = [ 'webpage' => ITEM_TYPE_CARD, @@ -95,9 +99,9 @@ class Cards extends \Zotlabs\Web\Controller { 'content_label' => t('Add Card'), 'button' => t('Create'), 'nickname' => $channel['channel_address'], - 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] + 'lockstate' => (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), - 'acl' => (($is_owner) ? populate_acl($channel_acl, false, + 'acl' => (($is_owner) ? populate_acl($channel_acl, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_pages')) : ''), 'permissions' => $channel_acl, 'showacl' => (($is_owner) ? true : false), @@ -110,7 +114,7 @@ class Cards extends \Zotlabs\Web\Controller { 'layoutselect' => false, 'expanded' => false, 'novoting' => false, - 'catsenabled' => feature_enabled($owner,'categories'), + 'catsenabled' => feature_enabled($owner, 'categories'), 'bbco_autocomplete' => 'bbcode', 'bbcode' => true ]; @@ -119,14 +123,14 @@ class Cards extends \Zotlabs\Web\Controller { $x['title'] = $_REQUEST['title']; if($_REQUEST['body']) $x['body'] = $_REQUEST['body']; - $editor = status_editor($a,$x); + $editor = status_editor($a, $x); } else { $editor = ''; } - - + + $sql_extra = item_permissions_sql($owner); if($selected_card) { @@ -137,9 +141,9 @@ class Cards extends \Zotlabs\Web\Controller { $sql_extra .= "and item.id = " . intval($r[0]['iid']) . " "; } } - - $r = q("select * from item - where item.uid = %d and item_type = %d + + $r = q("select * from item + where uid = %d and item_type = %d $sql_extra order by item.created desc", intval($owner), intval(ITEM_TYPE_CARD) @@ -149,9 +153,10 @@ class Cards extends \Zotlabs\Web\Controller { and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 and item.item_blocked = 0 "; + $items_result = []; if($r) { - $parents_str = ids_to_querystr($r,'id'); + $parents_str = ids_to_querystr($r, 'id'); $items = q("SELECT item.*, item.id AS item_id FROM item @@ -164,24 +169,22 @@ class Cards extends \Zotlabs\Web\Controller { if($items) { xchan_query($items); $items = fetch_post_tags($items, true); - $items = conv_sort($items,'updated'); + $items_result = conv_sort($items, 'updated'); } - else - $items = []; } $mode = 'cards'; - - $content = conversation($items,$mode,false,'traditional'); + + $content = conversation($items_result, $mode, false, 'traditional'); $o = replace_macros(get_markup_template('cards.tpl'), [ '$title' => t('Cards'), '$editor' => $editor, '$content' => $content, - '$pager' => alt_pager($a,count($items)) + '$pager' => alt_pager($a, count($items_result)) ]); - return $o; - } + return $o; + } } diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 7c4c900a1..3d3eb2a85 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -204,7 +204,7 @@ class Channel extends \Zotlabs\Web\Controller { $_SESSION['loadtime'] = datetime_convert(); } else { - $r = q("SELECT distinct parent AS item_id, created from item + $r = q("SELECT distinct parent AS item_id from item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE uid = %d $item_normal_update AND item_wall = 1 $simple_update @@ -239,7 +239,7 @@ class Channel extends \Zotlabs\Web\Controller { if($load || ($checkjs->disabled())) { if($mid) { - $r = q("SELECT distinct parent AS item_id from item where mid like '%s' and uid = %d $item_normal + $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d $item_normal AND item_wall = 1 $sql_extra limit 1", dbesc($mid . '%'), intval(\App::$profile['profile_uid']) @@ -249,13 +249,13 @@ class Channel extends \Zotlabs\Web\Controller { } } else { - $r = q("SELECT distinct id AS item_id, created FROM item - left join abook on item.author_xchan = abook.abook_xchan - WHERE uid = %d $item_normal - AND item_wall = 1 and item_thread_top = 1 - AND (abook_blocked = 0 or abook.abook_flags is null) + $r = q("SELECT item.parent AS item_id FROM item + left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) + WHERE true and item.uid = %d AND item.item_thread_top = 1 $item_normal + AND (abook.abook_blocked = 0 or abook.abook_flags is null) + AND item.item_wall = 1 $sql_extra $sql_extra2 - ORDER BY created DESC $pager_sql ", + ORDER BY created DESC, id $pager_sql ", intval(\App::$profile['profile_uid']) ); } diff --git a/Zotlabs/Module/Cloud.php b/Zotlabs/Module/Cloud.php index 2215507ca..8b5476efc 100644 --- a/Zotlabs/Module/Cloud.php +++ b/Zotlabs/Module/Cloud.php @@ -110,6 +110,9 @@ class Cloud extends \Zotlabs\Web\Controller { elseif($err instanceof \Sabre\DAV\Exception\Forbidden) { notice( t('Permission denied') . EOL); } + elseif($err instanceof \Sabre\DAV\Exception\NotImplemented) { + notice( t('Please refresh page') . EOL); + } else { notice( t('Unknown error') . EOL); } diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php index f42ff9b84..55e716ace 100644 --- a/Zotlabs/Module/Connections.php +++ b/Zotlabs/Module/Connections.php @@ -232,7 +232,7 @@ class Connections extends \Zotlabs\Web\Controller { if($rr['xchan_url']) { if(($rr['vcard']) && is_array($rr['vcard']['tels']) && $rr['vcard']['tels'][0]['nr']) - $phone = ((\App::$is_mobile || \App::$is_tablet) ? $rr['vcard']['tels'][0]['nr'] : ''); + $phone = $rr['vcard']['tels'][0]['nr']; else $phone = ''; @@ -245,6 +245,11 @@ class Connections extends \Zotlabs\Web\Controller { ((intval($rr['abook_blocked'])) ? t('Blocked') : ''), ((intval($rr['abook_not_here'])) ? t('Not connected at this location') : '') ); + + $oneway = false; + if(! intval(get_abconfig(local_channel(),$rr['xchan_hash'],'their_perms','post_comments'))) { + $oneway = true; + } foreach($status as $str) { if(!$str) @@ -283,7 +288,8 @@ class Connections extends \Zotlabs\Web\Controller { 'ignore_hover' => t('Ignore connection'), 'ignore' => ((! $rr['abook_ignored']) ? t('Ignore') : false), 'recent_label' => t('Recent activity'), - 'recentlink' => z_root() . '/network/?f=&cid=' . intval($rr['abook_id']) + 'recentlink' => z_root() . '/network/?f=&cid=' . intval($rr['abook_id']), + 'oneway' => $oneway ); } } diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 8288886cd..f359175c1 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -826,27 +826,10 @@ class Connedit extends \Zotlabs\Web\Controller { } } - $locstr = ''; - - $locs = q("select hubloc_addr as location from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s' - and hubloc_deleted = 0 and site_dead = 0", - dbesc($contact['xchan_hash']) - ); - - if($locs) { - foreach($locs as $l) { - if(!($l['location'])) - continue; - if(strpos($locstr,$l['location']) !== false) - continue; - if(strlen($locstr)) - $locstr .= ', '; - $locstr .= $l['location']; - } - } - else + $locstr = locations_by_netid($contact['xchan_hash']); + if(! $locstr) $locstr = $contact['xchan_url']; - + $clone_warn = ''; $clonable = (in_array($contact['xchan_network'],['zot','rss']) ? true : false); if(! $clonable) { @@ -912,7 +895,6 @@ class Connedit extends \Zotlabs\Web\Controller { '$permnote_self' => t('Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can change those settings here but they wont have any impact unless the inherited setting changes.'), '$lastupdtext' => t('Last update:'), '$last_update' => relative_date($contact['abook_connected']), - '$is_mobile' => ((\App::$is_mobile || \App::$is_tablet) ? true : false), '$profile_select' => contact_profile_assign($contact['abook_profile']), '$multiprofs' => $multiprofs, '$contact_id' => $contact['abook_id'], diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 47bce6c2b..56e35f912 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -64,12 +64,12 @@ class Cover_photo extends \Zotlabs\Web\Controller { $image_id = substr($image_id,0,-2); } - - $srcX = $_POST['xstart']; - $srcY = $_POST['ystart']; - $srcW = $_POST['xfinal'] - $srcX; - $srcH = $_POST['yfinal'] - $srcY; - + + + $srcX = intval($_POST['xstart']); + $srcY = intval($_POST['ystart']); + $srcW = intval($_POST['xfinal']) - $srcX; + $srcH = intval($_POST['yfinal']) - $srcY; $r = q("select gender from profile where uid = %d and is_default = 1 limit 1", intval(local_channel()) @@ -207,7 +207,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { } } - $imagedata = (($os_storage) ? @file_get_contents($imagedata) : $imagedata); + $imagedata = (($os_storage) ? @file_get_contents(dbunescbin($imagedata)) : dbunescbin($imagedata)); $ph = photo_factory($imagedata, $filetype); if(! $ph->is_valid()) { @@ -357,12 +357,23 @@ class Cover_photo extends \Zotlabs\Web\Controller { '$user' => \App::$channel['channel_address'], '$lbl_upfile' => t('Upload File:'), '$lbl_profiles' => t('Select a profile:'), - '$title' => t('Upload Cover Photo'), + '$title' => t('Change Cover Photo'), '$submit' => t('Upload'), '$profiles' => $profiles, + '$embedPhotos' => t('Use a photo from your albums'), + '$embedPhotosModalTitle' => t('Use a photo from your albums'), + '$embedPhotosModalCancel' => t('Cancel'), + '$embedPhotosModalOK' => t('OK'), + '$modalchooseimages' => t('Choose images to embed'), + '$modalchoosealbum' => t('Choose an album'), + '$modaldiffalbum' => t('Choose a different album'), + '$modalerrorlist' => t('Error getting album list'), + '$modalerrorlink' => t('Error getting photo link'), + '$modalerroralbum' => t('Error getting album'), '$form_security_token' => get_form_security_token("cover_photo"), /// @FIXME - yuk - '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . z_root() . '">' . t('skip this step') . '</a>' : '<a href="'. z_root() . '/photos/' . \App::$channel['channel_address'] . '">' . t('select a photo from your photo albums') . '</a>') + '$select' => t('Select existing photo'), + )); call_hooks('cover_photo_content_end', $o); diff --git a/Zotlabs/Module/Defperms.php b/Zotlabs/Module/Defperms.php index 422333a50..97d9cfd1d 100644 --- a/Zotlabs/Module/Defperms.php +++ b/Zotlabs/Module/Defperms.php @@ -22,7 +22,7 @@ class Defperms extends \Zotlabs\Web\Controller { $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash - WHERE abook_self = 1 and abook_id = %d LIMIT 1", + WHERE abook_self = 1 and abook_channel = %d LIMIT 1", intval(local_channel()) ); if($r) { diff --git a/Zotlabs/Module/Directory.php b/Zotlabs/Module/Directory.php index b1552a694..62a1670f9 100644 --- a/Zotlabs/Module/Directory.php +++ b/Zotlabs/Module/Directory.php @@ -17,7 +17,7 @@ class Directory extends \Zotlabs\Web\Controller { intval(local_channel()), dbesc($_GET['ignore']) ); - goaway(z_root() . '/directory?suggest=1'); + goaway(z_root() . '/directory?f=&suggest=1'); } $observer = get_observer_hash(); @@ -101,6 +101,11 @@ class Directory extends \Zotlabs\Web\Controller { if($suggest) { $r = suggestion_query(local_channel(),get_observer_hash()); + + if(! $r) { + notice( t('No default suggestions were found.') . EOL); + return; + } // Remember in which order the suggestions were $addresses = array(); diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php index e6cf5449a..08f1f7a13 100644 --- a/Zotlabs/Module/Dirsearch.php +++ b/Zotlabs/Module/Dirsearch.php @@ -97,7 +97,10 @@ class Dirsearch extends \Zotlabs\Web\Controller { else $sync = false; - + if(($dirmode == DIRECTORY_MODE_STANDALONE) && (! $hub)) { + $hub = \App::get_hostname(); + } + if($hub) $hub_query = " and xchan_hash in (select hubloc_hash from hubloc where hubloc_host = '" . protect_sprintf(dbesc($hub)) . "') "; else @@ -313,7 +316,7 @@ class Dirsearch extends \Zotlabs\Web\Controller { $ret['results'] = $entries; if($kw) { - $k = dir_tagadelic($kw); + $k = dir_tagadelic($kw, $hub); if($k) { $ret['keywords'] = array(); foreach($k as $kv) { diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 6d895feb5..8e8a1ed24 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -215,6 +215,7 @@ class Display extends \Zotlabs\Web\Controller { $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']),intval(\App::$pager['start'])); if($load || ($checkjs->disabled()) || ($module_format !== 'html')) { + $r = null; require_once('include/channel.php'); @@ -235,7 +236,7 @@ class Display extends \Zotlabs\Web\Controller { } } - if($r === null) { + if(! $r) { // in case somebody turned off public access to sys channel content using permissions // make that content unsearchable by ensuring the owner uid can't match @@ -281,7 +282,7 @@ class Display extends \Zotlabs\Web\Controller { } } - if($r === null) { + if(! $r) { // in case somebody turned off public access to sys channel content using permissions // make that content unsearchable by ensuring the owner_xchan can't match if(! perm_is_allowed($sysid,$observer_hash,'view_stream')) @@ -343,14 +344,15 @@ class Display extends \Zotlabs\Web\Controller { case 'atom': $atom = replace_macros(get_markup_template('atom_feed.tpl'), array( - '$version' => xmlify(\Zotlabs\Lib\System::get_project_version()), - '$red' => xmlify(\Zotlabs\Lib\System::get_platform_name()), - '$feed_id' => xmlify(\App::$cmd), - '$feed_title' => xmlify(t('Article')), - '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now', ATOM_TIME)), - '$author' => '', - '$owner' => '', - '$profile_page' => xmlify(z_root() . '/display/' . $target_item['mid']), + '$version' => xmlify(\Zotlabs\Lib\System::get_project_version()), + '$generator' => xmlify(\Zotlabs\Lib\System::get_platform_name()), + '$generator_uri' => 'https://hubzilla.org', + '$feed_id' => xmlify(\App::$cmd), + '$feed_title' => xmlify(t('Article')), + '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now', ATOM_TIME)), + '$author' => '', + '$owner' => '', + '$profile_page' => xmlify(z_root() . '/display/' . $target_item['mid']), )); $x = [ 'xml' => $atom, 'channel' => $channel, 'observer_hash' => $observer_hash, 'params' => $params ]; diff --git a/Zotlabs/Module/Email_resend.php b/Zotlabs/Module/Email_resend.php new file mode 100644 index 000000000..f8a336be0 --- /dev/null +++ b/Zotlabs/Module/Email_resend.php @@ -0,0 +1,46 @@ +<?php + +namespace Zotlabs\Module; + + +class Email_resend extends \Zotlabs\Web\Controller { + + function post() { + + if($_POST['token']) { + if(! account_approve(trim($_POST['token']))) { + notice(t('Token verification failed.')); + } + } + + } + + + function get() { + + if(argc() > 1) { + $result = false; + $email = hex2bin(argv(1)); + + if($email) { + $result = verify_email_address( [ 'resend' => true, 'email' => $email ] ); + } + + if($result) { + notice(t('Email verification resent')); + } + else { + notice(t('Unable to resend email verification message.')); + } + + goaway(z_root() . '/email_validation/' . bin2hex($email)); + + } + + // @todo - one can provide a form here to resend the mail + // after directing to here if a succesful login was attempted from an unverified address. + + + } + +} diff --git a/Zotlabs/Module/Email_validation.php b/Zotlabs/Module/Email_validation.php new file mode 100644 index 000000000..c1ba9a01a --- /dev/null +++ b/Zotlabs/Module/Email_validation.php @@ -0,0 +1,48 @@ +<?php + +namespace Zotlabs\Module; + + +class Email_validation extends \Zotlabs\Web\Controller { + + function post() { + + $success = false; + if($_POST['token']) { + // This will redirect internally on success unless the channel is auto_created + if(account_approve(trim(basename($_POST['token'])))) { + $success = true; + if(get_config('system','auto_channel_create')) { + $next_page = get_config('system', 'workflow_channel_next', 'profiles'); + } + if($next_page) { + goaway(z_root() . '/' . $next_page); + } + } + } + if(! $success) { + notice( t('Token verification failed.') . EOL); + } + } + + + function get() { + + if(argc() > 1) { + $email = hex2bin(argv(1)); + } + + $o = replace_macros(get_markup_template('email_validation.tpl'), [ + '$title' => t('Email Verification Required'), + '$desc' => sprintf( t('A verification token was sent to your email address [%s]. Enter that token here to complete the account verification step. Please allow a few minutes for delivery, and check your spam folder if you do not see the message.'),$email), + '$resend' => t('Resend Email'), + '$email' => bin2hex($email), + '$submit' => t('Submit'), + '$token' => [ 'token', t('Validation token'),'','' ], + ]); + + return $o; + + } + +}
\ No newline at end of file diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.php index 15cc68d7f..bcbb0e116 100644 --- a/Zotlabs/Module/Embedphotos.php +++ b/Zotlabs/Module/Embedphotos.php @@ -53,7 +53,7 @@ class Embedphotos extends \Zotlabs\Web\Controller { } else { json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false)); } - json_return_and_die(array('status' => true, 'photolink' => $photolink)); + json_return_and_die(array('status' => true, 'photolink' => $photolink, 'resource_id' => $resource_id)); } } diff --git a/Zotlabs/Module/Go.php b/Zotlabs/Module/Go.php new file mode 100644 index 000000000..d33136d9e --- /dev/null +++ b/Zotlabs/Module/Go.php @@ -0,0 +1,67 @@ +<?php + +namespace Zotlabs\Module; + + +class Go extends \Zotlabs\Web\Controller { + + function init() { + if(local_channel()) { + $channel = \App::get_channel(); + if($channel) { + profile_load($channel['channel_address'],0); + } + } + } + + + + function get() { + if(! local_channel()) { + notify( t('This page is available only to site members') . EOL); + } + + $channel = \App::get_channel(); + + + $title = t('Welcome'); + + $m = t('What would you like to do?'); + + $m1 = t('Please bookmark this page if you would like to return to it in the future'); + + + $options = [ + 'profile_photo' => t('Upload a profile photo'), + 'cover_photo' => t('Upload a cover photo'), + 'profiles' => t('Edit your default profile'), + 'suggest' => t('View friend suggestions'), + 'directory' => t('View the channel directory'), + 'settings' => t('View/edit your channel settings'), + 'help' => t('View the site or project documentation'), + 'channel/' . $channel['channel_address'] => t('Visit your channel homepage'), + 'connections' => t('View your connections and/or add somebody whose address you already know'), + 'network' => t('View your personal stream (this may be empty until you add some connections)'), + + ]; + + $site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); + $net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true); + + if($site_firehose || $net_firehose) { + $options['pubstream'] = t('View the public stream. Warning: this content is not moderated'); + } + + $o = replace_macros(get_markup_template('go.tpl'), [ + '$title' => $title, + '$m' => $m, + '$m1' => $m1, + '$options' => $options + + ]); + + return $o; + + } + +}
\ No newline at end of file diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php index 1e46a6353..baeba82e8 100644 --- a/Zotlabs/Module/Hq.php +++ b/Zotlabs/Module/Hq.php @@ -29,6 +29,8 @@ class Hq extends \Zotlabs\Web\Controller { ); } + killme(); + } function get($update = 0, $load = false) { @@ -50,9 +52,9 @@ class Hq extends \Zotlabs\Web\Controller { $item_normal_update = item_normal_update(); if(! $item_hash) { - $r = q("SELECT mid FROM item - WHERE uid = %d - AND mid = parent_mid + $r = q("SELECT mid FROM item + WHERE uid = %d $item_normal + AND mid = parent_mid ORDER BY created DESC LIMIT 1", intval(local_channel()) ); @@ -135,13 +137,11 @@ class Hq extends \Zotlabs\Web\Controller { $o = replace_macros(get_markup_template("hq.tpl"), [ '$no_messages' => (($target_item) ? false : true), - '$no_messages_label' => t('Welcome to hubzilla!') + '$no_messages_label' => [ t('Welcome to Hubzilla!'), t('You have got no unseen posts...') ], + '$editor' => status_editor($a,$x) ] ); - - $o = '<div id="jot-popup">'; - $o .= status_editor($a,$x); - $o .= '</div>'; + } if(! $update && ! $load) { @@ -266,23 +266,20 @@ class Hq extends \Zotlabs\Web\Controller { } if($r) { - $parents_str = ids_to_querystr($r,'item_id'); - if($parents_str) { - $items = q("SELECT item.*, item.id AS item_id - FROM item - WHERE parent IN ( %s ) $item_normal ", - dbesc($parents_str) - ); + $items = q("SELECT item.*, item.id AS item_id + FROM item + WHERE parent = '%s' $item_normal ", + dbesc($r[0]['item_id']) + ); - xchan_query($items,true,(($sys_item) ? local_channel() : 0)); - $items = fetch_post_tags($items,true); - $items = conv_sort($items,'created'); - } + xchan_query($items,true,(($sys_item) ? local_channel() : 0)); + $items = fetch_post_tags($items,true); + $items = conv_sort($items,'created'); } else { $items = []; } - + $o .= conversation($items, 'hq', $update, 'client'); if($updateable) { diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 2b16ff4e1..36bd72310 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -64,7 +64,7 @@ class Import extends \Zotlabs\Web\Controller { notice( t('Nothing to import.') . EOL); return; } else if(strpos($old_address, 'ï¼ ')) { - // if you copy the identity address from your profile page, make it work for convenience + // if you copy the identity address from your profile page, make it work for convenience - WARNING: this is a utf-8 variant and NOT an ASCII ampersand. Please do not edit. $old_address = str_replace('ï¼ ', '@', $old_address); } diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 6365230f8..3f857030b 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -39,6 +39,7 @@ class Item extends \Zotlabs\Web\Controller { $uid = local_channel(); $channel = null; $observer = null; + $datarray = []; /** @@ -504,7 +505,12 @@ class Item extends \Zotlabs\Web\Controller { $body = z_input_filter($body,$mimetype,$execflag); } - // Verify ability to use html or php!!! + + $arr = [ 'profile_uid' => $profile_uid, 'content' => $body, 'mimetype' => $mimetype ]; + call_hooks('post_content',$arr); + $body = $arr['content']; + $mimetype = $arr['mimetype']; + $gacl = $acl->get(); $str_contact_allow = $gacl['allow_cid']; @@ -516,13 +522,6 @@ class Item extends \Zotlabs\Web\Controller { require_once('include/text.php'); - if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) { - require_once('include/markdown.php'); - $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_shield',$body); - $body = markdown_to_bb($body,true,['preserve_lf' => true]); - $body = preg_replace_callback('/\[share(.*?)\]/ism','\share_unshield',$body); - - } // BBCODE alert: the following functions assume bbcode input // and will require alternatives for alternative content-types (text/html, text/markdown, text/plain, etc.) @@ -621,6 +620,21 @@ class Item extends \Zotlabs\Web\Controller { $i++; } } + + + if(preg_match_all('/(\[share=(.*?)\](.*?)\[\/share\])/',$body,$match)) { + // process share by id + + $verb = ACTIVITY_SHARE; + $i = 0; + foreach($match[2] as $mtch) { + $reshare = new \Zotlabs\Lib\Share($mtch); + $datarray['obj'] = $reshare->obj(); + $datarray['obj_type'] = $datarray['obj']['type']; + $body = str_replace($match[1][$i],$reshare->bbcode(),$body); + $i++; + } + } } @@ -722,7 +736,6 @@ class Item extends \Zotlabs\Web\Controller { if(!$thr_parent) $thr_parent = $mid; - $datarray = array(); $item_thread_top = ((! $parent) ? 1 : 0); @@ -755,6 +768,7 @@ class Item extends \Zotlabs\Web\Controller { if ((! $plink) && ($item_thread_top)) { $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid; + $plink = substr($plink,0,190); } $datarray['aid'] = $channel['channel_account_id']; diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index b07824363..6d9fde17c 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -9,9 +9,41 @@ require_once('include/items.php'); class Like extends \Zotlabs\Web\Controller { - function get() { + + + private function reaction_to_activity($reaction) { + + $acts = [ + 'like' => ACTIVITY_LIKE , + 'dislike' => ACTIVITY_DISLIKE , + 'agree' => ACTIVITY_AGREE , + 'disagree' => ACTIVITY_DISAGREE , + 'abstain' => ACTIVITY_ABSTAIN , + 'attendyes' => ACTIVITY_ATTEND , + 'attendno' => ACTIVITY_ATTENDNO , + 'attendmaybe' => ACTIVITY_ATTENDMAYBE + ]; + + // unlike (etc.) reactions are an undo of positive reactions, rather than a negative action. + // The activity is the same in undo actions and will have the same activity mapping + + if(substr($reaction,0,2) === 'un') { + $reaction = substr($reaction,2); + } + + if(array_key_exists($reaction,$acts)) { + return $acts[$reaction]; + } + + return EMPTY_STR; + + } + + + + public function get() { - $o = ''; + $o = EMPTY_STR; $sys_channel = get_sys_channel(); $sys_channel_id = (($sys_channel) ? $sys_channel['channel_id'] : 0); @@ -35,48 +67,17 @@ class Like extends \Zotlabs\Web\Controller { if(! $verb) $verb = 'like'; - switch($verb) { - case 'like': - case 'unlike': - $activity = ACTIVITY_LIKE; - break; - case 'dislike': - case 'undislike': - $activity = ACTIVITY_DISLIKE; - break; - case 'agree': - case 'unagree': - $activity = ACTIVITY_AGREE; - break; - case 'disagree': - case 'undisagree': - $activity = ACTIVITY_DISAGREE; - break; - case 'abstain': - case 'unabstain': - $activity = ACTIVITY_ABSTAIN; - break; - case 'attendyes': - case 'unattendyes': - $activity = ACTIVITY_ATTEND; - break; - case 'attendno': - case 'unattendno': - $activity = ACTIVITY_ATTENDNO; - break; - case 'attendmaybe': - case 'unattendmaybe': - $activity = ACTIVITY_ATTENDMAYBE; - break; - default: - return; - break; + $activity = $this->reaction_to_activity($verb); + + if(! $activity) { + return EMPTY_STR; } + $extended_like = false; $object = $target = null; - $post_type = ''; - $objtype = ''; + $post_type = EMPTY_STR; + $objtype = EMPTY_STR; if(argc() == 3) { diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php index 78c34583e..3392e4114 100644 --- a/Zotlabs/Module/Linkinfo.php +++ b/Zotlabs/Module/Linkinfo.php @@ -120,9 +120,9 @@ class Linkinfo extends \Zotlabs\Web\Controller { $siteinfo = self::parseurl_getsiteinfo($url); - // If this is a Red site, use zrl rather than url so they get zids sent to them by default + // If the site uses this platform, use zrl rather than url so they get zids sent to them by default - if( x($siteinfo,'generator') && (strpos($siteinfo['generator'], \Zotlabs\Lib\System::get_platform_name() . ' ') === 0)) + if(is_matrix_url($url)) $template = str_replace('url','zrl',$template); if($siteinfo["title"] == "") { diff --git a/Zotlabs/Module/Logout.php b/Zotlabs/Module/Logout.php index 6aa11d110..f06e7278b 100644 --- a/Zotlabs/Module/Logout.php +++ b/Zotlabs/Module/Logout.php @@ -9,4 +9,4 @@ class Logout extends \Zotlabs\Web\Controller { goaway(z_root()); } -}
\ No newline at end of file +} diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index 9ad9c951c..15e5cedcf 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -166,7 +166,7 @@ class Magic extends \Zotlabs\Web\Controller { $token = random_string(); - \Zotlabs\Zot\Verify::create('auth',$channel['channel_id'],$token,$x[0]['hubloc_url']); + \Zotlabs\Lib\Verify::create('auth',$channel['channel_id'],$token,$x[0]['hubloc_url']); $target_url = $x[0]['hubloc_callback'] . '/?f=&auth=' . urlencode(channel_reddress($channel)) . '&sec=' . $token . '&dest=' . urlencode($dest) . '&version=' . ZOT_REVISION; diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index a3e1eee88..6e961dc36 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -108,6 +108,9 @@ class Network extends \Zotlabs\Web\Controller { } + $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0); + $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99); + // if no tabs are selected, defaults to comments @@ -117,8 +120,8 @@ class Network extends \Zotlabs\Web\Controller { $liked = ((x($_GET,'liked')) ? intval($_GET['liked']) : 0); $conv = ((x($_GET,'conv')) ? intval($_GET['conv']) : 0); $spam = ((x($_GET,'spam')) ? intval($_GET['spam']) : 0); - $cmin = ((x($_GET,'cmin')) ? intval($_GET['cmin']) : 0); - $cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99); + $cmin = ((array_key_exists('cmin',$_GET)) ? intval($_GET['cmin']) : $default_cmin); + $cmax = ((array_key_exists('cmax',$_GET)) ? intval($_GET['cmax']) : $default_cmax); $file = ((x($_GET,'file')) ? $_GET['file'] : ''); $xchan = ((x($_GET,'xchan')) ? $_GET['xchan'] : ''); $net = ((x($_GET,'net')) ? $_GET['net'] : ''); @@ -141,7 +144,7 @@ class Network extends \Zotlabs\Web\Controller { // NOTREACHED } if($_GET['pf'] === '1') - $deftag = '@' . t('forum') . '+' . intval($cid) . '+'; + $deftag = '!' . t('forum') . '+' . intval($cid); else $def_acl = [ 'allow_cid' => '<' . $r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } @@ -206,8 +209,11 @@ class Network extends \Zotlabs\Web\Controller { : ''); $sql_nets = ''; + + $distinct = ''; + $item_thread_top = ' AND item_thread_top = 1 '; - $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 $sql_options ) "; + $sql_extra = $sql_options; if($group) { $contact_str = ''; @@ -223,7 +229,8 @@ class Network extends \Zotlabs\Web\Controller { $contact_str = ' 0 '; info( t('Privacy group is empty')); } - + $distinct = ' distinct '; + $item_thread_top = ''; $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent $item_normal ) "; $x = group_rec_byhash(local_channel(), $group_hash); @@ -247,6 +254,8 @@ class Network extends \Zotlabs\Web\Controller { intval(local_channel()) ); if($r) { + $distinct = ' distinct '; + $item_thread_top = ''; $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) $item_normal ) "; $title = replace_macros(get_markup_template("section_title.tpl"),array( '$title' => '<a href="' . zid($r[0]['xchan_url']) . '" ><img src="' . zid($r[0]['xchan_photo_s']) . '" alt="' . urlencode($r[0]['xchan_name']) . '" /></a> <a href="' . zid($r[0]['xchan_url']) . '" >' . $r[0]['xchan_name'] . '</a>' @@ -261,13 +270,15 @@ class Network extends \Zotlabs\Web\Controller { } } elseif($xchan) { - $r = q("select * from xchan where xchan_hash = '%s'", - dbesc($xchan) - ); - if($r) { - $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($xchan) . "' or owner_xchan = '" . dbesc($xchan) . "' ) $item_normal ) "; - $title = replace_macros(get_markup_template("section_title.tpl"),array( - '$title' => '<a href="' . zid($r[0]['xchan_url']) . '" ><img src="' . zid($r[0]['xchan_photo_s']) . '" alt="' . urlencode($r[0]['xchan_name']) . '" /></a> <a href="' . zid($r[0]['xchan_url']) . '" >' . $r[0]['xchan_name'] . '</a>' + $r = q("select * from xchan where xchan_hash = '%s'", + dbesc($xchan) + ); + if($r) { + $distinct = ' distinct '; + $item_thread_top = ''; + $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($xchan) . "' or owner_xchan = '" . dbesc($xchan) . "' ) $item_normal ) "; + $title = replace_macros(get_markup_template("section_title.tpl"),array( + '$title' => '<a href="' . zid($r[0]['xchan_url']) . '" ><img src="' . zid($r[0]['xchan_photo_s']) . '" alt="' . urlencode($r[0]['xchan_name']) . '" /></a> <a href="' . zid($r[0]['xchan_url']) . '" >' . $r[0]['xchan_name'] . '</a>' )); $o = $tabs; $o .= $title; @@ -370,6 +381,8 @@ class Network extends \Zotlabs\Web\Controller { } if($conv) { + $distinct = ' distinct '; + $item_thread_top = ''; $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ", dbesc(protect_sprintf($channel['channel_hash'])) ); @@ -406,7 +419,6 @@ class Network extends \Zotlabs\Web\Controller { if($cmax == 99) $sql_nets .= " OR abook.abook_closeness IS NULL ) "; - } $net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : ''); @@ -446,7 +458,7 @@ class Network extends \Zotlabs\Web\Controller { if($nouveau && $load) { // "New Item View" - show all items unthreaded in reverse created date order - $items = q("SELECT item.*, item.id AS item_id, received FROM item + $items = q("SELECT item.*, item.id AS item_id, received FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) $net_query WHERE true $uids $item_normal @@ -475,18 +487,16 @@ class Network extends \Zotlabs\Web\Controller { if($load) { // Fetch a page full of parent items for this page - - $r = q("SELECT distinct item.id AS item_id, $ordering FROM item + $r = q("SELECT $distinct item.parent AS item_id FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) $net_query - WHERE true $uids $item_normal - AND item.parent = item.id + WHERE true $uids $item_thread_top $item_normal + AND item.mid = item.parent_mid and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets $net_query2 ORDER BY $ordering DESC $pager_sql " ); - } else { diff --git a/Zotlabs/Module/New_channel.php b/Zotlabs/Module/New_channel.php index 2b73fa191..548f28c4f 100644 --- a/Zotlabs/Module/New_channel.php +++ b/Zotlabs/Module/New_channel.php @@ -89,9 +89,7 @@ class New_channel extends \Zotlabs\Web\Controller { change_channel($result['channel']['channel_id']); - if(! strlen($next_page = get_config('system','workflow_channel_next'))) - $next_page = 'settings'; - + $next_page = get_config('system', 'workflow_channel_next', 'profiles'); goaway(z_root() . '/' . $next_page); } @@ -144,6 +142,7 @@ class New_channel extends \Zotlabs\Web\Controller { '$role' => $role, '$default_role' => $default_role, '$nickname' => $nickname, + '$validate' => t('Validate'), '$submit' => t('Create'), '$channel_usage_message' => $channel_usage_message )); diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php index 23ee14f39..e62fc9592 100644 --- a/Zotlabs/Module/Owa.php +++ b/Zotlabs/Module/Owa.php @@ -42,7 +42,7 @@ class Owa extends \Zotlabs\Web\Controller { logger('OWA success: ' . $hubloc['hubloc_addr'],LOGGER_DATA); $ret['success'] = true; $token = random_string(32); - \Zotlabs\Zot\Verify::create('owt',0,$token,$hubloc['hubloc_addr']); + \Zotlabs\Lib\Verify::create('owt',0,$token,$hubloc['hubloc_addr']); $result = ''; openssl_public_encrypt($token,$result,$hubloc['xchan_pubkey']); $ret['encrypted_token'] = base64url_encode($result); diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index a3f6cdfec..eab49d69e 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -148,14 +148,12 @@ class Ping extends \Zotlabs\Web\Controller { $pubs = q("SELECT count(id) as total from item WHERE uid = %d - AND author_xchan != '%s' - AND obj_type != '%s' AND item_unseen = 1 + AND author_xchan != '%s' AND created > '" . datetime_convert('UTC','UTC',$_SESSION['static_loadtime']) . "' $item_normal", intval($sys['channel_id']), - dbesc(get_observer_hash()), - dbesc(ACTIVITY_OBJ_FILE) + dbesc(get_observer_hash()) ); if($pubs) @@ -168,8 +166,8 @@ class Ping extends \Zotlabs\Web\Controller { $r = q("SELECT * FROM item WHERE uid = %d - AND author_xchan != '%s' AND item_unseen = 1 + AND author_xchan != '%s' AND created > '" . datetime_convert('UTC','UTC',$_SESSION['static_loadtime']) . "' $item_normal ORDER BY created DESC @@ -210,22 +208,22 @@ class Ping extends \Zotlabs\Web\Controller { if(x($_REQUEST, 'markRead') && local_channel()) { switch($_REQUEST['markRead']) { case 'network': - $r = q("update item set item_unseen = 0 where item_unseen = 1 and uid = %d", + $r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1", intval(local_channel()) ); break; case 'home': - $r = q("update item set item_unseen = 0 where item_unseen = 1 and item_wall = 1 and uid = %d", + $r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1 AND item_wall = 1", intval(local_channel()) ); break; case 'mail': - $r = q("update mail set mail_seen = 1 where mail_seen = 0 and channel_id = %d ", + $r = q("UPDATE mail SET mail_seen = 1 WHERE channel_id = %d AND mail_seen = 0", intval(local_channel()) ); break; case 'all_events': - $r = q("update event set dismissed = 1 where dismissed = 0 and uid = %d AND dtstart < '%s' AND dtstart > '%s' ", + $r = q("UPDATE event SET dismissed = 1 WHERE uid = %d AND dismissed = 0 AND dtstart < '%s' AND dtstart > '%s' ", intval(local_channel()), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) @@ -245,9 +243,9 @@ class Ping extends \Zotlabs\Web\Controller { } if(x($_REQUEST, 'markItemRead') && local_channel()) { - $r = q("update item set item_unseen = 0 where parent = %d and uid = %d", - intval($_REQUEST['markItemRead']), - intval(local_channel()) + $r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND parent = %d", + intval(local_channel()), + intval($_REQUEST['markItemRead']) ); } @@ -256,7 +254,7 @@ class Ping extends \Zotlabs\Web\Controller { * dropdown menu. */ if(argc() > 1 && argv(1) === 'notify') { - $t = q("select * from notify where uid = %d and seen = 0 order by created desc", + $t = q("SELECT * FROM notify WHERE uid = %d AND seen = 0 ORDER BY CREATED DESC", intval(local_channel()) ); @@ -270,7 +268,18 @@ class Ping extends \Zotlabs\Web\Controller { $mid = basename($tt['link']); - $b64mid = ((strpos($mid, 'b64.' === 0)) ? $mid : 'b64.' . base64url_encode($mid)); + if(in_array($tt['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { + // we need the thread parent + $r = q("select thr_parent from item where mid = '%s' and uid = %d limit 1", + dbesc($mid), + intval(local_channel()) + ); + + $b64mid = ((strpos($r[0]['thr_parent'], 'b64.' === 0)) ? $r[0]['thr_parent'] : 'b64.' . base64url_encode($r[0]['thr_parent'])); + } + else { + $b64mid = ((strpos($mid, 'b64.' === 0)) ? $mid : 'b64.' . base64url_encode($mid)); + } $notifs[] = array( 'notify_link' => z_root() . '/notify/view/' . $tt['id'], @@ -320,10 +329,13 @@ class Ping extends \Zotlabs\Web\Controller { if(argc() > 1 && (argv(1) === 'network' || argv(1) === 'home')) { $result = array(); - $r = q("SELECT * FROM item - WHERE item_unseen = 1 and uid = %d $item_normal + $r = q("SELECT * FROM item + WHERE uid = %d + AND item_unseen = 1 AND author_xchan != '%s' - ORDER BY created DESC limit 300", + $item_normal + ORDER BY created DESC + LIMIT 300", intval(local_channel()), dbesc($ob_hash) ); @@ -492,9 +504,9 @@ class Ping extends \Zotlabs\Web\Controller { $t3 = dba_timer(); if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) { - - $r = q("SELECT id, item_wall FROM item - WHERE item_unseen = 1 and uid = %d + + $r = q("SELECT id, item_wall FROM item + WHERE uid = %d and item_unseen = 1 $item_normal AND author_xchan != '%s'", intval(local_channel()), diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index 45a606d5f..2ce8686b9 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -1,10 +1,11 @@ <?php namespace Zotlabs\Module; -/* @file profile_photo.php - @brief Module-file with functions for handling of profile-photos - -*/ +/* + * @file Profile_photo.php + * @brief Module-file with functions for handling of profile-photos + * + */ require_once('include/photo/photo_driver.php'); @@ -55,6 +56,10 @@ class Profile_photo extends \Zotlabs\Web\Controller { if((array_key_exists('cropfinal',$_POST)) && (intval($_POST['cropfinal']) == 1)) { + // logger('crop: ' . print_r($_POST,true)); + + + // phase 2 - we have finished cropping if(argc() != 2) { @@ -86,10 +91,10 @@ class Profile_photo extends \Zotlabs\Web\Controller { } - $srcX = $_POST['xstart']; - $srcY = $_POST['ystart']; - $srcW = $_POST['xfinal'] - $srcX; - $srcH = $_POST['yfinal'] - $srcY; + $srcX = intval($_POST['xstart']); + $srcY = intval($_POST['ystart']); + $srcW = intval($_POST['xfinal']) - $srcX; + $srcH = intval($_POST['yfinal']) - $srcY; $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND uid = %d AND imgscale = %d LIMIT 1", dbesc($image_id), @@ -299,7 +304,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { } $channel = \App::get_channel(); - + $pf = 0; $newuser = false; if(argc() == 2 && argv(1) === 'new') @@ -313,8 +318,8 @@ class Profile_photo extends \Zotlabs\Web\Controller { $resource_id = argv(2); - // When using an existing photo, we don't have a dialogue to offer a choice of profiles, - // so it gets attached to the default + + $pf = (($_REQUEST['pf']) ? intval($_REQUEST['pf']) : 0); $c = q("select id, is_default from profile where uid = %d", intval(local_channel()) @@ -326,6 +331,9 @@ class Profile_photo extends \Zotlabs\Web\Controller { $_REQUEST['profile'] = $c[0]['id']; $multi_profiles = false; } + else { + $_REQUEST['profile'] = $pf; + } $r = q("SELECT id, album, imgscale FROM photo WHERE uid = %d AND resource_id = '%s' ORDER BY imgscale ASC", intval(local_channel()), @@ -425,6 +433,16 @@ class Profile_photo extends \Zotlabs\Web\Controller { intval(local_channel()) ); + if($profiles) { + for($x = 0; $x < count($profiles); $x ++) { + $profiles[$x]['selected'] = false; + if($pf && $profiles[$x]['id'] == $pf) + $profiles[$x]['selected'] = true; + if((! $pf) && $profiles[$x]['is_default']) + $profiles[$x]['selected'] = true; + } + } + $importing = ((array_key_exists('importfile',\App::$data)) ? true : false); if(! x(\App::$data,'imagecrop')) { @@ -436,14 +454,23 @@ class Profile_photo extends \Zotlabs\Web\Controller { '$importfile' => (($importing) ? \App::$data['importfile'] : ''), '$lbl_upfile' => t('Upload File:'), '$lbl_profiles' => t('Select a profile:'), - '$title' => (($importing) ? t('Use Photo for Profile') : t('Upload Profile Photo')), + '$title' => (($importing) ? t('Use Photo for Profile') : t('Change Profile Photo')), '$submit' => (($importing) ? t('Use') : t('Upload')), '$profiles' => $profiles, '$single' => ((count($profiles) == 1) ? true : false), '$profile0' => $profiles[0], + '$embedPhotos' => t('Use a photo from your albums'), + '$embedPhotosModalTitle' => t('Use a photo from your albums'), + '$embedPhotosModalCancel' => t('Cancel'), + '$embedPhotosModalOK' => t('OK'), + '$modalchooseimages' => t('Choose images to embed'), + '$modalchoosealbum' => t('Choose an album'), + '$modaldiffalbum' => t('Choose a different album'), + '$modalerrorlist' => t('Error getting album list'), + '$modalerrorlink' => t('Error getting photo link'), + '$modalerroralbum' => t('Error getting album'), '$form_security_token' => get_form_security_token("profile_photo"), - // FIXME - yuk - '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . z_root() . '">' . t('skip this step') . '</a>' : '<a href="'. z_root() . '/photos/' . \App::$channel['channel_address'] . '">' . t('select a photo from your photo albums') . '</a>') + '$select' => t('Select existing photo'), )); call_hooks('profile_photo_content_end', $o); diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index c469a0eca..79f205a22 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -12,14 +12,26 @@ class Pubstream extends \Zotlabs\Web\Controller { if($load) $_SESSION['loadtime'] = datetime_convert(); - - if(observer_prohibited(true)) { + if((observer_prohibited(true))) { + return login(); + } + + if(! intval(get_config('system','open_pubstream',1))) { + if(! get_observer_hash()) { return login(); + } + } + + $site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); + $net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true); + + if(! ($site_firehose || $net_firehose)) { + return ''; + } + + if($net_firehose) { + $site_firehose = false; } - - $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false; - if($disable_discover_tab) - return; $mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : ''); @@ -142,7 +154,7 @@ class Pubstream extends \Zotlabs\Web\Controller { require_once('include/channel.php'); require_once('include/security.php'); - if(get_config('system','site_firehose')) { + if($site_firehose) { $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 "; } else { @@ -160,7 +172,8 @@ class Pubstream extends \Zotlabs\Web\Controller { $net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : ''); $net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : ''); - + + $abook_uids = " and abook.abook_channel = " . intval(\App::$profile['profile_uid']) . " "; $simple_update = (($_SESSION['loadtime']) ? " AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' " : ''); @@ -179,7 +192,7 @@ class Pubstream extends \Zotlabs\Web\Controller { if($load) { if($mid) { $r = q("SELECT parent AS item_id FROM item - left join abook on item.author_xchan = abook.abook_xchan + left join abook on item.author_xchan = abook.abook_xchan $net_query WHERE mid like '%s' $uids $item_normal and (abook.abook_blocked = 0 or abook.abook_flags is null) @@ -189,11 +202,10 @@ class Pubstream extends \Zotlabs\Web\Controller { } else { // Fetch a page full of parent items for this page - $r = q("SELECT distinct item.id AS item_id, $ordering FROM item - left join abook on item.author_xchan = abook.abook_xchan + $r = q("SELECT item.id AS item_id FROM item + left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids ) $net_query - WHERE true $uids $item_normal - AND item.parent = item.id + WHERE true $uids and item.item_thread_top = 1 $item_normal and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets $net_query2 ORDER BY $ordering DESC $pager_sql " diff --git a/Zotlabs/Module/Register.php b/Zotlabs/Module/Register.php index deaee31bf..5356669e9 100644 --- a/Zotlabs/Module/Register.php +++ b/Zotlabs/Module/Register.php @@ -123,9 +123,6 @@ class Register extends \Zotlabs\Web\Controller { if($policy == REGISTER_OPEN ) { if($email_verify) { $res = verify_email_address($result); - if($res) { - info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ; - } } else { $res = send_register_success_email($result['email'],$result['password']); @@ -133,7 +130,8 @@ class Register extends \Zotlabs\Web\Controller { if($res) { if($invite_code) { info( t('Registration successful. Continue to create your first channel...') . EOL ) ; - } else { + } + else { info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ; } } @@ -150,9 +148,11 @@ class Register extends \Zotlabs\Web\Controller { } if($email_verify) { - goaway(z_root()); + goaway(z_root() . '/email_validation/' . bin2hex($result['email'])); } - + + // fall through and authenticate if no approvals or verifications were required. + authenticate_success($result['account'],null,true,false,true); $new_channel = false; @@ -217,6 +217,9 @@ class Register extends \Zotlabs\Web\Controller { $privacy_role = ((x($_REQUEST,'permissions_role')) ? $_REQUEST['permissions_role'] : ""); $perm_roles = \Zotlabs\Access\PermissionRoles::roles(); + + // A new account will not have a techlevel, but accounts can also be created by the administrator. + if((get_account_techlevel() < 4) && $privacy_role !== 'custom') unset($perm_roles[t('Other')]); @@ -231,15 +234,17 @@ class Register extends \Zotlabs\Web\Controller { // Configurable whether to restrict age or not - default is based on international legal requirements // This can be relaxed if you are on a restricted server that does not share with public servers - if(get_config('system','no_age_restriction')) + if(get_config('system','no_age_restriction')) { $label_tos = sprintf( t('I accept the %s for this website'), $toslink); - else + } + else { $age = get_config('system','minimum_age'); if(!$age) { $age = 13; } $label_tos = sprintf( t('I am over %s years of age and accept the %s for this website'), $age, $toslink); - + } + $enable_tos = 1 - intval(get_config('system','no_termsofservice')); $email = array('email', t('Your email address'), ((x($_REQUEST,'email')) ? strip_tags(trim($_REQUEST['email'])) : "")); @@ -255,6 +260,7 @@ class Register extends \Zotlabs\Web\Controller { $auto_create = (get_config('system','auto_channel_create') ? true : false); $default_role = get_config('system','default_permissions_role'); + $email_verify = get_config('system','verify_email'); require_once('include/bbcode.php'); @@ -278,7 +284,7 @@ class Register extends \Zotlabs\Web\Controller { '$pass1' => $password, '$pass2' => $password2, '$submit' => t('Register'), - '$verify_note' => t('This site may require email verification after submitting this form. If you are returned to a login page, please check your email for instructions.') + '$verify_note' => (($email_verify) ? t('This site requires email verification. After completing this form, please check your email for further instructions.') : ''), )); return $o; diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index a572a5a42..55e0e746f 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -90,7 +90,7 @@ class Search extends \Zotlabs\Web\Controller { } else { $regstr = db_getfunc('REGEXP'); - $sql_extra = sprintf(" AND item.body $regstr '%s' ", dbesc(protect_sprintf(preg_quote($search)))); + $sql_extra = sprintf(" AND (item.title $regstr '%s' OR item.body $regstr '%s') ", dbesc(protect_sprintf(preg_quote($search))), dbesc(protect_sprintf(preg_quote($search)))); } // Here is the way permissions work in the search module... @@ -165,40 +165,41 @@ class Search extends \Zotlabs\Web\Controller { if($load) { $r = null; - if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $prefix = 'distinct on (created, mid)'; - $suffix = 'ORDER BY created DESC, mid'; - } else { - $prefix = 'distinct'; - $suffix = 'group by mid ORDER BY created DESC'; - } if(local_channel()) { - $r = q("SELECT $prefix mid, item.id as item_id, item.* from item + $r = q("SELECT mid, MAX(id) as item_id from item WHERE ((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' AND item.deny_gid = '' AND item_private = 0 ) OR ( item.uid = %d )) OR item.owner_xchan = '%s' ) $item_normal $sql_extra - $suffix $pager_sql ", + group by mid order by created desc $pager_sql ", intval(local_channel()), dbesc($sys['xchan_hash']) ); } if($r === null) { - $r = q("SELECT $prefix mid, item.id as item_id, item.* from item + $r = q("SELECT mid, MAX(id) as item_id from item WHERE (((( item.allow_cid = '' AND item.allow_gid = '' AND item.deny_cid = '' AND item.deny_gid = '' AND item_private = 0 ) and owner_xchan in ( " . stream_perms_xchans(($observer) ? (PERMS_NETWORK|PERMS_PUBLIC) : PERMS_PUBLIC) . " )) $pub_sql ) OR owner_xchan = '%s') $item_normal $sql_extra - $suffix $pager_sql", + group by mid order by created desc $pager_sql", dbesc($sys['xchan_hash']) ); } + if($r) { + $str = ids_to_querystr($r,'item_id'); + $r = q("select *, id as item_id from item where id in ( " . $str . ") order by created desc "); + } } else { $r = array(); } + + + + } if($r) { diff --git a/Zotlabs/Module/Settings/Account.php b/Zotlabs/Module/Settings/Account.php index 18890e89f..9643c5958 100644 --- a/Zotlabs/Module/Settings/Account.php +++ b/Zotlabs/Module/Settings/Account.php @@ -113,7 +113,7 @@ class Account { '$origpass' => array('origpass', t('Current Password'), ' ',''), '$password1'=> array('npassword', t('Enter New Password'), '', ''), '$password2'=> array('confirm', t('Confirm New Password'), '', t('Leave password fields blank unless changing')), - '$techlevel' => [ 'techlevel', t('Your technical skill level'), $def_techlevel, t('Used to provide a member experience matched to your comfort level'), $techlevels ], + '$techlevel' => [ 'techlevel', t('Your technical skill level'), $def_techlevel, t('Used to provide a member experience and additional features consistent with your comfort level'), $techlevels ], '$techlock' => $techlock, '$submit' => t('Submit'), '$email' => array('email', t('Email Address:'), $email, ''), diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index 5e9e88a6d..fb8284d2e 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -331,22 +331,21 @@ class Channel { ); $limits = \Zotlabs\Access\PermissionLimits::Get(local_channel()); + $anon_comments = get_config('system','anonymous_comments',true); foreach($global_perms as $k => $perm) { $options = array(); + $can_be_public = ((strstr($k,'view') || ($k === 'post_comments' && $anon_comments)) ? true : false); foreach($perm_opts as $opt) { - if(((! strstr($k,'view')) && $k !== 'post_comments') && $opt[1] == PERMS_PUBLIC) + if($opt[1] == PERMS_PUBLIC && (! $can_be_public)) continue; $options[$opt[1]] = $opt[0]; } $permiss[] = array($k,$perm,$limits[$k],'',$options); } - - + // logger('permiss: ' . print_r($permiss,true)); - - $username = $channel['channel_name']; $nickname = $channel['channel_address']; $timezone = $channel['channel_timezone']; diff --git a/Zotlabs/Module/Settings/Display.php b/Zotlabs/Module/Settings/Display.php index e1ea0e3e5..340b3c0bb 100644 --- a/Zotlabs/Module/Settings/Display.php +++ b/Zotlabs/Module/Settings/Display.php @@ -21,7 +21,7 @@ class Display { if(! $theme) $theme = 'redbasic'; - $mobile_theme = ((x($_POST,'mobile_theme')) ? notags(trim($_POST['mobile_theme'])) : ''); + $preload_images = ((x($_POST,'preload_images')) ? intval($_POST['preload_images']) : 0); $channel_menu = ((x($_POST,'channel_menu')) ? intval($_POST['channel_menu']) : 0); $user_scalable = ((x($_POST,'user_scalable')) ? intval($_POST['user_scalable']) : 0); @@ -47,11 +47,6 @@ class Display { if($itemspage > 100) $itemspage = 100; - if ($mobile_theme == "---") - del_pconfig(local_channel(),'system','mobile_theme'); - else { - set_pconfig(local_channel(),'system','mobile_theme',$mobile_theme); - } set_pconfig(local_channel(),'system','preload_images',$preload_images); set_pconfig(local_channel(),'system','user_scalable',$user_scalable); @@ -114,10 +109,6 @@ class Display { $theme = (($existing_theme) ? $existing_theme : $default_theme); - $default_mobile_theme = get_config('system','mobile_theme'); - if(! $mobile_default_theme) - $mobile_default_theme = 'none'; - $allowed_themes_str = get_config('system','allowed_themes'); $allowed_themes_raw = explode(',',$allowed_themes_str); $allowed_themes = array(); @@ -135,26 +126,19 @@ class Display { $info = get_theme_info($th); $compatible = check_plugin_versions($info); - if(!$compatible) { - $mobile_themes[$f] = $themes[$f] = sprintf(t('%s - (Incompatible)'), $f); + if(! $compatible) { + $themes[$f] = sprintf(t('%s - (Incompatible)'), $f); continue; } $is_experimental = file_exists('view/theme/' . $th . '/experimental'); $unsupported = file_exists('view/theme/' . $th . '/unsupported'); - $is_mobile = file_exists('view/theme/' . $th . '/mobile'); $is_library = file_exists('view/theme/'. $th . '/library'); - $mobile_themes['---'] = t("No special theme for mobile devices"); if (!$is_experimental or ($is_experimental && (get_config('experimentals','exp_themes')==1 or get_config('experimentals','exp_themes')===false))){ $theme_name = (($is_experimental) ? sprintf(t('%s - (Experimental)'), $f) : $f); if (! $is_library) { - if($is_mobile) { - $mobile_themes[$f] = $themes[$f] = $theme_name . ' (' . t('mobile') . ')'; - } - else { - $mobile_themes[$f] = $themes[$f] = $theme_name; - } + $themes[$f] = $theme_name; } } } @@ -166,7 +150,6 @@ class Display { $theme_selected = explode(':', $theme_selected)[0]; } - $mobile_theme_selected = (!x($_SESSION,'mobile_theme')? $default_mobile_theme : $_SESSION['mobile_theme']); $preload_images = get_pconfig(local_channel(),'system','preload_images'); $preload_images = (($preload_images===false)? '0': $preload_images); // default if not set: 0 @@ -213,7 +196,6 @@ class Display { '$theme' => (($themes) ? array('theme', t('Display Theme:'), $theme_selected, '', $themes, 'preview') : false), '$schema' => array('schema', t('Select scheme'), $existing_schema, '' , $schemas), - '$mobile_theme' => (($mobile_themes) ? array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, '') : false), '$preload_images' => array('preload_images', t("Preload images before rendering the page"), $preload_images, t("The subjective page load time will be longer but the page will be ready when displayed"), $yes_no), '$user_scalable' => array('user_scalable', t("Enable user zoom on mobile devices"), $user_scalable, '', $yes_no), '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), diff --git a/Zotlabs/Module/Settings/Featured.php b/Zotlabs/Module/Settings/Featured.php index 6a8d10b2d..1da139206 100644 --- a/Zotlabs/Module/Settings/Featured.php +++ b/Zotlabs/Module/Settings/Featured.php @@ -17,12 +17,8 @@ class Featured { $cmin = intval($_POST['affinity_cmin']); if($cmin < 0 || $cmin > 99) $cmin = 0; - if($cmin !== 0 || $cmax !== 99) { - set_pconfig(local_channel(),'system','network_page_default','cmin=' . $cmin . '&cmax=' . $cmax); - } - else { - set_pconfig(local_channel(),'system','network_page_default',''); - } + set_pconfig(local_channel(),'affinity','cmin',$cmin); + set_pconfig(local_channel(),'affinity','cmax',$cmax); info( t('Affinity Slider settings updated.') . EOL); @@ -46,12 +42,12 @@ class Featured { $cmax = intval(get_pconfig(local_channel(),'affinity','cmax')); $cmax = (($cmax) ? $cmax : 99); $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array( - '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, '') + '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, t('0-99 default 99')) )); $cmin = intval(get_pconfig(local_channel(),'affinity','cmin')); $cmin = (($cmin) ? $cmin : 0); $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array( - '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, '') + '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, t('0-99 - default 0')) )); $settings_addons .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array( @@ -65,7 +61,8 @@ class Featured { $tpl = get_markup_template("settings_addons.tpl"); $o .= replace_macros($tpl, array( '$form_security_token' => get_form_security_token("settings_featured"), - '$title' => t('Feature/Addon Settings'), + '$title' => t('Addon Settings'), + '$descrip' => t('Please save/submit changes to any panel before opening another.'), '$settings_addons' => $settings_addons )); return $o; diff --git a/Zotlabs/Module/Settings/Permcats.php b/Zotlabs/Module/Settings/Permcats.php index 336f69653..535399083 100644 --- a/Zotlabs/Module/Settings/Permcats.php +++ b/Zotlabs/Module/Settings/Permcats.php @@ -49,7 +49,7 @@ class Permcats { if(argc() > 2) - $name = argv(2); + $name = hex2bin(argv(2)); if(argc() > 3 && argv(3) === 'drop') { \Zotlabs\Lib\Permcat::delete(local_channel(),$name); @@ -70,7 +70,7 @@ class Permcats { if(($pc['name']) && ($name) && ($pc['name'] == $name)) $existing = $pc['perms']; if(! $pc['system']) - $permcats[$pc['name']] = $pc['localname']; + $permcats[bin2hex($pc['name'])] = $pc['localname']; } } diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php index 5c4811c59..7f4d8b1eb 100644 --- a/Zotlabs/Module/Share.php +++ b/Zotlabs/Module/Share.php @@ -14,6 +14,10 @@ class Share extends \Zotlabs\Web\Controller { if(! $post_id) killme(); + + echo '[share=' . $post_id . '][/share]'; + killme(); + if(! (local_channel() || remote_channel())) killme(); diff --git a/Zotlabs/Module/Siteinfo.php b/Zotlabs/Module/Siteinfo.php index fafd51f65..92ee78cc6 100644 --- a/Zotlabs/Module/Siteinfo.php +++ b/Zotlabs/Module/Siteinfo.php @@ -5,7 +5,6 @@ namespace Zotlabs\Module; class Siteinfo extends \Zotlabs\Web\Controller { function init() { -logger(print_r($_REQUEST,true)); if (argv(1) === 'json' || $_REQUEST['module_format'] === 'json') { $data = get_site_info(); json_return_and_die($data); diff --git a/Zotlabs/Module/Sitelist.php b/Zotlabs/Module/Sitelist.php index e7d4187b7..2ac5ed1b8 100644 --- a/Zotlabs/Module/Sitelist.php +++ b/Zotlabs/Module/Sitelist.php @@ -32,7 +32,7 @@ class Sitelist extends \Zotlabs\Web\Controller { $result = array('success' => false); - $r = q("select count(site_url) as total from site where site_type = %d $sql_extra ", + $r = q("select count(site_url) as total from site where site_type = %d and site_dead = 0 $sql_extra ", intval(SITE_TYPE_ZOT) ); @@ -42,7 +42,7 @@ class Sitelist extends \Zotlabs\Web\Controller { $result['start'] = $start; $result['limit'] = $limit; - $r = q("select * from site where site_type = %d $sql_extra $sql_order $sql_limit", + $r = q("select * from site where site_type = %d and site_dead = 0 $sql_extra $sql_order $sql_limit", intval(SITE_TYPE_ZOT) ); diff --git a/Zotlabs/Module/Thing.php b/Zotlabs/Module/Thing.php index f816632ab..c3d8ff802 100644 --- a/Zotlabs/Module/Thing.php +++ b/Zotlabs/Module/Thing.php @@ -20,6 +20,11 @@ class Thing extends \Zotlabs\Web\Controller { $channel = \App::get_channel(); + if($_SERVER['REQUEST_METHOD'] === 'GET' && argc() < 2) { + profile_load($channel['channel_address']); + } + + $term_hash = (($_REQUEST['term_hash']) ? $_REQUEST['term_hash'] : ''); $name = escape_tags($_REQUEST['term']); diff --git a/Zotlabs/Module/Token.php b/Zotlabs/Module/Token.php index e0d9d74d7..f7c074233 100644 --- a/Zotlabs/Module/Token.php +++ b/Zotlabs/Module/Token.php @@ -2,39 +2,36 @@ namespace Zotlabs\Module; - -class Token extends \Zotlabs\Web\Controller { +use Zotlabs\Identity\OAuth2Storage; - function get() { +class Token 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)) ; - if(strlen($userpass)) { - list($name, $password) = explode(':', $userpass); - $_SERVER['PHP_AUTH_USER'] = $name; - $_SERVER['PHP_AUTH_PW'] = $password; - } + // workaround for HTTP-auth in CGI mode + if (x($_SERVER, 'REDIRECT_REMOTE_USER')) { + $userpass = base64_decode(substr($_SERVER["REDIRECT_REMOTE_USER"], 6)) ; + if(strlen($userpass)) { + list($name, $password) = explode(':', $userpass); + $_SERVER['PHP_AUTH_USER'] = $name; + $_SERVER['PHP_AUTH_PW'] = $password; } - - if (x($_SERVER, 'HTTP_AUTHORIZATION')) { - $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; - if(strlen($userpass)) { - list($name, $password) = explode(':', $userpass); - $_SERVER['PHP_AUTH_USER'] = $name; - $_SERVER['PHP_AUTH_PW'] = $password; - } + } + + if (x($_SERVER, 'HTTP_AUTHORIZATION')) { + $userpass = base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)) ; + if(strlen($userpass)) { + list($name, $password) = explode(':', $userpass); + $_SERVER['PHP_AUTH_USER'] = $name; + $_SERVER['PHP_AUTH_PW'] = $password; } + } + $s = new \Zotlabs\Identity\OAuth2Server(new OAuth2Storage(\DBA::$dba->db)); + $s->handleTokenRequest(\OAuth2\Request::createFromGlobals())->send(); - - - require_once('include/oauth2.php'); - $oauth2_server->handleTokenRequest(\OAuth2\Request::createFromGlobals())->send(); - - killme(); + killme(); } -}
\ No newline at end of file +} diff --git a/Zotlabs/Module/Viewconnections.php b/Zotlabs/Module/Viewconnections.php index 1f9c03751..8366e1325 100644 --- a/Zotlabs/Module/Viewconnections.php +++ b/Zotlabs/Module/Viewconnections.php @@ -44,7 +44,7 @@ class Viewconnections extends \Zotlabs\Web\Controller { $sql_extra = ''; if(! $is_owner) { - $abook_flags = " and abook_hidden = 0 "; + $abook_flags .= " and abook_hidden = 0 "; $sql_extra = " and xchan_hidden = 0 "; } @@ -69,8 +69,13 @@ class Viewconnections extends \Zotlabs\Web\Controller { $contacts = array(); foreach($r as $rr) { + + $oneway = false; + if(! intval(get_abconfig(\App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_comments'))) { + $oneway = true; + } - $url = chanlink_hash($rr['xchan_hash']); + $url = chanlink_hash($rr['xchan_hash']); if($url) { $contacts[] = array( 'id' => $rr['abook_id'], @@ -83,6 +88,7 @@ class Viewconnections extends \Zotlabs\Web\Controller { 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => '', + 'oneway' => $oneway ); } } diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 753721d27..81d4beaed 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -123,7 +123,8 @@ class Wfinger extends \Zotlabs\Web\Controller { $result['properties'] = [ 'http://webfinger.net/ns/name' => $r[0]['channel_name'], 'http://xmlns.com/foaf/0.1/name' => $r[0]['channel_name'], - 'https://w3id.org/security/v1#publicKeyPem' => $r[0]['xchan_pubkey'] + 'https://w3id.org/security/v1#publicKeyPem' => $r[0]['xchan_pubkey'], + 'http://purl.org/zot/federation' => 'zot' ]; foreach($aliases as $alias) diff --git a/Zotlabs/Render/SmartyInterface.php b/Zotlabs/Render/SmartyInterface.php index 0e3a47c2f..9c9a501c0 100755 --- a/Zotlabs/Render/SmartyInterface.php +++ b/Zotlabs/Render/SmartyInterface.php @@ -2,8 +2,6 @@ namespace Zotlabs\Render; -require_once('library/Smarty/libs/Smarty.class.php'); - class SmartyInterface extends \Smarty { public $filename; diff --git a/Zotlabs/Render/Theme.php b/Zotlabs/Render/Theme.php index 09cc7a4d4..0eebba1ba 100644 --- a/Zotlabs/Render/Theme.php +++ b/Zotlabs/Render/Theme.php @@ -8,10 +8,8 @@ use App; class Theme { static $system_theme = null; - static $system_mobile_theme = null; static $session_theme = null; - static $session_mobile_theme = null; /** * @brief Array with base or fallback themes. @@ -32,10 +30,6 @@ class Theme { ? \App::$config['system']['theme'] : ''); self::$session_theme = ((isset($_SESSION) && x($_SESSION, 'theme')) ? $_SESSION['theme'] : self::$system_theme); - self::$system_mobile_theme = ((isset(\App::$config['system']['mobile_theme'])) - ? \App::$config['system']['mobile_theme'] : ''); - self::$session_mobile_theme = ((isset($_SESSION) && x($_SESSION, 'mobile_theme')) - ? $_SESSION['mobile_theme'] : self::$system_mobile_theme); $page_theme = null; @@ -55,30 +49,12 @@ class Theme { if(array_key_exists('theme', \App::$layout) && \App::$layout['theme']) $page_theme = \App::$layout['theme']; - // If the viewer is on a mobile device, ensure that we're using a mobile - // theme of some kind or whatever the viewer's preference is for mobile - // viewing (if applicable) + $chosen_theme = self::$session_theme; - if(\App::$is_mobile || \App::$is_tablet) { - if(isset($_SESSION['show_mobile']) && (! $_SESSION['show_mobile'])) { - $chosen_theme = self::$session_theme; - } - else { - $chosen_theme = self::$session_mobile_theme; - - if($chosen_theme === '' || $chosen_theme === '---' ) { - // user has selected to have the mobile theme be the same as the normal one - $chosen_theme = self::$session_theme; - } - } + if($page_theme) { + $chosen_theme = $page_theme; } - else { - $chosen_theme = self::$session_theme; - if($page_theme) { - $chosen_theme = $page_theme; - } - } if(array_key_exists('theme_preview', $_GET)) $chosen_theme = $_GET['theme_preview']; diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index c21b68971..f1c95802b 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -264,7 +264,10 @@ class Browser extends DAV\Browser\Plugin { $this->server->emit('onHTMLActionsPanel', array($parent, &$output, $path)); } - + $deftiles = (($is_owner) ? 0 : 1); + $tiles = ((array_key_exists('cloud_tiles',$_SESSION)) ? intval($_SESSION['cloud_tiles']) : $deftiles); + $_SESSION['cloud_tiles'] = $tiles; + $html .= replace_macros(get_markup_template('cloud.tpl'), array( '$header' => t('Files') . ": " . $this->escapeHTML($path) . "/", '$total' => t('Total'), diff --git a/Zotlabs/Thumbs/Epubthumb.php b/Zotlabs/Thumbs/Epubthumb.php index 4213b5267..22f1a5e8f 100644 --- a/Zotlabs/Thumbs/Epubthumb.php +++ b/Zotlabs/Thumbs/Epubthumb.php @@ -2,36 +2,54 @@ namespace Zotlabs\Thumbs; -require_once('library/epub-meta/epub.php'); +require_once 'library/epub-meta/epub.php'; +/** + * @brief Thumbnail creation for epub files. + * + */ class Epubthumb { + /** + * @brief Match for application/epub+zip. + * + * @param string $type MimeType + * @return boolean + */ function Match($type) { return(($type === 'application/epub+zip') ? true : false ); } - function Thumb($attach,$preview_style,$height = 300, $width = 300) { + /** + * @brief + * + * @param array $attach + * @param number $preview_style unused + * @param number $height (optional) default 300 + * @param number $width (optional) default 300 + */ + function Thumb($attach, $preview_style, $height = 300, $width = 300) { $photo = false; - $ep = new \Epub(dbunescbin($attach['content'])); + $ep = new \EPub(dbunescbin($attach['content'])); $data = $ep->Cover(); if($data['found']) { $photo = $data['data']; } - if($photo) { + if($photo) { $image = imagecreatefromstring($photo); - $dest = imagecreatetruecolor( $width, $height ); - $srcwidth = imagesx($image); - $srcheight = imagesy($image); + $dest = imagecreatetruecolor($width, $height); + $srcwidth = imagesx($image); + $srcheight = imagesy($image); - imagealphablending($dest, false); + imagealphablending($dest, false); imagesavealpha($dest, true); - imagecopyresampled($dest, $image, 0, 0, 0, 0, $width, $height, $srcwidth, $srcheight); - imagedestroy($image); - imagejpeg($dest,dbunescbin($attach['content']) . '.thumb'); + imagecopyresampled($dest, $image, 0, 0, 0, 0, $width, $height, $srcwidth, $srcheight); + imagedestroy($image); + imagejpeg($dest, dbunescbin($attach['content']) . '.thumb'); } } } diff --git a/Zotlabs/Thumbs/Video.php b/Zotlabs/Thumbs/Video.php index 05127355e..ff4d10a36 100644 --- a/Zotlabs/Thumbs/Video.php +++ b/Zotlabs/Thumbs/Video.php @@ -49,6 +49,7 @@ class Video { $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmpfile . '[0]') . ' -thumbnail ' . $width . 'x' . $height . ' ' . escapeshellarg(PROJECT_BASE . '/' . $outfile); // logger('imagick thumbnail command: ' . $cmd); + /** @scrutinizer ignore-unhandled */ @exec($cmd); if(! file_exists($outfile)) { 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 @@ +<?php + +namespace Zotlabs\Update; + +class _1000 { +function run() { + $r = q("ALTER TABLE `channel` ADD `channel_a_delegate` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '0', ADD INDEX ( `channel_a_delegate` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1001.php b/Zotlabs/Update/_1001.php new file mode 100644 index 000000000..9acc96373 --- /dev/null +++ b/Zotlabs/Update/_1001.php @@ -0,0 +1,27 @@ +<?php + +namespace Zotlabs\Update; + +class _1001 { +function run() { + $r = q("CREATE TABLE if not exists `verify` ( + `id` INT(10) UNSIGNED NOT NULL , + `channel` INT(10) UNSIGNED NOT NULL DEFAULT '0', + `type` CHAR( 32 ) NOT NULL DEFAULT '', + `token` CHAR( 255 ) NOT NULL DEFAULT '', + `meta` CHAR( 255 ) NOT NULL DEFAULT '', + `created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', + PRIMARY KEY ( `id` ) + ) ENGINE = MYISAM DEFAULT CHARSET=utf8"); + + $r2 = q("alter table `verify` add index (`channel`), add index (`type`), add index (`token`), + add index (`meta`), add index (`created`)"); + + if($r && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1002.php b/Zotlabs/Update/_1002.php new file mode 100644 index 000000000..1f42449c6 --- /dev/null +++ b/Zotlabs/Update/_1002.php @@ -0,0 +1,20 @@ +<?php + +namespace Zotlabs\Update; + +class _1002 { +function run() { + $r = q("ALTER TABLE `event` CHANGE `account` `aid` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r2 = q("alter table `event` drop index `account`, add index (`aid`)"); + + q("drop table contact"); + q("drop table deliverq"); + + if($r && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1003.php b/Zotlabs/Update/_1003.php new file mode 100644 index 000000000..18d99f985 --- /dev/null +++ b/Zotlabs/Update/_1003.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1003 { +function run() { + $r = q("ALTER TABLE `xchan` ADD `xchan_flags` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `xchan_network` , +ADD INDEX ( `xchan_flags` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1004.php b/Zotlabs/Update/_1004.php new file mode 100644 index 000000000..a86f5d824 --- /dev/null +++ b/Zotlabs/Update/_1004.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1004 { +function run() { + $r = q("CREATE TABLE if not exists `site` ( +`site_url` CHAR( 255 ) NOT NULL , +`site_flags` INT NOT NULL DEFAULT '0', +`site_update` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', +`site_directory` CHAR( 255 ) NOT NULL DEFAULT '', +PRIMARY KEY ( `site_url` ) +) ENGINE = MYISAM DEFAULT CHARSET=utf8"); + + $r2 = q("alter table site add index (site_flags), add index (site_update), add index (site_directory) "); + + if($r && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1005.php b/Zotlabs/Update/_1005.php new file mode 100644 index 000000000..ee8621a8d --- /dev/null +++ b/Zotlabs/Update/_1005.php @@ -0,0 +1,13 @@ +<?php + +namespace Zotlabs\Update; + +class _1005 { +function run() { + q("drop table guid"); + q("drop table `notify-threads`"); + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1006.php b/Zotlabs/Update/_1006.php new file mode 100644 index 000000000..43a2bb951 --- /dev/null +++ b/Zotlabs/Update/_1006.php @@ -0,0 +1,45 @@ +<?php + +namespace Zotlabs\Update; + +class _1006 { +function run() { + + $r = q("CREATE TABLE IF NOT EXISTS `xprof` ( + `xprof_hash` char(255) NOT NULL, + `xprof_desc` char(255) NOT NULL DEFAULT '', + `xprof_dob` char(12) NOT NULL DEFAULT '', + `xprof_gender` char(255) NOT NULL DEFAULT '', + `xprof_marital` char(255) NOT NULL DEFAULT '', + `xprof_sexual` char(255) NOT NULL DEFAULT '', + `xprof_locale` char(255) NOT NULL DEFAULT '', + `xprof_region` char(255) NOT NULL DEFAULT '', + `xprof_postcode` char(32) NOT NULL DEFAULT '', + `xprof_country` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`xprof_hash`), + KEY `xprof_desc` (`xprof_desc`), + KEY `xprof_dob` (`xprof_dob`), + KEY `xprof_gender` (`xprof_gender`), + KEY `xprof_marital` (`xprof_marital`), + KEY `xprof_sexual` (`xprof_sexual`), + KEY `xprof_locale` (`xprof_locale`), + KEY `xprof_region` (`xprof_region`), + KEY `xprof_postcode` (`xprof_postcode`), + KEY `xprof_country` (`xprof_country`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8"); + + $r2 = q("CREATE TABLE IF NOT EXISTS `xtag` ( + `xtag_hash` char(255) NOT NULL, + `xtag_term` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`xtag_hash`), + KEY `xtag_term` (`xtag_term`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8"); + + if($r && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1007.php b/Zotlabs/Update/_1007.php new file mode 100644 index 000000000..eb52c5bc5 --- /dev/null +++ b/Zotlabs/Update/_1007.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1007 { +function run() { + $r = q("ALTER TABLE `channel` ADD `channel_r_storage` INT UNSIGNED NOT NULL DEFAULT '128', ADD `channel_w_storage` INT UNSIGNED NOT NULL DEFAULT '128', add index ( channel_r_storage ), add index ( channel_w_storage )"); + + if($r && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1008.php b/Zotlabs/Update/_1008.php new file mode 100644 index 000000000..d5db24bc0 --- /dev/null +++ b/Zotlabs/Update/_1008.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1008 { +function run() { + $r = q("alter table profile drop prv_keywords, CHANGE `pub_keywords` `keywords` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, drop index pub_keywords"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1009.php b/Zotlabs/Update/_1009.php new file mode 100644 index 000000000..afb0d5e96 --- /dev/null +++ b/Zotlabs/Update/_1009.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1009 { +function run() { + $r = q("ALTER TABLE `xprof` ADD `xprof_keywords` TEXT NOT NULL"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1010.php b/Zotlabs/Update/_1010.php new file mode 100644 index 000000000..92405cce4 --- /dev/null +++ b/Zotlabs/Update/_1010.php @@ -0,0 +1,18 @@ +<?php + +namespace Zotlabs\Update; + +class _1010 { +function run() { + $r = q("ALTER TABLE `abook` ADD `abook_dob` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `abook_connnected` , +ADD INDEX ( `abook_dob` )"); + + $r2 = q("ALTER TABLE `profile` ADD `dob_tz` CHAR( 255 ) NOT NULL DEFAULT 'UTC' AFTER `dob`"); + + if($r && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1011.php b/Zotlabs/Update/_1011.php new file mode 100644 index 000000000..b6841a9fe --- /dev/null +++ b/Zotlabs/Update/_1011.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1011 { +function run() { + $r = q("ALTER TABLE `item` ADD `expires` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `edited` , +ADD INDEX ( `expires` )"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1012.php b/Zotlabs/Update/_1012.php new file mode 100644 index 000000000..3ae5caf65 --- /dev/null +++ b/Zotlabs/Update/_1012.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1012 { +function run() { + $r = q("ALTER TABLE `xchan` ADD `xchan_connurl` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `xchan_url` , +ADD INDEX ( `xchan_connurl` )"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1013.php b/Zotlabs/Update/_1013.php new file mode 100644 index 000000000..68fc9071d --- /dev/null +++ b/Zotlabs/Update/_1013.php @@ -0,0 +1,21 @@ +<?php + +namespace Zotlabs\Update; + +class _1013 { +function run() { + $r = q("CREATE TABLE if not exists `xlink` ( +`xlink_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , +`xlink_xchan` CHAR( 255 ) NOT NULL DEFAULT '', +`xlink_link` CHAR( 255 ) NOT NULL DEFAULT '', +`xlink_updated` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' +) ENGINE = MYISAM DEFAULT CHARSET=utf8"); + + $r2 = q("alter table xlink add index ( xlink_xchan ), add index ( xlink_link ), add index ( xlink_updated ) "); + if($r && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1014.php b/Zotlabs/Update/_1014.php new file mode 100644 index 000000000..e9b3a89e0 --- /dev/null +++ b/Zotlabs/Update/_1014.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1014 { +function run() { + $r = q("ALTER TABLE `verify` CHANGE `id` `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1015.php b/Zotlabs/Update/_1015.php new file mode 100644 index 000000000..d9d2d2f27 --- /dev/null +++ b/Zotlabs/Update/_1015.php @@ -0,0 +1,19 @@ +<?php + +namespace Zotlabs\Update; + +class _1015 { +function run() { + $r = q("ALTER TABLE `channel` ADD `channel_r_pages` INT UNSIGNED NOT NULL DEFAULT '128', +ADD `channel_w_pages` INT UNSIGNED NOT NULL DEFAULT '128'"); + + $r2 = q("ALTER TABLE `channel` ADD INDEX ( `channel_r_pages` ) , ADD INDEX ( `channel_w_pages` ) "); + + if($r && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1016.php b/Zotlabs/Update/_1016.php new file mode 100644 index 000000000..93f71a474 --- /dev/null +++ b/Zotlabs/Update/_1016.php @@ -0,0 +1,39 @@ +<?php + +namespace Zotlabs\Update; + +class _1016 { +function run() { + + $r = q("CREATE TABLE IF NOT EXISTS `menu` ( + `menu_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `menu_channel_id` int(10) unsigned NOT NULL DEFAULT '0', + `menu_desc` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`menu_id`), + KEY `menu_channel_id` (`menu_channel_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + $r2 = q("CREATE TABLE IF NOT EXISTS `menu_item` ( + `mitem_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `mitem_link` char(255) NOT NULL DEFAULT '', + `mitem_desc` char(255) NOT NULL DEFAULT '', + `allow_cid` mediumtext NOT NULL, + `allow_gid` mediumtext NOT NULL, + `deny_cid` mediumtext NOT NULL, + `deny_gid` mediumtext NOT NULL, + `mitem_channel_id` int(10) unsigned NOT NULL, + `mitem_menu_id` int(10) unsigned NOT NULL DEFAULT '0', + `mitem_order` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`mitem_id`), + KEY `mitem_channel_id` (`mitem_channel_id`), + KEY `mitem_menu_id` (`mitem_menu_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + + if($r && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1017.php b/Zotlabs/Update/_1017.php new file mode 100644 index 000000000..429eda67b --- /dev/null +++ b/Zotlabs/Update/_1017.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1017 { +function run() { + $r = q("ALTER TABLE `event` CHANGE `cid` `event_xchan` CHAR( 255 ) NOT NULL DEFAULT '', ADD INDEX ( `event_xchan` ), drop index cid "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1018.php b/Zotlabs/Update/_1018.php new file mode 100644 index 000000000..546ebffca --- /dev/null +++ b/Zotlabs/Update/_1018.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1018 { +function run() { + $r = q("ALTER TABLE `event` ADD `event_hash` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `event_xchan` , +ADD INDEX ( `event_hash` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1019.php b/Zotlabs/Update/_1019.php new file mode 100644 index 000000000..a7103c98c --- /dev/null +++ b/Zotlabs/Update/_1019.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1019 { +function run() { + $r = q("ALTER TABLE `event` DROP `message_id` "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1020.php b/Zotlabs/Update/_1020.php new file mode 100644 index 000000000..c898f31c2 --- /dev/null +++ b/Zotlabs/Update/_1020.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1020 { +function run() { + $r = q("alter table photo drop `contact-id`, drop guid, drop index `resource-id`, add index ( `resource_id` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1021.php b/Zotlabs/Update/_1021.php new file mode 100644 index 000000000..72203fadb --- /dev/null +++ b/Zotlabs/Update/_1021.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1021 { +function run() { + + $r = q("ALTER TABLE `abook` CHANGE `abook_connnected` `abook_connected` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', + drop index `abook_connnected`, add index ( `abook_connected` ) "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1022.php b/Zotlabs/Update/_1022.php new file mode 100644 index 000000000..7e13250c4 --- /dev/null +++ b/Zotlabs/Update/_1022.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1022 { +function run() { + $r = q("alter table attach add index ( filename ), add index ( filetype ), add index ( filesize ), add index ( created ), add index ( edited ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1023.php b/Zotlabs/Update/_1023.php new file mode 100644 index 000000000..0a8dd2f00 --- /dev/null +++ b/Zotlabs/Update/_1023.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1023 { +function run() { + $r = q("ALTER TABLE `item` ADD `revision` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `lang` , add index ( revision ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1024.php b/Zotlabs/Update/_1024.php new file mode 100644 index 000000000..004d8967a --- /dev/null +++ b/Zotlabs/Update/_1024.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1024 { +function run() { + $r = q("ALTER TABLE `attach` ADD `revision` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `filesize` , +ADD INDEX ( `revision` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1025.php b/Zotlabs/Update/_1025.php new file mode 100644 index 000000000..d498233b3 --- /dev/null +++ b/Zotlabs/Update/_1025.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1025 { +function run() { + $r = q("ALTER TABLE `attach` ADD `folder` CHAR( 64 ) NOT NULL DEFAULT '' AFTER `revision` , +ADD `flags` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `folder` , add index ( folder ), add index ( flags )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1026.php b/Zotlabs/Update/_1026.php new file mode 100644 index 000000000..d57fdec37 --- /dev/null +++ b/Zotlabs/Update/_1026.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1026 { +function run() { + $r = q("ALTER TABLE `item` ADD `mimetype` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `author_xchan` , +ADD INDEX ( `mimetype` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1027.php b/Zotlabs/Update/_1027.php new file mode 100644 index 000000000..04d09d202 --- /dev/null +++ b/Zotlabs/Update/_1027.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1027 { +function run() { + $r = q("ALTER TABLE `abook` ADD `abook_rating` INT NOT NULL DEFAULT '0' AFTER `abook_closeness` , +ADD INDEX ( `abook_rating` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1028.php b/Zotlabs/Update/_1028.php new file mode 100644 index 000000000..a58784a01 --- /dev/null +++ b/Zotlabs/Update/_1028.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1028 { +function run() { + $r = q("ALTER TABLE `xlink` ADD `xlink_rating` INT NOT NULL DEFAULT '0' AFTER `xlink_link` , +ADD INDEX ( `xlink_rating` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1029.php b/Zotlabs/Update/_1029.php new file mode 100644 index 000000000..7072647cb --- /dev/null +++ b/Zotlabs/Update/_1029.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1029 { +function run() { + $r = q("ALTER TABLE `channel` ADD `channel_deleted` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `channel_pageflags` , +ADD INDEX ( `channel_deleted` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1030.php b/Zotlabs/Update/_1030.php new file mode 100644 index 000000000..7aebde49e --- /dev/null +++ b/Zotlabs/Update/_1030.php @@ -0,0 +1,29 @@ +<?php + +namespace Zotlabs\Update; + +class _1030 { +function run() { + $r = q("CREATE TABLE IF NOT EXISTS `issue` ( +`issue_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , +`issue_created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', +`issue_updated` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', +`issue_assigned` CHAR( 255 ) NOT NULL , +`issue_priority` INT NOT NULL , +`issue_status` INT NOT NULL , +`issue_component` CHAR( 255 ) NOT NULL, +KEY `issue_created` (`issue_created`), +KEY `issue_updated` (`issue_updated`), +KEY `issue_assigned` (`issue_assigned`), +KEY `issue_priority` (`issue_priority`), +KEY `issue_status` (`issue_status`), +KEY `issue_component` (`issue_component`) +) ENGINE = MYISAM DEFAULT CHARSET=utf8"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1031.php b/Zotlabs/Update/_1031.php new file mode 100644 index 000000000..4463c9e04 --- /dev/null +++ b/Zotlabs/Update/_1031.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1031 { +function run() { + $r = q("ALTER TABLE `account` ADD `account_external` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `account_email` , +ADD INDEX ( `account_external` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1032.php b/Zotlabs/Update/_1032.php new file mode 100644 index 000000000..a9fbeca9e --- /dev/null +++ b/Zotlabs/Update/_1032.php @@ -0,0 +1,21 @@ +<?php + +namespace Zotlabs\Update; + +class _1032 { +function run() { + $r = q("CREATE TABLE if not exists `xign` ( +`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , +`uid` INT NOT NULL DEFAULT '0', +`xchan` CHAR( 255 ) NOT NULL DEFAULT '', +KEY `uid` (`uid`), +KEY `xchan` (`xchan`) +) ENGINE = MYISAM DEFAULT CHARSET = utf8"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1033.php b/Zotlabs/Update/_1033.php new file mode 100644 index 000000000..a201e1d1f --- /dev/null +++ b/Zotlabs/Update/_1033.php @@ -0,0 +1,29 @@ +<?php + +namespace Zotlabs\Update; + +class _1033 { +function run() { + $r = q("CREATE TABLE if not exists `shares` ( +`share_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , +`share_type` INT NOT NULL DEFAULT '0', +`share_target` INT UNSIGNED NOT NULL DEFAULT '0', +`share_xchan` CHAR( 255 ) NOT NULL DEFAULT '', +KEY `share_type` (`share_type`), +KEY `share_target` (`share_target`), +KEY `share_xchan` (`share_xchan`) +) ENGINE = MYISAM DEFAULT CHARSET = utf8"); + + // if these fail don't bother reporting it + + q("drop table gcign"); + q("drop table gcontact"); + q("drop table glink"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1034.php b/Zotlabs/Update/_1034.php new file mode 100644 index 000000000..646182cc0 --- /dev/null +++ b/Zotlabs/Update/_1034.php @@ -0,0 +1,20 @@ +<?php + +namespace Zotlabs\Update; + +class _1034 { +function run() { + $r = q("CREATE TABLE if not exists `updates` ( +`ud_hash` CHAR( 128 ) NOT NULL , +`ud_date` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', +PRIMARY KEY ( `ud_hash` ), +KEY `ud_date` ( `ud_date` ) +) ENGINE = MYISAM DEFAULT CHARSET = utf8"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1035.php b/Zotlabs/Update/_1035.php new file mode 100644 index 000000000..44e95189d --- /dev/null +++ b/Zotlabs/Update/_1035.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1035 { +function run() { + $r = q("CREATE TABLE if not exists `xconfig` ( +`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , +`xchan` CHAR( 255 ) NOT NULL , +`cat` CHAR( 255 ) NOT NULL , +`k` CHAR( 255 ) NOT NULL , +`v` MEDIUMTEXT NOT NULL, +KEY `xchan` ( `xchan` ), +KEY `cat` ( `cat` ), +KEY `k` ( `k` ) +) ENGINE = MYISAM DEFAULT CHARSET = utf8"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1036.php b/Zotlabs/Update/_1036.php new file mode 100644 index 000000000..700a82e12 --- /dev/null +++ b/Zotlabs/Update/_1036.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1036 { +function run() { + $r = q("ALTER TABLE `profile` ADD `channels` TEXT NOT NULL AFTER `contact` "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1037.php b/Zotlabs/Update/_1037.php new file mode 100644 index 000000000..a1ad20aa8 --- /dev/null +++ b/Zotlabs/Update/_1037.php @@ -0,0 +1,30 @@ +<?php + +namespace Zotlabs\Update; + +class _1037 { +function run() { + $r1 = q("ALTER TABLE `item` CHANGE `uri` `mid` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '', +CHANGE `parent_uri` `parent_mid` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '', + DROP INDEX `uri` , +ADD INDEX `mid` ( `mid` ), +DROP INDEX `parent_uri` , +ADD INDEX `parent_mid` ( `parent_mid` ), + DROP INDEX `uid_uri` , +ADD INDEX `uid_mid` ( `mid` , `uid` ) "); + + $r2 = q("ALTER TABLE `mail` CHANGE `uri` `mid` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , +CHANGE `parent_uri` `parent_mid` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , +DROP INDEX `uri` , +ADD INDEX `mid` ( `mid` ), + DROP INDEX `parent_uri` , +ADD INDEX `parent_mid` ( `parent_mid` ) "); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1038.php b/Zotlabs/Update/_1038.php new file mode 100644 index 000000000..b4a86f41e --- /dev/null +++ b/Zotlabs/Update/_1038.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1038 { +function run() { + $r = q("ALTER TABLE `manage` CHANGE `mid` `xchan` CHAR( 255 ) NOT NULL DEFAULT '', drop index `mid`, ADD INDEX ( `xchan` )"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1039.php b/Zotlabs/Update/_1039.php new file mode 100644 index 000000000..9214cdc4a --- /dev/null +++ b/Zotlabs/Update/_1039.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1039 { +function run() { + $r = q("ALTER TABLE `channel` CHANGE `channel_default_gid` `channel_default_group` CHAR( 255 ) NOT NULL DEFAULT ''"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1040.php b/Zotlabs/Update/_1040.php new file mode 100644 index 000000000..77dc75a48 --- /dev/null +++ b/Zotlabs/Update/_1040.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1040 { +function run() { + $r1 = q("ALTER TABLE `session` CHANGE `expire` `expire` BIGINT UNSIGNED NOT NULL "); + $r2 = q("ALTER TABLE `tokens` CHANGE `expires` `expires` BIGINT UNSIGNED NOT NULL "); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1041.php b/Zotlabs/Update/_1041.php new file mode 100644 index 000000000..4ed436e61 --- /dev/null +++ b/Zotlabs/Update/_1041.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1041 { +function run() { + $r = q("ALTER TABLE `outq` ADD `outq_driver` CHAR( 32 ) NOT NULL DEFAULT '' AFTER `outq_channel` "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1042.php b/Zotlabs/Update/_1042.php new file mode 100644 index 000000000..56298b6a3 --- /dev/null +++ b/Zotlabs/Update/_1042.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1042 { +function run() { + $r = q("ALTER TABLE `hubloc` ADD `hubloc_updated` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', +ADD `hubloc_connected` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD INDEX ( `hubloc_updated` ), ADD INDEX ( `hubloc_connected` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1043.php b/Zotlabs/Update/_1043.php new file mode 100644 index 000000000..b28203731 --- /dev/null +++ b/Zotlabs/Update/_1043.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1043 { +function run() { + $r = q("ALTER TABLE `item` ADD `comment_policy` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `coord` , +ADD INDEX ( `comment_policy` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1044.php b/Zotlabs/Update/_1044.php new file mode 100644 index 000000000..fc7e5438f --- /dev/null +++ b/Zotlabs/Update/_1044.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1044 { +function run() { + $r = q("ALTER TABLE `term` ADD `imgurl` CHAR( 255 ) NOT NULL , +ADD INDEX ( `imgurl` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1045.php b/Zotlabs/Update/_1045.php new file mode 100644 index 000000000..73570c316 --- /dev/null +++ b/Zotlabs/Update/_1045.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1045 { +function run() { + $r = q("ALTER TABLE `site` ADD `site_register` INT NOT NULL DEFAULT '0', +ADD INDEX ( `site_register` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1046.php b/Zotlabs/Update/_1046.php new file mode 100644 index 000000000..219d53e17 --- /dev/null +++ b/Zotlabs/Update/_1046.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1046 { +function run() { + $r = q("ALTER TABLE `term` ADD `term_hash` CHAR( 255 ) NOT NULL DEFAULT '', +ADD INDEX ( `term_hash` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1047.php b/Zotlabs/Update/_1047.php new file mode 100644 index 000000000..930c13eb8 --- /dev/null +++ b/Zotlabs/Update/_1047.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1047 { +function run() { + $r = q("ALTER TABLE `xprof` ADD `xprof_age` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `xprof_hash` , +ADD INDEX ( `xprof_age` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1048.php b/Zotlabs/Update/_1048.php new file mode 100644 index 000000000..20c8931d7 --- /dev/null +++ b/Zotlabs/Update/_1048.php @@ -0,0 +1,29 @@ +<?php + +namespace Zotlabs\Update; + +class _1048 { +function run() { + $r = q("CREATE TABLE IF NOT EXISTS `obj` ( + `obj_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `obj_page` char(64) NOT NULL DEFAULT '', + `obj_verb` char(255) NOT NULL DEFAULT '', + `obj_type` int(10) unsigned NOT NULL DEFAULT '0', + `obj_obj` char(255) NOT NULL DEFAULT '', + `obj_channel` int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`obj_id`), + KEY `obj_verb` (`obj_verb`), + KEY `obj_page` (`obj_page`), + KEY `obj_type` (`obj_type`), + KEY `obj_channel` (`obj_channel`), + KEY `obj_obj` (`obj_obj`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1049.php b/Zotlabs/Update/_1049.php new file mode 100644 index 000000000..622847727 --- /dev/null +++ b/Zotlabs/Update/_1049.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1049 { +function run() { + $r = q("ALTER TABLE `term` ADD `parent_hash` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `term_hash` , ADD INDEX ( `parent_hash` ) "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1050.php b/Zotlabs/Update/_1050.php new file mode 100644 index 000000000..1939d346f --- /dev/null +++ b/Zotlabs/Update/_1050.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1050 { +function run() { + $r = q("ALTER TABLE `xtag` DROP PRIMARY KEY , ADD `xtag_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST , ADD INDEX ( `xtag_hash` ) "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1051.php b/Zotlabs/Update/_1051.php new file mode 100644 index 000000000..041b51f21 --- /dev/null +++ b/Zotlabs/Update/_1051.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1051 { +function run() { + $r = q("ALTER TABLE `photo` ADD `photo_flags` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `profile` , ADD INDEX ( `photo_flags` ) "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1052.php b/Zotlabs/Update/_1052.php new file mode 100644 index 000000000..05addf21f --- /dev/null +++ b/Zotlabs/Update/_1052.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1052 { +function run() { + $r = q("ALTER TABLE `channel` ADD UNIQUE (`channel_address`) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1053.php b/Zotlabs/Update/_1053.php new file mode 100644 index 000000000..4752dca62 --- /dev/null +++ b/Zotlabs/Update/_1053.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1053 { +function run() { + $r = q("ALTER TABLE `profile` ADD `chandesc` TEXT NOT NULL DEFAULT '' AFTER `pdesc` "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1054.php b/Zotlabs/Update/_1054.php new file mode 100644 index 000000000..f4fc2eb5b --- /dev/null +++ b/Zotlabs/Update/_1054.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1054 { +function run() { + $r = q("ALTER TABLE `item` CHANGE `title` `title` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1055.php b/Zotlabs/Update/_1055.php new file mode 100644 index 000000000..6b3a4c1d9 --- /dev/null +++ b/Zotlabs/Update/_1055.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1055 { +function run() { + $r = q("ALTER TABLE `mail` CHANGE `title` `title` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1056.php b/Zotlabs/Update/_1056.php new file mode 100644 index 000000000..6c0510f88 --- /dev/null +++ b/Zotlabs/Update/_1056.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1056 { +function run() { + $r = q("ALTER TABLE `xchan` ADD `xchan_instance_url` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `xchan_network` , +ADD INDEX ( `xchan_instance_url` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1057.php b/Zotlabs/Update/_1057.php new file mode 100644 index 000000000..081e82d1f --- /dev/null +++ b/Zotlabs/Update/_1057.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1057 { +function run() { + $r = q("drop table intro"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1058.php b/Zotlabs/Update/_1058.php new file mode 100644 index 000000000..8e3ffdd6a --- /dev/null +++ b/Zotlabs/Update/_1058.php @@ -0,0 +1,19 @@ +<?php + +namespace Zotlabs\Update; + +class _1058 { +function run() { + $r1 = q("ALTER TABLE `menu` ADD `menu_name` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `menu_channel_id` , +ADD INDEX ( `menu_name` ) "); + + $r2 = q("ALTER TABLE `menu_item` ADD `mitem_flags` INT NOT NULL DEFAULT '0' AFTER `mitem_desc` , +ADD INDEX ( `mitem_flags` ) "); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1059.php b/Zotlabs/Update/_1059.php new file mode 100644 index 000000000..e035efb2c --- /dev/null +++ b/Zotlabs/Update/_1059.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1059 { +function run() { + $r = q("ALTER TABLE `mail` ADD `attach` MEDIUMTEXT NOT NULL DEFAULT '' AFTER `body` "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1060.php b/Zotlabs/Update/_1060.php new file mode 100644 index 000000000..5182b803a --- /dev/null +++ b/Zotlabs/Update/_1060.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1060 { +function run() { + + $r = q("CREATE TABLE IF NOT EXISTS `vote` ( + `vote_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `vote_poll` int(11) NOT NULL DEFAULT '0', + `vote_element` int(11) NOT NULL DEFAULT '0', + `vote_result` text NOT NULL, + `vote_xchan` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`vote_id`), + UNIQUE KEY `vote_vote` (`vote_poll`,`vote_element`,`vote_xchan`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1061.php b/Zotlabs/Update/_1061.php new file mode 100644 index 000000000..e7af5bcb1 --- /dev/null +++ b/Zotlabs/Update/_1061.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1061 { +function run() { + $r = q("ALTER TABLE `vote` ADD INDEX ( `vote_poll` ), ADD INDEX ( `vote_element` ) "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1062.php b/Zotlabs/Update/_1062.php new file mode 100644 index 000000000..39aa80e8a --- /dev/null +++ b/Zotlabs/Update/_1062.php @@ -0,0 +1,34 @@ +<?php + +namespace Zotlabs\Update; + +class _1062 { +function run() { + $r1 = q("CREATE TABLE IF NOT EXISTS `poll` ( +`poll_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , +`poll_channel` INT UNSIGNED NOT NULL DEFAULT '0', +`poll_desc` TEXT NOT NULL DEFAULT '', +`poll_flags` INT NOT NULL DEFAULT '0', +`poll_votes` INT NOT NULL DEFAULT '0', +KEY `poll_channel` (`poll_channel`), +KEY `poll_flags` (`poll_flags`), +KEY `poll_votes` (`poll_votes`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + $r2 = q("CREATE TABLE IF NOT EXISTS `poll_elm` ( +`pelm_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , +`pelm_poll` INT UNSIGNED NOT NULL DEFAULT '0', +`pelm_desc` TEXT NOT NULL DEFAULT '', +`pelm_flags` INT NOT NULL DEFAULT '0', +`pelm_result` FLOAT NOT NULL DEFAULT '0', +KEY `pelm_poll` (`pelm_poll`), +KEY `pelm_result` (`pelm_result`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1063.php b/Zotlabs/Update/_1063.php new file mode 100644 index 000000000..04d523df6 --- /dev/null +++ b/Zotlabs/Update/_1063.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1063 { +function run() { + $r = q("ALTER TABLE `xchan` ADD `xchan_follow` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `xchan_connurl` , +ADD `xchan_connpage` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `xchan_follow` , +ADD INDEX ( `xchan_follow` ), ADD INDEX ( `xchan_connpage`) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1064.php b/Zotlabs/Update/_1064.php new file mode 100644 index 000000000..295dd96c5 --- /dev/null +++ b/Zotlabs/Update/_1064.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1064 { +function run() { + $r = q("ALTER TABLE `updates` ADD `ud_guid` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `ud_hash` , +ADD INDEX ( `ud_guid` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1065.php b/Zotlabs/Update/_1065.php new file mode 100644 index 000000000..0a3e9082e --- /dev/null +++ b/Zotlabs/Update/_1065.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1065 { +function run() { + $r = q("ALTER TABLE `item` DROP `wall`, ADD `layout_mid` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `target` , +ADD INDEX ( `layout_mid` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1066.php b/Zotlabs/Update/_1066.php new file mode 100644 index 000000000..e7d3fbbb4 --- /dev/null +++ b/Zotlabs/Update/_1066.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1066 { +function run() { + $r = q("ALTER TABLE `site` ADD `site_access` INT NOT NULL DEFAULT '0' AFTER `site_url` , +ADD INDEX ( `site_access` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1067.php b/Zotlabs/Update/_1067.php new file mode 100644 index 000000000..94782a15e --- /dev/null +++ b/Zotlabs/Update/_1067.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1067 { +function run() { + $r = q("ALTER TABLE `updates` DROP PRIMARY KEY , ADD `ud_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST, ADD INDEX ( `ud_hash` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1068.php b/Zotlabs/Update/_1068.php new file mode 100644 index 000000000..e2a70684f --- /dev/null +++ b/Zotlabs/Update/_1068.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1068 { +function run(){ + $r = q("ALTER TABLE `hubloc` ADD `hubloc_status` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `hubloc_flags` , ADD INDEX ( `hubloc_status` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1069.php b/Zotlabs/Update/_1069.php new file mode 100644 index 000000000..437c7ffef --- /dev/null +++ b/Zotlabs/Update/_1069.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1069 { +function run() { + $r = q("ALTER TABLE `site` ADD `site_sellpage` CHAR( 255 ) NOT NULL DEFAULT '', +ADD INDEX ( `site_sellpage` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1070.php b/Zotlabs/Update/_1070.php new file mode 100644 index 000000000..2ec03f752 --- /dev/null +++ b/Zotlabs/Update/_1070.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1070 { +function run() { + $r = q("ALTER TABLE `updates` ADD `ud_flags` INT NOT NULL DEFAULT '0', +ADD INDEX ( `ud_flags` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1071.php b/Zotlabs/Update/_1071.php new file mode 100644 index 000000000..f4e627e7f --- /dev/null +++ b/Zotlabs/Update/_1071.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1071 { +function run() { + $r = q("ALTER TABLE `updates` ADD `ud_addr` CHAR( 255 ) NOT NULL DEFAULT '', +ADD INDEX ( `ud_addr` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1072.php b/Zotlabs/Update/_1072.php new file mode 100644 index 000000000..191893547 --- /dev/null +++ b/Zotlabs/Update/_1072.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1072 { +function run() { + $r = q("ALTER TABLE `xtag` ADD `xtag_flags` INT NOT NULL DEFAULT '0', +ADD INDEX ( `xtag_flags` ) "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1073.php b/Zotlabs/Update/_1073.php new file mode 100644 index 000000000..f238d7a36 --- /dev/null +++ b/Zotlabs/Update/_1073.php @@ -0,0 +1,23 @@ +<?php + +namespace Zotlabs\Update; + +class _1073 { +function run() { + $r1 = q("CREATE TABLE IF NOT EXISTS `source` ( +`src_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , +`src_channel_id` INT UNSIGNED NOT NULL DEFAULT '0', +`src_channel_xchan` CHAR( 255 ) NOT NULL DEFAULT '', +`src_xchan` CHAR( 255 ) NOT NULL DEFAULT '', +`src_patt` MEDIUMTEXT NOT NULL DEFAULT '' +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + $r2 = q("ALTER TABLE `source` ADD INDEX ( `src_channel_id` ), ADD INDEX ( `src_channel_xchan` ), ADD INDEX ( `src_xchan` ) "); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1074.php b/Zotlabs/Update/_1074.php new file mode 100644 index 000000000..d331b935a --- /dev/null +++ b/Zotlabs/Update/_1074.php @@ -0,0 +1,19 @@ +<?php + +namespace Zotlabs\Update; + +class _1074 { +function run() { + $r1 = q("ALTER TABLE `site` ADD `site_sync` DATETIME NOT NULL AFTER `site_update` "); + + $r2 = q("ALTER TABLE `updates` ADD `ud_last` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `ud_date` , +ADD INDEX ( `ud_last` ) "); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1075.php b/Zotlabs/Update/_1075.php new file mode 100644 index 000000000..ac7c48f71 --- /dev/null +++ b/Zotlabs/Update/_1075.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1075 { +function run() { + $r = q("ALTER TABLE `channel` ADD `channel_a_republish` INT UNSIGNED NOT NULL DEFAULT '128', +ADD INDEX ( `channel_a_republish` )"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1076.php b/Zotlabs/Update/_1076.php new file mode 100644 index 000000000..c8c631822 --- /dev/null +++ b/Zotlabs/Update/_1076.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1076 { +function run() { + $r = q("ALTER TABLE `item` CHANGE `inform` `sig` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1077.php b/Zotlabs/Update/_1077.php new file mode 100644 index 000000000..3c23affbc --- /dev/null +++ b/Zotlabs/Update/_1077.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1077 { +function run() { + $r = q("ALTER TABLE `item` ADD `source_xchan` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `author_xchan` "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1078.php b/Zotlabs/Update/_1078.php new file mode 100644 index 000000000..c832a1c2a --- /dev/null +++ b/Zotlabs/Update/_1078.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1078 { +function run() { + $r = q("ALTER TABLE `channel` ADD `channel_dirdate` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `channel_pageflags` , ADD INDEX ( `channel_dirdate` )"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1079.php b/Zotlabs/Update/_1079.php new file mode 100644 index 000000000..b10e2e7ae --- /dev/null +++ b/Zotlabs/Update/_1079.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1079 { +function run() { + $r = q("ALTER TABLE `site` ADD `site_location` CHAR( 255 ) NOT NULL DEFAULT ''"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1080.php b/Zotlabs/Update/_1080.php new file mode 100644 index 000000000..ab9c4c2f8 --- /dev/null +++ b/Zotlabs/Update/_1080.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1080 { +function run() { + $r = q("ALTER TABLE `mail` ADD `expires` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', +ADD INDEX ( `expires` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1081.php b/Zotlabs/Update/_1081.php new file mode 100644 index 000000000..521a39893 --- /dev/null +++ b/Zotlabs/Update/_1081.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1081 { +function run() { + $r = q("DROP TABLE `queue` "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1082.php b/Zotlabs/Update/_1082.php new file mode 100644 index 000000000..8ce8d20c1 --- /dev/null +++ b/Zotlabs/Update/_1082.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1082 { +function run() { + $r = q("DROP TABLE `challenge` "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1083.php b/Zotlabs/Update/_1083.php new file mode 100644 index 000000000..becb2b702 --- /dev/null +++ b/Zotlabs/Update/_1083.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1083 { +function run() { + $r = q("ALTER TABLE `notify` ADD `aid` INT NOT NULL AFTER `msg` , +ADD INDEX ( `aid` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1084.php b/Zotlabs/Update/_1084.php new file mode 100644 index 000000000..621d0346d --- /dev/null +++ b/Zotlabs/Update/_1084.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1084 { +function run() { + + + $r = q("CREATE TABLE if not exists `sys_perms` ( + `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , + `cat` CHAR( 255 ) NOT NULL , + `k` CHAR( 255 ) NOT NULL , + `v` MEDIUMTEXT NOT NULL, + `public_perm` TINYINT( 1 ) UNSIGNED NOT NULL +) ENGINE = MYISAM DEFAULT CHARSET = utf8"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1085.php b/Zotlabs/Update/_1085.php new file mode 100644 index 000000000..f50e56319 --- /dev/null +++ b/Zotlabs/Update/_1085.php @@ -0,0 +1,20 @@ +<?php + +namespace Zotlabs\Update; + +class _1085 { +function run() { + $r1 = q("ALTER TABLE `photo` CHANGE `desc` `description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL "); + + $r2 = q("RENAME TABLE `group` TO `groups`"); + + $r3 = q("ALTER TABLE `event` CHANGE `desc` `description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL "); + + if($r1 && $r2 && $r3) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1086.php b/Zotlabs/Update/_1086.php new file mode 100644 index 000000000..1b034daac --- /dev/null +++ b/Zotlabs/Update/_1086.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1086 { +function run() { + $r = q("ALTER TABLE `account` ADD `account_level` INT UNSIGNED NOT NULL DEFAULT '0', +ADD INDEX ( `account_level` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1087.php b/Zotlabs/Update/_1087.php new file mode 100644 index 000000000..839c16d91 --- /dev/null +++ b/Zotlabs/Update/_1087.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1087 { +function run() { + $r = q("ALTER TABLE `xprof` ADD `xprof_about` TEXT NOT NULL DEFAULT '', +ADD `xprof_homepage` CHAR( 255 ) NOT NULL DEFAULT '', +ADD `xprof_hometown` CHAR( 255 ) NOT NULL DEFAULT '', +ADD INDEX ( `xprof_hometown` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1088.php b/Zotlabs/Update/_1088.php new file mode 100644 index 000000000..5f478d0a1 --- /dev/null +++ b/Zotlabs/Update/_1088.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1088 { +function run() { + $r = q("ALTER TABLE `obj` ADD `allow_cid` MEDIUMTEXT NOT NULL DEFAULT '', +ADD `allow_gid` MEDIUMTEXT NOT NULL DEFAULT '', +ADD `deny_cid` MEDIUMTEXT NOT NULL DEFAULT '', +ADD `deny_gid` MEDIUMTEXT NOT NULL DEFAULT ''"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1089.php b/Zotlabs/Update/_1089.php new file mode 100644 index 000000000..0a8a1d55b --- /dev/null +++ b/Zotlabs/Update/_1089.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1089 { +function run() { + $r = q("ALTER TABLE `attach` ADD `creator` CHAR( 128 ) NOT NULL DEFAULT '' AFTER `hash` , +ADD INDEX ( `creator` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1090.php b/Zotlabs/Update/_1090.php new file mode 100644 index 000000000..efa7db7c2 --- /dev/null +++ b/Zotlabs/Update/_1090.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1090 { +function run() { + $r = q("ALTER TABLE `menu` ADD `menu_flags` INT NOT NULL DEFAULT '0', +ADD INDEX ( `menu_flags` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1091.php b/Zotlabs/Update/_1091.php new file mode 100644 index 000000000..ffb445c62 --- /dev/null +++ b/Zotlabs/Update/_1091.php @@ -0,0 +1,13 @@ +<?php + +namespace Zotlabs\Update; + +class _1091 { +function run() { + @os_mkdir('store/[data]/smarty3',STORAGE_DEFAULT_PERMISSIONS,true); + @file_put_contents('store/[data]/locks',''); + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1092.php b/Zotlabs/Update/_1092.php new file mode 100644 index 000000000..897c0c20b --- /dev/null +++ b/Zotlabs/Update/_1092.php @@ -0,0 +1,61 @@ +<?php + +namespace Zotlabs\Update; + +class _1092 { +function run() { + $r1 = q("CREATE TABLE IF NOT EXISTS `chat` ( + `chat_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `chat_room` int(10) unsigned NOT NULL DEFAULT '0', + `chat_xchan` char(255) NOT NULL DEFAULT '', + `chat_text` mediumtext NOT NULL, + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + PRIMARY KEY (`chat_id`), + KEY `chat_room` (`chat_room`), + KEY `chat_xchan` (`chat_xchan`), + KEY `created` (`created`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8"); + + $r2 = q("CREATE TABLE IF NOT EXISTS `chatpresence` ( + `cp_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `cp_room` int(10) unsigned NOT NULL DEFAULT '0', + `cp_xchan` char(255) NOT NULL DEFAULT '', + `cp_last` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `cp_status` char(255) NOT NULL, + PRIMARY KEY (`cp_id`), + KEY `cp_room` (`cp_room`), + KEY `cp_xchan` (`cp_xchan`), + KEY `cp_last` (`cp_last`), + KEY `cp_status` (`cp_status`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8"); + + $r3 = q("CREATE TABLE IF NOT EXISTS `chatroom` ( + `cr_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `cr_aid` int(10) unsigned NOT NULL DEFAULT '0', + `cr_uid` int(10) unsigned NOT NULL DEFAULT '0', + `cr_name` char(255) NOT NULL DEFAULT '', + `cr_created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `cr_edited` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `allow_cid` mediumtext NOT NULL, + `allow_gid` mediumtext NOT NULL, + `deny_cid` mediumtext NOT NULL, + `deny_gid` mediumtext NOT NULL, + PRIMARY KEY (`cr_id`), + KEY `cr_aid` (`cr_aid`), + KEY `cr_uid` (`cr_uid`), + KEY `cr_name` (`cr_name`), + KEY `cr_created` (`cr_created`), + KEY `cr_edited` (`cr_edited`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8"); + + + if($r1 && $r2 && $r3) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1093.php b/Zotlabs/Update/_1093.php new file mode 100644 index 000000000..eb692e0b7 --- /dev/null +++ b/Zotlabs/Update/_1093.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1093 { +function run() { + $r = q("ALTER TABLE `chatpresence` ADD `cp_client` CHAR( 128 ) NOT NULL DEFAULT ''"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1094.php b/Zotlabs/Update/_1094.php new file mode 100644 index 000000000..c502c7a06 --- /dev/null +++ b/Zotlabs/Update/_1094.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1094 { +function run() { + $r = q("ALTER TABLE `chatroom` ADD `cr_expire` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `cr_edited` , +ADD INDEX ( `cr_expire` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1095.php b/Zotlabs/Update/_1095.php new file mode 100644 index 000000000..0f11fda62 --- /dev/null +++ b/Zotlabs/Update/_1095.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1095 { +function run() { + $r = q("ALTER TABLE `channel` ADD `channel_a_bookmark` INT UNSIGNED NOT NULL DEFAULT '128', +ADD INDEX ( `channel_a_bookmark` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1096.php b/Zotlabs/Update/_1096.php new file mode 100644 index 000000000..67abb9ee2 --- /dev/null +++ b/Zotlabs/Update/_1096.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1096 { +function run() { + $r = q("ALTER TABLE `account` CHANGE `account_level` `account_level` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1097.php b/Zotlabs/Update/_1097.php new file mode 100644 index 000000000..bfe04cf5f --- /dev/null +++ b/Zotlabs/Update/_1097.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1097 { +function run() { + + // fix some mangled hublocs from a bug long ago + + $r = q("select hubloc_id, hubloc_addr from hubloc where hubloc_addr like '%%/%%'"); + if($r) { + foreach($r as $rr) { + q("update hubloc set hubloc_addr = '%s' where hubloc_id = %d", + dbesc(substr($rr['hubloc_addr'],0,strpos($rr['hubloc_addr'],'/'))), + intval($rr['hubloc_id']) + ); + } + } + return UPDATE_SUCCESS; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1098.php b/Zotlabs/Update/_1098.php new file mode 100644 index 000000000..e74ba640c --- /dev/null +++ b/Zotlabs/Update/_1098.php @@ -0,0 +1,25 @@ +<?php + +namespace Zotlabs\Update; + +class _1098 { +function run() { + $r = q("ALTER TABLE `channel` CHANGE `channel_r_stream` `channel_r_stream` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r2 = q("ALTER TABLE `channel` CHANGE `channel_r_profile` `channel_r_profile` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r3 = q("ALTER TABLE `channel` CHANGE `channel_r_photos` `channel_r_photos` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r4 = q("ALTER TABLE `channel` CHANGE `channel_r_abook` `channel_r_abook` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r4 = q("ALTER TABLE `channel` CHANGE `channel_w_stream` `channel_w_stream` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r5 = q("ALTER TABLE `channel` CHANGE `channel_w_wall` `channel_w_wall` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r6 = q("ALTER TABLE `channel` CHANGE `channel_w_tagwall` `channel_w_tagwall` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r7 = q("ALTER TABLE `channel` CHANGE `channel_w_comment` `channel_w_comment` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r8 = q("ALTER TABLE `channel` CHANGE `channel_w_mail` `channel_w_mail` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r9 = q("ALTER TABLE `channel` CHANGE `channel_w_photos` `channel_w_photos` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r10 = q("ALTER TABLE `channel` CHANGE `channel_w_chat` `channel_w_chat` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + $r11 = q("ALTER TABLE `channel` CHANGE `channel_a_delegate` `channel_a_delegate` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + if($r && $r2 && $r3 && $r3 && $r5 && $r6 && $r7 && $r8 && $r9 && $r9 && $r10 && $r11) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1099.php b/Zotlabs/Update/_1099.php new file mode 100644 index 000000000..a49e38c7c --- /dev/null +++ b/Zotlabs/Update/_1099.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1099 { +function run() { + $r = q("CREATE TABLE IF NOT EXISTS `xchat` ( + `xchat_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `xchat_url` char(255) NOT NULL DEFAULT '', + `xchat_desc` char(255) NOT NULL DEFAULT '', + `xchat_xchan` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`xchat_id`), + KEY `xchat_url` (`xchat_url`), + KEY `xchat_desc` (`xchat_desc`), + KEY `xchat_xchan` (`xchat_xchan`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1100.php b/Zotlabs/Update/_1100.php new file mode 100644 index 000000000..ffcd7dc1d --- /dev/null +++ b/Zotlabs/Update/_1100.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1100 { +function run() { + $r = q("ALTER TABLE `xchat` ADD `xchat_edited` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', +ADD INDEX ( `xchat_edited` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1101.php b/Zotlabs/Update/_1101.php new file mode 100644 index 000000000..709b6fa0a --- /dev/null +++ b/Zotlabs/Update/_1101.php @@ -0,0 +1,13 @@ +<?php + +namespace Zotlabs\Update; + +class _1101 { +function run() { + $r = q("update updates set ud_flags = 2 where ud_flags = (-1)"); + $r = q("update updates set ud_flags = 0 where ud_flags = 4096"); + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1102.php b/Zotlabs/Update/_1102.php new file mode 100644 index 000000000..d25979b1f --- /dev/null +++ b/Zotlabs/Update/_1102.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1102 { +function run() { + $r = q("update abook set abook_flags = (abook_flags - %d) + where ( abook_flags & %d)", + intval(ABOOK_FLAG_UNCONNECTED), + intval(ABOOK_FLAG_UNCONNECTED) + ); + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1103.php b/Zotlabs/Update/_1103.php new file mode 100644 index 000000000..3f9a9286c --- /dev/null +++ b/Zotlabs/Update/_1103.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1103 { +function run() { + $x = curl_version(); + if(stristr($x['ssl_version'],'openssl')) + set_config('system','curl_ssl_ciphers','ALL:!eNULL'); + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1104.php b/Zotlabs/Update/_1104.php new file mode 100644 index 000000000..0d299095b --- /dev/null +++ b/Zotlabs/Update/_1104.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1104 { +function run() { + $r = q("ALTER TABLE `item` ADD `route` TEXT NOT NULL DEFAULT '' AFTER `postopts` "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1105.php b/Zotlabs/Update/_1105.php new file mode 100644 index 000000000..a96600150 --- /dev/null +++ b/Zotlabs/Update/_1105.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1105 { +function run() { + $r = q("ALTER TABLE `site` ADD `site_pull` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `site_update` , +CHANGE `site_sync` `site_sync` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', ADD INDEX ( `site_pull` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1106.php b/Zotlabs/Update/_1106.php new file mode 100644 index 000000000..7e13d8993 --- /dev/null +++ b/Zotlabs/Update/_1106.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1106 { +function run() { + $r = q("ALTER TABLE `notify` CHANGE `parent` `parent` CHAR( 255 ) NOT NULL DEFAULT ''"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1107.php b/Zotlabs/Update/_1107.php new file mode 100644 index 000000000..bcac6cf19 --- /dev/null +++ b/Zotlabs/Update/_1107.php @@ -0,0 +1,34 @@ +<?php + +namespace Zotlabs\Update; + +class _1107 { +function run() { + $r = q("CREATE TABLE IF NOT EXISTS `app` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `app_id` char(64) NOT NULL DEFAULT '', + `app_sig` char(255) NOT NULL DEFAULT '', + `app_author` char(255) NOT NULL DEFAULT '', + `app_name` char(255) NOT NULL DEFAULT '', + `app_desc` text NOT NULL, + `app_url` char(255) NOT NULL DEFAULT '', + `app_photo` char(255) NOT NULL DEFAULT '', + `app_version` char(255) NOT NULL DEFAULT '', + `app_channel` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `app_id` (`app_id`), + KEY `app_name` (`app_name`), + KEY `app_url` (`app_url`), + KEY `app_photo` (`app_photo`), + KEY `app_version` (`app_version`), + KEY `app_channel` (`app_channel`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1108.php b/Zotlabs/Update/_1108.php new file mode 100644 index 000000000..d9d9b0c18 --- /dev/null +++ b/Zotlabs/Update/_1108.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1108 { +function run() { + $r = q("ALTER TABLE `app` ADD `app_addr` CHAR( 255 ) NOT NULL DEFAULT '', +ADD `app_price` CHAR( 255 ) NOT NULL DEFAULT '', +ADD `app_page` CHAR( 255 ) NOT NULL DEFAULT '', +ADD INDEX ( `app_price` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1109.php b/Zotlabs/Update/_1109.php new file mode 100644 index 000000000..6a0aed28f --- /dev/null +++ b/Zotlabs/Update/_1109.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1109 { +function run() { + $r = q("ALTER TABLE `app` CHANGE `app_id` `app_id` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + +// We ended up with an extra zero in the name for 1108, so do it over and ignore the result. + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1110.php b/Zotlabs/Update/_1110.php new file mode 100644 index 000000000..62bcbd0c8 --- /dev/null +++ b/Zotlabs/Update/_1110.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1110 { +function run() { + $r = q("ALTER TABLE `app` ADD `app_addr` CHAR( 255 ) NOT NULL DEFAULT '', +ADD `app_price` CHAR( 255 ) NOT NULL DEFAULT '', +ADD `app_page` CHAR( 255 ) NOT NULL DEFAULT '', +ADD INDEX ( `app_price` )"); + + return UPDATE_SUCCESS; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1111.php b/Zotlabs/Update/_1111.php new file mode 100644 index 000000000..a3080b465 --- /dev/null +++ b/Zotlabs/Update/_1111.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1111 { +function run() { + $r = q("ALTER TABLE `app` ADD `app_requires` CHAR( 255 ) NOT NULL DEFAULT '' "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1112.php b/Zotlabs/Update/_1112.php new file mode 100644 index 000000000..e81780519 --- /dev/null +++ b/Zotlabs/Update/_1112.php @@ -0,0 +1,29 @@ +<?php + +namespace Zotlabs\Update; + +class _1112 { +function run() { + $r = q("CREATE TABLE IF NOT EXISTS `likes` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `liker` char(128) NOT NULL DEFAULT '', + `likee` char(128) NOT NULL DEFAULT '', + `iid` int(11) NOT NULL DEFAULT '0', + `verb` char(255) NOT NULL DEFAULT '', + `target_type` char(255) NOT NULL DEFAULT '', + `target` mediumtext NOT NULL, + PRIMARY KEY (`id`), + KEY `liker` (`liker`), + KEY `likee` (`likee`), + KEY `iid` (`iid`), + KEY `verb` (`verb`), + KEY `target_type` (`target_type`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8"); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1113.php b/Zotlabs/Update/_1113.php new file mode 100644 index 000000000..0a726dcc3 --- /dev/null +++ b/Zotlabs/Update/_1113.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1113 { +function run() { + $r = q("ALTER TABLE `likes` ADD `channel_id` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `id` , +CHANGE `iid` `iid` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0', +ADD INDEX ( `channel_id` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1114.php b/Zotlabs/Update/_1114.php new file mode 100644 index 000000000..5b564d513 --- /dev/null +++ b/Zotlabs/Update/_1114.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1114 { +function run() { + $r = q("ALTER TABLE `likes` ADD `target_id` CHAR( 128 ) NOT NULL DEFAULT '' AFTER `target_type` , +ADD INDEX ( `target_id` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1115.php b/Zotlabs/Update/_1115.php new file mode 100644 index 000000000..4edf63b85 --- /dev/null +++ b/Zotlabs/Update/_1115.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1115 { +function run() { + + // Introducing email verification. Mark all existing accounts as verified or they + // won't be able to login. + + $r = q("update account set account_flags = (account_flags ^ 1) where (account_flags & 1) "); + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1116.php b/Zotlabs/Update/_1116.php new file mode 100644 index 000000000..9fa7270ea --- /dev/null +++ b/Zotlabs/Update/_1116.php @@ -0,0 +1,12 @@ +<?php + +namespace Zotlabs\Update; + +class _1116 { +function run() { + @os_mkdir('store/[data]/smarty3',STORAGE_DEFAULT_PERMISSIONS,true); + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1117.php b/Zotlabs/Update/_1117.php new file mode 100644 index 000000000..cc8edb3c9 --- /dev/null +++ b/Zotlabs/Update/_1117.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1117 { +function run() { + $r = q("ALTER TABLE `channel` CHANGE `channel_a_bookmark` `channel_w_like` INT( 10 ) UNSIGNED NOT NULL DEFAULT '128', +DROP INDEX `channel_a_bookmark` , ADD INDEX `channel_w_like` ( `channel_w_like` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1118.php b/Zotlabs/Update/_1118.php new file mode 100644 index 000000000..22cfc2357 --- /dev/null +++ b/Zotlabs/Update/_1118.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1118 { +function run() { + $r = q("ALTER TABLE `account` ADD `account_password_changed` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00', +ADD INDEX ( `account_password_changed` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1119.php b/Zotlabs/Update/_1119.php new file mode 100644 index 000000000..ccf03e45a --- /dev/null +++ b/Zotlabs/Update/_1119.php @@ -0,0 +1,35 @@ +<?php + +namespace Zotlabs\Update; + +class _1119 { +function run() { + $r1 = q("CREATE TABLE IF NOT EXISTS `profdef` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `field_name` char(255) NOT NULL DEFAULT '', + `field_type` char(16) NOT NULL DEFAULT '', + `field_desc` char(255) NOT NULL DEFAULT '', + `field_help` char(255) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `field_name` (`field_name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8"); + + $r2 = q("CREATE TABLE IF NOT EXISTS `profext` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `channel_id` int(10) unsigned NOT NULL DEFAULT '0', + `hash` char(255) NOT NULL DEFAULT '', + `k` char(255) NOT NULL DEFAULT '', + `v` mediumtext NOT NULL, + PRIMARY KEY (`id`), + KEY `channel_id` (`channel_id`), + KEY `hash` (`hash`), + KEY `k` (`k`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8"); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1120.php b/Zotlabs/Update/_1120.php new file mode 100644 index 000000000..c1f7e98d7 --- /dev/null +++ b/Zotlabs/Update/_1120.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1120 { +function run() { + $r = q("ALTER TABLE `item` ADD `public_policy` CHAR( 255 ) NOT NULL DEFAULT '' AFTER `coord` , +ADD INDEX ( `public_policy` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1121.php b/Zotlabs/Update/_1121.php new file mode 100644 index 000000000..c5ff00694 --- /dev/null +++ b/Zotlabs/Update/_1121.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1121 { +function run() { + $r = q("ALTER TABLE `site` ADD `site_realm` CHAR( 255 ) NOT NULL DEFAULT '', +ADD INDEX ( `site_realm` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1122.php b/Zotlabs/Update/_1122.php new file mode 100644 index 000000000..903e3aaeb --- /dev/null +++ b/Zotlabs/Update/_1122.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1122 { +function run() { + $r = q("update site set site_realm = '%s' where true", + dbesc(DIRECTORY_REALM) + ); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1123.php b/Zotlabs/Update/_1123.php new file mode 100644 index 000000000..96096beac --- /dev/null +++ b/Zotlabs/Update/_1123.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1123 { +function run() { + $r1 = q("ALTER TABLE `hubloc` ADD `hubloc_network` CHAR( 32 ) NOT NULL DEFAULT '' AFTER `hubloc_addr` , +ADD INDEX ( `hubloc_network` )"); + $r2 = q("update hubloc set hubloc_network = 'zot' where true"); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1124.php b/Zotlabs/Update/_1124.php new file mode 100644 index 000000000..1320b8b55 --- /dev/null +++ b/Zotlabs/Update/_1124.php @@ -0,0 +1,41 @@ +<?php + +namespace Zotlabs\Update; + +class _1124 { +function run() { + $r1 = q("CREATE TABLE IF NOT EXISTS `sign` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `iid` int(10) unsigned NOT NULL DEFAULT '0', + `retract_iid` int(10) unsigned NOT NULL DEFAULT '0', + `signed_text` mediumtext NOT NULL, + `signature` text NOT NULL, + `signer` char(255) NOT NULL, + PRIMARY KEY (`id`), + KEY `iid` (`iid`), + KEY `retract_iid` (`retract_iid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + $r2 = q("CREATE TABLE IF NOT EXISTS `conv` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `guid` char(255) NOT NULL, + `recips` mediumtext NOT NULL, + `uid` int(11) NOT NULL, + `creator` char(255) NOT NULL, + `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', + `subject` mediumtext NOT NULL, + PRIMARY KEY (`id`), + KEY `created` (`created`), + KEY `updated` (`updated`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1125.php b/Zotlabs/Update/_1125.php new file mode 100644 index 000000000..03f9640a4 --- /dev/null +++ b/Zotlabs/Update/_1125.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1125 { +function run() { + $r = q("ALTER TABLE `profdef` ADD `field_inputs` MEDIUMTEXT NOT NULL DEFAULT ''"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1126.php b/Zotlabs/Update/_1126.php new file mode 100644 index 000000000..f657cc6b2 --- /dev/null +++ b/Zotlabs/Update/_1126.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1126 { +function run() { + $r = q("ALTER TABLE `mail` ADD `convid` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `id` , +ADD INDEX ( `convid` )"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1127.php b/Zotlabs/Update/_1127.php new file mode 100644 index 000000000..8dec64ae4 --- /dev/null +++ b/Zotlabs/Update/_1127.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1127 { +function run() { + $r = q("ALTER TABLE `item` ADD `comments_closed` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `changed` , +ADD INDEX ( `comments_closed` ), ADD INDEX ( `changed` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1128.php b/Zotlabs/Update/_1128.php new file mode 100644 index 000000000..8ee6d225e --- /dev/null +++ b/Zotlabs/Update/_1128.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1128 { +function run() { + $r = q("ALTER TABLE `item` ADD `diaspora_meta` MEDIUMTEXT NOT NULL DEFAULT '' AFTER `sig` "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1129.php b/Zotlabs/Update/_1129.php new file mode 100644 index 000000000..76bd155ee --- /dev/null +++ b/Zotlabs/Update/_1129.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1129 { +function run() { + $r = q("update hubloc set hubloc_network = 'zot' where hubloc_network = ''"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1130.php b/Zotlabs/Update/_1130.php new file mode 100644 index 000000000..1322a0b13 --- /dev/null +++ b/Zotlabs/Update/_1130.php @@ -0,0 +1,28 @@ +<?php + +namespace Zotlabs\Update; + +class _1130 { +function run() { + $myperms = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK + |PERMS_W_STREAM|PERMS_W_WALL|PERMS_W_COMMENT|PERMS_W_MAIL|PERMS_W_CHAT + |PERMS_R_STORAGE|PERMS_R_PAGES|PERMS_W_LIKE; + + $r = q("select abook_channel, abook_my_perms from abook where (abook_flags & %d) and abook_my_perms != 0", + intval(ABOOK_FLAG_SELF) + ); + if($r) { + foreach($r as $rr) { + set_pconfig($rr['abook_channel'],'system','autoperms',$rr['abook_my_perms']); + } + } + $r = q("update abook set abook_my_perms = %d where (abook_flags & %d) and abook_my_perms = 0", + intval($myperms), + intval(ABOOK_FLAG_SELF) + ); + + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1131.php b/Zotlabs/Update/_1131.php new file mode 100644 index 000000000..72e968f67 --- /dev/null +++ b/Zotlabs/Update/_1131.php @@ -0,0 +1,20 @@ +<?php + +namespace Zotlabs\Update; + +class _1131 { +function run() { + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) // make sure this gets skipped for anyone who hasn't run it yet, it will fail on pg + return UPDATE_SUCCESS; + + $r1 = q("ALTER TABLE `abook` ADD `abook_rating_text` TEXT NOT NULL DEFAULT '' AFTER `abook_rating` "); + $r2 = q("ALTER TABLE `xlink` ADD `xlink_rating_text` TEXT NOT NULL DEFAULT '' AFTER `xlink_rating` "); + + if($r1 && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1132.php b/Zotlabs/Update/_1132.php new file mode 100644 index 000000000..9e085a351 --- /dev/null +++ b/Zotlabs/Update/_1132.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1132 { +function run() { + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { // correct previous failed update + $r1 = q("ALTER TABLE abook ADD abook_rating_text TEXT NOT NULL DEFAULT '' "); + $r2 = q("ALTER TABLE xlink ADD xlink_rating_text TEXT NOT NULL DEFAULT '' "); + if(!$r1 || !$r2) + return UPDATE_FAILED; + } + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1133.php b/Zotlabs/Update/_1133.php new file mode 100644 index 000000000..3820ef1ee --- /dev/null +++ b/Zotlabs/Update/_1133.php @@ -0,0 +1,38 @@ +<?php + +namespace Zotlabs\Update; + +class _1133 { +function run() { + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r1 = q("CREATE TABLE xperm ( + xp_id serial NOT NULL, + xp_client varchar( 20 ) NOT NULL DEFAULT '', + xp_channel bigint NOT NULL DEFAULT '0', + xp_perm varchar( 64 ) NOT NULL DEFAULT '', + PRIMARY KEY (xp_id) )"); + $r2 = 0; + foreach(array('xp_client', 'xp_channel', 'xp_perm') as $fld) + $r2 += ((q("create index $fld on xperm ($fld)") == false) ? 0 : 1); + + $r = (($r1 && $r2) ? true : false); + } + else { + $r = q("CREATE TABLE IF NOT EXISTS `xperm` ( + `xp_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , + `xp_client` VARCHAR( 20 ) NOT NULL DEFAULT '', + `xp_channel` INT UNSIGNED NOT NULL DEFAULT '0', + `xp_perm` VARCHAR( 64 ) NOT NULL DEFAULT '', + KEY `xp_client` (`xp_client`), + KEY `xp_channel` (`xp_channel`), + KEY `xp_perm` (`xp_perm`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 "); + } + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1134.php b/Zotlabs/Update/_1134.php new file mode 100644 index 000000000..d52bab044 --- /dev/null +++ b/Zotlabs/Update/_1134.php @@ -0,0 +1,20 @@ +<?php + +namespace Zotlabs\Update; + +class _1134 { +function run() { + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r1 = q("ALTER TABLE xlink ADD xlink_static numeric(1) NOT NULL DEFAULT '0' "); + $r2 = q("create index xlink_static on xlink ( xlink_static ) "); + $r = $r1 && $r2; + } + else + $r = q("ALTER TABLE xlink ADD xlink_static TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( xlink_static ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1135.php b/Zotlabs/Update/_1135.php new file mode 100644 index 000000000..92a3e04b6 --- /dev/null +++ b/Zotlabs/Update/_1135.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1135 { +function run() { + $r = q("ALTER TABLE xlink ADD xlink_sig TEXT NOT NULL DEFAULT ''"); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1136.php b/Zotlabs/Update/_1136.php new file mode 100644 index 000000000..0c1691fcb --- /dev/null +++ b/Zotlabs/Update/_1136.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1136 { +function run() { + $r1 = q("alter table item add item_unseen smallint not null default '0' "); + $r2 = q("create index item_unseen on item ( item_unseen ) "); + $r3 = q("update item set item_unseen = 1 where ( item_flags & 2 ) > 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 @@ +<?php + +namespace Zotlabs\Update; + +class _1137 { +function run() { + $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; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1138.php b/Zotlabs/Update/_1138.php new file mode 100644 index 000000000..b2eac12af --- /dev/null +++ b/Zotlabs/Update/_1138.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1138 { +function run() { + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1139.php b/Zotlabs/Update/_1139.php new file mode 100644 index 000000000..aa4863fc1 --- /dev/null +++ b/Zotlabs/Update/_1139.php @@ -0,0 +1,21 @@ +<?php + +namespace Zotlabs\Update; + +class _1139 { +function run() { + 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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1140.php b/Zotlabs/Update/_1140.php new file mode 100644 index 000000000..5b4c8f801 --- /dev/null +++ b/Zotlabs/Update/_1140.php @@ -0,0 +1,27 @@ +<?php + +namespace Zotlabs\Update; + +class _1140 { +function run() { + $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; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1141.php b/Zotlabs/Update/_1141.php new file mode 100644 index 000000000..e1f84f469 --- /dev/null +++ b/Zotlabs/Update/_1141.php @@ -0,0 +1,30 @@ +<?php + +namespace Zotlabs\Update; + +class _1141 { +function run() { + 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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1142.php b/Zotlabs/Update/_1142.php new file mode 100644 index 000000000..a8ffcc182 --- /dev/null +++ b/Zotlabs/Update/_1142.php @@ -0,0 +1,18 @@ +<?php + +namespace Zotlabs\Update; + +class _1142 { +function run() { + + $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; + + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1143.php b/Zotlabs/Update/_1143.php new file mode 100644 index 000000000..99f23af61 --- /dev/null +++ b/Zotlabs/Update/_1143.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1143 { +function run() { + + $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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1144.php b/Zotlabs/Update/_1144.php new file mode 100644 index 000000000..848897de7 --- /dev/null +++ b/Zotlabs/Update/_1144.php @@ -0,0 +1,27 @@ +<?php + +namespace Zotlabs\Update; + +class _1144 { +function run() { + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1145.php b/Zotlabs/Update/_1145.php new file mode 100644 index 000000000..5102acc8a --- /dev/null +++ b/Zotlabs/Update/_1145.php @@ -0,0 +1,30 @@ +<?php + +namespace Zotlabs\Update; + +class _1145 { +function run() { + + 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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1146.php b/Zotlabs/Update/_1146.php new file mode 100644 index 000000000..92a26adaf --- /dev/null +++ b/Zotlabs/Update/_1146.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1146 { +function run() { + + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1147.php b/Zotlabs/Update/_1147.php new file mode 100644 index 000000000..b8f6716f7 --- /dev/null +++ b/Zotlabs/Update/_1147.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1147 { +function run() { + + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1148.php b/Zotlabs/Update/_1148.php new file mode 100644 index 000000000..ed9a4d93a --- /dev/null +++ b/Zotlabs/Update/_1148.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1148 { +function run() { + $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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1149.php b/Zotlabs/Update/_1149.php new file mode 100644 index 000000000..f45bd995b --- /dev/null +++ b/Zotlabs/Update/_1149.php @@ -0,0 +1,35 @@ +<?php + +namespace Zotlabs\Update; + +class _1149 { +function run() { + 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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1150.php b/Zotlabs/Update/_1150.php new file mode 100644 index 000000000..896fc75e3 --- /dev/null +++ b/Zotlabs/Update/_1150.php @@ -0,0 +1,28 @@ +<?php + +namespace Zotlabs\Update; + +class _1150 { +function run() { + + 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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1151.php b/Zotlabs/Update/_1151.php new file mode 100644 index 000000000..d14baabb1 --- /dev/null +++ b/Zotlabs/Update/_1151.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1151 { +function run() { + + $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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1152.php b/Zotlabs/Update/_1152.php new file mode 100644 index 000000000..54393d590 --- /dev/null +++ b/Zotlabs/Update/_1152.php @@ -0,0 +1,57 @@ +<?php + +namespace Zotlabs\Update; + +class _1152 { +function run() { + + 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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1153.php b/Zotlabs/Update/_1153.php new file mode 100644 index 000000000..cf8d451b4 --- /dev/null +++ b/Zotlabs/Update/_1153.php @@ -0,0 +1,18 @@ +<?php + +namespace Zotlabs\Update; + +class _1153 { +function run() { + + $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; + + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1154.php b/Zotlabs/Update/_1154.php new file mode 100644 index 000000000..6e92f525d --- /dev/null +++ b/Zotlabs/Update/_1154.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1154 { +function run() { + + $r = q("ALTER TABLE event ADD event_vdata text NOT NULL "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1155.php b/Zotlabs/Update/_1155.php new file mode 100644 index 000000000..8f2553b3e --- /dev/null +++ b/Zotlabs/Update/_1155.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1155 { +function run() { + + $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; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1156.php b/Zotlabs/Update/_1156.php new file mode 100644 index 000000000..536a219d8 --- /dev/null +++ b/Zotlabs/Update/_1156.php @@ -0,0 +1,28 @@ +<?php + +namespace Zotlabs\Update; + +class _1156 { +function run() { + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1157.php b/Zotlabs/Update/_1157.php new file mode 100644 index 000000000..01f452f32 --- /dev/null +++ b/Zotlabs/Update/_1157.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1157 { +function run() { + $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; + +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1158.php b/Zotlabs/Update/_1158.php new file mode 100644 index 000000000..89ac3daa1 --- /dev/null +++ b/Zotlabs/Update/_1158.php @@ -0,0 +1,22 @@ +<?php + +namespace Zotlabs\Update; + +class _1158 { +function run() { + $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; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1159.php b/Zotlabs/Update/_1159.php new file mode 100644 index 000000000..1445092ad --- /dev/null +++ b/Zotlabs/Update/_1159.php @@ -0,0 +1,25 @@ +<?php + +namespace Zotlabs\Update; + +class _1159 { +function run() { + $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; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1160.php b/Zotlabs/Update/_1160.php new file mode 100644 index 000000000..b7b67076f --- /dev/null +++ b/Zotlabs/Update/_1160.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1160 { +function run() { + $r = q("alter table abook add abook_instance text not null default '' "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1161.php b/Zotlabs/Update/_1161.php new file mode 100644 index 000000000..870eb7ed6 --- /dev/null +++ b/Zotlabs/Update/_1161.php @@ -0,0 +1,43 @@ +<?php + +namespace Zotlabs\Update; + +class _1161 { +function run() { + + 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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1162.php b/Zotlabs/Update/_1162.php new file mode 100644 index 000000000..683ea9802 --- /dev/null +++ b/Zotlabs/Update/_1162.php @@ -0,0 +1,19 @@ +<?php + +namespace Zotlabs\Update; + +class _1162 { +function run() { + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1163.php b/Zotlabs/Update/_1163.php new file mode 100644 index 000000000..376447aea --- /dev/null +++ b/Zotlabs/Update/_1163.php @@ -0,0 +1,22 @@ +<?php + +namespace Zotlabs\Update; + +class _1163 { +function run() { + + 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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1164.php b/Zotlabs/Update/_1164.php new file mode 100644 index 000000000..bad9193d1 --- /dev/null +++ b/Zotlabs/Update/_1164.php @@ -0,0 +1,45 @@ +<?php + +namespace Zotlabs\Update; + +class _1164 { +function run() { + + 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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1165.php b/Zotlabs/Update/_1165.php new file mode 100644 index 000000000..fcea38dc8 --- /dev/null +++ b/Zotlabs/Update/_1165.php @@ -0,0 +1,20 @@ +<?php + +namespace Zotlabs\Update; + +class _1165 { +function run() { + + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1166.php b/Zotlabs/Update/_1166.php new file mode 100644 index 000000000..e320d5bc0 --- /dev/null +++ b/Zotlabs/Update/_1166.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1166 { +function run() { + + $r = q("alter table source add src_tag text not null default '' "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1167.php b/Zotlabs/Update/_1167.php new file mode 100644 index 000000000..b5510a21f --- /dev/null +++ b/Zotlabs/Update/_1167.php @@ -0,0 +1,26 @@ +<?php + +namespace Zotlabs\Update; + +class _1167 { +function run() { + + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1168.php b/Zotlabs/Update/_1168.php new file mode 100644 index 000000000..cf7d2689a --- /dev/null +++ b/Zotlabs/Update/_1168.php @@ -0,0 +1,23 @@ +<?php + +namespace Zotlabs\Update; + +class _1168 { +function run() { + + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1169.php b/Zotlabs/Update/_1169.php new file mode 100644 index 000000000..cfe4dbcd8 --- /dev/null +++ b/Zotlabs/Update/_1169.php @@ -0,0 +1,27 @@ +<?php + +namespace Zotlabs\Update; + +class _1169 { +function run() { + + 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; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1170.php b/Zotlabs/Update/_1170.php new file mode 100644 index 000000000..215aeebc7 --- /dev/null +++ b/Zotlabs/Update/_1170.php @@ -0,0 +1,21 @@ +<?php + +namespace Zotlabs\Update; + +class _1170 { +function run() { + + $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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1171.php b/Zotlabs/Update/_1171.php new file mode 100644 index 000000000..5cbf0ca21 --- /dev/null +++ b/Zotlabs/Update/_1171.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1171 { +function run() { + + $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; + + + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1172.php b/Zotlabs/Update/_1172.php new file mode 100644 index 000000000..117e87fa1 --- /dev/null +++ b/Zotlabs/Update/_1172.php @@ -0,0 +1,29 @@ +<?php + +namespace Zotlabs\Update; + +class _1172 { +function run() { + + $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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1173.php b/Zotlabs/Update/_1173.php new file mode 100644 index 000000000..7c0d76c73 --- /dev/null +++ b/Zotlabs/Update/_1173.php @@ -0,0 +1,27 @@ +<?php + +namespace Zotlabs\Update; + +class _1173 { +function run() { + + + 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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1174.php b/Zotlabs/Update/_1174.php new file mode 100644 index 000000000..0d68b2d65 --- /dev/null +++ b/Zotlabs/Update/_1174.php @@ -0,0 +1,32 @@ +<?php + +namespace Zotlabs\Update; + +class _1174 { +function run() { + + 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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1175.php b/Zotlabs/Update/_1175.php new file mode 100644 index 000000000..188586084 --- /dev/null +++ b/Zotlabs/Update/_1175.php @@ -0,0 +1,31 @@ +<?php + +namespace Zotlabs\Update; + +class _1175 { +function run() { + + 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; + +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1176.php b/Zotlabs/Update/_1176.php new file mode 100644 index 000000000..8c02ee436 --- /dev/null +++ b/Zotlabs/Update/_1176.php @@ -0,0 +1,19 @@ +<?php + +namespace Zotlabs\Update; + +class _1176 { +function run() { + + $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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1177.php b/Zotlabs/Update/_1177.php new file mode 100644 index 000000000..119e48ee8 --- /dev/null +++ b/Zotlabs/Update/_1177.php @@ -0,0 +1,66 @@ +<?php + +namespace Zotlabs\Update; + +class _1177 { +function run() { + + 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; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1178.php b/Zotlabs/Update/_1178.php new file mode 100644 index 000000000..97c42a16d --- /dev/null +++ b/Zotlabs/Update/_1178.php @@ -0,0 +1,42 @@ +<?php + +namespace Zotlabs\Update; + +class _1178 { +function run() { + + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1179.php b/Zotlabs/Update/_1179.php new file mode 100644 index 000000000..44227c8d3 --- /dev/null +++ b/Zotlabs/Update/_1179.php @@ -0,0 +1,49 @@ +<?php + +namespace Zotlabs\Update; + +class _1179 { +function run() { + + 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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1180.php b/Zotlabs/Update/_1180.php new file mode 100644 index 000000000..f02f46231 --- /dev/null +++ b/Zotlabs/Update/_1180.php @@ -0,0 +1,32 @@ +<?php + +namespace Zotlabs\Update; + +class _1180 { +function run() { + + 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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1181.php b/Zotlabs/Update/_1181.php new file mode 100644 index 000000000..fc2d94b6b --- /dev/null +++ b/Zotlabs/Update/_1181.php @@ -0,0 +1,14 @@ +<?php + +namespace Zotlabs\Update; + +class _1181 { +function run() { + if(\Zotlabs\Lib\System::get_server_role() == 'pro') { + q("update account set account_level = 5 where true"); + } + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1182.php b/Zotlabs/Update/_1182.php new file mode 100644 index 000000000..d652f432e --- /dev/null +++ b/Zotlabs/Update/_1182.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1182 { +function run() { + + $r1 = q("alter table site add site_version varchar(32) not null default '' "); + + if($r1) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1183.php b/Zotlabs/Update/_1183.php new file mode 100644 index 000000000..6e9f89271 --- /dev/null +++ b/Zotlabs/Update/_1183.php @@ -0,0 +1,25 @@ +<?php + +namespace Zotlabs\Update; + +class _1183 { +function run() { + + 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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1184.php b/Zotlabs/Update/_1184.php new file mode 100644 index 000000000..e8c37888c --- /dev/null +++ b/Zotlabs/Update/_1184.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1184 { +function run() { + + $r1 = q("alter table site add site_crypto text not null default '' "); + + if($r1) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1185.php b/Zotlabs/Update/_1185.php new file mode 100644 index 000000000..c7f4f1bd4 --- /dev/null +++ b/Zotlabs/Update/_1185.php @@ -0,0 +1,16 @@ +<?php + +namespace Zotlabs\Update; + +class _1185 { +function run() { + + $r1 = q("alter table app add app_plugin text not null default '' "); + + if($r1) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1186.php b/Zotlabs/Update/_1186.php new file mode 100644 index 000000000..a9c4f0e36 --- /dev/null +++ b/Zotlabs/Update/_1186.php @@ -0,0 +1,18 @@ +<?php + +namespace Zotlabs\Update; + +class _1186 { +function run() { + + $r1 = q("alter table profile add profile_vcard text not null"); + + if($r1) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1187.php b/Zotlabs/Update/_1187.php new file mode 100644 index 000000000..0fce5aa05 --- /dev/null +++ b/Zotlabs/Update/_1187.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1187 { +function run() { + + 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; + + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1188.php b/Zotlabs/Update/_1188.php new file mode 100644 index 000000000..eb0335aab --- /dev/null +++ b/Zotlabs/Update/_1188.php @@ -0,0 +1,18 @@ +<?php + +namespace Zotlabs\Update; + +class _1188 { +function run() { + + $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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1189.php b/Zotlabs/Update/_1189.php new file mode 100644 index 000000000..5cd180fbd --- /dev/null +++ b/Zotlabs/Update/_1189.php @@ -0,0 +1,23 @@ +<?php + +namespace Zotlabs\Update; + +class _1189 { +function run() { + + $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; + +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1190.php b/Zotlabs/Update/_1190.php new file mode 100644 index 000000000..9321b82b8 --- /dev/null +++ b/Zotlabs/Update/_1190.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1190 { +function run() { + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1191.php b/Zotlabs/Update/_1191.php new file mode 100644 index 000000000..015b9a2ca --- /dev/null +++ b/Zotlabs/Update/_1191.php @@ -0,0 +1,425 @@ +<?php + +namespace Zotlabs\Update; + +class _1191 { +function run() { + + $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; + } + } +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1192.php b/Zotlabs/Update/_1192.php new file mode 100644 index 000000000..f2445da05 --- /dev/null +++ b/Zotlabs/Update/_1192.php @@ -0,0 +1,21 @@ +<?php + +namespace Zotlabs\Update; + +class _1192 { +function run() { + + 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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1193.php b/Zotlabs/Update/_1193.php new file mode 100644 index 000000000..267e16da1 --- /dev/null +++ b/Zotlabs/Update/_1193.php @@ -0,0 +1,22 @@ +<?php + +namespace Zotlabs\Update; + +class _1193 { +function run() { + + 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; +} + + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1194.php b/Zotlabs/Update/_1194.php new file mode 100644 index 000000000..916723eaa --- /dev/null +++ b/Zotlabs/Update/_1194.php @@ -0,0 +1,22 @@ +<?php + +namespace Zotlabs\Update; + +class _1194 { +function run() { + $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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1195.php b/Zotlabs/Update/_1195.php new file mode 100644 index 000000000..248e9a34a --- /dev/null +++ b/Zotlabs/Update/_1195.php @@ -0,0 +1,21 @@ +<?php + +namespace Zotlabs\Update; + +class _1195 { +function run() { + + 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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1196.php b/Zotlabs/Update/_1196.php new file mode 100644 index 000000000..720252bf8 --- /dev/null +++ b/Zotlabs/Update/_1196.php @@ -0,0 +1,45 @@ +<?php + +namespace Zotlabs\Update; + +class _1196 { +function run() { + + 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; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1197.php b/Zotlabs/Update/_1197.php new file mode 100644 index 000000000..72e4ca59d --- /dev/null +++ b/Zotlabs/Update/_1197.php @@ -0,0 +1,17 @@ +<?php + +namespace Zotlabs\Update; + +class _1197 { +function run() { + + $r = q("select diaspora_meta from item where true limit 1"); + if($r) { + $r = q("ALTER TABLE item DROP diaspora_meta"); + } + + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1198.php b/Zotlabs/Update/_1198.php new file mode 100644 index 000000000..d188c94f6 --- /dev/null +++ b/Zotlabs/Update/_1198.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1198 { +function run() { + + 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; +} + + +} diff --git a/Zotlabs/Update/_1199.php b/Zotlabs/Update/_1199.php new file mode 100644 index 000000000..7ab03b073 --- /dev/null +++ b/Zotlabs/Update/_1199.php @@ -0,0 +1,19 @@ +<?php + +namespace Zotlabs\Update; + +class _1199 { +function run() { + + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { + $r = q("ALTER TABLE item + DROP INDEX uid, + ADD INDEX (item_type) + "); + } + + return UPDATE_SUCCESS; +} + + +}
\ No newline at end of file diff --git a/Zotlabs/Update/_1200.php b/Zotlabs/Update/_1200.php new file mode 100644 index 000000000..9f7bfb152 --- /dev/null +++ b/Zotlabs/Update/_1200.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1200 { +function run() { + + 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; + } + else { + return UPDATE_SUCCESS; + } + +} + +} diff --git a/Zotlabs/Update/_1201.php b/Zotlabs/Update/_1201.php new file mode 100644 index 000000000..920a7401e --- /dev/null +++ b/Zotlabs/Update/_1201.php @@ -0,0 +1,27 @@ +<?php + +namespace Zotlabs\Update; + +class _1201 { + + function run() { + + 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; + } + else { + return UPDATE_SUCCESS; + } + + } + +} diff --git a/Zotlabs/Update/_1202.php b/Zotlabs/Update/_1202.php new file mode 100644 index 000000000..c9ccd157b --- /dev/null +++ b/Zotlabs/Update/_1202.php @@ -0,0 +1,15 @@ +<?php + +namespace Zotlabs\Update; + +class _1202 { + + function run() { + + // empty update in order to make the DB_UPDATE_VERSION equal to the current maximum update function + // rather than being one greater than the last known update + + return UPDATE_SUCCESS; + + } +} diff --git a/Zotlabs/Update/_1203.php b/Zotlabs/Update/_1203.php new file mode 100644 index 000000000..2968d209d --- /dev/null +++ b/Zotlabs/Update/_1203.php @@ -0,0 +1,29 @@ +<?php + +namespace Zotlabs\Update; + +class _1203 { + + function run() { + + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { + $r = q("ALTER TABLE item + DROP INDEX item_wall, + DROP INDEX item_starred, + DROP INDEX item_retained, + ADD INDEX uid_item_wall (uid, item_wall), + ADD INDEX uid_item_starred (uid, item_starred), + ADD INDEX uid_item_retained (uid, item_retained) + "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + } + else { + return UPDATE_SUCCESS; + } + + } + +} diff --git a/Zotlabs/Update/_1204.php b/Zotlabs/Update/_1204.php new file mode 100644 index 000000000..0b9204b9b --- /dev/null +++ b/Zotlabs/Update/_1204.php @@ -0,0 +1,34 @@ +<?php + +namespace Zotlabs\Update; + +class _1204 { + + function run() { + + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r1 = q("ALTER TABLE poll ADD poll_guid text NOT NULL"); + $r2 = q("create index \"poll_guid_idx\" on poll (\"poll_guid\")"); + $r3 = q("ALTER TABLE poll_elm ADD pelm_guid text NOT NULL"); + $r4 = q("create index \"pelm_guid_idx\" on poll_elm (\"pelm_guid\")"); + $r5 = q("ALTER TABLE vote ADD vote_guid text NOT NULL"); + $r6 = q("create index \"vote_guid_idx\" on vote (\"vote_guid\")"); + + $r = ($r1 && $r2 && $r3 && $r4 && $r5 && $r6); + } + else { + $r1 = q("ALTER TABLE `poll` ADD `poll_guid` VARCHAR(191) NOT NULL, ADD INDEX `poll_guid` (`poll_guid`) "); + $r2 = q("ALTER TABLE `poll_elm` ADD `pelm_guid` VARCHAR(191) NOT NULL, ADD INDEX `pelm_guid` (`pelm_guid`) "); + $r3 = q("ALTER TABLE `vote` ADD `vote_guid` VARCHAR(191) NOT NULL, ADD INDEX `vote_guid` (`vote_guid`) "); + + $r = ($r1 && $r2 && $r3); + } + + if($r) + return UPDATE_SUCCESS; + + return UPDATE_FAILED; + + } + +} diff --git a/Zotlabs/Update/_1205.php b/Zotlabs/Update/_1205.php new file mode 100644 index 000000000..968833726 --- /dev/null +++ b/Zotlabs/Update/_1205.php @@ -0,0 +1,38 @@ +<?php + +namespace Zotlabs\Update; + +class _1205 { + + function run() { + + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { + + q("ALTER TABLE item DROP INDEX title"); + q("ALTER TABLE item DROP INDEX body"); + q("ALTER TABLE item DROP INDEX allow_cid"); + q("ALTER TABLE item DROP INDEX allow_gid"); + q("ALTER TABLE item DROP INDEX deny_cid"); + q("ALTER TABLE item DROP INDEX deny_gid"); + q("ALTER TABLE item DROP INDEX item_flags"); + q("ALTER TABLE item DROP INDEX item_restrict"); + q("ALTER TABLE item DROP INDEX aid"); + + $r = q("ALTER TABLE item + DROP INDEX item_private, + ADD INDEX uid_item_private (uid, item_private), + ADD INDEX item_wall (item_wall), + ADD INDEX item_pending_remove_changed (item_pending_remove, changed) + "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + } + else { + return UPDATE_SUCCESS; + } + + } + +} diff --git a/Zotlabs/Update/_1206.php b/Zotlabs/Update/_1206.php new file mode 100644 index 000000000..351d53ff6 --- /dev/null +++ b/Zotlabs/Update/_1206.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1206 { + + function run() { + + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { + $r = q("ALTER TABLE item + ADD INDEX uid_resource_type (uid, resource_type) + "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + } + else { + return UPDATE_SUCCESS; + } + + } + +} diff --git a/Zotlabs/Update/_1207.php b/Zotlabs/Update/_1207.php new file mode 100644 index 000000000..f53bc46ae --- /dev/null +++ b/Zotlabs/Update/_1207.php @@ -0,0 +1,24 @@ +<?php + +namespace Zotlabs\Update; + +class _1207 { + + function run() { + + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { + $r = q("ALTER TABLE item + DROP INDEX resource_type + "); + + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; + } + else { + return UPDATE_SUCCESS; + } + + } + +} diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index 63033ce5e..a27edb73d 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -137,7 +137,22 @@ class HTTPSig { } } - logger('Content_Valid: ' . $result['content_valid']); + + if(in_array('x-zot-digest',$signed_headers)) { + $result['content_signed'] = true; + $digest = explode('=', $headers['x-zot-digest']); + if($digest[0] === 'SHA-256') + $hashalg = 'sha256'; + if($digest[0] === 'SHA-512') + $hashalg = 'sha512'; + + // The explode operation will have stripped the '=' padding, so compare against unpadded base64 + if(rtrim(base64_encode(hash($hashalg,$_POST['data'],true)),'=') === $digest[1]) { + $result['content_valid'] = true; + } + } + + logger('Content_Valid: ' . (($result['content_valid']) ? 'true' : 'false')); return $result; @@ -194,8 +209,8 @@ class HTTPSig { . '",headers="' . $x['headers'] . '",signature="' . $x['signature'] . '"'; if($crypt_key) { - $x = crypto_encapsulate($headerval,$crypt_key,$crypt_alg); - $headerval = 'iv="' . $x['iv'] . '",key="' . $x['key'] . '",alg="' . $x['alg'] . '",data="' . $x['data']; + $x = crypto_encapsulate($headerval,$crypt_key,$crypt_algo); + $headerval = 'iv="' . $x['iv'] . '",key="' . $x['key'] . '",alg="' . $x['alg'] . '",data="' . $x['data'] . '"'; } if($auth) { diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php index a6b780cdc..fb551e36f 100644 --- a/Zotlabs/Web/Router.php +++ b/Zotlabs/Web/Router.php @@ -38,10 +38,9 @@ class Router { /** * @brief Router constructor. * - * @param[in,out] App &$a * @throws Exception module not found */ - function __construct(&$a) { + function __construct() { $module = \App::$module; $modname = "Zotlabs\\Module\\" . ucfirst($module); @@ -179,9 +178,8 @@ class Router { /** * @brief * - * @param[in,out] App &$a */ - function Dispatch(&$a) { + function Dispatch() { /** * Call module functions diff --git a/Zotlabs/Web/WebServer.php b/Zotlabs/Web/WebServer.php index 9e6af8c4c..5183fb2b0 100644 --- a/Zotlabs/Web/WebServer.php +++ b/Zotlabs/Web/WebServer.php @@ -58,11 +58,10 @@ class WebServer { if((x($_GET,'zid')) && (! \App::$install)) { \App::$query_string = strip_zids(\App::$query_string); if(! local_channel()) { - if ($_SESSION['my_address']!=$_GET['zid']) - { - $_SESSION['my_address'] = $_GET['zid']; - $_SESSION['authenticated'] = 0; - } + if ($_SESSION['my_address']!=$_GET['zid']) { + $_SESSION['my_address'] = $_GET['zid']; + $_SESSION['authenticated'] = 0; + } zid_init(); } } @@ -107,9 +106,43 @@ class WebServer { check_config(); } - //nav_set_selected('nothing'); + $this->create_channel_links(); - $Router = new Router($a); + $Router = new Router(); + + $this->initialise_content(); + + $Router->Dispatch(); + + $this->set_homebase(); + + // now that we've been through the module content, see if the page reported + // a permission problem and if so, a 403 response would seem to be in order. + + if(is_array($_SESSION['sysmsg']) && stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) { + header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.')); + } + + call_hooks('page_end', \App::$page['content']); + + construct_page(); + + killme(); + } + + + private function initialise_content() { + + /* initialise content region */ + + if(! x(\App::$page, 'content')) + \App::$page['content'] = ''; + + call_hooks('page_content_top', \App::$page['content']); + + } + + private function create_channel_links() { /* Initialise the Link: response header if this is a channel page. * This cannot be done inside the channel module because some protocol @@ -135,26 +168,17 @@ class WebServer { \App::$channel_links = $x['channel_links']; header('Link: ' . \App::get_channel_links()); } + } - - - /* initialise content region */ - - if(! x(\App::$page, 'content')) - \App::$page['content'] = ''; - - call_hooks('page_content_top', \App::$page['content']); - - - $Router->Dispatch($a); - + private function set_homebase() { // If you're just visiting, let javascript take you home if(x($_SESSION, 'visitor_home')) { $homebase = $_SESSION['visitor_home']; - } elseif(local_channel()) { + } + elseif(local_channel()) { $homebase = z_root() . '/channel/' . \App::$channel['channel_address']; } @@ -162,17 +186,8 @@ class WebServer { \App::$page['content'] .= '<script>var homebase = "' . $homebase . '";</script>'; } - // now that we've been through the module content, see if the page reported - // a permission problem and if so, a 403 response would seem to be in order. - - if(is_array($_SESSION['sysmsg']) && stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) { - header($_SERVER['SERVER_PROTOCOL'] . ' 403 ' . t('Permission denied.')); - } + } - call_hooks('page_end', \App::$page['content']); - construct_page(); - killme(); - } } diff --git a/Zotlabs/Widget/Affinity.php b/Zotlabs/Widget/Affinity.php index a3e5b5c07..4fb2874ae 100644 --- a/Zotlabs/Widget/Affinity.php +++ b/Zotlabs/Widget/Affinity.php @@ -9,9 +9,11 @@ class Affinity { if(! local_channel()) return ''; + $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0); + $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99); - $cmin = ((x($_REQUEST,'cmin')) ? intval($_REQUEST['cmin']) : 0); - $cmax = ((x($_REQUEST,'cmax')) ? intval($_REQUEST['cmax']) : 99); + $cmin = ((x($_REQUEST,'cmin')) ? intval($_REQUEST['cmin']) : $default_cmin); + $cmax = ((x($_REQUEST,'cmax')) ? intval($_REQUEST['cmax']) : $default_cmax); if(feature_enabled(local_channel(),'affinity')) { diff --git a/Zotlabs/Widget/Forums.php b/Zotlabs/Widget/Forums.php index 91b987746..f65a639ff 100644 --- a/Zotlabs/Widget/Forums.php +++ b/Zotlabs/Widget/Forums.php @@ -11,8 +11,8 @@ class Forums { $o = ''; - if(is_array($arr) && array_key_exists('limit',$arr)) - $limit = " limit " . intval($limit) . " "; + if(is_array($arr) && array_key_exists('limit',$arr) && intval($arr['limit']) >= 0) + $limit = " limit " . intval($arr['limit']) . " "; else $limit = ''; @@ -64,13 +64,16 @@ class Forums { // There also should be a way to update this via ajax. for($x = 0; $x < count($r1); $x ++) { - $r = q("select sum(item_unseen) as unseen from item where owner_xchan = '%s' and uid = %d and item_unseen = 1 $perms_sql ", + $r = q("select sum(item_unseen) as unseen from item + where uid = %d and owner_xchan = '%s' and item_unseen = 1 $perms_sql ", dbesc($r1[$x]['xchan_hash']), intval(local_channel()) ); if($r) $r1[$x]['unseen'] = $r[0]['unseen']; + } + /** * @FIXME * This SQL makes the counts correct when you get forum posts arriving from different routes/sources @@ -79,21 +82,19 @@ class Forums { * It may make more sense in that query to look for the mention in the body rather than another join, * but that makes it very inefficient. * - $r = q("select sum(item_unseen) as unseen from item left join term on oid = id where otype = %d and owner_xchan != '%s' and item.uid = %d and url = '%s' and ttype = %d $perms_sql ", - intval(TERM_OBJ_POST), - dbesc($r1[$x]['xchan_hash']), - intval(local_channel()), - dbesc($r1[$x]['xchan_url']), - intval(TERM_MENTION) - ); - if($r) - $r1[$x]['unseen'] = ((array_key_exists('unseen',$r1[$x])) ? $r1[$x]['unseen'] + $r[0]['unseen'] : $r[0]['unseen']); + * $r = q("select sum(item_unseen) as unseen from item left join term on oid = id where otype = %d and owner_xchan != '%s' and item.uid = %d and url = '%s' and ttype = %d $perms_sql ", + * intval(TERM_OBJ_POST), + * dbesc($r1[$x]['xchan_hash']), + * intval(local_channel()), + * dbesc($r1[$x]['xchan_url']), + * intval(TERM_MENTION) + * ); + * if($r) + * $r1[$x]['unseen'] = ((array_key_exists('unseen',$r1[$x])) ? $r1[$x]['unseen'] + $r[0]['unseen'] : $r[0]['unseen']); * * end @FIXME */ - } - if($r1) { $o .= '<div class="widget">'; $o .= '<h3>' . t('Forums') . '</h3><ul class="nav nav-pills flex-column">'; diff --git a/Zotlabs/Widget/Newmember.php b/Zotlabs/Widget/Newmember.php new file mode 100644 index 000000000..cdb70e23d --- /dev/null +++ b/Zotlabs/Widget/Newmember.php @@ -0,0 +1,83 @@ +<?php + +namespace Zotlabs\Widget; + +class Newmember { + + function widget($arr) { + + if(! local_channel()) + return EMPTY_STR; + + $c = \App::get_channel(); + if(! $c) + return EMPTY_STR; + + + $a = \App::get_account(); + if(! $a) + return EMPTY_STR; + + + if(datetime_convert('UTC','UTC',$a['account_created']) < datetime_convert('UTC','UTC', 'now - 60 days')) + return EMPTY_STR; + + // This could be a new account that was used to clone a very old channel + + $ob = \App::get_observer(); + if($ob && array_key_exists('xchan_name_date',$ob) && $ob['xchan_name_date'] < datetime_convert('UTC','UTC','now - 60 days')) + return EMPTY_STR; + + + $options = [ + t('Profile Creation'), + [ + 'profile_photo' => t('Upload profile photo'), + 'cover_photo' => t('Upload cover photo'), + 'profiles' => t('Edit your profile'), + ], + + t('Find and Connect with others'), + [ + 'directory' => t('View the directory'), + 'directory?f=&suggest=1' => t('View friend suggestions'), + 'connections' => t('Manage your connections'), + ], + + t('Communicate'), + [ + 'channel/' . $channel['channel_address'] => t('View your channel homepage'), + 'network' => t('View your network stream'), + ], + + t('Miscellaneous'), + [ + 'settings' => t('Settings'), + 'help' => t('Documentation'), + ] + ]; + + $site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false); + $net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true); + + + // hack to put this in the correct spot of the array + + if($site_firehose || $net_firehose) { + $options[5]['pubstream'] = t('View public stream'); + } + + $o = replace_macros(get_markup_template('new_member.tpl'), [ + '$title' => t('New Member Links'), + '$options' => $options + + ]); + + return $o; + + } + +} + + + diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index 5a0c1f3d5..f2619c5cf 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -23,7 +23,8 @@ class Notifications { 'label' => t('Mark all notifications read') ], 'filter' => [ - 'label' => t('Show new posts only') + 'posts_label' => t('Show new posts only'), + 'name_label' => t('Filter by name') ] ]; @@ -41,7 +42,8 @@ class Notifications { 'label' => t('Mark all notifications seen') ], 'filter' => [ - 'label' => t('Show new posts only') + 'posts_label' => t('Show new posts only'), + 'name_label' => t('Filter by name') ] ]; @@ -67,7 +69,7 @@ class Notifications { 'label' => t('New Events'), 'title' => t('New Events Notifications'), 'viewall' => [ - 'url' => 'mail/combined', + 'url' => 'events', 'label' => t('View events') ], 'markall' => [ @@ -136,7 +138,8 @@ class Notifications { 'label' => t('Mark all notifications seen') ], 'filter' => [ - 'label' => t('Show new posts only') + 'posts_label' => t('Show new posts only'), + 'name_label' => t('Filter by name') ] ]; } @@ -145,7 +148,8 @@ class Notifications { '$module' => \App::$module, '$notifications' => $notifications, '$no_notifications' => t('Sorry, you have got no notifications at the moment'), - '$loading' => t('Loading') + '$loading' => t('Loading'), + '$startpage' => get_pconfig(local_channel(), 'system', 'startpage') )); return $o; diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php index e15ed96a5..455fdcb9b 100644 --- a/Zotlabs/Widget/Settings_menu.php +++ b/Zotlabs/Widget/Settings_menu.php @@ -54,7 +54,7 @@ class Settings_menu { } $tabs[] = array( - 'label' => t('Feature/Addon settings'), + 'label' => t('Addon settings'), 'url' => z_root().'/settings/featured', 'selected' => ((argv(1) === 'featured') ? 'active' : ''), ); @@ -79,7 +79,7 @@ class Settings_menu { 'selected' => '' ); - if(get_account_techlevel() > 0) { + if(feature_enabled(local_channel(),'oauth_clients')) { $tabs[] = array( 'label' => t('Connected apps'), 'url' => z_root() . '/settings/oauth', @@ -87,7 +87,7 @@ class Settings_menu { ); } - if(get_account_techlevel() > 2) { + if(feature_enabled(local_channel(),'access_tokens')) { $tabs[] = array( 'label' => t('Guest Access Tokens'), 'url' => z_root() . '/settings/tokens', |