aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/attach.php6
-rw-r--r--include/import.php45
-rw-r--r--include/network.php37
-rw-r--r--include/text.php2
-rw-r--r--include/zot.php4
5 files changed, 54 insertions, 40 deletions
diff --git a/include/attach.php b/include/attach.php
index 80f71b9ea..c9649a4ce 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -2807,6 +2807,12 @@ function save_chunk($channel,$start,$end,$len) {
$new_path = $new_base . '/' . $_FILES['files']['name'];
+ if(file_exists($new_path) && intval($start) === 0) {
+ $result['partial'] = true;
+ $result['length'] = intval(filesize($new_path));
+ return $result;
+ }
+
if(! file_exists($new_path)) {
rename($tmp_path,$new_path);
}
diff --git a/include/import.php b/include/import.php
index 910cb8be7..82c23e116 100644
--- a/include/import.php
+++ b/include/import.php
@@ -210,17 +210,24 @@ function import_hublocs($channel, $hublocs, $seize, $moving = false) {
if($channel && $hublocs) {
foreach($hublocs as $hubloc) {
- $hash = make_xchan_hash($hubloc['hubloc_guid'],$hubloc['hubloc_guid_sig']);
- if($hubloc['hubloc_network'] === 'zot' && $hash !== $hubloc['hubloc_hash']) {
- logger('forged hubloc: ' . print_r($hubloc,true));
- continue;
- }
+ // verify the hash. We can only do this if we already stored the xchan corresponding to this hubloc
+ // as we need the public key from there
- if(! array_key_exists('hubloc_primary',$hubloc)) {
- $hubloc['hubloc_primary'] = (($hubloc['hubloc_flags'] & 0x0001) ? 1 : 0);
- $hubloc['hubloc_orphancheck'] = (($hubloc['hubloc_flags'] & 0x0004) ? 1 : 0);
- $hubloc['hubloc_error'] = (($hubloc['hubloc_status'] & 0x0003) ? 1 : 0);
- $hubloc['hubloc_deleted'] = (($hubloc['hubloc_flags'] & 0x1000) ? 1 : 0);
+ if ($hubloc['hubloc_network'] === 'zot6') {
+ $x = q("select xchan_pubkey from xchan where xchan_guid = '%s' and xchan_hash = '%s'",
+ dbesc($hubloc['hubloc_guid']),
+ dbesc($hubloc['hubloc_hash'])
+ );
+
+ if (! $x) {
+ logger('hubloc could not be verified. ' . print_r($hubloc,true));
+ continue;
+ }
+ $hash = Libzot::make_xchan_hash($hubloc['hubloc_guid'],$x[0]['xchan_pubkey']);
+ if ($hash !== $hubloc['hubloc_hash']) {
+ logger('forged hubloc: ' . print_r($hubloc,true));
+ continue;
+ }
}
if($moving && $hubloc['hubloc_hash'] === $channel['channel_hash'] && $hubloc['hubloc_url'] !== z_root()) {
@@ -228,17 +235,17 @@ function import_hublocs($channel, $hublocs, $seize, $moving = false) {
}
$arr = [
- 'guid' => $hubloc['hubloc_guid'],
- 'guid_sig' => $hubloc['hubloc_guid_sig'],
- 'url' => $hubloc['hubloc_url'],
- 'url_sig' => $hubloc['hubloc_url_sig'],
- 'sitekey' => ((array_key_exists('hubloc_sitekey',$hubloc)) ? $hubloc['hubloc_sitekey'] : '')
+ 'id' => $hubloc['hubloc_guid'],
+ 'id_sig' => $hubloc['hubloc_guid_sig'],
+ 'location' => $hubloc['hubloc_url'],
+ 'location_sig' => $hubloc['hubloc_url_sig']
];
- if(($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize))
+ if (($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize)) {
$hubloc['hubloc_primary'] = 0;
+ }
- if(($x = zot_gethub($arr,false)) === false) {
+ if (($x = Libzot::gethub($arr,false)) === false) {
unset($hubloc['hubloc_id']);
hubloc_store_lowlevel($hubloc);
}
@@ -1333,7 +1340,7 @@ function sync_files($channel, $files) {
'time' => $time,
'resource' => $att['hash'],
'revision' => 0,
- 'signature' => base64url_encode(rsa_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey']))
+ 'signature' => Libzot::sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey'])
);
$store_path = $newfname;
@@ -1419,7 +1426,7 @@ function sync_files($channel, $files) {
'time' => $time,
'resource' => $p['resource_id'],
'revision' => 0,
- 'signature' => base64url_encode(rsa_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey'])),
+ 'signature' => Libzot::sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey']),
'resolution' => intval($p['imgscale'])
);
diff --git a/include/network.php b/include/network.php
index 4457f59bc..bcd66cf85 100644
--- a/include/network.php
+++ b/include/network.php
@@ -2,6 +2,7 @@
use Zotlabs\Lib\Zotfinger;
use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\Queue;
/**
* @file include/network.php
@@ -1333,14 +1334,15 @@ function fetch_xrd_links($url) {
*/
function scrape_feed($url) {
- require_once('library/HTML5/Parser.php');
$ret = array();
$level = 0;
$x = z_fetch_url($url,false,$level,array('novalidate' => true));
- if(! $x['success'])
+ if(! $x['success']) {
+ logger('ERROR fetching URL');
return $ret;
+ }
$headers = $x['header'];
$code = $x['return_code'];
@@ -1374,17 +1376,16 @@ function scrape_feed($url) {
}
}
+ $dom = new DOMDocument();
try {
- $dom = HTML5_Parser::parse($s);
+ $dom->loadHTML( $s);
} catch (DOMException $e) {
- logger('Parse error: ' . $e);
- }
-
- if(! $dom) {
- logger('Failed to parse.');
+ logger('Feed parse error: ' . $e);
+ // logger('Feed parse ERROR: ' . libxml_get_last_error()->message);
return $ret;
}
+
$head = $dom->getElementsByTagName('base');
if($head) {
foreach($head as $head0) {
@@ -1437,10 +1438,10 @@ function do_delivery($deliveries, $force = false) {
$x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
- if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300)) && (! $force)) {
+ if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',3000)) && (! $force)) {
logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
foreach($deliveries as $d) {
- update_queue_item($d);
+ Queue::update($d);
}
return;
}
@@ -1846,15 +1847,15 @@ function probe_api_path($host) {
function scrape_vcard($url) {
- require_once('library/HTML5/Parser.php');
-
$ret = array();
logger('url=' . $url);
$x = z_fetch_url($url);
- if(! $x['success'])
+ if(! $x['success']) {
+ logger('ERROR fetching URL');
return $ret;
+ }
$s = $x['body'];
@@ -1871,14 +1872,14 @@ function scrape_vcard($url) {
}
}
+ $dom = new DOMDocument();
try {
- $dom = HTML5_Parser::parse($s);
+ $dom->loadHTML( $s);
} catch (DOMException $e) {
- logger('Parse error: ' . $e);
- }
-
- if(! $dom)
+ logger('hCard parse error: ' . $e);
+ // logger('hCard fetch ERROR: ' . libxml_get_last_error()->message);
return $ret;
+ }
// Pull out hCard profile elements
diff --git a/include/text.php b/include/text.php
index a300ccf58..58cde7838 100644
--- a/include/text.php
+++ b/include/text.php
@@ -672,7 +672,7 @@ function bt_syslog($msg, $priority = LOG_INFO) {
for($x = 1; $x < count($stack); $x ++) {
$s = 'stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()';
openlog("bt-log", LOG_PID | LOG_PERROR, LOG_LOCAL0);
- syslog($priority, $msg);
+ syslog($priority, $s);
closelog();
}
}
diff --git a/include/zot.php b/include/zot.php
index 8a2177de7..d61873ba2 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3452,7 +3452,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
$x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
- if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) {
+ if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',3000))) {
logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
update_queue_item($hash);
continue;
@@ -4286,7 +4286,7 @@ function zot_reply_message_request($data) {
$x = q("select count(outq_hash) as total from outq where outq_delivered = 0");
- if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) {
+ if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',3000))) {
logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO);
update_queue_item($hash);
continue;