Merge branch 'master' into z6
This commit is contained in:
@@ -5,104 +5,9 @@
|
||||
* @package acl_selectors
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param string $selname
|
||||
* @param string $selclass
|
||||
* @param mixed $preselected
|
||||
* @param number $size
|
||||
* @return string
|
||||
*/
|
||||
function group_select($selname, $selclass, $preselected = false, $size = 4) {
|
||||
|
||||
$o = '';
|
||||
|
||||
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\">\r\n";
|
||||
|
||||
$r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
|
||||
intval(local_channel())
|
||||
);
|
||||
|
||||
|
||||
$arr = array('group' => $r, 'entry' => $o);
|
||||
|
||||
// e.g. 'network_pre_group_deny', 'profile_pre_group_allow'
|
||||
|
||||
call_hooks(App::$module . '_pre_' . $selname, $arr);
|
||||
|
||||
if($r) {
|
||||
foreach($r as $rr) {
|
||||
if((is_array($preselected)) && in_array($rr['id'], $preselected))
|
||||
$selected = " selected=\"selected\" ";
|
||||
else
|
||||
$selected = '';
|
||||
$trimmed = mb_substr($rr['gname'],0,12);
|
||||
|
||||
$o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}\" >$trimmed</option>\r\n";
|
||||
}
|
||||
|
||||
}
|
||||
$o .= "</select>\r\n";
|
||||
|
||||
call_hooks(App::$module . '_post_' . $selname, $o);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) {
|
||||
|
||||
$o = '';
|
||||
|
||||
// When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector
|
||||
// to one recipient. By default our selector allows multiple selects amongst all contacts.
|
||||
|
||||
$sql_extra = '';
|
||||
|
||||
$tabindex = ($tabindex > 0 ? 'tabindex="$tabindex"' : '');
|
||||
|
||||
if($privmail)
|
||||
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" $tabindex >\r\n";
|
||||
else
|
||||
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex>\r\n";
|
||||
|
||||
$r = q("SELECT abook_id, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash
|
||||
where abook_self = 0 and abook_channel = %d
|
||||
$sql_extra
|
||||
ORDER BY xchan_name ASC",
|
||||
intval(local_channel())
|
||||
);
|
||||
|
||||
|
||||
$arr = array('contact' => $r, 'entry' => $o);
|
||||
|
||||
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
|
||||
|
||||
call_hooks(App::$module . '_pre_' . $selname, $arr);
|
||||
|
||||
if($r) {
|
||||
foreach($r as $rr) {
|
||||
if((is_array($preselected)) && in_array($rr['id'], $preselected))
|
||||
$selected = ' selected="selected" ';
|
||||
else
|
||||
$selected = '';
|
||||
|
||||
$trimmed = mb_substr($rr['xchan_name'], 0, 20);
|
||||
|
||||
$o .= "<option value=\"{$rr['abook_id']}\" $selected title=\"{$rr['xchan_name']}|{$rr['xchan_url']}\" >$trimmed</option>\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
$o .= "</select>\r\n";
|
||||
|
||||
call_hooks(App::$module . '_post_' . $selname, $o);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
function fixacl(&$item) {
|
||||
$item = str_replace(array('<', '>'), array('', ''), $item);
|
||||
$item = str_replace( [ '<', '>' ], [ '', '' ], $item);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,19 +31,6 @@ function rsa_verify($data,$sig,$key,$alg = 'sha256') {
|
||||
return (($verify > 0) ? true : false);
|
||||
}
|
||||
|
||||
function pkcs5_pad ($text, $blocksize)
|
||||
{
|
||||
$pad = $blocksize - (strlen($text) % $blocksize);
|
||||
return $text . str_repeat(chr($pad), $pad);
|
||||
}
|
||||
|
||||
function pkcs5_unpad($text)
|
||||
{
|
||||
$pad = ord($text{strlen($text)-1});
|
||||
if ($pad > strlen($text)) return false;
|
||||
if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false;
|
||||
return substr($text, 0, -1 * $pad);
|
||||
}
|
||||
|
||||
function AES256CBC_encrypt($data,$key,$iv) {
|
||||
|
||||
@@ -282,37 +269,6 @@ function new_keypair($bits) {
|
||||
|
||||
}
|
||||
|
||||
function pkcs1to8($oldkey,$len) {
|
||||
|
||||
if($len == 4096)
|
||||
$c = 'g';
|
||||
if($len == 2048)
|
||||
$c = 'Q';
|
||||
|
||||
if(strstr($oldkey,'BEGIN PUBLIC'))
|
||||
return $oldkey;
|
||||
|
||||
$oldkey = str_replace('-----BEGIN RSA PUBLIC KEY-----', '', $oldkey);
|
||||
$oldkey = trim(str_replace('-----END RSA PUBLIC KEY-----', '', $oldkey));
|
||||
$key = 'MIICIjANBgkqhkiG9w0BAQEFAAOCA' . $c . '8A' . str_replace("\n", '', $oldkey);
|
||||
$key = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($key, 64, "\n", true) . "\n-----END PUBLIC KEY-----";
|
||||
return $key;
|
||||
}
|
||||
|
||||
function pkcs8to1($oldkey,$len) {
|
||||
|
||||
if(strstr($oldkey,'BEGIN RSA'))
|
||||
return $oldkey;
|
||||
|
||||
$oldkey = str_replace('-----BEGIN PUBLIC KEY-----', '', $oldkey);
|
||||
$oldkey = trim(str_replace('-----END PUBLIC KEY-----', '', $oldkey));
|
||||
$key = str_replace("\n",'',$oldkey);
|
||||
$key = substr($key,32);
|
||||
$key = "-----BEGIN RSA PUBLIC KEY-----\n" . wordwrap($key, 64, "\n", true) . "\n-----END RSA PUBLIC KEY-----";
|
||||
return $key;
|
||||
}
|
||||
|
||||
|
||||
function DerToPem($Der, $Private=false)
|
||||
{
|
||||
//Encode:
|
||||
|
||||
@@ -93,16 +93,6 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
|
||||
return $d->format($fmt);
|
||||
}
|
||||
|
||||
// Slight hackish adjustment so that 'zero' datetime actually returns what is intended
|
||||
// otherwise we end up with -0001-11-30 ...
|
||||
// add 32 days so that we at least get year 00, and then hack around the fact that
|
||||
// months and days always start with 1.
|
||||
|
||||
// if(substr($s,0,10) == '0000-00-00') {
|
||||
// $d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
|
||||
// return str_replace('1', '0', $d->format($fmt));
|
||||
// }
|
||||
|
||||
try {
|
||||
$from_obj = new DateTimeZone($from);
|
||||
} catch(Exception $e) {
|
||||
@@ -135,69 +125,19 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
|
||||
*/
|
||||
function dob($dob) {
|
||||
|
||||
list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d');
|
||||
$f = get_config('system', 'birthday_input_format');
|
||||
if (! $f)
|
||||
$f = 'ymd';
|
||||
|
||||
if ($dob === '0000-00-00')
|
||||
$value = '';
|
||||
else
|
||||
$value = (($year) ? datetime_convert('UTC','UTC',$dob,'Y-m-d') : datetime_convert('UTC','UTC',$dob,'m-d'));
|
||||
|
||||
$o = replace_macros(get_markup_template("field_input.tpl"), array('$field' => array(
|
||||
'dob',
|
||||
t('Birthday'),
|
||||
$value,
|
||||
((intval($value)) ? t('Age: ') . age($value,App::$user['timezone'],App::$user['timezone']) : ''),
|
||||
'',
|
||||
'placeholder="' . t('YYYY-MM-DD or MM-DD') .'"'
|
||||
)));
|
||||
$o = replace_macros(get_markup_template("field_input.tpl"), [
|
||||
'$field' => [ 'dob', t('Birthday'), $value, ((intval($value)) ? t('Age: ') . age($value,App::$user['timezone'],App::$user['timezone']) : ''), '', 'placeholder="' . t('YYYY-MM-DD or MM-DD') .'"' ]
|
||||
]);
|
||||
|
||||
|
||||
// if ($dob && $dob != '0000-00-00')
|
||||
// $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),mktime(0,0,0,$month,$day,$year),'dob');
|
||||
// else
|
||||
// $o = datesel($f,mktime(0,0,0,0,0,1900),mktime(),false,'dob');
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a date selector.
|
||||
*
|
||||
* @see datetimesel()
|
||||
* @param string $format
|
||||
* format string, e.g. 'ymd' or 'mdy'. Not currently supported
|
||||
* @param DateTime $min
|
||||
* unix timestamp of minimum date
|
||||
* @param DateTime $max
|
||||
* unix timestap of maximum date
|
||||
* @param DateTime $default
|
||||
* unix timestamp of default date
|
||||
* @param string $id
|
||||
* id and name of datetimepicker (defaults to "datetimepicker")
|
||||
*/
|
||||
function datesel($format, $min, $max, $default, $id = 'datepicker') {
|
||||
return datetimesel($format, $min, $max, $default, '', $id, true, false, '', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a time selector.
|
||||
*
|
||||
* @param string $format
|
||||
* format string, e.g. 'ymd' or 'mdy'. Not currently supported
|
||||
* @param string $h
|
||||
* already selected hour
|
||||
* @param string $m
|
||||
* already selected minute
|
||||
* @param string $id
|
||||
* id and name of datetimepicker (defaults to "timepicker")
|
||||
*/
|
||||
function timesel($format, $h, $m, $id='timepicker') {
|
||||
return datetimesel($format, new DateTime(), new DateTime(), new DateTime("$h:$m"), '', $id, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a datetime selector.
|
||||
*
|
||||
@@ -449,12 +389,7 @@ function cal($y = 0, $m = 0, $links = false, $class='') {
|
||||
|
||||
// month table - start at 1 to match human usage.
|
||||
|
||||
$mtab = array(' ',
|
||||
'January','February','March',
|
||||
'April','May','June',
|
||||
'July','August','September',
|
||||
'October','November','December'
|
||||
);
|
||||
$mtab = [ ' ', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ];
|
||||
|
||||
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
|
||||
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
|
||||
@@ -463,7 +398,7 @@ function cal($y = 0, $m = 0, $links = false, $class='') {
|
||||
if (! $m)
|
||||
$m = intval($thismonth);
|
||||
|
||||
$dn = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
|
||||
$dn = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ];
|
||||
$f = get_first_dim($y, $m);
|
||||
$l = get_dim($y, $m);
|
||||
$d = 1;
|
||||
@@ -569,17 +504,17 @@ function update_birthdays() {
|
||||
if (! perm_is_allowed($rr['abook_channel'], $rr['xchan_hash'], 'send_stream'))
|
||||
continue;
|
||||
|
||||
$ev = array();
|
||||
$ev['uid'] = $rr['abook_channel'];
|
||||
$ev['account'] = $rr['abook_account'];
|
||||
$ev['event_xchan'] = $rr['xchan_hash'];
|
||||
$ev['dtstart'] = datetime_convert('UTC', 'UTC', $rr['abook_dob']);
|
||||
$ev['dtend'] = datetime_convert('UTC', 'UTC', $rr['abook_dob'] . ' + 1 day ');
|
||||
$ev['adjust'] = intval(feature_enabled($rr['abook_channel'],'smart_birthdays'));
|
||||
$ev['summary'] = sprintf( t('%1$s\'s birthday'), $rr['xchan_name']);
|
||||
$ev['description'] = sprintf( t('Happy Birthday %1$s'),
|
||||
'[zrl=' . $rr['xchan_url'] . ']' . $rr['xchan_name'] . '[/zrl]') ;
|
||||
$ev['etype'] = 'birthday';
|
||||
$ev = [
|
||||
'uid' => $rr['abook_channel'],
|
||||
'account' => $rr['abook_account'],
|
||||
'event_xchan' => $rr['xchan_hash'],
|
||||
'dtstart' => datetime_convert('UTC', 'UTC', $rr['abook_dob']),
|
||||
'dtend' => datetime_convert('UTC', 'UTC', $rr['abook_dob'] . ' + 1 day '),
|
||||
'adjust' => intval(feature_enabled($rr['abook_channel'],'smart_birthdays')),
|
||||
'summary' => sprintf( t('%1$s\'s birthday'), $rr['xchan_name']),
|
||||
'description' => sprintf( t('Happy Birthday %1$s'), '[zrl=' . $rr['xchan_url'] . ']' . $rr['xchan_name'] . '[/zrl]'),
|
||||
'etype' => 'birthday',
|
||||
];
|
||||
|
||||
$z = event_store_event($ev);
|
||||
if ($z) {
|
||||
|
||||
@@ -487,7 +487,7 @@ function get_atom_elements($feed, $item) {
|
||||
}
|
||||
}
|
||||
|
||||
$ostatus_protocol = (($ostatus_conversation) ? true : false);
|
||||
$ostatus_protocol = (($ostatus_conversation || $res['verb']) ? true : false);
|
||||
|
||||
$mastodon = (($item->get_item_tags('http://mastodon.social/schema/1.0','scope')) ? true : false);
|
||||
if($mastodon) {
|
||||
@@ -496,6 +496,8 @@ function get_atom_elements($feed, $item) {
|
||||
$res['item_private'] = 1;
|
||||
}
|
||||
|
||||
logger('ostatus_protocol: ' . intval($ostatus_protocol));
|
||||
|
||||
$apps = $item->get_item_tags(NAMESPACE_STATUSNET, 'notice_info');
|
||||
if($apps && $apps[0]['attribs']['']['source']) {
|
||||
$res['app'] = strip_tags(unxmlify($apps[0]['attribs']['']['source']));
|
||||
@@ -599,9 +601,8 @@ function get_atom_elements($feed, $item) {
|
||||
);
|
||||
}
|
||||
|
||||
// turn Mastodon content warning into a #nsfw hashtag
|
||||
if($mastodon && $summary) {
|
||||
$res['body'] = $summary . "\n\n" . $res['body'] . "\n\n#ContentWarning\n";
|
||||
if($summary && $res['body']) {
|
||||
$res['body'] = '[summary]' . $summary . '[/summary]' . $res['body'];
|
||||
}
|
||||
|
||||
|
||||
@@ -802,7 +803,7 @@ function get_atom_elements($feed, $item) {
|
||||
*/
|
||||
call_hooks('parse_atom', $arr);
|
||||
|
||||
logger('result: ' .print_r($arr['result'], true), LOGGER_DATA);
|
||||
logger('result: ' . print_r($arr['result'], true), LOGGER_DATA);
|
||||
|
||||
return $arr['result'];
|
||||
}
|
||||
@@ -1001,9 +1002,9 @@ function process_feed_tombstones($feed,$importer,$contact,$pass) {
|
||||
* @param string $xml
|
||||
* The (atom) feed to consume - RSS isn't as fully supported but may work for simple feeds.
|
||||
* @param array $importer
|
||||
* The contact_record (joined to user_record) of the local user who owns this
|
||||
* The channel record of the local user who owns this
|
||||
* relationship. It is this person's stuff that is going to be updated.
|
||||
* @param[in,out] array $contact
|
||||
* @param[in,out] array $contact (abook record joined to xchan record)
|
||||
* The person who is sending us stuff. If not set, we MAY be processing a "follow" activity
|
||||
* from an external network and MAY create an appropriate contact record. Otherwise, we MUST
|
||||
* have a contact record.
|
||||
|
||||
Reference in New Issue
Block a user