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

This commit is contained in:
nobody 2021-03-10 18:06:24 -08:00
commit 20ae97efd6
19 changed files with 97 additions and 79 deletions

View file

@ -64,11 +64,13 @@ class Poller {
// Only poll from those with suitable relationships
$abandon_sql = (($abandon_days)
? sprintf(" AND account_lastlog > %s - INTERVAL %s ", db_utcnow(), db_quoteinterval(intval($abandon_days).' DAY'))
: ''
);
// $abandon_sql = (($abandon_days)
// ? sprintf(" AND account_lastlog > %s - INTERVAL %s ", db_utcnow(), db_quoteinterval(intval($abandon_days).' DAY'))
// : ''
// );
$abandon_sql = EMPTY_STR;
$randfunc = db_getfunc('RAND');
$contacts = q("SELECT abook.abook_updated, abook.abook_connected, abook.abook_feed,

View file

@ -47,7 +47,7 @@ class Enotify {
dbesc($params['to_xchan'])
);
}
if ($x & $y) {
if ($x && $y) {
$sender = $x[0];
$recip = $y[0];
} else {

View file

@ -44,13 +44,13 @@ class Libprofile {
// Can the observer see our profile?
require_once('include/permissions.php');
if (! perm_is_allowed($channel['channel_id'],$observer['xchan_hash'],'view_profile')) {
if (! perm_is_allowed($channel['channel_id'],(($observer) ? $observer['xchan_hash'] : ''),'view_profile')) {
$can_view_profile = false;
}
if (! $profile) {
$r = q("SELECT abook_profile FROM abook WHERE abook_xchan = '%s' and abook_channel = '%d' limit 1",
dbesc($observer['xchan_hash']),
dbesc(($observer) ? $observer['xchan_hash'] : ''),
intval($channel['channel_id'])
);
if ($r)
@ -98,7 +98,7 @@ class Libprofile {
);
if ($q) {
$extra_fields = array();
$extra_fields = [];
$profile_fields_basic = get_profile_fields_basic();
$profile_fields_advanced = get_profile_fields_advanced();
@ -120,7 +120,7 @@ class Libprofile {
}
}
$p[0]['extra_fields'] = $extra_fields;
$p[0]['extra_fields'] = ((isset($extra_fields)) ? $extra_fields : []);
$z = q("select xchan_photo_date, xchan_addr from xchan where xchan_hash = '%s' limit 1",
dbesc($p[0]['channel_hash'])
@ -142,8 +142,12 @@ class Libprofile {
if ($p[0]['keywords']) {
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$p[0]['keywords']);
if (strlen($keywords) && $can_view_profile)
if (strlen($keywords) && $can_view_profile) {
if (! isset(App::$page['htmlhead'])) {
App::$page['htmlhead'] = EMPTY_STR;
}
App::$page['htmlhead'] .= '<meta name="keywords" content="' . htmlentities($keywords,ENT_COMPAT,'UTF-8') . '" />' . "\r\n" ;
}
}
App::$profile = $p[0];

View file

@ -755,7 +755,7 @@ class Libzot {
if (intval($r[0]['xchan_selfcensored']) != intval($arr['adult_content'])) {
$adult_changed = 1;
}
if (intval($r[0]['xchan_deleted']) != intval($arr['deleted'])) {
if (isset($arr['deleted']) && intval($r[0]['xchan_deleted']) != intval($arr['deleted'])) {
$deleted_changed = 1;
}
@ -3146,7 +3146,7 @@ class Libzot {
}
// This is a template for our follow url, %s will be replaced with a webbie
if (! $ret['follow_url']) {
if (! isset($ret['follow_url'])) {
$ret['follow_url'] = z_root() . '/follow?f=&url=%s';
}

View file

@ -2,6 +2,8 @@
namespace Zotlabs\Lib;
use App;
/**
* @brief Class for handling observer's config.
*
@ -39,8 +41,8 @@ class XConfig {
if(! $xchan)
return false;
if(! array_key_exists($xchan, \App::$config))
\App::$config[$xchan] = array();
if(! array_key_exists($xchan, App::$config))
App::$config[$xchan] = [];
$r = q("SELECT * FROM xconfig WHERE xchan = '%s'",
dbesc($xchan)
@ -50,11 +52,11 @@ class XConfig {
foreach($r as $rr) {
$k = $rr['k'];
$c = $rr['cat'];
if(! array_key_exists($c, \App::$config[$xchan])) {
\App::$config[$xchan][$c] = array();
\App::$config[$xchan][$c]['config_loaded'] = true;
if(! array_key_exists($c, App::$config[$xchan])) {
App::$config[$xchan][$c] = array();
App::$config[$xchan][$c]['config_loaded'] = true;
}
\App::$config[$xchan][$c][$k] = $rr['v'];
App::$config[$xchan][$c][$k] = $rr['v'];
}
}
}
@ -82,13 +84,13 @@ class XConfig {
if(! $xchan)
return $default;
if(! array_key_exists($xchan, \App::$config))
if(! array_key_exists($xchan, App::$config))
load_xconfig($xchan);
if((! array_key_exists($family, \App::$config[$xchan])) || (! array_key_exists($key, \App::$config[$xchan][$family])))
if((! array_key_exists($family, App::$config[$xchan])) || (! array_key_exists($key, App::$config[$xchan][$family])))
return $default;
return unserialise(\App::$config[$xchan][$family][$key]);
return unserialise(App::$config[$xchan][$family][$key]);
}
/**
@ -114,10 +116,10 @@ class XConfig {
$dbvalue = ((is_bool($dbvalue)) ? intval($dbvalue) : $dbvalue);
if(self::Get($xchan, $family, $key) === false) {
if(! array_key_exists($xchan, \App::$config))
\App::$config[$xchan] = array();
if(! array_key_exists($family, \App::$config[$xchan]))
\App::$config[$xchan][$family] = array();
if(! array_key_exists($xchan, App::$config))
App::$config[$xchan] = [];
if(! array_key_exists($family, App::$config[$xchan]))
App::$config[$xchan][$family] = [];
$ret = q("INSERT INTO xconfig ( xchan, cat, k, v ) VALUES ( '%s', '%s', '%s', '%s' )",
dbesc($xchan),
@ -135,7 +137,7 @@ class XConfig {
);
}
\App::$config[$xchan][$family][$key] = $value;
App::$config[$xchan][$family][$key] = $value;
if($ret)
return $value;
@ -159,8 +161,8 @@ class XConfig {
*/
static public function Delete($xchan, $family, $key) {
if(x(\App::$config[$xchan][$family], $key))
unset(\App::$config[$xchan][$family][$key]);
if(isset(App::$config[$xchan]) && isset(App::$config[$xchan][$family]) && isset(App::$config[$xchan][$family][$key]))
unset(App::$config[$xchan][$family][$key]);
$ret = q("DELETE FROM xconfig WHERE xchan = '%s' AND cat = '%s' AND k = '%s'",
dbesc($xchan),

View file

@ -342,7 +342,7 @@ class Channel extends Controller {
'title' => 'oembed'
]);
if ($update && $_SESSION['loadtime']) {
if ($update && isset($_SESSION['loadtime'])) {
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
}
if ($load) {
@ -524,13 +524,13 @@ class Channel extends Controller {
* comment likes could also get somewhat hairy.
*/
if ($parents_str) {
if (isset($parents_str) && $parents_str) {
$update_unseen = " AND ( id IN ( " . dbesc($parents_str) . " )";
$update_unseen .= " OR ( parent IN ( " . dbesc($parents_str) . " ) AND verb in ( '" . dbesc(ACTIVITY_LIKE) . "','" . dbesc(ACTIVITY_DISLIKE) . "' ))) ";
}
}
else {
if ($parents_str) {
if (isset($parents_str) && $parents_str) {
$update_unseen = " AND parent IN ( " . dbesc($parents_str) . " )";
}
}
@ -572,7 +572,7 @@ class Channel extends Controller {
// We reset $channel so that info can be obtained for unlogged visitors
$channel = channelx_by_n(App::$profile['profile_uid']);
if ($_REQUEST['mid']) {
if (isset($_REQUEST['mid']) && $_REQUEST['mid']) {
if(preg_match("/\[[zi]mg(.*?)\]([^\[]+)/is", $items[0]['body'], $matches)) {
$ogimage = $matches[2];

View file

@ -51,12 +51,13 @@ class Ping extends Controller {
$result['forums_sub'] = [];
$result['reports'] = 0;
if (! $_SESSION['static_loadtime']) {
if (! (isset($_SESSION['static_loadtime']) && $_SESSION['static_loadtime'])) {
$_SESSION['static_loadtime'] = datetime_convert();
}
$vnotify = false;
$evdays = 3;
$item_normal = item_normal();
if (local_channel()) {
@ -82,7 +83,7 @@ class Ping extends Controller {
* of the now current channel.
*/
$result['invalid'] = ((intval($_GET['uid'])) && (intval($_GET['uid']) != local_channel()) ? 1 : 0);
$result['invalid'] = ((isset($_GET['uid']) && intval($_GET['uid'])) && (intval($_GET['uid']) != local_channel()) ? 1 : 0);
/**
* Send all system messages (alerts) to the browser.

View file

@ -13,13 +13,13 @@ class HTTPHeaders {
if ($lines) {
foreach ($lines as $line) {
if (preg_match('/^\s+/',$line,$matches) && trim($line)) {
if ($this->in_progress['k']) {
if (isset($this->in_progress['k'])) {
$this->in_progress['v'] .= ' ' . ltrim($line);
continue;
}
}
else {
if ($this->in_progress['k']) {
if (isset($this->in_progress['k'])) {
$this->parsed[] = [ $this->in_progress['k'] => $this->in_progress['v'] ];
$this->in_progress = [];
}

View file

@ -165,13 +165,13 @@ class WebServer {
[
'rel' => 'jrd',
'type' => 'application/jrd+json',
'url' => z_root() . '/.well-known/webfinger?f=&resource=acct%3A' . argv(1) . '%40' . App::get_hostname()
'href' => z_root() . '/.well-known/webfinger?f=&resource=acct%3A' . argv(1) . '%40' . App::get_hostname()
],
[
'rel' => 'zot',
'type' => 'application/x-zot+json',
'url' => z_root() . '/channel/' . argv(1)
'href' => z_root() . '/channel/' . argv(1)
],
[

View file

@ -8,7 +8,7 @@ interface IHandler {
function Rekey($sender,$data,$hub);
function Refresh($sender,$recipients,$hub);
function Refresh($sender,$recipients,$hub,$force);
function Purge($sender,$recipients,$hub);

View file

@ -187,7 +187,11 @@ class Receiver {
break;
case 'refresh':
$this->response = $this->handler->Refresh($this->sender,$this->recipients,$this->hub);
$this->response = $this->handler->Refresh($this->sender,$this->recipients,$this->hub,false);
break;
case 'force_refresh':
$this->response = $this->handler->Refresh($this->sender,$this->recipients,$this->hub,true);
break;
case 'rekey':

View file

@ -15,8 +15,8 @@ class Zot6Handler implements IHandler {
return self::reply_rekey_request($sender,$data,$hub);
}
function Refresh($sender,$recipients,$hub) {
return self::reply_refresh($sender,$recipients,$hub);
function Refresh($sender,$recipients,$hub,$force) {
return self::reply_refresh($sender,$recipients,$hub,$force);
}
function Purge($sender,$recipients,$hub) {
@ -58,7 +58,7 @@ class Zot6Handler implements IHandler {
* @return json_return_and_die()
*/
static function reply_refresh($sender, $recipients,$hub) {
static function reply_refresh($sender, $recipients,$hub,$force) {
$ret = array('success' => false);
if($recipients) {
@ -72,13 +72,13 @@ class Zot6Handler implements IHandler {
dbesc($recip)
);
$x = Libzot::refresh( [ 'hubloc_id_url' => $hub['hubloc_id_url'] ], $r[0], (($msgtype === 'force_refresh') ? true : false));
$x = Libzot::refresh( [ 'hubloc_id_url' => $hub['hubloc_id_url'] ], $r[0], $force );
}
}
else {
// system wide refresh
$x = Libzot::refresh( [ 'hubloc_id_url' => $hub['hubloc_id_url'] ], null, (($msgtype === 'force_refresh') ? true : false));
$x = Libzot::refresh( [ 'hubloc_id_url' => $hub['hubloc_id_url'] ], null, $force );
}
$ret['success'] = true;

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', '21.03.08' );
define ( 'STD_VERSION', '21.03.11' );
define ( 'ZOT_REVISION', '6.0' );
define ( 'DB_UPDATE_VERSION', 1247 );
@ -1042,7 +1042,7 @@ class App {
if ($s) {
$s .= ',';
}
$s .= '<' . $y['url'] . '>; rel="' . $y['rel'] . '"; type="' . $y['type'] . '"';
$s .= '<' . $y['href'] . '>; rel="' . $y['rel'] . '"; type="' . $y['type'] . '"';
}
}
return $s;

View file

@ -599,11 +599,13 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa
$channel = App::get_channel();
$observer = App::get_observer();
if($update)
if($update && isset($_SESSION['return_url'])) {
$return_url = $_SESSION['return_url'];
else
}
else {
$return_url = $_SESSION['return_url'] = App::$query_string;
}
load_contact_links(local_channel());
$cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview);

View file

@ -46,7 +46,7 @@ function feature_level($feature,$def) {
function get_features($filtered = true, $level = (-1)) {
$account = \App::get_account();
$account = App::get_account();
$arr = [
@ -59,7 +59,7 @@ function get_features($filtered = true, $level = (-1)) {
'start_menu',
t('New Member Links'),
t('Display new member quick links menu'),
(($account['account_created'] > datetime_convert('','','now - 30 days')) ? true : false),
(($account && $account['account_created'] > datetime_convert('','','now - 30 days')) ? true : false),
get_config('feature_lock','start_menu'),
feature_level('start_menu',1),
],

View file

@ -118,7 +118,7 @@ function html2plain($html, $wraplength = 75, $compact = false)
@$doc->loadHTML($tmp_message);
$xpath = new DomXPath($doc);
$xpath = new DOMXPath($doc);
$list = $xpath->query("//pre");
foreach ($list as $node) {
$node->nodeValue = str_replace("\n", "\r", htmlspecialchars($node->nodeValue));

View file

@ -7,6 +7,9 @@ use Zotlabs\Lib\Apps;
use Zotlabs\Lib\Connect;
use Zotlabs\Lib\LibBlock;
use Zotlabs\Daemon\Run;
use Zotlabs\Access\PermissionRoles;
use Zotlabs\Access\PermissionLimits;
require_once('include/menu.php');

View file

@ -177,8 +177,8 @@ function oembed_fetch_url($embedurl){
logger('fetch failure: ' . $furl);
if($html_text) {
$dom = @DOMDocument::loadHTML($html_text);
if ($dom){
$dom = DOMDocument::loadHTML($html_text);
if ($dom) {
$xpath = new DOMXPath($dom);
$attr = "oembed";
$xattr = oe_build_xpath("class","oembed");
@ -418,30 +418,30 @@ function oe_get_inner_html( $node ) {
*/
function oembed_html2bbcode($text) {
// start parser only if 'oembed' is in text
if (strpos($text, "oembed")){
if (strpos($text, "oembed")) {
// convert non ascii chars to html entities
$html_text = mb_convert_encoding($text, 'HTML-ENTITIES', mb_detect_encoding($text));
// If it doesn't parse at all, just return the text.
$dom = @DOMDocument::loadHTML($html_text);
if(! $dom)
return $text;
$xpath = new DOMXPath($dom);
$attr = "oembed";
$dom = DOMDocument::loadHTML($html_text);
if ($dom) {
$xpath = new DOMXPath($dom);
$attr = "oembed";
$xattr = oe_build_xpath("class","oembed");
$entries = $xpath->query("//span[$xattr]");
$xattr = oe_build_xpath("class","oembed");
$entries = $xpath->query("//span[$xattr]");
$xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed");
foreach($entries as $e) {
$href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue;
if(!is_null($href)) $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
$xattr = "@rel='oembed'";//oe_build_xpath("rel","oembed");
foreach($entries as $e) {
$href = $xpath->evaluate("a[$xattr]/@href", $e)->item(0)->nodeValue;
if(!is_null($href)) $e->parentNode->replaceChild(new DOMText("[embed]".$href."[/embed]"), $e);
}
return oe_get_inner_html( $dom->getElementsByTagName("body")->item(0) );
}
return oe_get_inner_html( $dom->getElementsByTagName("body")->item(0) );
} else {
return $text;
}
}
return $text;
}

View file

@ -421,7 +421,7 @@ function poco() {
$system_mode = true;
}
$format = (($_REQUEST['format']) ? $_REQUEST['format'] : 'json');
$format = ((isset($_REQUEST['format']) && $_REQUEST['format']) ? $_REQUEST['format'] : 'json');
$justme = false;
@ -456,15 +456,15 @@ function poco() {
}
if($justme)
if(isset($justme) && $justme)
$sql_extra = " and abook_self = 1 ";
else
$sql_extra = " and abook_self = 0 ";
if($cid)
if(isset($cid) && $cid)
$sql_extra = sprintf(" and abook_id = %d and abook_archived = 0 and abook_hidden = 0 and abook_pending = 0 ",intval($cid));
if($system_mode) {
if(isset($system_mode) && $system_mode) {
$r = q("SELECT count(*) as total from abook where abook_self = 1
and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') ");
}
@ -482,11 +482,11 @@ function poco() {
else
$totalResults = 0;
$startIndex = intval($_GET['startIndex']);
if(! $startIndex)
$startIndex = ((isset($_GET['startIndex'])) ? intval($_GET['startIndex']) : 0);
if($startIndex < 0)
$startIndex = 0;
$itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults);
$itemsPerPage = ((isset($_GET['count']) && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults);
if($system_mode) {
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_self = 1