Merge branch 'dev' into 'dev'

Sync dev

See merge request kostikov/core!1
This commit is contained in:
Max Kostikov 2018-12-20 20:51:26 +01:00
commit 89e734dcca
16 changed files with 196 additions and 41 deletions

View File

@ -625,7 +625,12 @@ class Notifier {
continue;
}
$hash = new_uuid();
// Do not change this to a uuid as long as we have traditional zot servers
// in the loop. The signature verification step can't handle dashes in the
// hashes.
$hash = random_string(48);
$packet = null;
$pmsg = '';

View File

@ -546,6 +546,12 @@ class Activity {
}
static function activity_mapper($verb) {
if(strpos($verb,'/') === false) {
@ -588,6 +594,67 @@ class Activity {
}
static function activity_decode_mapper($verb) {
$acts = [
'http://activitystrea.ms/schema/1.0/post' => 'Create',
'http://activitystrea.ms/schema/1.0/share' => 'Announce',
'http://activitystrea.ms/schema/1.0/update' => 'Update',
'http://activitystrea.ms/schema/1.0/like' => 'Like',
'http://activitystrea.ms/schema/1.0/favorite' => 'Like',
'http://purl.org/zot/activity/dislike' => 'Dislike',
'http://activitystrea.ms/schema/1.0/tag' => 'Add',
'http://activitystrea.ms/schema/1.0/follow' => 'Follow',
'http://activitystrea.ms/schema/1.0/unfollow' => 'Unfollow',
];
foreach($acts as $k => $v) {
if($verb === $v) {
return $k;
}
}
logger('Unmapped activity: ' . $verb);
return 'Create';
}
static function activity_obj_decode_mapper($obj) {
$objs = [
'http://activitystrea.ms/schema/1.0/note' => 'Note',
'http://activitystrea.ms/schema/1.0/note' => 'Article',
'http://activitystrea.ms/schema/1.0/comment' => 'Note',
'http://activitystrea.ms/schema/1.0/person' => 'Person',
'http://purl.org/zot/activity/profile' => 'Profile',
'http://activitystrea.ms/schema/1.0/photo' => 'Image',
'http://activitystrea.ms/schema/1.0/profile-photo' => 'Icon',
'http://activitystrea.ms/schema/1.0/event' => 'Event',
'http://activitystrea.ms/schema/1.0/wiki' => 'Document',
'http://purl.org/zot/activity/location' => 'Place',
'http://purl.org/zot/activity/chessgame' => 'Game',
'http://purl.org/zot/activity/tagterm' => 'zot:Tag',
'http://purl.org/zot/activity/thing' => 'Object',
'http://purl.org/zot/activity/file' => 'zot:File',
'http://purl.org/zot/activity/mood' => 'zot:Mood',
];
foreach($objs as $k => $v) {
if($obj === $v) {
return $k;
}
}
logger('Unmapped activity object: ' . $obj);
return 'Note';
}
static function activity_obj_mapper($obj) {
if(strpos($obj,'/') === false) {
@ -1236,6 +1303,20 @@ class Activity {
}
static function get_actor_bbmention($id) {
$x = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash where hubloc_hash = '%s' or hubloc_id_url = '%s' limit 1",
dbesc($id),
dbesc($id)
);
if($x) {
return sprintf('@[zrl=%s]%s[/zrl]',$x[0]['xchan_url'],$x[0]['xchan_name']);
}
return '@{' . $id . '}';
}
static function decode_note($act) {
@ -1320,13 +1401,17 @@ class Activity {
$s['summary'] = self::bb_content($content,'summary');
$s['body'] = ((self::bb_content($content,'bbcode') && (! $response_activity)) ? self::bb_content($content,'bbcode') : self::bb_content($content,'content'));
$s['verb'] = self::activity_mapper($act->type);
$s['verb'] = self::activity_decode_mapper($act->type);
if($act->type === 'Tombstone') {
$s['item_deleted'] = 1;
}
$s['obj_type'] = self::activity_obj_mapper($act->obj['type']);
$s['obj_type'] = self::activity_obj_decode_mapper($act->obj['type']);
if($s['obj_type'] === ACTIVITY_OBJ_NOTE && $s['mid'] !== $s['parent_mid']) {
$s['obj_type'] = ACTIVITY_OBJ_COMMENT;
}
$s['obj'] = $act->obj;
$instrument = $act->get_property_obj('instrument');

View File

@ -397,9 +397,7 @@ logger('4');
}
}
$closeness = get_pconfig($channel['channel_id'],'system','new_abook_closeness');
if($closeness === false)
$closeness = 80;
$closeness = get_pconfig($channel['channel_id'],'system','new_abook_closeness',80);
$y = abook_store_lowlevel(
[

View File

@ -124,6 +124,11 @@ class Channel extends Controller {
$mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : '');
if(strpos($mid,'b64.') === 0)
$decoded = @base64url_decode(substr($mid,4));
if($decoded)
$mid = $decoded;
$datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : '');
$datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : '');
@ -375,6 +380,9 @@ class Channel extends Controller {
if((! $update) && (! $load)) {
if($decoded)
$mid = 'b64.' . base64url_encode($mid);
// This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
// because browser prefetching might change it on us. We have to deliver it with the page.

View File

@ -101,7 +101,8 @@ class Connedit extends \Zotlabs\Web\Controller {
}
$profile_id = $_POST['profile_assign'];
$profile_id = ((array_key_exists('profile_assign',$_POST)) ? $_POST['profile_assign'] : $orig_record[0]['abook_profile']);
if($profile_id) {
$r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND uid = %d LIMIT 1",
dbesc($profile_id),
@ -113,18 +114,23 @@ class Connedit extends \Zotlabs\Web\Controller {
}
}
$abook_incl = escape_tags($_POST['abook_incl']);
$abook_excl = escape_tags($_POST['abook_excl']);
$abook_incl = ((array_key_exists('abook_incl',$_POST)) ? escape_tags($_POST['abook_incl']) : $orig_record[0]['abook_incl']);
$abook_excl = ((array_key_exists('abook_excl',$_POST)) ? escape_tags($_POST['abook_excl']) : $orig_record[0]['abook_excl']);
$hidden = intval($_POST['hidden']);
$priority = intval($_POST['poll']);
if($priority > 5 || $priority < 0)
$priority = 0;
if(! array_key_exists('closeness',$_POST)) {
$_POST['closeness'] = 80;
}
$closeness = intval($_POST['closeness']);
if($closeness < 0)
$closeness = 99;
if($closeness < 0 || $closeness > 99) {
$closeness = 80;
}
$rating = intval($_POST['rating']);
if($rating < (-10))
@ -231,6 +237,8 @@ class Connedit extends \Zotlabs\Web\Controller {
}
$abook_pending = (($new_friend) ? 0 : $orig_record[0]['abook_pending']);
$r = q("UPDATE abook SET abook_profile = '%s', abook_closeness = %d, abook_pending = %d,
abook_incl = '%s', abook_excl = '%s'
@ -733,9 +741,12 @@ class Connedit extends \Zotlabs\Web\Controller {
}
$slider_tpl = get_markup_template('contact_slider.tpl');
$slideval = intval($contact['abook_closeness']);
$slide = replace_macros($slider_tpl,array(
'$min' => 1,
'$val' => (($contact['abook_closeness']) ? $contact['abook_closeness'] : 99),
'$val' => $slideval,
'$labels' => $label_str,
));
}
@ -892,7 +903,7 @@ class Connedit extends \Zotlabs\Web\Controller {
'$inherited' => t('inherited'),
'$submit' => t('Submit'),
'$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['xchan_name']),
'$close' => $contact['abook_closeness'],
'$close' => (($contact['abook_closeness']) ? $contact['abook_closeness'] : 80),
'$them' => t('Their Settings'),
'$me' => t('My Settings'),
'$perms' => $perms,

View File

@ -251,6 +251,9 @@ class Like extends \Zotlabs\Web\Controller {
}
}
else {
if(! $observer)
killme();
// this is used to like an item or comment

View File

@ -441,13 +441,18 @@ class Setup extends \Zotlabs\Web\Controller {
require_once 'include/environment.php';
$help = '';
$mem_warning = '';
$result = getPhpiniUploadLimits();
if($result['post_max_size'] < 4194304 || $result['max_upload_filesize'] < 4194304) {
$mem_warning = '<strong>' .t('This is not sufficient to upload larger images or files. You should be able to upload at least 4 MB at once.') . '</strong>';
}
$help = sprintf(t('Your max allowed total upload size is set to %s. Maximum size of one file to upload is set to %s. You are allowed to upload up to %d files at once.'),
userReadableSize($result['post_max_size']),
userReadableSize($result['max_upload_filesize']),
$result['max_file_uploads']
);
$help .= $mem_warning;
$help .= '<br><br>' . t('You can adjust these settings in the server php.ini file.');
$this->check_add($checks, t('PHP upload limits'), true, false, $help);

12
Zotlabs/Update/_1230.php Normal file
View File

@ -0,0 +1,12 @@
<?php
namespace Zotlabs\Update;
class _1230 {
function run() {
q("update abook set abook_closeness = 80 where abook_closeness = 0 and abook_self = 0");
return UPDATE_SUCCESS;
}
}

View File

@ -53,7 +53,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '3.9.5' );
define ( 'ZOT_REVISION', '6.0a' );
define ( 'DB_UPDATE_VERSION', 1229 );
define ( 'DB_UPDATE_VERSION', 1230 );
define ( 'PROJECT_BASE', __DIR__ );

View File

@ -1021,7 +1021,7 @@ function bbcode($Text, $options = []) {
}
// Check for colored text
if (strpos($Text,'[/hl]') !== false) {
$Text = preg_replace("(\[hl\](.*?)\[\/hl\])ism", "<span style=\"background-color: yellow;\">$1</span>", $Text);
$Text = preg_replace("(\[hl\](.*?)\[\/hl\])ism", "<span class=\"default-highlight\">$1</span>", $Text);
$Text = preg_replace("(\[hl=(.*?)\](.*?)\[\/hl\])ism", "<span style=\"background-color: $1;\">$2</span>", $Text);
}

View File

@ -266,9 +266,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
}
}
else {
$closeness = get_pconfig($uid,'system','new_abook_closeness');
if($closeness === false)
$closeness = 80;
$closeness = get_pconfig($uid,'system','new_abook_closeness',80);
$r = abook_store_lowlevel(
[

View File

@ -120,6 +120,9 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
@curl_setopt($ch, CURLOPT_USERPWD, $opts['http_auth']);
}
if(array_key_exists('http_version',$opts))
@curl_setopt($ch,CURLOPT_HTTP_VERSION,$opts['http_version']);
if(x($opts,'cookiejar'))
@curl_setopt($ch, CURLOPT_COOKIEJAR, $opts['cookiejar']);
if(x($opts,'cookiefile'))
@ -157,7 +160,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
// Pull out multiple headers, e.g. proxy and continuation headers
// allow for HTTP/2.x without fixing code
while(preg_match('/^HTTP\/[1-3].+? [1-5][0-9][0-9]/',$base)) {
while(preg_match('/^HTTP\/[1-3](\.\d)? [1-5][0-9][0-9]/',$base)) {
$chunk = substr($base,0,strpos($base,"\r\n\r\n")+4);
$header .= $chunk;
$base = substr($base,strlen($chunk));
@ -290,6 +293,9 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) {
@curl_setopt($ch, CURLOPT_USERPWD, $opts['http_auth']);
}
if(array_key_exists('http_version',$opts))
@curl_setopt($ch,CURLOPT_HTTP_VERSION,$opts['http_version']);
if(x($opts,'cookiejar'))
@curl_setopt($ch, CURLOPT_COOKIEJAR, $opts['cookiejar']);
if(x($opts,'cookiefile'))
@ -323,7 +329,7 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) {
// Pull out multiple headers, e.g. proxy and continuation headers
// allow for HTTP/2.x without fixing code
while(preg_match('/^HTTP\/[1-3].+? [1-5][0-9][0-9]/',$base)) {
while(preg_match('/^HTTP\/[1-3](\.\d)? [1-5][0-9][0-9]/',$base)) {
$chunk = substr($base,0,strpos($base,"\r\n\r\n")+4);
$header .= $chunk;
$base = substr($base,strlen($chunk));

View File

@ -1232,6 +1232,7 @@ function zot_fetch($arr) {
$datatosend = json_encode(crypto_encapsulate(json_encode($data),$hub['hubloc_sitekey'], $algorithm));
$import = zot_zot($url,$datatosend);
}
else {
$algorithm = zot_best_algorithm($hub['site_crypto']);
@ -4913,6 +4914,7 @@ function zot_reply_pickup($data) {
dbesc($data['secret']),
dbesc($data['callback'])
);
if(! $r) {
$ret['message'] = 'nothing to pick up';
logger('mod_zot: pickup: ' . $ret['message']);

View File

@ -10,6 +10,7 @@ echo <<< EOT
util/addons list all # list all addons (*)= installed, (!)= disabled due to version compatibility
util/addons install foo # install addon named 'foo'
util/addons uninstall foo # uninstall addon named 'foo'
util/addons reinstall # reinstall all plugins
EOT;
}
@ -68,6 +69,20 @@ if($argc == 2 && $argv[1] === 'list') {
killme();
}
if($argc == 2 && $argv[1] === 'reinstall') {
require_once("include/plugin.php");
if($plugins) {
foreach($plugins as $p) {
if($p[1]) {
echo "Reinstall: ". $p[0] . "\n";
uninstall_plugin($p[0]);
install_plugin($p[0]);
}
}
}
killme();
}
if($argc == 3 && $argv[1] === 'list' && $argv[2] === 'all') {
if($plugins) {

View File

@ -1803,3 +1803,9 @@ dl.bb-dl > dd > li {
.hover-fx-show:hover .hover-fx-hide {
opacity: 1;
}
/* default highlighted text if not specified by schema: */
span.default-highlight {
background-color: yellow;
padding: 2px 4px;
}

View File

@ -322,20 +322,6 @@ a, a:visited, a:link, .fakelink, .fakelink:visited, .fakelink:link {
.text-dark {
color: #aaa !important;
}
a.text-dark:focus, a.text-dark:hover {
color: #ddd !important;
}
.badge-warning {
background-color: #ffc927;
}
.badge-warning a.text-dark {
color: #333 !important;
}
.badge-warning a.text-dark:focus, .badge-warning a.text-dark:hover {
color: red !important;
text-decoration: none;
}
.group-selected, .fileas-selected, .categories-selected, .search-selected, a.active {
color: #fff !important;
@ -492,10 +478,25 @@ pre {
background-color: #222;
}
/* change color of [hl] tag: */
div.wall-item-body span /*strong:only-of-type */{
color: #1212b6;
padding: 2px 3px;
/* font-weight: 500; */
white-space: nowrap;
/* category badge fix: */
a.text-dark:focus, a.text-dark:hover {
color: #ddd !important;
}
.badge-warning {
/* background-color: #ffc927; */
}
.badge-warning a.text-dark {
color: #333 !important;
}
.badge-warning a.text-dark:focus, .badge-warning a.text-dark:hover {
color: red !important;
text-decoration: none;
}
/* fix color for highlithed text */
span.default-highlight {
color: #333;
border-radius: 4px;
}