Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge

This commit is contained in:
zotlabs 2017-12-12 11:54:26 -08:00
commit 215d615fc3
19 changed files with 199 additions and 38 deletions

View file

@ -39,7 +39,7 @@ class Cdav extends \Zotlabs\Web\Controller {
$sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]);
if($sigblock) {
$keyId = $sigblock['keyId'];
$keyId = str_replace('acct:','',$sigblock['keyId']);
if($keyId) {
$r = q("select * from hubloc where hubloc_addr = '%s' limit 1",
dbesc($keyId)

View file

@ -48,7 +48,7 @@ class Dav extends \Zotlabs\Web\Controller {
$sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]);
if($sigblock) {
$keyId = $sigblock['keyId'];
$keyId = str_replace('acct:','',$sigblock['keyId']);
if($keyId) {
$r = q("select * from hubloc where hubloc_addr = '%s' limit 1",
dbesc($keyId)

View file

@ -1140,6 +1140,28 @@ class Item extends \Zotlabs\Web\Controller {
return $ret;
}
// auto-upgrade beginner (techlevel 0) accounts - if they have at least two friends and ten posts
// and have uploaded something (like a profile photo), promote them to level 1.
$a = q("select account_id, account_level from account where account_id = (select channel_account_id from channel where channel_id = %d limit 1)",
intval($channel_id)
);
if((! intval($a[0]['account_level'])) && intval($r[0]['total']) > 10) {
$x = q("select count(abook_id) as total from abook where abook_channel = %d",
intval($channel_id)
);
if($x && intval($x[0]['total']) > 2) {
$y = q("select count(id) as total from attach where uid = %d",
intval($channel_id)
);
if($y && intval($y[0]['total']) > 1) {
q("update account set account_level = 1 where account_id = %d limit 1",
intval($a[0]['account_id'])
);
}
}
}
if (!$iswebpage) {
$max = engr_units_to_bytes(service_class_fetch($channel_id,'total_items'));
if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) {

View file

@ -534,7 +534,12 @@ class Comanche {
require_once('widget/' . $clsname . '/' . $clsname . '.php');
elseif(file_exists('Zotlabs/Widget/' . $clsname . '.php'))
require_once('Zotlabs/Widget/' . $clsname . '.php');
else {
$pth = theme_include($clsname . '.php');
if($pth) {
require_once($pth);
}
}
if(class_exists($nsname)) {
$x = new $nsname;
$f = 'widget';
@ -550,12 +555,14 @@ class Comanche {
require_once('widget/' . trim($name) . '.php');
elseif(file_exists('widget/' . trim($name) . '/' . trim($name) . '.php'))
require_once('widget/' . trim($name) . '/' . trim($name) . '.php');
}
else {
if(! function_exists($func)) {
$theme_widget = $func . '.php';
if((! function_exists($func)) && theme_include($theme_widget))
if(theme_include($theme_widget)) {
require_once(theme_include($theme_widget));
}
}
}
if(function_exists($func))
return $func($vars);

View file

@ -144,7 +144,7 @@ class Notifications {
$o = replace_macros(get_markup_template('notifications_widget.tpl'), array(
'$module' => \App::$module,
'$notifications' => $notifications,
'$loading' => t('Loading...')
'$loading' => t('Loading')
));
return $o;

View file

@ -52,6 +52,7 @@ function api_login(&$a){
/* Signature authentication */
if(array_key_exists($head,$_SERVER) && substr(trim($_SERVER[$head]),0,9) === 'Signature') {
if($head !== 'HTTP_AUTHORIZATION') {
$_SERVER['HTTP_AUTHORIZATION'] = $_SERVER[$head];
continue;
@ -59,7 +60,7 @@ function api_login(&$a){
$sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]);
if($sigblock) {
$keyId = $sigblock['keyId'];
$keyId = str_replace('acct:','',$sigblock['keyId']);
if($keyId) {
$r = q("select * from hubloc where hubloc_addr = '%s' limit 1",
dbesc($keyId)

View file

@ -150,7 +150,11 @@
$start = ((array_key_exists('start',$_REQUEST)) ? intval($_REQUEST['start']) : 0);
$records = ((array_key_exists('records',$_REQUEST)) ? intval($_REQUEST['records']) : 0);
$x = attach_list_files(api_user(),get_observer_hash(),$hash,$filename,$filetype,'created asc',$start,$records);
$since = ((array_key_exists('since',$_REQUEST)) ? datetime_convert(date_default_timezone_get(),'UTC',$_REQUEST['since']) : NULL_DATE);
$until = ((array_key_exists('until',$_REQUEST)) ? datetime_convert(date_default_timezone_get(),'UTC',$_REQUEST['until']) : datetime_convert());
$x = attach_list_files(api_user(),get_observer_hash(),$hash,$filename,$filetype,'created asc',$start,$records, $since, $until);
if($start || $records) {
$x['start'] = $start;
$x['records'] = count($x['results']);
@ -226,7 +230,10 @@
if(! $_REQUEST['file_id'])
return false;
$ret = attach_export_data(api_user(),$_REQUEST['file_id']);
$channel = channelx_by_n(api_user());
$ret = attach_export_data($channel,$_REQUEST['file_id']);
if($ret) {
json_return_and_die($ret);
}

View file

@ -189,7 +189,7 @@ function attach_count_files($channel_id, $observer, $hash = '', $filename = '',
* * \e array|boolean \b results array with results, or false
* * \e string \b message with error messages if any
*/
function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $filetype = '', $orderby = 'created desc', $start = 0, $entries = 0) {
function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $filetype = '', $orderby = 'created desc', $start = 0, $entries = 0, $since = '', $until = '') {
$ret = array('success' => false);
@ -198,6 +198,7 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
return $ret;
}
require_once('include/security.php');
$sql_extra = permissions_sql($channel_id);
@ -213,14 +214,22 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
if($entries)
$limit = " limit " . intval($start) . ", " . intval($entries) . " ";
// Retrieve all columns except 'data'
if(! $since)
$since = NULL_DATE;
if(! $until)
$until = datetime_convert();
$sql_extra .= " and created >= '" . dbesc($since) . "' and created <= '" . dbesc($until) . "' ";
// Retrieve all columns except 'content'
$r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, folder, os_path, display_path, os_storage, is_dir, is_photo, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d $sql_extra ORDER BY $orderby $limit",
intval($channel_id)
);
$ret['success'] = ((is_array($r)) ? true : false);
$ret['results'] = ((is_array($r)) ? $r : false);
$ret['results'] = ((is_array($r)) ? $r : []);
return $ret;
}
@ -2052,6 +2061,9 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
if($attach_ptr['is_photo']) {
// This query could potentially result in a few megabytes of data use.
$r = q("select * from photo where resource_id = '%s' and uid = %d order by imgscale asc",
dbesc($resource_id),
intval($channel['channel_id'])
@ -2063,6 +2075,17 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
$ret['photo'] = $r;
}
// This query can be used instead in memory starved environments. There will be a corresponding
// performance hit during sync because the data will need to be fetched over the network.
// $r = q("select aid,uid,xchan,resource_id,created,edited,title,description,album,filename,mimetype,height,width,filesize,imgscale,photo_usage,profile,is_nsfw,os_storage,display_path,photo_flags,allow_cid,allow_gid,deny_cid,deny_gid from photo where resource_id = '%s' and uid = %d order by imgscale asc",
// dbesc($resource_id),
// intval($channel['channel_id'])
// );
// if($r) {
// $ret['photo'] = $r;
// }
$r = q("select * from item where resource_id = '%s' and resource_type = 'photo' and uid = %d ",
dbesc($resource_id),
intval($channel['channel_id'])

View file

@ -711,7 +711,7 @@ function parseIdentityAwareHTML($Text) {
function bbcode($Text, $options = []) {
$preserve_nl = ((array_key_exists('preserve_nl',$options)) ? $options['preserve_nl'] : false);
$tryoembed = ((array_key_exists('tryomebed',$options)) ? $options['tryoembed'] : true);
$tryoembed = ((array_key_exists('tryoembed',$options)) ? $options['tryoembed'] : true);
$cache = ((array_key_exists('cache',$options)) ? $options['cache'] : false);

View file

@ -325,7 +325,7 @@ function create_identity($arr) {
'hubloc_guid_sig' => $sig,
'hubloc_hash' => $hash,
'hubloc_addr' => channel_reddress($ret['channel']),
'hubloc_primary' => $primary,
'hubloc_primary' => intval($primary),
'hubloc_url' => z_root(),
'hubloc_url_sig' => base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey'])),
'hubloc_host' => App::get_hostname(),

View file

@ -1263,10 +1263,43 @@ function sync_files($channel, $files) {
);
}
if($p['imgscale'] === 0 && $p['os_storage'])
if(intval($p['imgscale']) === 0 && $p['os_storage'])
$p['content'] = $store_path;
else
$p['content'] = base64_decode($p['content']);
$p['content'] = (($p['content'])? base64_decode($p['content']) : '');
if(intval($p['imgscale']) && (! $p['content'])) {
$time = datetime_convert();
$parr = array('hash' => $channel['channel_hash'],
'time' => $time,
'resource' => $att['hash'],
'revision' => 0,
'signature' => base64url_encode(rsa_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey'])),
'resolution' => $p['imgscale']
);
$stored_image = $newfname . '-' . intval($p['imgscale']);
$fp = fopen($stored_image,'w');
if(! $fp) {
logger('failed to open storage file.',LOGGER_NORMAL,LOG_ERR);
continue;
}
$redirects = 0;
$headers = [];
$headers['Accept'] = 'application/x-zot+json' ;
$headers['Sigtoken'] = random_string();
$headers = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'], 'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,true,'sha512');
$x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]);
fclose($fp);
$p['content'] = file_get_contents($stored_image);
unlink($stored_image);
}
if(!isset($p['display_path']))
$p['display_path'] = '';

View file

@ -2694,8 +2694,8 @@ function tag_deliver($uid, $item_id) {
}
if((! $mention) && (! $union)) {
logger('No mention for ' . $u[0]['channel_name'] . ' and no union.');
if(! $mention) {
logger('No mention for ' . $u[0]['channel_name']);
continue;
}
@ -2714,6 +2714,18 @@ function tag_deliver($uid, $item_id) {
}
}
if($union) {
if(intval($item['item_wall']) || intval($item['item_origin']) || (! intval($item['item_thread_top'])) || ($item['id'] != $item['parent'])) {
logger('Item was local or a comment. rejected.');
return;
}
logger('Creating second delivery chain.');
start_delivery_chain($u[0],$item,$item_id,null);
}
}
/**

View file

@ -313,7 +313,7 @@ EOT;
'$sitelocation' => $sitelocation,
'$nav' => $x['nav'],
'$banner' => $banner,
'$emptynotifications' => t('Loading...'),
'$emptynotifications' => t('Loading'),
'$userinfo' => $x['usermenu'],
'$localuser' => local_channel(),
'$is_owner' => $is_owner,

View file

@ -178,9 +178,11 @@ function poco_load($xchan = '', $url = null) {
);
if(! $r) {
q("insert into xlink ( xlink_xchan, xlink_link, xlink_updated, xlink_static ) values ( '%s', '%s', '%s', 0 ) ",
q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', 0 ) ",
dbesc($xchan),
dbesc($hash),
intval(0),
dbesc(''),
dbesc(datetime_convert())
);
}

View file

@ -2552,7 +2552,7 @@ function sync_locations($sender, $arr, $absolute = false) {
'hubloc_hash' => $sender['hash'],
'hubloc_addr' => $location['address'],
'hubloc_network' => 'zot',
'hubloc_primary' => $location['primary'],
'hubloc_primary' => intval($location['primary']),
'hubloc_url' => $location['url'],
'hubloc_url_sig' => $location['url_sig'],
'hubloc_host' => $location['host'],

View file

@ -306,6 +306,49 @@ nav {
/* spinner end */
/* jumping dots */
.jumping-dots span {
position: relative;
bottom: 0px;
transition-timing-function: ease-in-out;
-webkit-animation: jump 1s infinite;
animation: jump 1s infinite;
}
.jumping-dots .dot-1 {
-webkit-animation-delay: 200ms;
animation-delay: 200ms;
}
.jumping-dots .dot-2 {
-webkit-animation-delay: 400ms;
animation-delay: 400ms;
}
.jumping-dots .dot-3 {
-webkit-animation-delay: 600ms;
animation-delay: 600ms;
}
@-webkit-keyframes jump {
0% {
bottom: 0px;
}
20% {
bottom: 3px;
}
40% {
bottom: 0px;
}
}
@keyframes jump {
0% {bottom: 0px;}
20% {bottom: 3px;}
40% {bottom: 0px;}
}
/* jumping dots end */
/* footer */
footer {
@ -1759,3 +1802,12 @@ dl.bb-dl > dd > li {
overflow: hidden;
}
#cloud-index {
width: 100%;
table-layout: fixed;
}
#cloud-index td {
width: auto;
overflow: hidden;
}

View file

@ -39,12 +39,12 @@
{{else}}
<table id="cloud-index">
<tr>
<th width="1%"></th>
<th width="92%">{{$name}}</th>
<th width="1%"></th><th width="1%"></th><th width="1%"></th><th width="1%"></th>
<th width="4%"></th>
<th width="47%">{{$name}}</th>
<th width="4%"></th><th width="4%"></th><th width="4%"></th><th width="4%"></th>
<th width="1%">{{*{{$type}}*}}</th>
<th width="1%" class="d-none d-md-table-cell">{{$size}}</th>
<th width="1%" class="d-none d-md-table-cell">{{$lastmod}}</th>
<th width="10%" class="d-none d-md-table-cell">{{$size}}</th>
<th width="22%" class="d-none d-md-table-cell">{{$lastmod}}</th>
</tr>
{{if $parentpath}}
<tr>

View file

@ -113,7 +113,7 @@
<div id="navbar-network-menu" class="dropdown-menu" rel="network">
<a class="dropdown-item" id="nav-network-see-all" href="{{$nav.network.all.0}}">{{$nav.network.all.1}}</a>
<a class="dropdown-item" id="nav-network-mark-all" href="#" onclick="markRead('network'); return false;">{{$nav.network.mark.1}}</a>
{{$emptynotifications}}
{{$emptynotifications}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
</div>
</li>
{{/if}}
@ -126,7 +126,7 @@
<div id="navbar-home-menu" class="dropdown-menu" rel="home">
<a class="dropdown-item" id="nav-home-see-all" href="{{$nav.home.all.0}}">{{$nav.home.all.1}}</a>
<a class="dropdown-item" id="nav-home-mark-all" href="#" onclick="markRead('home'); return false;">{{$nav.home.mark.1}}</a>
{{$emptynotifications}}
{{$emptynotifications}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
</div>
</li>
{{/if}}
@ -139,7 +139,7 @@
<div id="navbar-mail-menu" class="dropdown-menu" rel="messages">
<a class="dropdown-item" id="nav-messages-see-all" href="{{$nav.messages.all.0}}">{{$nav.messages.all.1}}</a>
<a class="dropdown-item" id="nav-messages-mark-all" href="#" onclick="markRead('messages'); return false;">{{$nav.messages.mark.1}}</a>
{{$emptynotifications}}
{{$emptynotifications}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
</div>
</li>
{{/if}}
@ -152,7 +152,7 @@
<div id="navbar-all_events-menu" class="dropdown-menu" rel="all_events">
<a class="dropdown-item" id="nav-all_events-see-all" href="{{$nav.all_events.all.0}}">{{$nav.all_events.all.1}}</a>
<a class="dropdown-item" id="nav-all_events-mark-all" href="#" onclick="markRead('all_events'); return false;">{{$nav.all_events.mark.1}}</a>
{{$emptynotifications}}
{{$emptynotifications}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
</div>
</li>
{{/if}}
@ -164,7 +164,7 @@
</a>
<div id="navbar-intros-menu" class="dropdown-menu" rel="intros">
<a class="dropdown-item" id="nav-intros-see-all" href="{{$nav.intros.all.0}}">{{$nav.intros.all.1}}</a>
{{$emptynotifications}}
{{$emptynotifications}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
</div>
</li>
{{/if}}
@ -177,7 +177,7 @@
<div id="navbar-notify-menu" class="dropdown-menu" rel="notify">
<a class="dropdown-item" id="nav-notify-see-all" href="{{$nav.notifications.all.0}}">{{$nav.notifications.all.1}}</a>
<a class="dropdown-item" id="nav-notify-mark-all" href="#" onclick="markRead('notify'); return false;">{{$nav.notifications.mark.1}}</a>
{{$emptynotifications}}
{{$emptynotifications}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
</div>
</li>
{{/if}}

View file

@ -43,7 +43,9 @@
e.preventDefault();
if(! page_load) {
if($(this).parent().attr('id') !== 'nav-pubs-menu')
$(this).fadeOut();
getData(b64mid, notify_id);
}
@ -110,7 +112,7 @@
<i class="fa fa-fw fa-filter"></i> {{$notification.filter.label}}
</div>
{{/if}}
{{$loading}}
{{$loading}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span>
</div>
</div>
{{/foreach}}