Merge branch 'dev' into oauth2

This commit is contained in:
Andrew Manning
2018-03-04 06:45:07 -05:00
93 changed files with 3172 additions and 1828 deletions
+1 -1
View File
@@ -530,7 +530,7 @@ function account_deny($hash) {
function account_approve($hash) {
$ret = array('success' => false);
$ret = false;
// Note: when the password in the register table is 'verify', the uid actually contains the account_id
+30
View File
@@ -668,6 +668,31 @@ function bb_fixtable_lf($match) {
}
function bbtopoll($s) {
$pl = [];
$match = '';
if(! preg_match("/\[poll=(.*?)\](.*?)\[\/poll\]/ism",$s,$match)) {
return null;
}
$pl['poll_id'] = $match[1];
$pl['poll_question'] = $match[2];
$match = '';
if(preg_match_all("/\[poll\-answer=(.*?)\](.*?)\[\/poll\-answer\]/is",$s,$match,PREG_SET_ORDER)) {
$pl['answer'] = [];
foreach($match as $m) {
$ans = [ 'answer_id' => $m[1], 'answer_text' => $m[2] ];
$pl['answer'][] = $ans;
}
}
return $pl;
}
function parseIdentityAwareHTML($Text) {
// Hide all [noparse] contained bbtags by spacefying them
@@ -766,6 +791,11 @@ function bbcode($Text, $options = []) {
$ev = bbtoevent($Text);
// and the same with polls
$pl = bbtopoll($Text);
// process [observer] tags before we do anything else because we might
// be stripping away stuff that then doesn't need to be worked on anymore
+3 -3
View File
@@ -1005,7 +1005,7 @@ function thread_author_menu($item, $mode = '') {
$contact = App::$contacts[$item['author_xchan']];
else
if($local_channel && $item['author']['xchan_addr'])
$follow_url = z_root() . '/follow/?f=&url=' . urlencode($item['author']['xchan_addr']);
$follow_url = z_root() . '/follow/?f=&url=' . urlencode($item['author']['xchan_addr']) . '&interactive=0';
if($item['uid'] > 0 && author_is_pmable($item['author'],$contact)) {
@@ -1051,8 +1051,8 @@ function thread_author_menu($item, $mode = '') {
'menu' => 'follow',
'title' => t('Connect'),
'icon' => 'fw',
'action' => '',
'href' => $follow_url
'action' => 'doFollowAuthor(\'' . $follow_url . '\'); return false;',
'href' => '#',
];
}
+1 -1
View File
@@ -125,7 +125,7 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
*/
function dob($dob) {
if ($dob === '0000-00-00')
if ($dob === '0000-00-00' || $dob === '')
$value = '';
else
$value = (($year) ? datetime_convert('UTC','UTC',$dob,'Y-m-d') : datetime_convert('UTC','UTC',$dob,'m-d'));
+22
View File
@@ -1322,3 +1322,25 @@ function translate_type($type) {
return [$type, t('Other') . ' (' . $type . ')'];
}
}
function cal_store_lowlevel($arr) {
$store = [
'cal_aid' => ((array_key_exists('cal_aid',$arr)) ? $arr['cal_aid'] : 0),
'cal_uid' => ((array_key_exists('cal_uid',$arr)) ? $arr['cal_uid'] : 0),
'cal_hash' => ((array_key_exists('cal_hash',$arr)) ? $arr['cal_hash'] : ''),
'cal_name' => ((array_key_exists('cal_name',$arr)) ? $arr['cal_name'] : ''),
'uri' => ((array_key_exists('uri',$arr)) ? $arr['uri'] : ''),
'logname' => ((array_key_exists('logname',$arr)) ? $arr['logname'] : ''),
'pass' => ((array_key_exists('pass',$arr)) ? $arr['pass'] : ''),
'ctag' => ((array_key_exists('ctag',$arr)) ? $arr['ctag'] : ''),
'synctoken' => ((array_key_exists('synctoken',$arr)) ? $arr['synctoken'] : ''),
'cal_types' => ((array_key_exists('cal_types',$arr)) ? $arr['cal_types'] : ''),
];
return create_table_from_array('cal', $store);
}
+12 -3
View File
@@ -88,9 +88,18 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
// Premium channel, set confirm before callback to avoid recursion
if(array_key_exists('connect_url',$j) && ($interactive) && (! $confirm))
goaway(zid($j['connect_url']));
if(array_key_exists('connect_url',$j) && (! $confirm)) {
if($interactive) {
goaway(zid($j['connect_url']));
}
else {
$result['message'] = t('Premium channel - please visit:') . ' ' . zid($j['connect_url']);
logger('mod_follow: ' . $result['message']);
return $result;
}
}
// do we have an xchan and hubloc?
// If not, create them.
+6
View File
@@ -3311,4 +3311,10 @@ function purify_filename($s) {
return $s;
}
// callback for sorting the settings/featured entries.
function featured_sort($a,$b) {
$s1 = substr($a,strpos($a,'id='),20);
$s2 = substr($b,strpos($b,'id='),20);
return(strcmp($s1,$s2));
}
+6 -4
View File
@@ -171,6 +171,8 @@ function zot_build_packet($channel, $type = 'notify', $recipients = null, $remot
* packet type: one of 'ping', 'pickup', 'purge', 'refresh', 'keychange', 'force_refresh', 'notify', 'auth_check'
* @param array $recipients
* envelope information, array ( 'guid' => string, 'guid_sig' => string ); empty for public posts
* @param string msg
* optional message
* @param string $remote_key
* optional public site key of target hub used to encrypt entire packet
* NOTE: remote_key and encrypted packets are required for 'auth_check' packets, optional for all others
@@ -299,7 +301,7 @@ function zot_zot($url, $data, $channel = null,$crypto = null) {
if($channel) {
$headers['X-Zot-Token'] = random_string();
$hash = \Zotlabs\Web\HTTPSig::generate_digest($data,false);
$headers['X-Zot-Digest'] = 'SHA-256=' . $hash;
$headers['X-Zot-Digest'] = 'SHA-256=' . $hash;
$h = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'],'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,false,'sha512',(($crypto) ? $crypto['hubloc_sitekey'] : ''), (($crypto) ? zot_best_algorithm($crypto['site_crypto']) : ''));
}
@@ -393,7 +395,7 @@ function zot_refresh($them, $channel = null, $force = false) {
if($s && intval($s[0]['site_dead']) && (! $force)) {
logger('zot_refresh: site ' . $url . ' is marked dead and force flag is not set. Cancelling operation.');
return false;
}
}
$token = random_string();
@@ -1156,7 +1158,7 @@ function zot_process_response($hub, $arr, $outq) {
* and also that the signer and the sender match.
* If that happens, we do not need to fetch/pickup the message - we have it already and it is verified.
* Translate it into the form we need for zot_import() and import it.
*
*
* Otherwise send back a pickup message, using our message tracking ID ($arr['secret']), which we will sign with our site
* private key.
* The entire pickup message is encrypted with the remote site's public key.
@@ -5090,7 +5092,7 @@ function zot_reply_refresh($sender, $recipients) {
function zot6_check_sig() {
$ret = [ 'success' => false ];
logger('server: ' . print_r($_SERVER,true), LOGGER_DATA);
if(array_key_exists('HTTP_SIGNATURE',$_SERVER)) {