diff options
author | zotlabs <mike@macgirvin.com> | 2017-09-14 15:02:18 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-09-14 15:02:18 -0700 |
commit | b1876ac14fc4f9b7e39989ef7e69c8135a25c13f (patch) | |
tree | 9fd6068adf3735f5f391b4c5cf6df1b091ac8e51 | |
parent | e8e61c83d572b41664a1066d60f2f78ef596183e (diff) | |
parent | 46b6415f5fddcea5aa7c4c55842405b68a7ccd6a (diff) | |
download | volse-hubzilla-b1876ac14fc4f9b7e39989ef7e69c8135a25c13f.tar.gz volse-hubzilla-b1876ac14fc4f9b7e39989ef7e69c8135a25c13f.tar.bz2 volse-hubzilla-b1876ac14fc4f9b7e39989ef7e69c8135a25c13f.zip |
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
-rw-r--r-- | Zotlabs/Daemon/Deliver.php | 31 | ||||
-rw-r--r-- | Zotlabs/Daemon/Notifier.php | 2 | ||||
-rw-r--r-- | Zotlabs/Lib/NativeWikiPage.php | 7 | ||||
-rw-r--r-- | Zotlabs/Module/Post.php | 9 | ||||
-rw-r--r-- | Zotlabs/Module/Wiki.php | 19 | ||||
-rw-r--r-- | Zotlabs/Web/HTTPSig.php | 7 | ||||
-rw-r--r-- | Zotlabs/Widget/Wiki_pages.php | 2 | ||||
-rwxr-xr-x | boot.php | 51 | ||||
-rw-r--r-- | include/connections.php | 15 | ||||
-rw-r--r-- | include/zot.php | 51 | ||||
-rw-r--r-- | view/tpl/wiki.tpl | 2 |
11 files changed, 131 insertions, 65 deletions
diff --git a/Zotlabs/Daemon/Deliver.php b/Zotlabs/Daemon/Deliver.php index dbc311cf5..7c1ff717f 100644 --- a/Zotlabs/Daemon/Deliver.php +++ b/Zotlabs/Daemon/Deliver.php @@ -53,22 +53,29 @@ class Deliver { remove_queue_item($r[0]['outq_hash']); if($dresult && is_array($dresult)) { - foreach($dresult as $xx) { - if(is_array($xx) && array_key_exists('message_id',$xx)) { - if(delivery_report_is_storable($xx)) { - q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", - dbesc($xx['message_id']), - dbesc($xx['location']), - dbesc($xx['recipient']), - dbesc($xx['status']), - dbesc(datetime_convert($xx['date'])), - dbesc($xx['sender']) - ); + if(array_key_exists('iv',$dresult)) { + $dresult = json_decode(crypto_unencapsulate($dresult,get_config('system','prvkey')),true); + } + if(! $dresult) { + logger('dreport decryption failure'); + } + else { + foreach($dresult as $xx) { + if(is_array($xx) && array_key_exists('message_id',$xx)) { + if(delivery_report_is_storable($xx)) { + q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", + dbesc($xx['message_id']), + dbesc($xx['location']), + dbesc($xx['recipient']), + dbesc($xx['status']), + dbesc(datetime_convert($xx['date'])), + dbesc($xx['sender']) + ); + } } } } } - q("delete from dreport where dreport_queue = '%s'", dbesc($argv[$x]) ); diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index e8cd4dac8..0e8c99572 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -492,7 +492,7 @@ class Notifier { // Now we have collected recipients (except for external mentions, FIXME) // Let's reduce this to a set of hubs; checking that the site is not dead. - $r = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . implode(',',$recipients) . ") + $r = q("select hubloc.*, site.site_crypto, site.site_flags from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . implode(',',$recipients) . ") and hubloc_error = 0 and hubloc_deleted = 0 and ( site_dead = 0 OR site_dead is null ) " ); diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index ffd5aec31..558a70a3c 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -607,10 +607,13 @@ class NativeWikiPage { } static public function get_file_ext($arr) { - if($arr['mimeType'] == 'text/bbcode') + if($arr['mimeType'] === 'text/bbcode') return '.bb'; - else + elseif($arr['mimeType'] === 'text/markdown') return '.md'; + elseif($arr['mimeType'] === 'text/plain') + return '.txt'; + } // This function is derived from diff --git a/Zotlabs/Module/Post.php b/Zotlabs/Module/Post.php index c78484a45..dba26075f 100644 --- a/Zotlabs/Module/Post.php +++ b/Zotlabs/Module/Post.php @@ -19,12 +19,19 @@ class Post extends \Zotlabs\Web\Controller { function init() { if(array_key_exists('auth', $_REQUEST)) { $x = new \Zotlabs\Zot\Auth($_REQUEST); - exit; } } function post() { + + + + + + + + $z = new \Zotlabs\Zot\Receiver($_REQUEST['data'], get_config('system', 'prvkey'), new \Zotlabs\Zot\ZotHandler()); // notreached; diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index df747a07a..1eb600f51 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -170,7 +170,7 @@ class Wiki extends \Zotlabs\Web\Controller { '$create' => t('Create New'), '$submit' => t('Submit'), '$wikiName' => array('wikiName', t('Wiki name')), - '$mimeType' => array('mimeType', t('Content type'), '', '', ['text/markdown' => 'Markdown', 'text/bbcode' => 'BB Code']), + '$mimeType' => array('mimeType', t('Content type'), '', '', ['text/markdown' => t('Markdown'), 'text/bbcode' => t('BBcode'), 'text/plain' => t('Text') ]), '$name' => t('Name'), '$type' => t('Type'), '$lockstate' => $x['lockstate'], @@ -262,6 +262,8 @@ class Wiki extends \Zotlabs\Web\Controller { $mimeType = $p['pageMimeType']; $sampleContent = (($mimeType == 'text/bbcode') ? '[h3]' . t('New page') . '[/h3]' : '### ' . t('New page')); + if($mimeType === 'text/plain') + $sampleContent = t('New page'); $content = (($p['content'] == '') ? $sampleContent : $p['content']); @@ -269,7 +271,10 @@ class Wiki extends \Zotlabs\Web\Controller { if($mimeType == 'text/bbcode') { $renderedContent = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))), argv(0) . '/' . argv(1) . '/' . $wikiUrlName); } - else { + elseif($mimeType === 'text/plain') { + $renderedContent = str_replace(["\n",' ',"\t"],[EOL,' ',' '],htmlentities($content,ENT_COMPAT,'UTF-8',false)); + } + elseif($mimeType === 'text/markdown') { $content = Zlib\MarkdownSoap::unescape($content); $html = Zlib\NativeWikiPage::generate_toc(zidify_text(MarkdownExtra::defaultTransform(Zlib\NativeWikiPage::bbcode($content)))); $renderedContent = Zlib\NativeWikiPage::convert_links($html, argv(0) . '/' . argv(1) . '/' . $wikiUrlName); @@ -323,7 +328,7 @@ class Wiki extends \Zotlabs\Web\Controller { '$modalerroralbum' => t('Error getting album'), )); - if($p['pageMimeType'] != 'text/bbcode') + if($p['pageMimeType'] === 'text/markdown') head_add_js('/library/ace/ace.js'); // Ace Code Editor return $o; @@ -354,11 +359,10 @@ class Wiki extends \Zotlabs\Web\Controller { $mimeType = $_POST['mimetype']; - if($mimeType == 'text/bbcode') { + if($mimeType === 'text/bbcode') { $html = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))),$wikiURL); } - else { - + elseif($mimeType === 'text/markdown') { $bb = Zlib\NativeWikiPage::bbcode($content); $x = new ZLib\MarkdownSoap($bb); $md = $x->clean(); @@ -367,6 +371,9 @@ class Wiki extends \Zotlabs\Web\Controller { $html = Zlib\NativeWikiPage::generate_toc(zidify_text($html)); $html = Zlib\NativeWikiPage::convert_links($html,$wikiURL); } + elseif($mimeType === 'text/plain') { + $html = str_replace(["\n",' ',"\t"],[EOL,' ',' '],htmlentities($content,ENT_COMPAT,'UTF-8',false)); + } json_return_and_die(array('html' => $html, 'success' => true)); } diff --git a/Zotlabs/Web/HTTPSig.php b/Zotlabs/Web/HTTPSig.php index fee8aaa41..6526fa7c8 100644 --- a/Zotlabs/Web/HTTPSig.php +++ b/Zotlabs/Web/HTTPSig.php @@ -95,13 +95,18 @@ class HTTPSig { $algorithm = 'sha512'; } + if($key && function_exists($key)) { + $result['signer'] = $sig_block['keyId']; + $key = $key($sig_block['keyId']); + } + if(! $key) { $result['signer'] = $sig_block['keyId']; $key = self::get_activitypub_key($sig_block['keyId']); } if(! $key) - return null; + return $result; $x = rsa_verify($signed_data,$sig_block['signature'],$key,$algorithm); diff --git a/Zotlabs/Widget/Wiki_pages.php b/Zotlabs/Widget/Wiki_pages.php index ac6549ffd..3999d9858 100644 --- a/Zotlabs/Widget/Wiki_pages.php +++ b/Zotlabs/Widget/Wiki_pages.php @@ -50,7 +50,7 @@ class Wiki_pages { '$canadd' => $can_create, '$candel' => $can_delete, '$addnew' => t('Add new page'), - '$mimetype' => mimetype_select(0,$p['mimeType'], [ 'text/markdown','text/bbcode' ]), + '$mimetype' => mimetype_select(0,$w['mimeType'], [ 'text/markdown','text/bbcode', 'text/plain' ]), '$pageName' => array('pageName', t('Page name')), '$refresh' => $arr['refresh'] )); @@ -72,6 +72,8 @@ define ( 'DIRECTORY_MODE_PRIMARY', 0x0001); // There can only be *one* prima define ( 'DIRECTORY_MODE_SECONDARY', 0x0002); // All other mirror directory servers define ( 'DIRECTORY_MODE_STANDALONE', 0x0100); // A detached (off the grid) hub with itself as directory server. +define ( 'ZOT6_COMPLIANT', 0x1000); + // We will look for upstream directories whenever me make contact // with other sites, but if this is a new installation and isn't // a standalone hub, we need to seed the service with a starting @@ -80,7 +82,7 @@ define ( 'DIRECTORY_MODE_STANDALONE', 0x0100); // A detached (off the grid) hub define ( 'DIRECTORY_REALM', 'RED_GLOBAL'); define ( 'DIRECTORY_FALLBACK_MASTER', 'https://gravizot.de'); -$DIRECTORY_FALLBACK_SERVERS = array( +$DIRECTORY_FALLBACK_SERVERS = array( 'https://hubzilla.zottel.net', 'https://my.federated.social', //'https://hubzilla.nl', @@ -205,7 +207,7 @@ define ( 'PAGE_PREMIUM', 0x0010 ); define ( 'PAGE_ADULT', 0x0020 ); define ( 'PAGE_CENSORED', 0x0040 ); // Site admin has blocked this channel from appearing in casual search results and site feeds define ( 'PAGE_SYSTEM', 0x1000 ); -define ( 'PAGE_HUBADMIN', 0x2000 ); // set this to indicate a preferred admin channel rather than the +define ( 'PAGE_HUBADMIN', 0x2000 ); // set this to indicate a preferred admin channel rather than the // default channel of any accounts with the admin role. define ( 'PAGE_REMOVED', 0x8000 ); @@ -606,13 +608,15 @@ function sys_boot() { if(! defined('DEFAULT_PLATFORM_ICON')) { - define( 'DEFAULT_PLATFORM_ICON', '/images/rm-32.png' ); + define( 'DEFAULT_PLATFORM_ICON', '/images/hz-32.png' ); } if(! defined('DEFAULT_NOTIFY_ICON')) { - define( 'DEFAULT_NOTIFY_ICON', '/images/rm-32.png' ); + define( 'DEFAULT_NOTIFY_ICON', '/images/hz-white-64.png' ); } + App::head_set_icon(DEFAULT_PLATFORM_ICON); + /* * Try to open the database; */ @@ -943,8 +947,6 @@ class App { self::$is_mobile = $mobile_detect->isMobile(); self::$is_tablet = $mobile_detect->isTablet(); - self::head_set_icon(DEFAULT_PLATFORM_ICON); - /* * register template engines */ @@ -1120,7 +1122,7 @@ class App { * being first */ - self::$page['htmlhead'] = replace_macros(get_markup_template('head.tpl'), + self::$page['htmlhead'] = replace_macros(get_markup_template('head.tpl'), [ '$preload_images' => $preload_images, '$user_scalable' => $user_scalable, @@ -1152,7 +1154,7 @@ class App { public static function register_template_engine($class, $name = '') { if(! $name) { $v = get_class_vars($class); - if(x($v, "name")) { + if(x($v, "name")) { $name = $v['name']; } } @@ -1194,7 +1196,7 @@ class App { } } - echo "template engine <tt>$template_engine</tt> is not registered!\n"; + echo "template engine <tt>$template_engine</tt> is not registered!\n"; killme(); } @@ -1321,7 +1323,7 @@ function os_mkdir($path, $mode = 0777, $recursive = false) { $oldumask = @umask(0); $result = @mkdir($path, $mode, $recursive); @umask($oldumask); - return $result; + return $result; } @@ -1671,8 +1673,8 @@ function get_account_id() { * @return int|bool channel_id or false */ function local_channel() { - if(session_id() - && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] + if(session_id() + && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] && array_key_exists('uid',$_SESSION) && intval($_SESSION['uid'])) return intval($_SESSION['uid']); @@ -1692,8 +1694,8 @@ function local_channel() { * @return string|bool visitor_id or false */ function remote_channel() { - if(session_id() - && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] + if(session_id() + && array_key_exists('authenticated',$_SESSION) && $_SESSION['authenticated'] && array_key_exists('visitor_id',$_SESSION) && $_SESSION['visitor_id']) return $_SESSION['visitor_id']; @@ -1712,8 +1714,8 @@ function notice($s) { if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array(); - // ignore duplicated error messages which haven't yet been displayed - // - typically seen as multiple 'permission denied' messages + // ignore duplicated error messages which haven't yet been displayed + // - typically seen as multiple 'permission denied' messages // as a result of auto-reloading a protected page with &JS=1 if(in_array($s,$_SESSION['sysmsg'])) @@ -1735,7 +1737,7 @@ function notice($s) { function info($s) { if(! session_id()) return; - if(! x($_SESSION, 'sysmsg_info')) + if(! x($_SESSION, 'sysmsg_info')) $_SESSION['sysmsg_info'] = array(); if(App::$interactive) $_SESSION['sysmsg_info'][] = $s; @@ -1811,7 +1813,7 @@ function proc_run(){ proc_close(proc_open($cmd, array(), $foo)); } else { - if(get_config('system','use_proc_open')) + if(get_config('system','use_proc_open')) proc_close(proc_open($cmdline ." &", array(), $foo)); else exec($cmdline . ' > /dev/null &'); @@ -1824,8 +1826,8 @@ function proc_run(){ * @return bool true if we run on M$ Windows * * It's possible you might be able to run on WAMP or XAMPP, and this - * has been accomplished, but is not officially supported. Good luck. - * + * has been accomplished, but is not officially supported. Good luck. + * */ function is_windows() { return ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false); @@ -2174,7 +2176,7 @@ function construct_page() { if(App::$config['system']['x_security_headers']) { header("X-Frame-Options: SAMEORIGIN"); header("X-Xss-Protection: 1; mode=block;"); - header("X-Content-Type-Options: nosniff"); + header("X-Content-Type-Options: nosniff"); } if(App::$config['system']['public_key_pins']) { @@ -2287,7 +2289,7 @@ function z_check_cert() { cert_bad_email(); } } -} +} /** @@ -2396,7 +2398,7 @@ function check_for_new_perms() { function check_cron_broken() { $d = get_config('system','lastcron'); - + if((! $d) || ($d < datetime_convert('UTC','UTC','now - 4 hours'))) { Zotlabs\Daemon\Master::Summon(array('Cron')); set_config('system','lastcron',datetime_convert()); @@ -2441,9 +2443,8 @@ function check_cron_broken() { function observer_prohibited($allow_account = false) { - if($allow_account) + if($allow_account) return (((get_config('system','block_public')) && (! get_account_id()) && (! remote_channel())) ? true : false ); return (((get_config('system','block_public')) && (! local_channel()) && (! remote_channel())) ? true : false ); } - diff --git a/include/connections.php b/include/connections.php index a9f906649..0cf4cdc5a 100644 --- a/include/connections.php +++ b/include/connections.php @@ -629,13 +629,20 @@ function get_vcard_array($vc,$id) { if($vc->ADR) { foreach($vc->ADR as $adr) { $type = (($adr['TYPE']) ? vcard_translate_type((string)$adr['TYPE']) : ''); - $adrs[] = [ + $entry = [ 'type' => $type, 'address' => $adr->getParts() ]; - $last_entry = end($adrs); - if($last_entry && is_array($adrs[$last_entry]['address'])) - array_walk($adrs[$last_entry]['address'],'array_escape_tags'); + + if(is_array($entry['address'])) { + array_walk($entry['address'],'array_escape_tags'); + } + else { + $entry['address'] = (string) escape_tags($entry['address']); + } + + $adrs[] = $entry; + } } diff --git a/include/zot.php b/include/zot.php index cb213eff3..c8321c2ae 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2875,8 +2875,13 @@ function import_site($arr, $pubkey) { $site_directory = DIRECTORY_MODE_NORMAL; } + $site_flags = $site_directory; + + if(array_key_exists('zot',$arr) && ((float) $arr['zot']) >= 6.0) + $site_flags = ($site_flags & ZOT6_COMPLIANT); + if($exists) { - if(($siterecord['site_flags'] != $site_directory) + if(($siterecord['site_flags'] != $site_flags) || ($siterecord['site_access'] != $access_policy) || ($siterecord['site_directory'] != $directory_url) || ($siterecord['site_sellpage'] != $sellpage) @@ -2896,7 +2901,7 @@ function import_site($arr, $pubkey) { $r = q("update site set site_dead = 0, site_location = '%s', site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s', site_sellpage = '%s', site_realm = '%s', site_type = %d, site_project = '%s', site_version = '%s', site_crypto = '%s' where site_url = '%s'", dbesc($site_location), - intval($site_directory), + intval($site_flags), intval($access_policy), dbesc($directory_url), intval($register_policy), @@ -2929,7 +2934,7 @@ function import_site($arr, $pubkey) { 'site_location' => $site_location, 'site_url' => $url, 'site_access' => intval($access_policy), - 'site_flags' => intval($site_directory), + 'site_flags' => intval($site_flags), 'site_update' => datetime_convert(), 'site_directory' => $directory_url, 'site_register' => intval($register_policy), @@ -4161,10 +4166,31 @@ function zotinfo($arr) { if($x) $ret['locations'] = $x; - $ret['site'] = array(); + $ret['site'] = zot_site_info($e); + + + check_zotinfo($e,$x,$ret); + + + call_hooks('zot_finger',$ret); + return($ret); + +} + + +function zot_site_info($channel = null) { + + $signing_key = (($channel) ? $channel['channel_prvkey'] : get_config('system','prvkey')); + $sig_method = get_config('system','signature_algorithm','sha256'); + + $ret = []; + $ret['site'] = []; $ret['site']['url'] = z_root(); - $ret['site']['url_sig'] = base64url_encode(rsa_sign(z_root(),$e['channel_prvkey'],$sig_method)); - $ret['site']['zot_auth'] = z_root() . '/magic'; + $ret['site']['url_sig'] = base64url_encode(rsa_sign(z_root(),$signing_key,$sig_method)); + $ret['site']['post'] = z_root() . '/post'; + $ret['site']['openWebAuth'] = z_root() . '/owa'; + $ret['site']['authRedirect'] = z_root() . '/magic'; + $ret['site']['key'] = get_config('system','pubkey'); $dirmode = get_config('system','directory_mode'); if(($dirmode === false) || ($dirmode == DIRECTORY_MODE_NORMAL)) @@ -4182,6 +4208,12 @@ function zotinfo($arr) { $ret['site']['encryption'] = crypto_methods(); $ret['site']['signing'] = signing_methods(); + if(function_exists('zotvi_load')) { + $ret['site']['zot'] = '6.0'; + } + else { + $ret['site']['zot'] = ZOT_REVISION; + } // hide detailed site information if you're off the grid @@ -4234,15 +4266,10 @@ function zotinfo($arr) { } - check_zotinfo($e,$x,$ret); - - - call_hooks('zot_finger',$ret); - return($ret); + return $ret['site']; } - function check_zotinfo($channel,$locations,&$ret) { diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl index 681269002..7995b7bb1 100644 --- a/view/tpl/wiki.tpl +++ b/view/tpl/wiki.tpl @@ -455,8 +455,10 @@ window.editor.on("input", function() { $('#save-page').removeClass('disabled'); }); + {{if $mimeType == 'text/bbcode'}} window.editor.bbco_autocomplete('bbcode'); {{/if}} + {{/if}} }); $(window).resize(function () { |