From 1029939f5622d03e3efad297476be14a2313169c Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 15 Nov 2015 17:28:45 -0800 Subject: issues connecting to local forum --- include/deliver.php | 12 ++++-------- include/zot.php | 8 ++++---- version.inc | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/deliver.php b/include/deliver.php index 11c1b249e..de93e316e 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -107,15 +107,10 @@ function deliver_run($argv, $argc) { $notify = json_decode($r[0]['outq_notify'],true); - // Check if this is a conversation request packet. It won't have outq_msg - // but will be an encrypted packet - so will need to be handed off to - // web delivery rather than processed inline. + // Messages without an outq_msg will need to go via the web, even if it's a + // local delivery. This includes conversation requests and refresh packets. - $sendtoweb = false; - if(array_key_exists('iv',$notify) && (! $r[0]['outq_msg'])) - $sendtoweb = true; - - if(($r[0]['outq_posturl'] === z_root() . '/post') && (! $sendtoweb)) { + if(($r[0]['outq_posturl'] === z_root() . '/post') && ($r[0]['outq_msg'])) { logger('deliver: local delivery', LOGGER_DEBUG); // local delivery // we should probably batch these and save a few delivery processes @@ -166,6 +161,7 @@ function deliver_run($argv, $argc) { } else { logger('deliver: remote zot delivery failed to ' . $r[0]['outq_posturl']); + logger('deliver: remote zot delivery fail data: ' . print_r($result,true), LOGGER_DATA); $y = q("update outq set outq_updated = '%s' where outq_hash = '%s'", dbesc(datetime_convert()), dbesc($argv[$x]) diff --git a/include/zot.php b/include/zot.php index d5d68f72c..0a1a8ee51 100644 --- a/include/zot.php +++ b/include/zot.php @@ -745,8 +745,8 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { || ($r[0]['xchan_follow'] != $arr['follow_url']) || ($r[0]['xchan_connpage'] != $arr['connect_url']) || ($r[0]['xchan_url'] != $arr['url']) - || $hidden_changed || adult_changed || deleted_changed || $pubforum_changed ) { - $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s', + || $hidden_changed || $adult_changed || $deleted_changed || $pubforum_changed ) { + $rup = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s', xchan_connpage = '%s', xchan_hidden = %d, xchan_selfcensored = %d, xchan_deleted = %d, xchan_pubforum = %d, xchan_addr = '%s', xchan_url = '%s' where xchan_hash = '%s'", dbesc(($arr['name']) ? $arr['name'] : '-'), @@ -763,8 +763,8 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { dbesc($xchan_hash) ); - logger('import_xchan: existing: ' . print_r($r[0],true), LOGGER_DATA); - logger('import_xchan: new: ' . print_r($arr,true), LOGGER_DATA); + logger('import_xchan: update: existing: ' . print_r($r[0],true), LOGGER_DATA); + logger('import_xchan: update: new: ' . print_r($arr,true), LOGGER_DATA); $what .= 'xchan '; $changed = true; } diff --git a/version.inc b/version.inc index 1c628f631..e9eed26db 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-11-13.1215 +2015-11-15.1217 -- cgit v1.2.3 From 3d80073a0e1e0847cad2e2fbe86aa66a1fbec983 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 15 Nov 2015 18:03:37 -0800 Subject: revert html in markdown for posts, but trim the input before processing the markdown --- include/items.php | 2 +- mod/item.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/items.php b/include/items.php index 3e4805212..fd23b7e6b 100755 --- a/include/items.php +++ b/include/items.php @@ -3181,7 +3181,7 @@ function tag_deliver($uid, $item_id) { } if((! $mention) && (! $union)) { - logger('tag_deliver: no mention and no union.'); + logger('tag_deliver: no mention for ' . $u[0]['channel_name'] . ' and no union.'); return; } diff --git a/mod/item.php b/mod/item.php index 5bf59de26..b66d71797 100644 --- a/mod/item.php +++ b/mod/item.php @@ -473,8 +473,8 @@ function item_post(&$a) { require_once('include/text.php'); if($uid && $uid == $profile_uid && feature_enabled($uid,'markdown')) { require_once('include/bb2diaspora.php'); + $body = escape_tags(trim($body)); $body = str_replace("\n",'
', $body); - $body = purify_html($body); $body = preg_replace_callback('/\[share(.*?)\]/ism','share_shield',$body); $body = diaspora2bb($body,true); -- cgit v1.2.3 From 6ad35e3d843bbc0483e21ed6f31c8942513290b6 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 15 Nov 2015 18:12:53 -0800 Subject: issue with dead hub detection --- include/notifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/notifier.php b/include/notifier.php index 34a527e15..b7830285a 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -101,7 +101,7 @@ function notifier_run($argv, $argc){ $dead_hubs = array(); $dh = q("select site_url from site where site_dead = 1"); - if(dh) { + if($dh) { foreach($dh as $dead) { $dead_hubs[] = $dead['site_url']; } -- cgit v1.2.3 From fff30b1c3d7030ff63c880c13bcb47e2932cd1b8 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 15 Nov 2015 19:36:17 -0800 Subject: permission issues editing wall-to-wall posts --- doc/hooklist.bb | 3 +++ include/text.php | 11 +++++++++-- mod/editpost.php | 14 +++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/doc/hooklist.bb b/doc/hooklist.bb index 2285ef1cf..45a4861d9 100644 --- a/doc/hooklist.bb +++ b/doc/hooklist.bb @@ -263,6 +263,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the [zrl=[baseurl]/help/hook/logged_in]logged_in[/zrl] Called when authentication by any means has succeeeded +[zrl=[baseurl]/help/hook/logger]logger[/zrl] + Called when making an entry to the application logfile + [zrl=[baseurl]/help/hook/logging_out]logging_out[/zrl] Called when logging out diff --git a/include/text.php b/include/text.php index ed0e21a71..166dbb4fb 100644 --- a/include/text.php +++ b/include/text.php @@ -531,11 +531,12 @@ function attribute_contains($attr, $s) { * LOGGER_DATA and LOGGER_ALL. * * Since PHP5.4 we get the file, function and line automatically where the logger - * was caleld, so no need to add it to the message anymore. + * was called, so no need to add it to the message anymore. * * @param string $msg Message to log * @param int $level A log level. */ + function logger($msg, $level = 0) { // turn off logger in install mode global $a; @@ -557,7 +558,13 @@ function logger($msg, $level = 0) { $where = basename($stack[0]['file']) . ':' . $stack[0]['line'] . ':' . $stack[1]['function'] . ': '; } - @file_put_contents($logfile, datetime_convert() . ':' . session_id() . ' ' . $where . $msg . PHP_EOL, FILE_APPEND); + $s = datetime_convert() . ':' . session_id() . ' ' . $where . $msg . PHP_EOL; + $pluginfo = array('filename' => $logfile, 'loglevel' => $level, 'message' => $s,'logged' => false); + + call_hooks('logger',$pluginfo); + + if(! $pluginfo['logged']) + @file_put_contents($logfile, $s, FILE_APPEND); } /** diff --git a/mod/editpost.php b/mod/editpost.php index 2f999858f..bd46ac14a 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -21,9 +21,9 @@ function editpost_content(&$a) { return; } - $itm = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d and author_xchan = '%s' LIMIT 1", + $itm = q("SELECT * FROM `item` WHERE `id` = %d AND ( owner_xchan = '%s' OR author_xchan = '%s' ) LIMIT 1", intval($post_id), - intval(local_channel()), + dbesc(get_observer_hash()), dbesc(get_observer_hash()) ); @@ -37,6 +37,8 @@ function editpost_content(&$a) { } + $owner_uid = $itm[0]['uid']; + $plaintext = true; // if(feature_enabled(local_channel(),'richtext')) @@ -71,14 +73,12 @@ function editpost_content(&$a) { call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); - $channel = $a->get_channel(); - //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); - $voting = feature_enabled(local_channel(),'consensus_tools'); + $voting = feature_enabled($owner_uid,'consensus_tools'); $category = ''; - $catsenabled = ((feature_enabled(local_channel(),'categories')) ? 'categories' : ''); + $catsenabled = ((feature_enabled($owner_uid,'categories')) ? 'categories' : ''); if ($catsenabled){ $itm = fetch_post_tags($itm); @@ -145,7 +145,7 @@ function editpost_content(&$a) { '$lockstate' => $lockstate, '$acl' => '', '$bang' => '', - '$profile_uid' => local_channel(), + '$profile_uid' => $owner_uid, '$preview' => t('Preview'), '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), -- cgit v1.2.3 From 12b0a9f35f589d2d571b1362c47dc85aa2cc9970 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 15 Nov 2015 19:37:26 -0800 Subject: add logger plugin hook --- doc/hook/logger.bb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 doc/hook/logger.bb diff --git a/doc/hook/logger.bb b/doc/hook/logger.bb new file mode 100644 index 000000000..8fe989abd --- /dev/null +++ b/doc/hook/logger.bb @@ -0,0 +1,16 @@ +[h2]logger[/h2] + +Called when making an entry to the application logfile + +Hook data: + + array( + 'filename' => name of logfile relative to application basedir. String. + 'loglevel' => the log level of this log entry, if this is higher than the configured maximum loglevel + this hook will not be called. Integer. + 'message' => The formatted log message, ready for logging. String. + 'logged' => boolean, default is false. Set to true to prevent the normal logfile entry to be made + (e.g. if the plugin is configured to handle this aspect of the function, or if it is determined + that this log entry should not be made) + ) + -- cgit v1.2.3 From c7b2ec8bbaf30a1836f3778c5d62eeb0246e97f4 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 15 Nov 2015 19:40:01 -0800 Subject: allow plugins to also log to a different named logfile and also alter the log message --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/text.php b/include/text.php index 166dbb4fb..4053c15b2 100644 --- a/include/text.php +++ b/include/text.php @@ -564,7 +564,7 @@ function logger($msg, $level = 0) { call_hooks('logger',$pluginfo); if(! $pluginfo['logged']) - @file_put_contents($logfile, $s, FILE_APPEND); + @file_put_contents($pluginfo['filename'], $pluginfo['message'], FILE_APPEND); } /** -- cgit v1.2.3 From 0cb5f009b483ff570ded4570bb45023573531494 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 15 Nov 2015 20:52:50 -0800 Subject: tag_deliver of an edit to an already uplinked item wasn't resetting permissions and ownership bits before starting delivery chain on the edit. --- include/items.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/items.php b/include/items.php index fd23b7e6b..43bbdda28 100755 --- a/include/items.php +++ b/include/items.php @@ -2962,9 +2962,12 @@ function tag_deliver($uid, $item_id) { if(($item['source_xchan']) && intval($item['item_uplink']) && intval($item['item_thread_top']) && ($item['edited'] != $item['created'])) { + // this is an update (edit) to a post which was already processed by us and has a second delivery chain // Just start the second delivery chain to deliver the updated post - proc_run('php','include/notifier.php','tgroup',$item['id']); + // after resetting ownership and permission bits + + start_delivery_chain($u[0], $item, $item_id, 0); return; } -- cgit v1.2.3