Merge remote-tracking branch 'friendika/master'
This commit is contained in:
@@ -153,6 +153,9 @@ ACL.prototype.updateview = function(){
|
||||
$('#jot-perms-icon').removeClass('lock').addClass('unlock');
|
||||
$('#jot-public').show();
|
||||
$('.profile-jot-net input').attr('disabled', false);
|
||||
if(editor != false) {
|
||||
$('#profile-jot-desc').html(ispublic);
|
||||
}
|
||||
|
||||
} else {
|
||||
that.showall.removeClass("selected");
|
||||
@@ -160,6 +163,7 @@ ACL.prototype.updateview = function(){
|
||||
$('#jot-perms-icon').removeClass('unlock').addClass('lock');
|
||||
$('#jot-public').hide();
|
||||
$('.profile-jot-net input').attr('disabled', 'disabled');
|
||||
$('#profile-jot-desc').html(' ');
|
||||
}
|
||||
|
||||
$("#acl-list-content .acl-list-item").each(function(){
|
||||
|
||||
@@ -561,3 +561,30 @@
|
||||
|
||||
}
|
||||
api_register_func('api/account/rate_limit_status','api_account_rate_limit_status',true);
|
||||
|
||||
|
||||
function api_statusnet_config(&$a,$type) {
|
||||
$name = $a->config['sitename'];
|
||||
$server = $a->get_hostname();
|
||||
$logo = $a->get_baseurl() . '/images/friendika-64.png';
|
||||
$email = $a->config['admin_email'];
|
||||
$closed = (($a->config['register_policy'] == REGISTER_CLOSED) ? 'true' : 'false');
|
||||
$private = (($a->config['system']['block_public']) ? 'true' : 'false');
|
||||
$textlimit = (($a->config['max_import_size']) ? $a->config['max_import_size'] : '200000');
|
||||
$ssl = (($a->config['system']['have_ssl']) ? 'true' : 'false');
|
||||
$sslserver = (($ssl === 'true') ? str_replace('http:','https:',$a->get_baseurl()) : '');
|
||||
|
||||
$config = array(
|
||||
'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '',
|
||||
'logo' => $logo, 'fancy' => 'true', 'language' => 'en', 'email' => $email, 'broughtby' => '',
|
||||
'broughtbyurl' => '', 'timezone' => 'UTC', 'closed' => $closed, 'inviteonly' => 'false',
|
||||
'private' => $private, 'textlimit' => $textlimit, 'sslserver' => $sslserver, 'ssl' => $ssl,
|
||||
'shorturllength' => '30'
|
||||
),
|
||||
);
|
||||
|
||||
return api_apply_template('config', $type, array('$config' => $config));
|
||||
|
||||
}
|
||||
api_register_func('api/statusnet/config','api_statusnet_config',true);
|
||||
|
||||
|
||||
143
include/certfns.php
Normal file
143
include/certfns.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
require_once('library/ASNValue.class.php');
|
||||
|
||||
function DerToPem($Der, $Private=false)
|
||||
{
|
||||
//Encode:
|
||||
$Der = base64_encode($Der);
|
||||
//Split lines:
|
||||
$lines = str_split($Der, 65);
|
||||
$body = implode("\n", $lines);
|
||||
//Get title:
|
||||
$title = $Private? 'RSA PRIVATE KEY' : 'PUBLIC KEY';
|
||||
//Add wrapping:
|
||||
$result = "-----BEGIN {$title}-----\n";
|
||||
$result .= $body . "\n";
|
||||
$result .= "-----END {$title}-----\n";
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function DerToRsa($Der)
|
||||
{
|
||||
//Encode:
|
||||
$Der = base64_encode($Der);
|
||||
//Split lines:
|
||||
$lines = str_split($Der, 65);
|
||||
$body = implode("\n", $lines);
|
||||
//Get title:
|
||||
$title = 'RSA PUBLIC KEY';
|
||||
//Add wrapping:
|
||||
$result = "-----BEGIN {$title}-----\n";
|
||||
$result .= $body . "\n";
|
||||
$result .= "-----END {$title}-----\n";
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function pkcs8_encode($Modulus,$PublicExponent) {
|
||||
//Encode key sequence
|
||||
$modulus = new ASNValue(ASNValue::TAG_INTEGER);
|
||||
$modulus->SetIntBuffer($Modulus);
|
||||
$publicExponent = new ASNValue(ASNValue::TAG_INTEGER);
|
||||
$publicExponent->SetIntBuffer($PublicExponent);
|
||||
$keySequenceItems = array($modulus, $publicExponent);
|
||||
$keySequence = new ASNValue(ASNValue::TAG_SEQUENCE);
|
||||
$keySequence->SetSequence($keySequenceItems);
|
||||
//Encode bit string
|
||||
$bitStringValue = $keySequence->Encode();
|
||||
$bitStringValue = chr(0x00) . $bitStringValue; //Add unused bits byte
|
||||
$bitString = new ASNValue(ASNValue::TAG_BITSTRING);
|
||||
$bitString->Value = $bitStringValue;
|
||||
//Encode body
|
||||
$bodyValue = "\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00" . $bitString->Encode();
|
||||
$body = new ASNValue(ASNValue::TAG_SEQUENCE);
|
||||
$body->Value = $bodyValue;
|
||||
//Get DER encoded public key:
|
||||
$PublicDER = $body->Encode();
|
||||
return $PublicDER;
|
||||
}
|
||||
|
||||
|
||||
function pkcs1_encode($Modulus,$PublicExponent) {
|
||||
//Encode key sequence
|
||||
$modulus = new ASNValue(ASNValue::TAG_INTEGER);
|
||||
$modulus->SetIntBuffer($Modulus);
|
||||
$publicExponent = new ASNValue(ASNValue::TAG_INTEGER);
|
||||
$publicExponent->SetIntBuffer($PublicExponent);
|
||||
$keySequenceItems = array($modulus, $publicExponent);
|
||||
$keySequence = new ASNValue(ASNValue::TAG_SEQUENCE);
|
||||
$keySequence->SetSequence($keySequenceItems);
|
||||
//Encode bit string
|
||||
$bitStringValue = $keySequence->Encode();
|
||||
return $bitStringValue;
|
||||
|
||||
// $bitStringValue = chr(0x00) . $bitStringValue; //Add unused bits byte
|
||||
// $bitString = new ASNValue(ASNValue::TAG_BITSTRING);
|
||||
// $bitString->Value = $bitStringValue;
|
||||
//Encode body
|
||||
// $bodyValue = "\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01\x05\x00" . $bitString->Encode();
|
||||
// $body = new ASNValue(ASNValue::TAG_SEQUENCE);
|
||||
// $body->Value = $bodyValue;
|
||||
//Get DER encoded public key:
|
||||
// $PublicDER = $body->Encode();
|
||||
// return $PublicDER;
|
||||
}
|
||||
|
||||
|
||||
function metopem($m,$e) {
|
||||
$der = pkcs8_encode($m,$e);
|
||||
$key = DerToPem($der,false);
|
||||
return $key;
|
||||
}
|
||||
|
||||
|
||||
function pubrsatome($key,&$m,&$e) {
|
||||
require_once('library/asn1.php');
|
||||
require_once('include/salmon.php');
|
||||
|
||||
$lines = explode("\n",$key);
|
||||
unset($lines[0]);
|
||||
unset($lines[count($lines)]);
|
||||
$x = base64_decode(implode('',$lines));
|
||||
|
||||
$r = ASN_BASE::parseASNString($x);
|
||||
|
||||
// print_r($r);
|
||||
|
||||
$m = base64url_decode($r[0]->asnData[0]->asnData);
|
||||
$e = base64url_decode($r[0]->asnData[1]->asnData);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function rsatopem($key) {
|
||||
pubrsatome($key,$m,$e);
|
||||
return(metopem($m,$e));
|
||||
}
|
||||
|
||||
|
||||
function pemtome($key,&$m,&$e) {
|
||||
require_once('include/salmon.php');
|
||||
$lines = explode("\n",$key);
|
||||
unset($lines[0]);
|
||||
unset($lines[count($lines)]);
|
||||
$x = base64_decode(implode('',$lines));
|
||||
|
||||
$r = ASN_BASE::parseASNString($x);
|
||||
|
||||
$m = base64url_decode($r[0]->asnData[1]->asnData[0]->asnData[0]->asnData);
|
||||
$e = base64url_decode($r[0]->asnData[1]->asnData[0]->asnData[1]->asnData);
|
||||
}
|
||||
|
||||
function metorsa($m,$e) {
|
||||
$der = pkcs1_encode($m,$e);
|
||||
$key = DerToRsa($der);
|
||||
return $key;
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ function conversation(&$a, $items, $mode, $update) {
|
||||
|
||||
if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {
|
||||
|
||||
if($item['type'] === 'wall') {
|
||||
if($item['wall']) {
|
||||
|
||||
// On the network page, I am the owner. On the display page it will be the profile owner.
|
||||
// This will have been stored in $a->page_contact by our calling page.
|
||||
@@ -359,7 +359,7 @@ function conversation(&$a, $items, $mode, $update) {
|
||||
$template = $wallwall;
|
||||
$commentww = 'ww';
|
||||
}
|
||||
if(($item['type'] === 'remote') && (strlen($item['owner-link'])) && ($item['owner-link'] != $item['author-link'])) {
|
||||
if((! $item['wall']) && (strlen($item['owner-link'])) && ($item['owner-link'] != $item['author-link'])) {
|
||||
|
||||
// Could be anybody.
|
||||
|
||||
|
||||
@@ -84,12 +84,47 @@ 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');
|
||||
$y = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
|
||||
$o = datesel('',1920,$y,true,$year,$month,$day);
|
||||
$f = get_config('system','birthday_input_format');
|
||||
if(! $f)
|
||||
$f = 'ymd';
|
||||
$o = datesel($f,'',1920,$y,true,$year,$month,$day);
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
function datesel_format($f) {
|
||||
|
||||
$o = '';
|
||||
|
||||
if(strlen($f)) {
|
||||
for($x = 0; $x < strlen($f); $x ++) {
|
||||
switch($f[$x]) {
|
||||
case 'y':
|
||||
if(strlen($o))
|
||||
$o .= '-';
|
||||
$o .= t('year');
|
||||
break;
|
||||
case 'm':
|
||||
if(strlen($o))
|
||||
$o .= '-';
|
||||
$o .= t('month');
|
||||
break;
|
||||
case 'd':
|
||||
if(strlen($o))
|
||||
$o .= '-';
|
||||
$o .= t('day');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
// returns a date selector.
|
||||
// $f = format string, e.g. 'ymd' or 'mdy'
|
||||
// $pre = prefix (if needed) for HTML name and class fields
|
||||
// $ymin = first year shown in selector dropdown
|
||||
// $ymax = last year shown in selector dropdown
|
||||
@@ -99,40 +134,52 @@ function dob($dob) {
|
||||
// $d = already selected day
|
||||
|
||||
if(! function_exists('datesel')) {
|
||||
function datesel($pre,$ymin,$ymax,$allow_blank,$y,$m,$d) {
|
||||
function datesel($f,$pre,$ymin,$ymax,$allow_blank,$y,$m,$d) {
|
||||
|
||||
$o = '';
|
||||
$o .= "<select name=\"{$pre}year\" class=\"{$pre}year\" size=\"1\">";
|
||||
if($allow_blank) {
|
||||
$sel = (($y == '0000') ? " selected=\"selected\" " : "");
|
||||
$o .= "<option value=\"0000\" $sel ></option>";
|
||||
}
|
||||
|
||||
if($ymax > $ymin) {
|
||||
for($x = $ymax; $x >= $ymin; $x --) {
|
||||
$sel = (($x == $y) ? " selected=\"selected\" " : "");
|
||||
$o .= "<option value=\"$x\" $sel>$x</option>";
|
||||
}
|
||||
}
|
||||
else {
|
||||
for($x = $ymax; $x <= $ymin; $x ++) {
|
||||
$sel = (($x == $y) ? " selected=\"selected\" " : "");
|
||||
$o .= "<option value=\"$x\" $sel>$x</option>";
|
||||
}
|
||||
}
|
||||
if(strlen($f)) {
|
||||
for($z = 0; $z < strlen($f); $z ++) {
|
||||
if($f[$z] === 'y') {
|
||||
|
||||
$o .= "<select name=\"{$pre}year\" class=\"{$pre}year\" size=\"1\">";
|
||||
if($allow_blank) {
|
||||
$sel = (($y == '0000') ? " selected=\"selected\" " : "");
|
||||
$o .= "<option value=\"0000\" $sel ></option>";
|
||||
}
|
||||
|
||||
if($ymax > $ymin) {
|
||||
for($x = $ymax; $x >= $ymin; $x --) {
|
||||
$sel = (($x == $y) ? " selected=\"selected\" " : "");
|
||||
$o .= "<option value=\"$x\" $sel>$x</option>";
|
||||
}
|
||||
}
|
||||
else {
|
||||
for($x = $ymax; $x <= $ymin; $x ++) {
|
||||
$sel = (($x == $y) ? " selected=\"selected\" " : "");
|
||||
$o .= "<option value=\"$x\" $sel>$x</option>";
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($f[$z] == 'm') {
|
||||
|
||||
$o .= "</select> <select name=\"{$pre}month\" class=\"{$pre}month\" size=\"1\">";
|
||||
for($x = (($allow_blank) ? 0 : 1); $x <= 12; $x ++) {
|
||||
$sel = (($x == $m) ? " selected=\"selected\" " : "");
|
||||
$y = (($x) ? $x : '');
|
||||
$o .= "<option value=\"$x\" $sel>$y</option>";
|
||||
}
|
||||
$o .= "</select> <select name=\"{$pre}month\" class=\"{$pre}month\" size=\"1\">";
|
||||
for($x = (($allow_blank) ? 0 : 1); $x <= 12; $x ++) {
|
||||
$sel = (($x == $m) ? " selected=\"selected\" " : "");
|
||||
$y = (($x) ? $x : '');
|
||||
$o .= "<option value=\"$x\" $sel>$y</option>";
|
||||
}
|
||||
}
|
||||
elseif($f[$z] == 'd') {
|
||||
|
||||
$o .= "</select> <select name=\"{$pre}day\" class=\"{$pre}day\" size=\"1\">";
|
||||
for($x = (($allow_blank) ? 0 : 1); $x <= 31; $x ++) {
|
||||
$sel = (($x == $d) ? " selected=\"selected\" " : "");
|
||||
$y = (($x) ? $x : '');
|
||||
$o .= "<option value=\"$x\" $sel>$y</option>";
|
||||
$o .= "</select> <select name=\"{$pre}day\" class=\"{$pre}day\" size=\"1\">";
|
||||
for($x = (($allow_blank) ? 0 : 1); $x <= 31; $x ++) {
|
||||
$sel = (($x == $d) ? " selected=\"selected\" " : "");
|
||||
$y = (($x) ? $x : '');
|
||||
$o .= "<option value=\"$x\" $sel>$y</option>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$o .= "</select>";
|
||||
|
||||
@@ -197,6 +197,7 @@ function event_store($arr) {
|
||||
$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
|
||||
$arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0);
|
||||
$arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(),$arr['uid']));
|
||||
$arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0);
|
||||
|
||||
if($arr['cid'])
|
||||
$c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
@@ -275,7 +276,7 @@ function event_store($arr) {
|
||||
$object .= '</object>' . "\n";
|
||||
|
||||
|
||||
q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s', `private` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
dbesc(format_event_bbcode($arr)),
|
||||
dbesc($object),
|
||||
dbesc($arr['allow_cid']),
|
||||
@@ -283,6 +284,7 @@ function event_store($arr) {
|
||||
dbesc($arr['deny_cid']),
|
||||
dbesc($arr['deny_gid']),
|
||||
dbesc($arr['edited']),
|
||||
intval($arr['private']),
|
||||
intval($r[0]['id']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
@@ -341,10 +343,11 @@ function event_store($arr) {
|
||||
$item_arr['author-link'] = $contact['url'];
|
||||
$item_arr['author-avatar'] = $contact['thumb'];
|
||||
$item_arr['title'] = '';
|
||||
$item_arr['allow_cid'] = $str_contact_allow;
|
||||
$item_arr['allow_gid'] = $str_group_allow;
|
||||
$item_arr['deny_cid'] = $str_contact_deny;
|
||||
$item_arr['deny_gid'] = $str_group_deny;
|
||||
$item_arr['allow_cid'] = $arr['allow_cid'];
|
||||
$item_arr['allow_gid'] = $arr['allow_gid'];
|
||||
$item_arr['deny_cid'] = $arr['deny_cid'];
|
||||
$item_arr['deny_gid'] = $arr['deny_gid'];
|
||||
$item_arr['private'] = $arr['private'];
|
||||
$item_arr['last-child'] = 1;
|
||||
$item_arr['visible'] = 1;
|
||||
$item_arr['verb'] = ACTIVITY_POST;
|
||||
|
||||
@@ -1349,6 +1349,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee
|
||||
$ev['uid'] = $importer['uid'];
|
||||
$ev['uri'] = $item_id;
|
||||
$ev['edited'] = $datarray['edited'];
|
||||
$ev['private'] = $datarray['private'];
|
||||
|
||||
if(is_array($contact))
|
||||
$ev['cid'] = $contact['id'];
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
in_progress = true;
|
||||
var udargs = ((netargs.length) ? '/' + netargs : '');
|
||||
var update_url = 'update_' + src + udargs + '?p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
|
||||
var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
|
||||
|
||||
$.get(update_url,function(data) {
|
||||
in_progress = false;
|
||||
|
||||
@@ -145,7 +145,7 @@ function notifier_run($argv, $argc){
|
||||
|
||||
$parent = $items[0];
|
||||
|
||||
if($parent['type'] === 'remote' && (! $expire)) {
|
||||
if($parent['wall'] == 0 && (! $expire)) {
|
||||
// local followup to remote post
|
||||
$followup = true;
|
||||
$notify_hub = false; // not public
|
||||
@@ -504,7 +504,7 @@ function notifier_run($argv, $argc){
|
||||
|
||||
// send additional slaps to mentioned remote tags (@foo@example.com)
|
||||
|
||||
if($slap && count($url_recipients) && $followup && $notify_hub && (! $expire)) {
|
||||
if($slap && count($url_recipients) && ($followup || $top_level) && $notify_hub && (! $expire)) {
|
||||
if(! get_config('system','dfrn_only')) {
|
||||
foreach($url_recipients as $url) {
|
||||
if($url) {
|
||||
|
||||
Reference in New Issue
Block a user