Merge branch 'dev' of /home/macgirvin/z into dev

This commit is contained in:
nobody 2020-10-27 18:04:54 -07:00
commit a3ba276728
20 changed files with 65 additions and 443 deletions

View file

@ -1,14 +0,0 @@
<?php /** @file */
namespace Zotlabs\Daemon;
require_once('include/socgraph.php');
class Cli_suggest {
static public function run($argc,$argv) {
update_suggestions();
}
}

View file

@ -171,12 +171,6 @@ class Cron {
}
}
// pull in some public posts
$disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false;
if(! $disable_discover_tab)
Run::Summon(array('Externals'));
$generation = 0;
$restart = false;

View file

@ -70,21 +70,8 @@ class Cron_daily {
// expire any expired accounts
downgrade_accounts();
// If this is a directory server, request a sync with an upstream
// directory at least once a day, up to once every poll interval.
// Pull remote changes and push local changes.
// potential issue: how do we keep from creating an endless update loop?
// $dirmode = get_config('system','directory_mode');
// if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) {
// Libzotdir::sync_directories($dirmode);
// }
Run::Summon(array('Expire'));
// Run::Summon(array('Cli_suggest'));
// remove xchan photos that were stored in the DB ine earlier versions
// and were migrated to filesystem storage.

View file

@ -43,11 +43,6 @@ class Cron_weekly {
db_utcnow(), db_quoteinterval('14 DAY')
);
$dirmode = intval(get_config('system','directory_mode'));
if($dirmode === DIRECTORY_MODE_SECONDARY || $dirmode === DIRECTORY_MODE_PRIMARY) {
logger('regdir: ' . print_r(z_fetch_url(get_directory_primary() . '/regdir?f=&url=' . urlencode(z_root()) . '&realm=' . urlencode(get_directory_realm())),true));
}
// Check for dead sites
Run::Summon(array('Checksites'));

View file

@ -4,6 +4,22 @@ namespace Zotlabs\Daemon;
use Zotlabs\Lib\Libzot;
/*
This file is being kept for archival reference at this time.
It is not currently referenced elsewhere. Its purpose is to grab
some public posts from random zot sites by polling occasionally
and asking for a 'zotfeed'. This is generally stored in the
'public stream' which is owned by the system channel on this site.
If somebody wishes to bring back this functionality, it should be
modified to read public outboxes in ActivityStreams format.
*/
class Externals {

View file

@ -11,62 +11,6 @@ require_once('include/permissions.php');
class Libzotdir {
/**
* @brief
*
* @param int $dirmode
* @return array
*/
static function find_upstream_directory($dirmode) {
global $DIRECTORY_FALLBACK_SERVERS;
$preferred = get_config('system','directory_server');
// Thwart attempts to use a private directory
if(($preferred) && ($preferred != z_root())) {
$r = q("select * from site where site_url = '%s' limit 1",
dbesc($preferred)
);
if(($r) && ($r[0]['site_flags'] & DIRECTORY_MODE_STANDALONE)) {
$preferred = '';
}
}
if (! $preferred) {
/*
* No directory has yet been set. For most sites, pick one at random
* from our list of directory servers. However, if we're a directory
* server ourself, point at the local instance
* We will then set this value so this should only ever happen once.
* Ideally there will be an admin setting to change to a different
* directory server if you don't like our choice or if circumstances change.
*/
$dirmode = intval(get_config('system','directory_mode'));
if ($dirmode == DIRECTORY_MODE_NORMAL) {
$toss = mt_rand(0,count($DIRECTORY_FALLBACK_SERVERS));
$preferred = $DIRECTORY_FALLBACK_SERVERS[$toss];
if(! $preferred) {
$preferred = DIRECTORY_FALLBACK_MASTER;
}
set_config('system','directory_server',$preferred);
}
else {
set_config('system','directory_server',z_root());
}
}
if($preferred) {
return [ 'url' => $preferred ];
}
else {
return [];
}
}
/**
* Directories may come and go over time. We will need to check that our
@ -174,132 +118,6 @@ class Libzotdir {
return $o;
}
/**
* @brief Checks the directory mode of this hub.
*
* Checks the directory mode of this hub to see if it is some form of directory server. If it is,
* get the directory realm of this hub. Fetch a list of all other directory servers in this realm and request
* a directory sync packet. This will contain both directory updates and new ratings. Store these all in the DB.
* In the case of updates, we will query each of them asynchronously from a poller task. Ratings are stored
* directly if the rater's signature matches.
*
* @param int $dirmode;
*/
static function sync_directories($dirmode) {
// !!!!!!!!!
return;
// !!!!!!!!!
if ($dirmode == DIRECTORY_MODE_STANDALONE || $dirmode == DIRECTORY_MODE_NORMAL)
return;
$realm = get_directory_realm();
if ($realm == DIRECTORY_REALM) {
$r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and site_type = %d and ( site_realm = '%s' or site_realm = '') ",
intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY),
dbesc(z_root()),
intval(SITE_TYPE_ZOT),
dbesc($realm)
);
}
else {
$r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and site_realm like '%s' and site_type = %d ",
intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY),
dbesc(z_root()),
dbesc(protect_sprintf('%' . $realm . '%')),
intval(SITE_TYPE_ZOT)
);
}
// If there are no directory servers, setup the fallback master
/** @FIXME What to do if we're in a different realm? */
if ((! $r) && (z_root() != DIRECTORY_FALLBACK_MASTER)) {
$x = site_store_lowlevel(
[
'site_url' => DIRECTORY_FALLBACK_MASTER,
'site_flags' => DIRECTORY_MODE_PRIMARY,
'site_update' => NULL_DATE,
'site_directory' => DIRECTORY_FALLBACK_MASTER . '/dirsearch',
'site_realm' => DIRECTORY_REALM,
'site_valid' => 1,
]
);
$r = q("select * from site where site_flags in (%d, %d) and site_url != '%s' and site_type = %d ",
intval(DIRECTORY_MODE_PRIMARY),
intval(DIRECTORY_MODE_SECONDARY),
dbesc(z_root()),
intval(SITE_TYPE_ZOT)
);
}
if (! $r)
return;
foreach ($r as $rr) {
if (! $rr['site_directory'])
continue;
logger('sync directories: ' . $rr['site_directory']);
// for brand new directory servers, only load the last couple of days.
// It will take about a month for a new directory to obtain the full current repertoire of channels.
$token = get_config('system','realm_token');
$syncdate = (($rr['site_sync'] <= NULL_DATE) ? datetime_convert('UTC','UTC','now - 2 days') : $rr['site_sync']);
$x = z_fetch_url($rr['site_directory'] . '?f=&sync=' . urlencode($syncdate) . (($token) ? '&t=' . $token : ''));
if (! $x['success'])
continue;
$j = json_decode($x['body'],true);
if (!($j['transactions']) || ($j['ratings']))
continue;
q("update site set site_sync = '%s' where site_url = '%s'",
dbesc(datetime_convert()),
dbesc($rr['site_url'])
);
logger('sync_directories: ' . $rr['site_url'] . ': ' . print_r($j,true), LOGGER_DATA);
if (is_array($j['transactions']) && count($j['transactions'])) {
foreach ($j['transactions'] as $t) {
$r = q("select * from updates where ud_guid = '%s' limit 1",
dbesc($t['transaction_id'])
);
if ($r) {
continue;
}
$ud_flags = 0;
if (is_array($t['flags']) && in_array('deleted',$t['flags']))
$ud_flags |= UPDATE_FLAGS_DELETED;
if (is_array($t['flags']) && in_array('forced',$t['flags']))
$ud_flags |= UPDATE_FLAGS_FORCED;
if (is_array($t['flags']) && in_array('censored',$t['flags']))
$ud_flags |= UPDATE_FLAGS_CENSORED;
$z = q("insert into updates ( ud_hash, ud_guid, ud_date, ud_flags, ud_addr )
values ( '%s', '%s', '%s', %d, '%s' ) ",
dbesc($t['hash']),
dbesc($t['transaction_id']),
dbesc($t['timestamp']),
intval($ud_flags),
dbesc($t['address'])
);
}
}
}
}
/**
* @brief
*

View file

@ -232,6 +232,7 @@ class Queue {
$channel = channelx_by_n($outq['outq_channel']);
$retries = 0;
$m = parse_url($outq['outq_posturl']);
$headers = [];
$headers['Content-Type'] = 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ;
@ -239,6 +240,7 @@ class Queue {
logger('ActivityPub send: ' . jindent($ret), LOGGER_DATA);
$headers['Date'] = datetime_convert('UTC','UTC', 'now', 'D, d M Y H:i:s \\G\\M\\T');
$headers['Digest'] = HTTPSig::generate_digest_header($ret);
$headers['Host'] = $m['host'];
$headers['(request-target)'] = 'post ' . get_request_string($outq['outq_posturl']);
$xhead = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel));

View file

@ -33,6 +33,13 @@ class System {
return z_root() . '/images/' . PLATFORM_NAME . '-64.png';
}
static public function get_project_favicon() {
if(is_array(App::$config) && is_array(App::$config['system']) && array_key_exists('favicon',App::$config['system'])) {
return App::$config['system']['favicon'];
}
return z_root() . '/images/' . PLATFORM_NAME . '.ico';
}
static public function get_project_version() {
if(is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['hide_version'])
@ -62,6 +69,11 @@ class System {
return self::get_project_icon();
}
static public function get_site_favicon() {
if(is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['site_favicon_url'])
return App::$config['system']['site_favicon_url'];
return self::get_project_favicon();
}
static public function get_project_link() {
if(is_array(App::$config) && is_array(App::$config['system']) && App::$config['system']['project_link'])

View file

@ -1,30 +1,28 @@
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
class Oexchange extends \Zotlabs\Web\Controller {
class Oexchange extends Controller {
function init() {
if((argc() > 1) && (argv(1) === 'xrd')) {
$tpl = get_markup_template('oexchange_xrd.tpl');
$o = replace_macros($tpl, array('$base' => z_root()));
echo $o;
if ((argc() > 1) && (argv(1) === 'xrd')) {
echo replace_macros(get_markup_template('oexchange_xrd.tpl'), [ '$base' => z_root() ] );
killme();
}
}
function get() {
if(! local_channel()) {
if(remote_channel()) {
$observer = \App::get_observer();
if($observer && $observer['xchan_url']) {
if (! local_channel()) {
if (remote_channel()) {
$observer = App::get_observer();
if ($observer && $observer['xchan_url']) {
$parsed = @parse_url($observer['xchan_url']);
if(! $parsed) {
notice( t('Unable to find your hub.') . EOL);
if (! $parsed) {
notice( t('Unable to find your site.') . EOL);
return;
}
$url = $parsed['scheme'] . '://' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '');
@ -37,7 +35,7 @@ class Oexchange extends \Zotlabs\Web\Controller {
return login(false);
}
if((argc() > 1) && argv(1) === 'done') {
if ((argc() > 1) && argv(1) === 'done') {
info( t('Post successful.') . EOL);
return;
}
@ -51,15 +49,17 @@ class Oexchange extends \Zotlabs\Web\Controller {
$tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags']))
? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
$ret = z_fetch_url(z_root() . '/urlinfo?f=&url=' . $url . $title . $description . $tags);
$ret = z_fetch_url(z_root() . '/linkinfo?f=&url=' . $url . $title . $description . $tags);
if($ret['success'])
if ($ret['success']) {
$s = $ret['body'];
}
if(! strlen($s))
if (! strlen($s)) {
return;
}
$post = array();
$post = [];
$post['profile_uid'] = local_channel();
$post['return'] = '/oexchange/done' ;

View file

@ -1,102 +0,0 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Zotfinger;
use Zotlabs\Web\Controller;
/**
* With args, register a directory server for this realm.
* With no args, return a JSON array of directory servers for this realm.
*
* @FIXME Not yet implemented: Some realms may require authentication to join their realm.
* The RED_GLOBAL realm does not require authentication.
* We would then need a flag in the site table to indicate that they've been
* validated by the PRIMARY directory for that realm. Sites claiming to be PRIMARY
* but are not the realm PRIMARY will be marked invalid.
*
* @param App &$a
*/
class Regdir extends Controller {
function init() {
$result = array('success' => false);
$url = $_REQUEST['url'];
$access_token = $_REQUEST['t'];
$valid = 0;
// we probably don't need the realm as we will find out in the probe.
// What we may want to do is throw an error if you're trying to register in a different realm
// so this configuration issue can be discovered.
$realm = $_REQUEST['realm'];
if(! $realm)
$realm = DIRECTORY_REALM;
if($realm === DIRECTORY_REALM) {
$valid = 1;
} else {
$token = get_config('system','realm_token');
if($token && $access_token != $token) {
$result['message'] = 'This realm requires an access token';
return;
}
$valid = 1;
}
$dirmode = intval(get_config('system','directory_mode'));
if ($dirmode == DIRECTORY_MODE_NORMAL) {
$ret['message'] = t('This site is not a directory server');
json_return_and_die($ret);
}
$m = null;
if ($url) {
$m = parse_url($url);
if ((! $m) || (! z_dns_check($m['host']))) {
$result['message'] = 'unparseable url';
json_return_and_die($result);
}
$j = Zotfinger::exec($url);
if($j) {
$result['success'] = true;
}
else {
$valid = 0;
}
q("update site set site_valid = %d where site_url = '%s'",
intval($valid),
strtolower($url)
);
json_return_and_die($result);
}
else {
if ($dirmode == DIRECTORY_MODE_STANDALONE) {
$r = array(array('site_url' => z_root()));
} else {
$r = q("select site_url from site where site_flags in ( 1, 2 ) and site_realm = '%s' and site_type = %d and site_valid = 1 ",
dbesc(get_directory_realm()),
intval(SITE_TYPE_ZOT)
);
}
if ($r) {
$result['success'] = true;
$result['directories'] = array();
foreach ($r as $rr)
$result['directories'][] = $rr['site_url'];
json_return_and_die($result);
}
}
json_return_and_die($result);
}
}

View file

@ -131,7 +131,7 @@ class Channel {
PermissionLimits::Set(local_channel(),'post_comments',$post_comments);
$publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
$username = ((x($_POST,'username')) ? notags(trim($_POST['username'])) : '');
$username = ((x($_POST,'username')) ? escape_tags(trim($_POST['username'])) : '');
$timezone = ((x($_POST,'timezone_select')) ? notags(trim($_POST['timezone_select'])) : '');
$defloc = ((x($_POST,'defloc')) ? notags(trim($_POST['defloc'])) : '');
$openid = ((x($_POST,'openid_url')) ? notags(trim($_POST['openid_url'])) : '');

View file

@ -16,7 +16,7 @@ use Zotlabs\Daemon\Run;
* @brief This file defines some global constants and includes the central App class.
*/
define ( 'STD_VERSION', '20.10.26' );
define ( 'STD_VERSION', '20.10.27' );
define ( 'ZOT_REVISION', '6.0' );
define ( 'DB_UPDATE_VERSION', 1243 );
@ -83,10 +83,6 @@ define ( 'DIRECTORY_MODE_STANDALONE', 0x0100); // A detached (off the grid) hub
// point to go out and find the rest of the world.
define ( 'DIRECTORY_REALM', 'ZAP');
define ( 'DIRECTORY_FALLBACK_MASTER', 'https://zap.macgirvin.com');
$DIRECTORY_FALLBACK_SERVERS = [ ];
/**
*
@ -2365,26 +2361,6 @@ function get_directory_realm() {
return DIRECTORY_REALM;
}
/**
* @brief Return the primary directory server.
*
* @return string
*/
function get_directory_primary() {
$dirmode = intval(get_config('system','directory_mode'));
if($dirmode == DIRECTORY_MODE_STANDALONE || $dirmode == DIRECTORY_MODE_PRIMARY) {
return z_root();
}
if($x = get_config('system', 'directory_primary'))
return $x;
return DIRECTORY_FALLBACK_MASTER;
}
/**
* @brief Return relative date of last completed poller execution.
*

BIN
images/misty.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/osada.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
images/redmatrix.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -26,7 +26,7 @@
inkscape:pageshadow="2"
inkscape:zoom="1.979899"
inkscape:cx="35.049163"
inkscape:cy="27.799654"
inkscape:cy="88.408806"
inkscape:document-units="px"
inkscape:current-layer="g2985"
showgrid="false"
@ -34,11 +34,11 @@
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1848"
inkscape:window-height="1016"
inkscape:window-x="72"
inkscape:window-y="27"
inkscape:window-maximized="1" />
inkscape:window-width="1521"
inkscape:window-height="830"
inkscape:window-x="192"
inkscape:window-y="212"
inkscape:window-maximized="0" />
<metadata
id="metadata3058">
<rdf:RDF>
@ -61,21 +61,20 @@
id="g2985"
transform="matrix(4.7619048,0,0,4.7619048,-1370.7143,-2042.6958)">
<ellipse
style="fill:#c60032;fill-opacity:1;stroke-width:0.90943448;stroke-miterlimit:4;stroke-dasharray:none;stroke:#000000;stroke-opacity:1"
style="fill:#c60032;fill-opacity:1;stroke:#000000;stroke-width:0.8202405;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path3028-4-5-3"
transform="matrix(0.94,0,0,0.9075862,191.00001,171.28726)"
cx="195.74467"
cy="397.84091"
rx="22.340425"
ry="23.138298" />
cx="375.05301"
cy="532.36218"
rx="20.532581"
ry="20.479477" />
<g
id="text3003-0-4-0"
style="font-style:normal;font-weight:normal;font-size:46px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:0.83999999;stroke-miterlimit:4;stroke-dasharray:none"
style="font-style:normal;font-weight:normal;font-size:46px;line-height:125%;font-family:Sans;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.83999997;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
transform="translate(52.138256,-208.57143)">
<path
inkscape:connector-curvature="0"
id="path3008"
style="font-variant:normal;font-weight:bold;font-stretch:normal;font-size:45.09999847px;font-family:generic;-inkscape-font-specification:'generic Bold';fill:#ffffff;stroke:#000000;stroke-opacity:1;stroke-width:0.83999999;stroke-miterlimit:4;stroke-dasharray:none"
style="font-variant:normal;font-weight:bold;font-stretch:normal;font-size:45.09999847px;font-family:generic;-inkscape-font-specification:'generic Bold';fill:#ffffff;stroke:#000000;stroke-width:0.83999997;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 322.85053,756.03406 h 4.7355 l 1.3079,-7.9827 h 4.8708 v -4.4649 h -4.1492 l 1.0373,-6.4944 h 4.9159 v -4.4649 h -4.1492 l 1.1275,-7.0356 h -4.7355 l -1.1275,7.0356 h -5.1865 l 1.1275,-7.0356 h -4.7355 l -1.1275,7.0356 h -5.0963 v 4.4649 h 4.3296 l -1.0373,6.4944 h -5.0963 v 4.4649 h 4.3747 l -1.3079,7.9827 h 4.7355 l 1.3079,-7.9827 h 5.1865 l -1.3079,7.9827 m 2.0295,-12.4476 h -5.1865 l 1.0373,-6.4944 h 5.1865 l -1.0373,6.4944" />
</g>
</g>

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
images/zap.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -398,67 +398,6 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) {
}
// This function fetches a number of sitenames from the directory and searches them
// for channels that have opted-in to be "default" suggestions to new channels which
// have no connections.
// @TODO: We currently use a hardwired path of '/poco'. This should be configurable
// and based on discovered endpoint locations.
function update_suggestions() {
// this function is no longer used
// remove any existing entries it once created
//
$r = q("delete from xlink where xlink_xchan = '' and xlink_static = 0",
db_utcnow(), db_quoteinterval('7 DAY')
);
// !!!!!
return;
// !!!!!
$dirmode = get_config('system', 'directory_mode', DIRECTORY_MODE_NORMAL);
if ($dirmode == DIRECTORY_MODE_STANDALONE) {
poco_load('', z_root() . '/poco');
return;
}
if ($dirmode == DIRECTORY_MODE_PRIMARY) {
$url = z_root() . '/sitelist';
}
else {
$directory = Libzotdir::find_upstream_directory($dirmode);
$url = $directory['url'] . '/sitelist';
}
if (! $url)
return;
$ret = z_fetch_url($url);
if ($ret['success']) {
// We will grab fresh data once a day via the poller. Remove anything over a week old because
// the targets may have changed their preferences and don't want to be suggested - and they
// may have simply gone away.
$r = q("delete from xlink where xlink_xchan = '' and xlink_updated < %s - INTERVAL %s and xlink_static = 0",
db_utcnow(), db_quoteinterval('7 DAY')
);
$j = json_decode($ret['body'],true);
if ($j && $j['success']) {
foreach ($j['entries'] as $host) {
poco_load('',$host['url'] . '/poco');
}
}
}
}
function poco() {
$system_mode = false;