aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/directory.php5
-rw-r--r--include/identity.php15
-rwxr-xr-xinclude/items.php2
-rw-r--r--include/network.php42
-rw-r--r--include/notifier.php6
-rw-r--r--include/queue.php8
-rw-r--r--include/socgraph.php5
-rw-r--r--include/widgets.php2
-rw-r--r--include/zot.php5
9 files changed, 69 insertions, 21 deletions
diff --git a/include/directory.php b/include/directory.php
index 794420b6f..c69fb1f4b 100644
--- a/include/directory.php
+++ b/include/directory.php
@@ -69,11 +69,12 @@ function directory_run($argv, $argc){
// the directory packet. That means we'll try again on the next poll run.
$hash = random_string();
- q("insert into outq ( outq_hash, outq_account, outq_channel, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg )
- values ( '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s' )",
+ q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg )
+ values ( '%s', %d, %d, '%s', '%s', %d, '%s', '%s', '%s', '%s' )",
dbesc($hash),
intval($channel['channel_account_id']),
intval($channel['channel_id']),
+ dbesc('zot'),
dbesc($url),
intval(1),
dbesc(datetime_convert()),
diff --git a/include/identity.php b/include/identity.php
index efc0d7d87..c8a925dac 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -80,6 +80,16 @@ function validate_channelname($name) {
function create_sys_channel() {
if(get_sys_channel())
return;
+
+ // Ensure that there is a host keypair.
+
+ if((! get_config('system','pubkey')) && (! get_config('system','prvkey'))) {
+ require_once('include/crypto.php');
+ $hostkey = new_keypair(4096);
+ set_config('system','pubkey',$hostkey['pubkey']);
+ set_config('system','prvkey',$hostkey['prvkey']);
+ }
+
create_identity(array(
'account_id' => 'xxx', // This will create an identity with an (integer) account_id of 0, but account_id is required
'nickname' => 'sys',
@@ -167,6 +177,11 @@ function create_identity($arr) {
return $ret;
}
+ if($nick === 'sys' && (! ($pageflags & PAGE_SYSTEM))) {
+ $ret['message'] = t('Reserved nickname. Please choose another.');
+ return $ret;
+ }
+
if(check_webbie(array($nick)) !== $nick) {
$ret['message'] = t('Nickname has unsupported characters or is already being used on this site.');
return $ret;
diff --git a/include/items.php b/include/items.php
index 6788ac3da..428767676 100755
--- a/include/items.php
+++ b/include/items.php
@@ -859,7 +859,7 @@ function encode_item($item) {
if($item['term'])
$x['tags'] = encode_item_terms($item['term']);
- logger('encode_item: ' . print_r($x,true));
+ logger('encode_item: ' . print_r($x,true), LOGGER_DATA);
return $x;
diff --git a/include/network.php b/include/network.php
index 1fb4beaa7..14771d88f 100644
--- a/include/network.php
+++ b/include/network.php
@@ -43,8 +43,14 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
@curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Red)");
+ $ciphers = @get_config('system','curl_ssl_ciphers');
+ if(! $ciphers)
+ $ciphers = 'ALL:!eNULL';
+
+ @curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, $ciphers);
+
if (x($opts,'accept_content')){
- curl_setopt($ch,CURLOPT_HTTPHEADER, array (
+ @curl_setopt($ch,CURLOPT_HTTPHEADER, array (
"Accept: " . $opts['accept_content']
));
}
@@ -115,7 +121,9 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
$ret['return_code'] = $rc;
$ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false);
if(! $ret['success']) {
+ $ret['error'] = curl_error($ch);
$ret['debug'] = $curl_info;
+ logger('z_fetch_url: error:' . $ret['error'], LOGGER_DEBUG);
logger('z_fetch_url: debug:' . print_r($curl_info,true), LOGGER_DATA);
}
$ret['body'] = substr($s,strlen($header));
@@ -136,21 +144,27 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
if(($redirects > 8) || (! $ch))
return ret;
- curl_setopt($ch, CURLOPT_HEADER, true);
+ @curl_setopt($ch, CURLOPT_HEADER, true);
@curl_setopt($ch, CURLOPT_CAINFO, get_capath());
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch, CURLOPT_POST,1);
- curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
- curl_setopt($ch, CURLOPT_USERAGENT, "Red");
+ @curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
+ @curl_setopt($ch, CURLOPT_POST,1);
+ @curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
+ @curl_setopt($ch, CURLOPT_USERAGENT, "Red");
+
+ $ciphers = @get_config('system','curl_ssl_ciphers');
+ if(! $ciphers)
+ $ciphers = 'ALL:!eNULL';
+
+ @curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, $ciphers);
if (x($opts,'accept_content')){
- curl_setopt($ch,CURLOPT_HTTPHEADER, array (
+ @curl_setopt($ch,CURLOPT_HTTPHEADER, array (
"Accept: " . $opts['accept_content']
));
}
if(x($opts,'headers'))
- curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
+ @curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
if(x($opts,'timeout') && intval($opts['timeout'])) {
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
@@ -170,11 +184,11 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
$prx = get_config('system','proxy');
if(strlen($prx)) {
- curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
- curl_setopt($ch, CURLOPT_PROXY, $prx);
+ @curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
+ @curl_setopt($ch, CURLOPT_PROXY, $prx);
$prxusr = get_config('system','proxyuser');
if(strlen($prxusr))
- curl_setopt($ch, CURLOPT_PROXYUSERPWD, $prxusr);
+ @curl_setopt($ch, CURLOPT_PROXYUSERPWD, $prxusr);
}
// don't let curl abort the entire application
@@ -183,7 +197,7 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
$s = @curl_exec($ch);
$base = $s;
- $curl_info = curl_getinfo($ch);
+ $curl_info = @curl_getinfo($ch);
$http_code = $curl_info['http_code'];
$header = '';
@@ -217,8 +231,10 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
$ret['return_code'] = $rc;
$ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false);
if(! $ret['success']) {
+ $ret['error'] = curl_error($ch);
$ret['debug'] = $curl_info;
- logger('z_fetch_url: debug:' . print_r($curl_info,true), LOGGER_DATA);
+ logger('z_post_url: error:' . $ret['error'], LOGGER_DEBUG);
+ logger('z_post_url: debug:' . print_r($curl_info,true), LOGGER_DATA);
}
$ret['body'] = substr($s,strlen($header));
diff --git a/include/notifier.php b/include/notifier.php
index a4a9051c3..4bf2ac153 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -486,10 +486,11 @@ function notifier_run($argv, $argc){
$hash = random_string();
if($packet_type === 'refresh' || $packet_type === 'purge') {
$n = zot_build_packet($channel,$packet_type);
- q("insert into outq ( outq_hash, outq_account, outq_channel, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s' )",
+ q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', '%s', %d, '%s', '%s', '%s', '%s' )",
dbesc($hash),
intval($channel['channel_account_id']),
intval($channel['channel_id']),
+ dbesc('zot'),
dbesc($hub['hubloc_callback']),
intval(1),
dbesc(datetime_convert()),
@@ -500,10 +501,11 @@ function notifier_run($argv, $argc){
}
else {
$n = zot_build_packet($channel,'notify',$env_recips,(($private) ? $hub['hubloc_sitekey'] : null),$hash);
- q("insert into outq ( outq_hash, outq_account, outq_channel, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s' )",
+ q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', '%s', %d, '%s', '%s', '%s', '%s' )",
dbesc($hash),
intval($target_item['aid']),
intval($target_item['uid']),
+ dbesc('zot'),
dbesc($hub['hubloc_callback']),
intval(1),
dbesc(datetime_convert()),
diff --git a/include/queue.php b/include/queue.php
index ec7246cb2..239d61fc0 100644
--- a/include/queue.php
+++ b/include/queue.php
@@ -33,8 +33,12 @@ function queue_run($argv, $argc){
// For the first 12 hours we'll try to deliver every 15 minutes
// After that, we'll only attempt delivery once per hour.
-
- $r = q("SELECT * FROM outq WHERE outq_delivered = 0 and (( outq_created > UTC_TIMESTAMP() - INTERVAL 12 HOUR and outq_updated < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ) OR ( outq_updated < UTC_TIMESTAMP() - INTERVAL 1 HOUR ))");
+ // This currently only handles the default queue drivers ('zot' or '') which we will group by posturl
+ // so that we don't start off a thousand deliveries for a couple of dead hubs.
+ // The zot driver will deliver everything destined for a single hub once contact is made (*if* contact is made).
+ // Other drivers will have to do something different here and may need their own query.
+
+ $r = q("SELECT * FROM outq WHERE outq_delivered = 0 and (( outq_created > UTC_TIMESTAMP() - INTERVAL 12 HOUR and outq_updated < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ) OR ( outq_updated < UTC_TIMESTAMP() - INTERVAL 1 HOUR )) and outq_driver in ('','zot') group by outq_posturl");
}
if(! $r)
return;
diff --git a/include/socgraph.php b/include/socgraph.php
index 10d52da66..65e23f9df 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -62,6 +62,11 @@ function poco_load($xchan = '',$url = null) {
$j = json_decode($s['body'],true);
+ if(! $j) {
+ logger('poco_load: unable to json_decode returned data.');
+ return;
+ }
+
logger('poco_load: ' . print_r($j,true),LOGGER_DATA);
if($xchan) {
diff --git a/include/widgets.php b/include/widgets.php
index 90586397f..82769d925 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -306,6 +306,7 @@ function widget_archive($arr) {
$wall = ((array_key_exists('wall', $arr)) ? intval($arr['wall']) : 0);
+ $style = ((array_key_exists('style', $arr)) ? $arr['style'] : 'select');
$url = z_root() . '/' . $a->cmd;
@@ -318,6 +319,7 @@ function widget_archive($arr) {
'$title' => t('Archives'),
'$size' => ((count($ret) > 6) ? 6 : count($ret)),
'$url' => $url,
+ '$style' => $style,
'$dates' => $ret
));
return $o;
diff --git a/include/zot.php b/include/zot.php
index 35b322b54..c82918b3a 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -943,6 +943,8 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED) {
$ret['hash'] = $xchan_hash;
}
+
+
logger('import_xchan: result: ' . print_r($ret,true), LOGGER_DATA);
return $ret;
}
@@ -2072,10 +2074,11 @@ function build_sync_packet($uid = 0, $packet = null) {
foreach($synchubs as $hub) {
$hash = random_string();
$n = zot_build_packet($channel,'notify',$env_recips,$hub['hubloc_sitekey'],$hash);
- q("insert into outq ( outq_hash, outq_account, outq_channel, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s' )",
+ q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', '%s', %d, '%s', '%s', '%s', '%s' )",
dbesc($hash),
intval($channel['channel_account']),
intval($channel['channel_id']),
+ dbesc('zot'),
dbesc($hub['hubloc_callback']),
intval(1),
dbesc(datetime_convert()),