Merge remote-tracking branch 'upstream/develop' into item-permissions

This commit is contained in:
Michael 2018-01-20 10:17:04 +00:00
commit b5b298c8d6
21 changed files with 177 additions and 243 deletions

View file

@ -18,7 +18,6 @@
"ezyang/htmlpurifier": "~4.7.0",
"mobiledetect/mobiledetectlib": "2.8.*",
"league/html-to-markdown": "~4.4.1",
"defuse/php-encryption": "1.*",
"pear/Text_LanguageDetect": "1.*",
"pear/Text_Highlighter": "dev-master",
"paragonie/random_compat": "^2.0",
@ -27,7 +26,8 @@
"fxp/composer-asset-plugin": "~1.3",
"bower-asset/base64": "^1.0",
"npm-asset/jquery": "^1.11.2",
"npm-asset/jquery-colorbox": "^1.6"
"npm-asset/jquery-colorbox": "^1.6",
"bower-asset/Chart-js": "^2.7"
},
"repositories": [
{

79
composer.lock generated
View file

@ -4,8 +4,40 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "228247829bf46d313ca451f94b87c7ef",
"content-hash": "7fcbb730be98076fe8318b03c858f41c",
"packages": [
{
"name": "bower-asset/Chart-js",
"version": "v2.7.1",
"source": {
"type": "git",
"url": "https://github.com/chartjs/Chart.js.git",
"reference": "0fead21939b92c15093c1b7d5ee2627fb5900fff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/chartjs/Chart.js/zipball/0fead21939b92c15093c1b7d5ee2627fb5900fff",
"reference": "0fead21939b92c15093c1b7d5ee2627fb5900fff",
"shasum": ""
},
"type": "bower-asset-library",
"extra": {
"bower-asset-main": "./dist/Chart.js",
"bower-asset-ignore": [
".github",
".codeclimate.yml",
".gitignore",
".npmignore",
".travis.yml",
"scripts"
]
},
"license": [
"MIT"
],
"description": "Simple HTML5 charts using the canvas element.",
"time": "2017-10-28T15:01:52+00:00"
},
{
"name": "bower-asset/base64",
"version": "1.0.1",
@ -37,51 +69,6 @@
"description": "Base64 encoding and decoding",
"time": "2017-03-25T21:16:21+00:00"
},
{
"name": "defuse/php-encryption",
"version": "v1.2.1",
"source": {
"type": "git",
"url": "https://github.com/defuse/php-encryption.git",
"reference": "b87737b2eec06b13f025cabea847338fa203d1b4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/defuse/php-encryption/zipball/b87737b2eec06b13f025cabea847338fa203d1b4",
"reference": "b87737b2eec06b13f025cabea847338fa203d1b4",
"shasum": ""
},
"require": {
"ext-mcrypt": "*",
"ext-openssl": "*",
"php": ">=5.4.0"
},
"type": "library",
"autoload": {
"files": [
"Crypto.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Hornby",
"email": "havoc@defuse.ca"
}
],
"description": "Secure PHP Encryption Library",
"keywords": [
"aes",
"cipher",
"encryption",
"mcrypt",
"security"
],
"time": "2015-03-14T20:27:45+00:00"
},
{
"name": "ezyang/htmlpurifier",
"version": "v4.7.0",

View file

@ -61,10 +61,9 @@ $a->config['system']['maximagesize'] = 800000;
$a->config['php_path'] = 'php';
// Server-to-server private message encryption (RINO) is allowed by default.
// Encryption will only be provided if this setting is set to a non zero value
// set to 0 to disable, 2 to enable, 1 is deprecated
// set to 0 to disable, 1 to enable
$a->config['system']['rino_encrypt'] = 2;
$a->config['system']['rino_encrypt'] = 1;
// allowed themes (change this from admin panel after installation)

View file

@ -968,11 +968,12 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
if (!$forplaintext) {
// Autolink feature
// Autolink feature (thanks to http://code.seebz.net/p/autolink-php/)
$autolink_regex = "`([^\]\=\"']|^)(https?\://[^\s<]+[^\s<\.\)])`ism";
if ($simplehtml != 7) {
$Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+)/ism", '$1<a href="$2" target="_blank">$2</a>', $Text);
$Text = preg_replace($autolink_regex, '$1<a href="$2" target="_blank">$2</a>', $Text);
} else {
$Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+)/ism", '$1[url]$2[/url]', $Text);
$Text = preg_replace($autolink_regex, '$1[url]$2[/url]', $Text);
$Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism", 'bb_style_url', $Text);
$Text = preg_replace_callback("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", 'bb_style_url', $Text);

View file

@ -1145,6 +1145,7 @@ class dba {
$condition_string = self::buildCondition($condition);
$order_string = '';
if (isset($params['order'])) {
$order_string = " ORDER BY ";
foreach ($params['order'] AS $fields => $order) {
@ -1157,6 +1158,7 @@ class dba {
$order_string = substr($order_string, 0, -2);
}
$limit_string = '';
if (isset($params['limit']) && is_int($params['limit'])) {
$limit_string = " LIMIT " . $params['limit'];
}

View file

@ -488,7 +488,7 @@ function validate_url($url)
/// @TODO Really suppress function outcomes? Why not find them + debug them?
$h = @parse_url($url);
if ((is_array($h)) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
if ((is_array($h)) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
return $url;
}

View file

@ -19,12 +19,12 @@ require_once "include/dba.php";
*/
function get_browser_language() {
$lang_list = [];
if (x($_SERVER, 'HTTP_ACCEPT_LANGUAGE')) {
// break up string into pieces (languages and q factors)
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i',
$_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
$lang_list = [];
if (count($lang_parse[1])) {
// go through the list of prefered languages and add a generic language
// for sub-linguas (e.g. de-ch will add de) if not already in array
@ -41,8 +41,7 @@ function get_browser_language() {
}
// check if we have translations for the preferred languages and pick the 1st that has
for ($i = 0; $i < count($lang_list); $i++) {
$lang = $lang_list[$i];
foreach ($lang_list as $lang) {
if ($lang === 'en' || (file_exists("view/lang/$lang") && is_dir("view/lang/$lang"))) {
$preferred = $lang;
break;

File diff suppressed because one or more lines are too long

View file

@ -1,7 +0,0 @@
Copyright (c) 2013-2015 Nick Downie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,20 +0,0 @@
# Chart.js
[![Build Status](https://travis-ci.org/nnnick/Chart.js.svg?branch=master)](https://travis-ci.org/nnnick/Chart.js) [![Code Climate](https://codeclimate.com/github/nnnick/Chart.js/badges/gpa.svg)](https://codeclimate.com/github/nnnick/Chart.js)
*Simple HTML5 Charts using the canvas element* [chartjs.org](http://www.chartjs.org)
## Documentation
You can find documentation at [chartjs.org/docs](http://www.chartjs.org/docs/). The markdown files that build the site are available under `/docs`. Please note - in some of the json examples of configuration you might notice some liquid tags - this is just for the generating the site html, please disregard.
## Bugs, issues and contributing
Before submitting an issue or a pull request to the project, please take a moment to look over the [contributing guidelines](https://github.com/nnnick/Chart.js/blob/master/CONTRIBUTING.md) first.
For support using Chart.js, please post questions with the [`chartjs` tag on Stack Overflow](http://stackoverflow.com/questions/tagged/chartjs).
## License
Chart.js is available under the [MIT license](http://opensource.org/licenses/MIT).

View file

@ -1336,7 +1336,7 @@ function admin_page_site(App $a)
'$relocate_url' => ['relocate_url', t("New base url"), System::baseUrl(), t("Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.")],
'$rino' => ['rino', t("RINO Encryption"), intval(Config::get('system','rino_encrypt')), t("Encryption layer between nodes."), ["Disabled", "RINO1 (deprecated)", "RINO2"]],
'$rino' => ['rino', t("RINO Encryption"), intval(Config::get('system','rino_encrypt')), t("Encryption layer between nodes."), [0 => "Disabled", 1 => "Enabled"]],
'$worker_queues' => ['worker_queues', t("Maximum number of parallel workers"), Config::get('system','worker_queues'), t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")],
'$worker_dont_fork' => ['worker_dont_fork', t("Don't use 'proc_open' with the worker"), Config::get('system','worker_dont_fork'), t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of worker calls in your crontab.")],

View file

@ -143,7 +143,7 @@ function dfrn_notify_post(App $a) {
// if local rino is lower than remote rino, abort: should not happen!
// but only for $remote_rino > 1, because old code did't send rino version
if ($rino_remote_version > 1 && $rino < $rino_remote) {
if ($rino_remote > 1 && $rino < $rino_remote) {
logger("rino version '$rino_remote' is lower than supported '$rino'");
xml_status(0, "rino version '$rino_remote' is lower than supported '$rino'");
}
@ -166,44 +166,18 @@ function dfrn_notify_post(App $a) {
}
}
#logger('rino: received key : ' . $final_key);
switch($rino_remote) {
case 0:
case 1:
/*
*we got a key. old code send only the key, without RINO version.
* we assume RINO 1 if key and no RINO version
*/
// we got a key. old code send only the key, without RINO version.
// we assume RINO 1 if key and no RINO version
$data = DFRN::aesDecrypt(hex2bin($data), $final_key);
break;
case 2:
try {
$data = \Crypto::decrypt(hex2bin($data), $final_key);
} catch (\InvalidCiphertextException $ex) { // VERY IMPORTANT
/*
* Either:
* 1. The ciphertext was modified by the attacker,
* 2. The key is wrong, or
* 3. $ciphertext is not a valid ciphertext or was corrupted.
* Assume the worst.
*/
logger('The ciphertext has been tampered with!');
xml_status(0, 'The ciphertext has been tampered with!');
} catch (\CryptoTestFailedException $ex) {
logger('Cannot safely perform dencryption');
xml_status(0, 'CryptoTestFailed');
} catch (\CannotPerformOperationException $ex) {
logger('Cannot safely perform decryption');
xml_status(0, 'Cannot safely perform decryption');
}
break;
default:
logger("rino: invalid sent version '$rino_remote'");
xml_status(0, "Invalid sent version '$rino_remote'");
}
logger('rino: decrypted data: ' . $data, LOGGER_DATA);
}

View file

@ -638,8 +638,8 @@ function dfrn_request_content(App $a)
$page_desc = t("Please enter your 'Identity Address' from one of the following supported communications networks:");
$invite_desc = sprintf(
t('If you are not yet a member of the free social web, <a href="%s/siteinfo">follow this link to find a public Friendica site and join us today</a>.'),
get_server()
t('If you are not yet a member of the free social web, <a href="%s">follow this link to find a public Friendica site and join us today</a>.'),
get_server() . '/servers'
);
$o = replace_macros($tpl, [

View file

@ -63,7 +63,7 @@ function install_post(App $a) {
$timezone = notags(trim($_POST['timezone']));
$language = notags(trim($_POST['language']));
$adminmail = notags(trim($_POST['adminmail']));
$rino = 2;
$rino = 1;
// connect to db
dba::connect($dbhost, $dbuser, $dbpass, $dbdata, true);

View file

@ -135,6 +135,7 @@ function search_content(App $a) {
Nav::setSelected('search');
$search = '';
if (x($a->data,'search'))
$search = notags(trim($a->data['search']));
else

View file

@ -22,11 +22,14 @@ use Friendica\Model\Term;
use Friendica\Model\User;
use Friendica\Object\Image;
use Friendica\Protocol\OStatus;
use Friendica\Util\Crypto;
use Friendica\Util\XML;
use dba;
use DOMDocument;
use DOMXPath;
use HTMLPurifier;
use HTMLPurifier_Config;
require_once 'boot.php';
require_once 'include/dba.php';
@ -1291,31 +1294,9 @@ class DFRN
switch ($rino_remote_version) {
case 1:
// Deprecated rino version!
$key = openssl_random_pseudo_bytes(16);
$data = self::aesEncrypt($postvars['data'], $key);
break;
case 2:
// RINO 2 based on php-encryption
try {
$key = \Crypto::CreateNewRandomKey();
} catch (\CryptoTestFailedException $ex) {
logger('Cannot safely create a key');
return -4;
} catch (\CannotPerformOperationException $ex) {
logger('Cannot safely create a key');
return -5;
}
try {
$data = \Crypto::Encrypt($postvars['data'], $key);
} catch (\CryptoTestFailedException $ex) {
logger('Cannot safely perform encryption');
return -6;
} catch (\CannotPerformOperationException $ex) {
logger('Cannot safely perform encryption');
return -7;
}
break;
default:
logger("rino: invalid requested version '$rino_remote_version'");
return -8;
@ -1324,9 +1305,6 @@ class DFRN
$postvars['rino'] = $rino_remote_version;
$postvars['data'] = bin2hex($data);
//logger('rino: sent key = ' . $key, LOGGER_DEBUG);
if ($dfrn_version >= 2.1) {
if (($contact['duplex'] && strlen($contact['pubkey']))
|| ($owner['page-flags'] == PAGE_COMMUNITY && strlen($contact['pubkey']))
@ -2177,8 +2155,6 @@ class DFRN
* valid community action. Also forum_mode makes it valid for sure.
* If neither, it's not.
*/
/// @TODO Maybe merge these if() blocks into one?
if ($is_a_remote_action && $community && (!$r[0]["forum_mode"]) && (!$r[0]["wall"])) {
$is_a_remote_action = false;
logger("not a community action");
@ -2380,21 +2356,12 @@ class DFRN
$title = "";
foreach ($links as $link) {
foreach ($link->attributes as $attributes) {
/// @TODO Rewrite these repeated (same) if () statements to a switch()
if ($attributes->name == "href") {
$href = $attributes->textContent;
}
if ($attributes->name == "rel") {
$rel = $attributes->textContent;
}
if ($attributes->name == "type") {
$type = $attributes->textContent;
}
if ($attributes->name == "length") {
$length = $attributes->textContent;
}
if ($attributes->name == "title") {
$title = $attributes->textContent;
switch ($attributes->name) {
case "href" : $href = $attributes->textContent; break;
case "rel" : $rel = $attributes->textContent; break;
case "type" : $type = $attributes->textContent; break;
case "length": $length = $attributes->textContent; break;
case "title" : $title = $attributes->textContent; break;
}
}
if (($rel != "") && ($href != "")) {
@ -2489,13 +2456,13 @@ class DFRN
$item['body'] = OEmbed::HTML2BBCode($item['body']);
$config = \HTMLPurifier_Config::createDefault();
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
// we shouldn't need a whitelist, because the bbcode converter
// will strip out any unsupported tags.
$purifier = new \HTMLPurifier($config);
$purifier = new HTMLPurifier($config);
$item['body'] = $purifier->purify($item['body']);
$item['body'] = @html2bbcode($item['body']);
@ -2645,16 +2612,6 @@ class DFRN
if (($item["network"] != $author["network"]) && ($author["network"] != "")) {
$item["network"] = $author["network"];
}
/// @TODO maybe remove this old-lost code then?
// This code was taken from the old DFRN code
// When activated, forums don't work.
// And: Why should we disallow commenting by followers?
// the behaviour is now similar to the Diaspora part.
//if ($importer["rel"] == CONTACT_IS_FOLLOWER) {
// logger("Contact ".$importer["id"]." is only follower. Quitting", LOGGER_DEBUG);
// return;
//}
}
if ($entrytype == DFRN_REPLY_RC) {
@ -2671,12 +2628,11 @@ class DFRN
$ev = bbtoevent($item["body"]);
if ((x($ev, "desc") || x($ev, "summary")) && x($ev, "start")) {
logger("Event in item ".$item["uri"]." was found.", LOGGER_DEBUG);
/// @TODO Mixure of "/' ahead ...
$ev["cid"] = $importer["id"];
$ev["uid"] = $importer["uid"];
$ev["uri"] = $item["uri"];
$ev["edited"] = $item["edited"];
$ev['private'] = $item['private'];
$ev["private"] = $item["private"];
$ev["guid"] = $item["guid"];
$r = q(

View file

@ -49,10 +49,9 @@ $a->config['php_path'] = '/usr/bin/php';
// Server-to-server private message encryption (RINO) is allowed by default.
// Encryption will only be provided if this setting is true and the
// PHP mcrypt extension is installed on both systems
// set to 0 to disable, 1 to enable
$a->config['system']['rino_encrypt'] = true;
$a->config['system']['rino_encrypt'] = 1;
// default system theme

View file

@ -399,14 +399,9 @@ a {
color: #00a700;
}
.federation-graph {
width: 400px;
height: 400px;
float: right;
margin: 20px;
margin: 0 auto;
}
.federation-network-graph {
width: 240px;
height: 240px;
float: left;
margin: 20px;
}

View file

@ -1,12 +1,12 @@
<script src="{{$baseurl}}/library/Chart.js-1.0.2/Chart.min.js"></script>
<canvas id="FederationChart" class="federation-graph"></canvas>
<script src="{{$baseurl}}/vendor/asset/Chart-js/dist/Chart.min.js"></script>
<canvas id="FederationChart" class="federation-graph" width="400" height="400"></canvas>
<div id="adminpage">
<h1>{{$title}} - {{$page}}</h1>
<p>{{$intro}}</p>
{{if not $autoactive}}
<p class="error-message">{{$hint}}</p>
{{/if}}
<p>{{$legendtext}}
<p>{{$legendtext}}</p>
<ul>
{{foreach $counts as $c}}
{{if $c[0]['total'] > 0}}
@ -14,16 +14,42 @@
{{/if}}
{{/foreach}}
</ul>
</p>
</div>
<script>
var FedData = [
var FedData = {
datasets: [{
data: [
{{foreach $counts as $c}}
{ value: {{$c[0]['total']}}, label: "{{$c[0]['platform']}}", color: '{{$c[3]}}', highlight: "#EE90A1", },
{{$c[0]['total']}},
{{/foreach}}
];
],
backgroundColor: [
{{foreach $counts as $c}}
'{{$c[3]}}',
{{/foreach}}
],
hoverBackgroundColor: [
{{foreach $counts as $c}}
'#EE90A1',
{{/foreach}}
]
}],
labels: [
{{foreach $counts as $c}}
"{{$c[0]['platform']}}",
{{/foreach}}
]
};
var ctx = document.getElementById("FederationChart").getContext("2d");
var myDoughnutChart = new Chart(ctx).Doughnut(FedData, { animateRotate : false, });
var myDoughnutChart = new Chart(ctx, {
type: 'doughnut',
data: FedData,
options: {
legend: {display: false},
animation: {animateRotate: false},
responsive: false
}
});
</script>
<table id="federation-stats">
@ -36,19 +62,53 @@ var myDoughnutChart = new Chart(ctx).Doughnut(FedData, { animateRotate : false,
</tr>
<tr>
<td colspan="3" class="federation-data">
<canvas id="{{$c[2]}}Chart" class="federation-network-graph"></canvas>
<canvas id="{{$c[2]}}Chart" class="federation-network-graph" width="240" height="240"></canvas>
<script>
var {{$c[2]}}data = [
var {{$c[2]}}data = {
datasets: [{
data: [
{{foreach $c[1] as $v}}
{ value: {{$v['total']}}, label: '{{$v['version']}}', color: "{{$c[3]}}", highlight: "#EE90A1",},
{{$v['total']}},
{{/foreach}}
];
],
backgroundColor: [
{{foreach $c[1] as $v}}
'{{$c[3]}}',
{{/foreach}}
],
hoverBackgroundColor: [
{{foreach $c[1] as $v}}
'#EE90A1',
{{/foreach}}
]
}],
labels: [
{{foreach $c[1] as $v}}
'{{$v['version']}}',
{{/foreach}}
]
};
var ctx = document.getElementById("{{$c[2]}}Chart").getContext("2d");
var my{{$c[2]}}DoughnutChart = new Chart(ctx).Doughnut({{$c[2]}}data, {animateRotate : false,});
var my{{$c[2]}}DoughnutChart = new Chart(ctx, {
type: 'doughnut',
data: {{$c[2]}}data,
options: {
legend: {display: false},
animation: {animateRotate: false},
responsive: false
}
});
</script>
<ul class="federation-stats">
{{foreach $c[1] as $v}}
<li>{{if ($c[0]['platform']==='Friendica' and $version===$v['version']) }}<span class="version-match">{{$v['version']}}</span>{{else}}{{$v['version']}}{{/if}} ({{$v['total']}})</li>
<li>
{{if ($c[0]['platform']==='Friendica' and $version===$v['version']) }}
<span class="version-match">{{$v['version']}}</span>
{{else}}
{{$v['version']}}
{{/if}}
({{$v['total']}})
</li>
{{/foreach}}
</ul>
</td>

View file

@ -78,8 +78,7 @@ $a->config['max_import_size'] = 200000;
$a->config['system']['maximagesize'] = 800000;
// Server-to-server private message encryption (RINO) is allowed by default.
// Encryption will only be provided if this setting is set to a non zero value
// set to 0 to disable, 2 to enable, 1 is deprecated
// set to 0 to disable, 1 to enable
$a->config['system']['rino_encrypt'] = {{$rino}};

View file

@ -73,7 +73,7 @@ aside hr,
section hr {
border-color: rgba(238, 238, 238, $contentbg_transp);
}
iframe, img {
iframe, img, video {
max-width: 100%;
}
blockquote {