forked from friendica/friendica-addons
Compare commits
208 commits
fancybox
...
2025.07-rc
Author | SHA1 | Date | |
---|---|---|---|
28fcccd9d5 | |||
1cc54a83a9 | |||
e76575eb52 | |||
b39ab36cee | |||
ea41e2f1b6 | |||
9387db358c | |||
715f700323 | |||
|
8a8639b07e | ||
97b09d34e9 | |||
2289fdc97e | |||
d95137ce6b | |||
cd4f102d02 | |||
4daaf17110 | |||
|
48ff761bdb | ||
45d3a6fb74 | |||
97a3b5815b | |||
95a9f7038a | |||
|
06b4f164f5 | ||
|
38a8e9a169 | ||
|
db875bc755 | ||
|
dd58b000d9 | ||
|
cdeaa433a1 | ||
|
ad31685237 | ||
|
2667b4d78e | ||
|
c56ec7c7c4 | ||
|
417a3a8198 | ||
|
dda6710b10 | ||
|
21a7529a0e | ||
|
bbce8c345f | ||
|
512ad63dbf | ||
|
cfe27582ee | ||
|
d488c1907a | ||
81b4d3cab4 | |||
ec718ea294 | |||
8411a0f5ed | |||
859d92ab02 | |||
73d4bed31c | |||
07008af9c1 | |||
0fb2c05244 | |||
373c30b5d0 | |||
4454ce5883 | |||
|
5701853d29 | ||
|
ed75360eb4 | ||
|
c4f8c65817 | ||
|
f7ec934893 | ||
|
0bafcc78f8 | ||
|
e6d92cc94a | ||
16a8172c37 | |||
16127854dd | |||
7e1bcbdedb | |||
|
8384b74696 | ||
c5e3d1f047 | |||
cbfcfb3349 | |||
cdba300c7b | |||
|
4c8c262b07 | ||
|
dd775645d4 | ||
|
e4d14cab62 | ||
|
a7b26f6453 | ||
|
763c5026f2 | ||
|
bfdccb451c | ||
|
ac6c1d7a49 | ||
|
32a3160445 | ||
|
d50650b8cf | ||
|
e32ba1ce7b | ||
|
119ba0a78e | ||
|
469d3e6d61 | ||
|
757d72c360 | ||
|
9ceff8f592 | ||
|
9a91bae363 | ||
|
9ed02034f1 | ||
|
f08750199d | ||
|
a488f25131 | ||
|
5d51c5b56e | ||
|
5002318089 | ||
|
15a951235f | ||
|
e7755584cb | ||
|
1db552ead9 | ||
|
b38c2d18be | ||
|
4881e6004a | ||
|
1d1a00df27 | ||
|
77ebaca281 | ||
|
d78ea50516 | ||
|
41f280f0c7 | ||
|
4310c1355d | ||
1cc5a6688e | |||
|
0b4aaac9fd | ||
|
c506367273 | ||
|
792f50f835 | ||
|
2b5764c132 | ||
69e75ef88b | |||
|
7a7940a8ed | ||
|
2741227bfa | ||
13cffd76db | |||
|
0d0aae36cd | ||
28d3041694 | |||
cb70a4eaff | |||
0c96d0f4bb | |||
|
ee8c852d38 | ||
|
807598dbd0 | ||
|
8ba4cd5f61 | ||
|
3441c9bd0e | ||
44d2079da2 | |||
|
b360b553ed | ||
|
46b3836720 | ||
|
81639ff615 | ||
|
d495810b2d | ||
|
2ef9cb8add | ||
|
8e65141cb5 | ||
|
d034e311cb | ||
db10da2f02 | |||
995e81e951 |
|||
cb2ab0684e | |||
3b079aef8d | |||
9e1f7dc468 | |||
|
5f557ed0ab | ||
7172695705 | |||
5f50fd2498 |
|||
0697f078f1 |
|||
f2a9eb151d | |||
16e06f9b2b | |||
a63fb08525 | |||
6cf388f141 | |||
|
c4bea164c7 | ||
04c402607b | |||
|
68ee5260b0 |
||
81a84fb895 | |||
|
729b6e5210 | ||
|
a71db771d9 | ||
|
2f89827dea | ||
|
8e778593ca | ||
|
5b623c8368 | ||
|
bda683c56b | ||
|
7fa2dfc608 | ||
|
c0971779c6 | ||
|
6b1b043dd8 | ||
|
984e7c5e5d | ||
|
d08a280ba6 | ||
|
ee1a917612 | ||
|
a53d5ae29b | ||
|
3cf53a334d | ||
|
81f232d57e | ||
|
1860e732ae | ||
|
cf8a7870f3 | ||
|
31198294c7 | ||
|
84659fc1ad | ||
|
5f7482d081 | ||
|
fff140ad43 | ||
|
cfb6b3123f | ||
|
b99ac65c0b | ||
|
89a673cc11 | ||
|
2fe37c6d4a | ||
|
5b13274bed | ||
|
82ed43f507 | ||
|
43c71412e4 | ||
fb9c10f8c5 | |||
|
1e68417278 | ||
|
7d02c9b53c | ||
|
b5c647bd5d | ||
|
1bd7cd6e71 | ||
|
def43f3167 | ||
|
b661448344 | ||
|
922bace555 | ||
|
4a2fc7884c | ||
|
9d172b7082 | ||
|
4527df602f | ||
|
15c21cebb1 | ||
|
b6a47699bf | ||
|
a41f8c13fe | ||
|
fccf361ef1 | ||
|
43ee267d38 | ||
|
3f89aa1806 | ||
|
50912fdc17 | ||
|
c04016b7d3 | ||
|
5f6f374f09 | ||
|
e86d15993b | ||
|
ace19814d7 | ||
|
fcec1a3d83 | ||
|
04afbe36e3 | ||
|
07993f7098 | ||
|
bee780552d | ||
|
5664bc84fb | ||
|
7246f3deda | ||
|
0204f54b0e | ||
72e7e2a5b7 | |||
|
5f2a9e9891 | ||
|
a6de4225c6 | ||
|
23227e5b0f | ||
|
7872400467 | ||
|
a5aaea5211 | ||
|
7453c6f41a | ||
|
9cb728d19a | ||
|
e488f597be | ||
|
1346a92505 | ||
|
9117626c6a | ||
|
90ffd40d58 | ||
93a91a95e9 | |||
|
fc0dda0cd9 | ||
|
d7d6a43655 | ||
|
c58ca7dcc9 | ||
|
6df91dd37b | ||
|
e9d3afb483 | ||
|
348c44c972 | ||
58180bd732 | |||
|
bf679262b0 | ||
c4e24833eb | |||
|
ecf0edb520 | ||
3a5acf95f7 | |||
|
2ea40dc897 |
169 changed files with 10644 additions and 2960 deletions
|
@ -1,6 +1,6 @@
|
|||
skip_clone: true
|
||||
|
||||
pipeline:
|
||||
steps:
|
||||
clone_friendica_base:
|
||||
image: alpine/git
|
||||
commands:
|
||||
|
@ -56,6 +56,10 @@ pipeline:
|
|||
- /tmp/drone-cache:/tmp/cache
|
||||
when:
|
||||
event: pull_request
|
||||
phpstan:
|
||||
image: friendicaci/php8.3:php8.3.3
|
||||
commands:
|
||||
- ./bin/composer.phar run phpstan;
|
||||
check:
|
||||
image: friendicaci/php-cs
|
||||
commands:
|
||||
|
|
|
@ -5,7 +5,7 @@ labels:
|
|||
|
||||
skip_clone: true
|
||||
|
||||
pipeline:
|
||||
steps:
|
||||
clone_friendica_base:
|
||||
image: alpine/git
|
||||
commands:
|
||||
|
@ -48,7 +48,7 @@ pipeline:
|
|||
branch: [ develop, '*-rc' ]
|
||||
event: push
|
||||
composer_install:
|
||||
image: friendicaci/php8.2:php8.2.16
|
||||
image: friendicaci/php8.2:php8.2.28
|
||||
commands:
|
||||
- export COMPOSER_HOME=.composer
|
||||
- composer validate
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
skip_clone: true
|
||||
|
||||
pipeline:
|
||||
steps:
|
||||
clone_friendica_base:
|
||||
image: alpine/git
|
||||
commands:
|
||||
|
|
|
@ -5,11 +5,13 @@ matrix:
|
|||
- PHP_MAJOR_VERSION: 8.0
|
||||
PHP_VERSION: 8.0.30
|
||||
- PHP_MAJOR_VERSION: 8.1
|
||||
PHP_VERSION: 8.1.27
|
||||
PHP_VERSION: 8.1.31
|
||||
- PHP_MAJOR_VERSION: 8.2
|
||||
PHP_VERSION: 8.2.16
|
||||
PHP_VERSION: 8.2.28
|
||||
- PHP_MAJOR_VERSION: 8.3
|
||||
PHP_VERSION: 8.3.3
|
||||
PHP_VERSION: 8.3.17
|
||||
- PHP_MAJOR_VERSION: 8.4
|
||||
PHP_VERSION: 8.4.5
|
||||
|
||||
# This forces PHP Unit executions at the "opensocial" labeled location (because of much more power...)
|
||||
labels:
|
||||
|
@ -17,7 +19,7 @@ labels:
|
|||
|
||||
skip_clone: true
|
||||
|
||||
pipeline:
|
||||
steps:
|
||||
clone_friendica_base:
|
||||
image: alpine/git
|
||||
commands:
|
||||
|
@ -98,9 +100,9 @@ pipeline:
|
|||
- friendica/friendica-addons
|
||||
commands:
|
||||
- codecov -R '.' -Z -f 'clover.xml'
|
||||
secrets:
|
||||
- source: codecov-token
|
||||
target: codecov_token
|
||||
environment:
|
||||
CODECOV_TOKEN:
|
||||
from_secret: codecov-token
|
||||
|
||||
services:
|
||||
mariadb:
|
||||
|
|
|
@ -5,7 +5,7 @@ labels:
|
|||
|
||||
skip_clone: true
|
||||
|
||||
pipeline:
|
||||
steps:
|
||||
clone_friendica_base:
|
||||
image: alpine/git
|
||||
commands:
|
||||
|
@ -45,7 +45,7 @@ pipeline:
|
|||
repo: friendica/friendica-addons
|
||||
event: tag
|
||||
composer_install:
|
||||
image: friendicaci/php8.2:php8.2.16
|
||||
image: friendicaci/php8.2:php8.2.28
|
||||
commands:
|
||||
- export COMPOSER_HOME=.composer
|
||||
- composer validate
|
||||
|
|
|
@ -33,16 +33,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Text\Markdown;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
|
@ -64,7 +61,7 @@ function advancedcontentfilter_install()
|
|||
Hook::add('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
|
||||
DBStructure::performUpdate();
|
||||
|
||||
Logger::notice('installed advancedcontentfilter');
|
||||
DI::logger()->notice('installed advancedcontentfilter');
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -123,21 +120,22 @@ function advancedcontentfilter_prepare_body_content_filter(&$hook_data)
|
|||
$expressionLanguage = new ExpressionLanguage\ExpressionLanguage();
|
||||
}
|
||||
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
$uid = $hook_data['uid'] ?? DI::userSession()->getLocalUserId();
|
||||
if (!$uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
$vars = advancedcontentfilter_get_filter_fields($hook_data['item']);
|
||||
|
||||
$rules = DI::cache()->get('rules_' . DI::userSession()->getLocalUserId());
|
||||
$rules = DI::cache()->get('rules_' . $uid);
|
||||
if (!isset($rules)) {
|
||||
$rules = DBA::toArray(DBA::select(
|
||||
'advancedcontentfilter_rules',
|
||||
['name', 'expression', 'serialized'],
|
||||
['uid' => DI::userSession()->getLocalUserId(), 'active' => true]
|
||||
['uid' => $uid, 'active' => true]
|
||||
));
|
||||
|
||||
DI::cache()->set('rules_' . DI::userSession()->getLocalUserId(), $rules);
|
||||
DI::cache()->set('rules_' . $uid, $rules);
|
||||
}
|
||||
|
||||
if ($rules) {
|
||||
|
@ -192,9 +190,30 @@ function advancedcontentfilter_init()
|
|||
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'api') {
|
||||
$slim = \Slim\Factory\AppFactory::create();
|
||||
|
||||
require __DIR__ . '/src/middlewares.php';
|
||||
/**
|
||||
* The routing middleware should be added before the ErrorMiddleware
|
||||
* Otherwise exceptions thrown from it will not be handled
|
||||
*/
|
||||
$slim->addRoutingMiddleware();
|
||||
|
||||
$slim->addErrorMiddleware(true, true, true, DI::logger());
|
||||
|
||||
// register routes
|
||||
$slim->group('/advancedcontentfilter/api', function (\Slim\Routing\RouteCollectorProxy $app) {
|
||||
$app->group('/rules', function (\Slim\Routing\RouteCollectorProxy $app) {
|
||||
$app->get('', 'advancedcontentfilter_get_rules');
|
||||
$app->post('', 'advancedcontentfilter_post_rules');
|
||||
|
||||
$app->get('/{id}', 'advancedcontentfilter_get_rules_id');
|
||||
$app->put('/{id}', 'advancedcontentfilter_put_rules_id');
|
||||
$app->delete('/{id}', 'advancedcontentfilter_delete_rules_id');
|
||||
});
|
||||
|
||||
$app->group('/variables', function (\Slim\Routing\RouteCollectorProxy $app) {
|
||||
$app->get('/{guid}', 'advancedcontentfilter_get_variables_guid');
|
||||
});
|
||||
});
|
||||
|
||||
require __DIR__ . '/src/routes.php';
|
||||
$slim->run();
|
||||
|
||||
exit;
|
||||
|
@ -252,7 +271,7 @@ function advancedcontentfilter_content()
|
|||
'rule_expression' => DI::l10n()->t('Rule Expression'),
|
||||
'cancel' => DI::l10n()->t('Cancel'),
|
||||
],
|
||||
'$current_theme' => DI::app()->getCurrentTheme(),
|
||||
'$current_theme' => DI::appHelper()->getCurrentTheme(),
|
||||
'$rules' => DBA::toArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => DI::userSession()->getLocalUserId()])),
|
||||
'$form_security_token' => BaseModule::getFormSecurityToken()
|
||||
]);
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2020, Friendica
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
use Friendica\DI;
|
||||
|
||||
/** @var $slim \Slim\App */
|
||||
|
||||
/**
|
||||
* The routing middleware should be added before the ErrorMiddleware
|
||||
* Otherwise exceptions thrown from it will not be handled
|
||||
*/
|
||||
$slim->addRoutingMiddleware();
|
||||
|
||||
$errorMiddleware = $slim->addErrorMiddleware(true, true, true, DI::logger());
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2020, Friendica
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/* @var $slim Slim\App */
|
||||
$slim->group('/advancedcontentfilter/api', function (\Slim\Routing\RouteCollectorProxy $app) {
|
||||
$app->group('/rules', function (\Slim\Routing\RouteCollectorProxy $app) {
|
||||
$app->get('', 'advancedcontentfilter_get_rules');
|
||||
$app->post('', 'advancedcontentfilter_post_rules');
|
||||
|
||||
$app->get('/{id}', 'advancedcontentfilter_get_rules_id');
|
||||
$app->put('/{id}', 'advancedcontentfilter_put_rules_id');
|
||||
$app->delete('/{id}', 'advancedcontentfilter_delete_rules_id');
|
||||
});
|
||||
|
||||
$app->group('/variables', function (\Slim\Routing\RouteCollectorProxy $app) {
|
||||
$app->get('/{guid}', 'advancedcontentfilter_get_variables_guid');
|
||||
});
|
||||
});
|
|
@ -6,9 +6,7 @@
|
|||
* Author: Fabio <https://kirgroup.com/profile/fabrixxm>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -28,7 +26,7 @@ function birdavatar_install()
|
|||
Hook::register('addon_settings', __FILE__, 'birdavatar_addon_settings');
|
||||
Hook::register('addon_settings_post', __FILE__, 'birdavatar_addon_settings_post');
|
||||
|
||||
Logger::info('registered birdavatar');
|
||||
DI::logger()->info('registered birdavatar');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,9 +44,7 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
|
@ -78,7 +76,7 @@ function blackout_redirect ($b)
|
|||
}
|
||||
|
||||
if (( $date1 <= $now ) && ( $now <= $date2 )) {
|
||||
Logger::notice('redirecting user to blackout page');
|
||||
DI::logger()->notice('redirecting user to blackout page');
|
||||
System::externalRedirect($myurl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
use Jaybizzle\CrawlerDetect\CrawlerDetect;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Network\HTTPException\ForbiddenException;
|
||||
|
@ -70,7 +69,7 @@ function blockbot_init_1()
|
|||
}
|
||||
|
||||
if (empty($parts)) {
|
||||
Logger::debug('Known frontend found - accept', $logdata);
|
||||
DI::logger()->debug('Known frontend found - accept', $logdata);
|
||||
if ($isCrawler) {
|
||||
blockbot_save('badly-parsed-agents', $_SERVER['HTTP_USER_AGENT']);
|
||||
}
|
||||
|
@ -80,66 +79,66 @@ function blockbot_init_1()
|
|||
blockbot_log_activitypub($_SERVER['REQUEST_URI'], $_SERVER['HTTP_USER_AGENT']);
|
||||
|
||||
if (blockbot_is_crawler($parts)) {
|
||||
Logger::debug('Crawler found - reject', $logdata);
|
||||
DI::logger()->debug('Crawler found - reject', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
|
||||
if (blockbot_is_searchbot($parts)) {
|
||||
Logger::debug('Search bot found - reject', $logdata);
|
||||
DI::logger()->debug('Search bot found - reject', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
|
||||
if (blockbot_is_unwanted($parts)) {
|
||||
Logger::debug('Uncategorized unwanted agent found - reject', $logdata);
|
||||
DI::logger()->debug('Uncategorized unwanted agent found - reject', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
|
||||
if (blockbot_is_security_checker($parts)) {
|
||||
if (!DI::config()->get('blockbot', 'security_checker')) {
|
||||
Logger::debug('Security checker found - reject', $logdata);
|
||||
DI::logger()->debug('Security checker found - reject', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
Logger::debug('Security checker found - accept', $logdata);
|
||||
DI::logger()->debug('Security checker found - accept', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_social_media($parts)) {
|
||||
Logger::debug('Social media service found - accept', $logdata);
|
||||
DI::logger()->debug('Social media service found - accept', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_fediverse_client($parts)) {
|
||||
Logger::debug('Fediverse client found - accept', $logdata);
|
||||
DI::logger()->debug('Fediverse client found - accept', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_feed_reader($parts)) {
|
||||
Logger::debug('Feed reader found - accept', $logdata);
|
||||
DI::logger()->debug('Feed reader found - accept', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_fediverse_tool($parts)) {
|
||||
Logger::debug('Fediverse tool found - accept', $logdata);
|
||||
DI::logger()->debug('Fediverse tool found - accept', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_service_agent($parts)) {
|
||||
Logger::debug('Service agent found - accept', $logdata);
|
||||
DI::logger()->debug('Service agent found - accept', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_monitor($parts)) {
|
||||
Logger::debug('Monitoring service found - accept', $logdata);
|
||||
DI::logger()->debug('Monitoring service found - accept', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_validator($parts)) {
|
||||
Logger::debug('Validation service found - accept', $logdata);
|
||||
DI::logger()->debug('Validation service found - accept', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_good_tool($parts)) {
|
||||
Logger::debug('Uncategorized helpful service found - accept', $logdata);
|
||||
DI::logger()->debug('Uncategorized helpful service found - accept', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -147,10 +146,10 @@ function blockbot_init_1()
|
|||
if (blockbot_is_http_library($parts)) {
|
||||
blockbot_check_login_attempt($_SERVER['REQUEST_URI'], $logdata);
|
||||
if (!DI::config()->get('blockbot', 'http_libraries')) {
|
||||
Logger::debug('HTTP Library found - reject', $logdata);
|
||||
DI::logger()->debug('HTTP Library found - reject', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
Logger::debug('HTTP Library found - accept', $logdata);
|
||||
DI::logger()->debug('HTTP Library found - accept', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -161,12 +160,12 @@ function blockbot_init_1()
|
|||
|
||||
if (!$isCrawler) {
|
||||
blockbot_save('good-agents', $_SERVER['HTTP_USER_AGENT']);
|
||||
Logger::debug('Non-bot user agent detected', $logdata);
|
||||
DI::logger()->debug('Non-bot user agent detected', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
blockbot_save('bad-agents', $_SERVER['HTTP_USER_AGENT']);
|
||||
Logger::notice('Possible bot found - reject', $logdata);
|
||||
DI::logger()->notice('Possible bot found - reject', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
|
||||
|
@ -209,7 +208,7 @@ function blockbot_log_activitypub(string $url, string $agent)
|
|||
blockbot_save('activitypub-inbox-agents', $agent);
|
||||
}
|
||||
|
||||
if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER))) {
|
||||
if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER, false))) {
|
||||
blockbot_save('activitypub-signature-agents', $agent);
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +216,7 @@ function blockbot_log_activitypub(string $url, string $agent)
|
|||
function blockbot_check_login_attempt(string $url, array $logdata)
|
||||
{
|
||||
if (in_array(trim(parse_url($url, PHP_URL_PATH), '/'), ['login', 'lostpass', 'register'])) {
|
||||
Logger::debug('Login attempt detected - reject', $logdata);
|
||||
DI::logger()->debug('Login attempt detected - reject', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ use Friendica\Content\Text\Plaintext;
|
|||
use Friendica\Core\Cache\Enum\Duration;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -73,7 +72,7 @@ function bluesky_install()
|
|||
|
||||
function bluesky_load_config(ConfigFileManager $loader)
|
||||
{
|
||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('bluesky'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('bluesky'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
}
|
||||
|
||||
function bluesky_check_item_notification(array &$notification_data)
|
||||
|
@ -97,12 +96,7 @@ function bluesky_item_by_link(array &$hookData)
|
|||
return;
|
||||
}
|
||||
|
||||
$token = DI::atProtocol()->getUserToken($hookData['uid']);
|
||||
if (empty($token)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// @todo also support the URI format (at://did/app.bsky.feed.post/cid)
|
||||
if (substr($hookData['uri'], 0, 5) != 'at://') {
|
||||
if (!preg_match('#^' . ATProtocol::WEB . '/profile/(.+)/post/(.+)#', $hookData['uri'], $matches)) {
|
||||
return;
|
||||
}
|
||||
|
@ -112,12 +106,15 @@ function bluesky_item_by_link(array &$hookData)
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::debug('Found bluesky post', ['url' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]);
|
||||
DI::logger()->debug('Found bluesky post', ['uri' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]);
|
||||
|
||||
$uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2];
|
||||
} else {
|
||||
$uri = $hookData['uri'];
|
||||
}
|
||||
|
||||
$uri = DI::atpProcessor()->fetchMissingPost($uri, $hookData['uid'], Item::PR_FETCHED, 0, 0);
|
||||
Logger::debug('Got post', ['did' => $did, 'cid' => $matches[2], 'result' => $uri]);
|
||||
DI::logger()->debug('Got post', ['uri' => $uri]);
|
||||
if (!empty($uri)) {
|
||||
$item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]);
|
||||
if (!empty($item['id'])) {
|
||||
|
@ -140,7 +137,7 @@ function bluesky_follow(array &$hook_data)
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::debug('Check if contact is bluesky', ['data' => $hook_data]);
|
||||
DI::logger()->debug('Check if contact is bluesky', ['data' => $hook_data]);
|
||||
$contact = DBA::selectFirst('contact', [], ['network' => Protocol::BLUESKY, 'url' => $hook_data['url'], 'uid' => [0, $hook_data['uid']]]);
|
||||
if (empty($contact)) {
|
||||
return;
|
||||
|
@ -161,7 +158,7 @@ function bluesky_follow(array &$hook_data)
|
|||
$activity = DI::atProtocol()->XRPCPost($hook_data['uid'], 'com.atproto.repo.createRecord', $post);
|
||||
if (!empty($activity->uri)) {
|
||||
$hook_data['contact'] = $contact;
|
||||
Logger::debug('Successfully start following', ['url' => $contact['url'], 'uri' => $activity->uri]);
|
||||
DI::logger()->debug('Successfully start following', ['url' => $contact['url'], 'uri' => $activity->uri]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,7 +212,7 @@ function bluesky_block(array &$hook_data)
|
|||
if ($ucid) {
|
||||
Contact::remove($ucid);
|
||||
}
|
||||
Logger::debug('Successfully blocked contact', ['url' => $hook_data['contact']['url'], 'uri' => $activity->uri]);
|
||||
DI::logger()->debug('Successfully blocked contact', ['url' => $hook_data['contact']['url'], 'uri' => $activity->uri]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,11 +420,11 @@ function bluesky_cron()
|
|||
if ($last) {
|
||||
$next = $last + ($poll_interval * 60);
|
||||
if ($next > time()) {
|
||||
Logger::notice('poll interval not reached');
|
||||
DI::logger()->notice('poll interval not reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
Logger::notice('cron_start');
|
||||
DI::logger()->notice('cron_start');
|
||||
|
||||
$abandon_days = intval(DI::config()->get('system', 'account_abandon_days'));
|
||||
if ($abandon_days < 1) {
|
||||
|
@ -439,19 +436,19 @@ function bluesky_cron()
|
|||
$pconfigs = DBA::selectToArray('pconfig', [], ["`cat` = ? AND `k` IN (?, ?) AND `v`", 'bluesky', 'import', 'import_feeds']);
|
||||
foreach ($pconfigs as $pconfig) {
|
||||
if (empty(DI::atProtocol()->getUserDid($pconfig['uid']))) {
|
||||
Logger::debug('User has got no valid DID', ['uid' => $pconfig['uid']]);
|
||||
DI::logger()->debug('User has got no valid DID', ['uid' => $pconfig['uid']]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($abandon_days != 0) {
|
||||
if (!DBA::exists('user', ["`uid` = ? AND `login_date` >= ?", $pconfig['uid'], $abandon_limit])) {
|
||||
Logger::notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]);
|
||||
DI::logger()->notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh the token now, so that it doesn't need to be refreshed in parallel by the following workers
|
||||
Logger::debug('Refresh the token', ['uid' => $pconfig['uid']]);
|
||||
DI::logger()->debug('Refresh the token', ['uid' => $pconfig['uid']]);
|
||||
DI::atProtocol()->getUserToken($pconfig['uid']);
|
||||
|
||||
$last_sync = DI::pConfig()->get($pconfig['uid'], 'bluesky', 'last_contact_sync');
|
||||
|
@ -465,32 +462,32 @@ function bluesky_cron()
|
|||
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_timeline.php', $pconfig['uid']);
|
||||
}
|
||||
if (DI::pConfig()->get($pconfig['uid'], 'bluesky', 'import_feeds')) {
|
||||
Logger::debug('Fetch feeds for user', ['uid' => $pconfig['uid']]);
|
||||
DI::logger()->debug('Fetch feeds for user', ['uid' => $pconfig['uid']]);
|
||||
$feeds = bluesky_get_feeds($pconfig['uid']);
|
||||
foreach ($feeds as $feed) {
|
||||
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_feed.php', $pconfig['uid'], $feed);
|
||||
}
|
||||
}
|
||||
Logger::debug('Polling done for user', ['uid' => $pconfig['uid']]);
|
||||
DI::logger()->debug('Polling done for user', ['uid' => $pconfig['uid']]);
|
||||
}
|
||||
|
||||
Logger::notice('Polling done for all users');
|
||||
DI::logger()->notice('Polling done for all users');
|
||||
|
||||
DI::keyValue()->set('bluesky_last_poll', time());
|
||||
|
||||
$last_clean = DI::keyValue()->get('bluesky_last_clean');
|
||||
if (empty($last_clean) || ($last_clean + 86400 < time())) {
|
||||
Logger::notice('Start contact cleanup');
|
||||
DI::logger()->notice('Start contact cleanup');
|
||||
$contacts = DBA::select('account-user-view', ['id', 'pid'], ["`network` = ? AND `uid` != ? AND `rel` = ?", Protocol::BLUESKY, 0, Contact::NOTHING]);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
Worker::add(Worker::PRIORITY_LOW, 'MergeContact', $contact['pid'], $contact['id'], 0);
|
||||
}
|
||||
DBA::close($contacts);
|
||||
DI::keyValue()->set('bluesky_last_clean', time());
|
||||
Logger::notice('Contact cleanup done');
|
||||
DI::logger()->notice('Contact cleanup done');
|
||||
}
|
||||
|
||||
Logger::notice('cron_end');
|
||||
DI::logger()->notice('cron_end');
|
||||
}
|
||||
|
||||
function bluesky_hook_fork(array &$b)
|
||||
|
@ -510,7 +507,7 @@ function bluesky_hook_fork(array &$b)
|
|||
if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) {
|
||||
// Don't post if it isn't a reply to a bluesky post
|
||||
if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::BLUESKY])) {
|
||||
Logger::notice('No bluesky parent found', ['item' => $post['id']]);
|
||||
DI::logger()->notice('No bluesky parent found', ['item' => $post['id']]);
|
||||
$b['execute'] = false;
|
||||
return;
|
||||
}
|
||||
|
@ -557,12 +554,12 @@ function bluesky_send(array &$b)
|
|||
}
|
||||
|
||||
if ($b['gravity'] != Item::GRAVITY_PARENT) {
|
||||
Logger::debug('Got comment', ['item' => $b]);
|
||||
DI::logger()->debug('Got comment', ['item' => $b]);
|
||||
|
||||
if ($b['deleted']) {
|
||||
$uri = DI::atpProcessor()->getUriClass($b['uri']);
|
||||
if (empty($uri)) {
|
||||
Logger::debug('Not a bluesky post', ['uri' => $b['uri']]);
|
||||
DI::logger()->debug('Not a bluesky post', ['uri' => $b['uri']]);
|
||||
return;
|
||||
}
|
||||
bluesky_delete_post($b['uri'], $b['uid']);
|
||||
|
@ -573,12 +570,12 @@ function bluesky_send(array &$b)
|
|||
$parent = DI::atpProcessor()->getUriClass($b['thr-parent']);
|
||||
|
||||
if (empty($root) || empty($parent)) {
|
||||
Logger::debug('No bluesky post', ['parent' => $b['parent'], 'thr-parent' => $b['thr-parent']]);
|
||||
DI::logger()->debug('No bluesky post', ['parent' => $b['parent'], 'thr-parent' => $b['thr-parent']]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($b['gravity'] == Item::GRAVITY_COMMENT) {
|
||||
Logger::debug('Posting comment', ['root' => $root, 'parent' => $parent]);
|
||||
DI::logger()->debug('Posting comment', ['root' => $root, 'parent' => $parent]);
|
||||
bluesky_create_post($b, $root, $parent);
|
||||
return;
|
||||
} elseif (in_array($b['verb'], [Activity::LIKE, Activity::ANNOUNCE])) {
|
||||
|
@ -605,6 +602,8 @@ function bluesky_create_activity(array $item, stdClass $parent = null)
|
|||
return;
|
||||
}
|
||||
|
||||
$post = [];
|
||||
|
||||
if ($item['verb'] == Activity::LIKE) {
|
||||
$record = [
|
||||
'subject' => $parent,
|
||||
|
@ -635,10 +634,10 @@ function bluesky_create_activity(array $item, stdClass $parent = null)
|
|||
if (empty($activity->uri)) {
|
||||
return;
|
||||
}
|
||||
Logger::debug('Activity done', ['return' => $activity]);
|
||||
DI::logger()->debug('Activity done', ['return' => $activity]);
|
||||
$uri = DI::atpProcessor()->getUri($activity);
|
||||
Item::update(['extid' => $uri], ['guid' => $item['guid']]);
|
||||
Logger::debug('Set extid', ['id' => $item['id'], 'extid' => $activity]);
|
||||
DI::logger()->debug('Set extid', ['id' => $item['id'], 'extid' => $activity]);
|
||||
}
|
||||
|
||||
function bluesky_create_post(array $item, stdClass $root = null, stdClass $parent = null)
|
||||
|
@ -673,6 +672,8 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren
|
|||
}
|
||||
}
|
||||
|
||||
$item['body'] = bluesky_set_mentions($item['body']);
|
||||
|
||||
$urls = bluesky_get_urls($item['body']);
|
||||
$item['body'] = $urls['body'];
|
||||
|
||||
|
@ -722,26 +723,53 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren
|
|||
}
|
||||
return;
|
||||
}
|
||||
Logger::debug('Posting done', ['return' => $parent]);
|
||||
DI::logger()->debug('Posting done', ['return' => $parent]);
|
||||
if (empty($root)) {
|
||||
$root = $parent;
|
||||
}
|
||||
if (($key == 0) && ($item['gravity'] != Item::GRAVITY_PARENT)) {
|
||||
$uri = DI::atpProcessor()->getUri($parent);
|
||||
Item::update(['extid' => $uri], ['guid' => $item['guid']]);
|
||||
Logger::debug('Set extid', ['id' => $item['id'], 'extid' => $uri]);
|
||||
DI::logger()->debug('Set extid', ['id' => $item['id'], 'extid' => $uri]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function bluesky_set_mentions(string $body): string
|
||||
{
|
||||
// Remove all url based mention links
|
||||
$body = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $body);
|
||||
|
||||
if (!preg_match_all("/[@!]\[url\=(did:.*?)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER)) {
|
||||
return $body;
|
||||
}
|
||||
|
||||
foreach ($matches as $match) {
|
||||
$contact = Contact::selectFirst(['addr'], ['nurl' => $match[1]]);
|
||||
if (!empty($contact['addr'])) {
|
||||
$body = str_replace($match[0], '@[url=' . $match[1] . ']' . $contact['addr'] . '[/url]', $body);
|
||||
} else {
|
||||
$body = str_replace($match[0], '@' . $match[2], $body);
|
||||
}
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
function bluesky_get_urls(string $body): array
|
||||
{
|
||||
// Remove all hashtag and mention links
|
||||
$body = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $body);
|
||||
|
||||
$body = BBCode::expandVideoLinks($body);
|
||||
$urls = [];
|
||||
|
||||
// Search for Mentions
|
||||
if (preg_match_all("/[@!]\[url\=(did:.*?)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$text = '@' . $match[2];
|
||||
$urls[strpos($body, $match[0])] = ['mention' => $match[1], 'text' => $text, 'hash' => $text];
|
||||
$body = str_replace($match[0], $text, $body);
|
||||
}
|
||||
}
|
||||
|
||||
// Search for hash tags
|
||||
if (preg_match_all("/#\[url\=(https?:.*?)\](.*?)\[\/url\]/ism", $body, $matches, PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
|
@ -826,6 +854,9 @@ function bluesky_get_facets(string $body, array $urls): array
|
|||
} elseif (!empty($url['url'])) {
|
||||
$feature->uri = $url['url'];
|
||||
$feature->$type = 'app.bsky.richtext.facet#link';
|
||||
} elseif (!empty($url['mention'])) {
|
||||
$feature->did = $url['mention'];
|
||||
$feature->$type = 'app.bsky.richtext.facet#mention';
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
@ -899,20 +930,20 @@ function bluesky_upload_blob(int $uid, array $photo): ?stdClass
|
|||
$new_size = strlen($content);
|
||||
|
||||
if (($size != 0) && ($new_size == 0) && ($retrial == 0)) {
|
||||
Logger::warning('Size is empty after resize, uploading original file', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
DI::logger()->warning('Size is empty after resize, uploading original file', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
$content = Photo::getImageForPhoto($photo);
|
||||
} else {
|
||||
Logger::info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
DI::logger()->info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
}
|
||||
|
||||
$data = DI::atProtocol()->post($uid, '/xrpc/com.atproto.repo.uploadBlob', $content, ['Content-type' => $photo['type'], 'Authorization' => ['Bearer ' . DI::atProtocol()->getUserToken($uid)]]);
|
||||
if (empty($data) || empty($data->blob)) {
|
||||
Logger::info('Uploading failed', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
DI::logger()->info('Uploading failed', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
return null;
|
||||
}
|
||||
|
||||
Item::incrementOutbound(Protocol::BLUESKY);
|
||||
Logger::debug('Uploaded blob', ['return' => $data, 'uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
DI::logger()->debug('Uploaded blob', ['return' => $data, 'uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
return $data->blob;
|
||||
}
|
||||
|
||||
|
@ -920,11 +951,11 @@ function bluesky_delete_post(string $uri, int $uid)
|
|||
{
|
||||
$parts = DI::atpProcessor()->getUriParts($uri);
|
||||
if (empty($parts)) {
|
||||
Logger::debug('No uri delected', ['uri' => $uri]);
|
||||
DI::logger()->debug('No uri delected', ['uri' => $uri]);
|
||||
return;
|
||||
}
|
||||
DI::atProtocol()->XRPCPost($uid, 'com.atproto.repo.deleteRecord', $parts);
|
||||
Logger::debug('Deleted', ['parts' => $parts]);
|
||||
DI::logger()->debug('Deleted', ['parts' => $parts]);
|
||||
}
|
||||
|
||||
function bluesky_fetch_timeline(int $uid)
|
||||
|
@ -1006,6 +1037,10 @@ function bluesky_process_reason(stdClass $reason, string $uri, int $uid)
|
|||
return;
|
||||
}
|
||||
|
||||
if (Post::exists(['uid' => $item['uid'], 'thr-parent' => $item['thr-parent'], 'verb' => $item['verb'], 'contact-id' => $item['contact-id']])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$item['guid'] = Item::guidFromUri($item['uri'], $contact['alias']);
|
||||
$item['owner-name'] = $item['author-name'];
|
||||
$item['owner-link'] = $item['author-link'];
|
||||
|
@ -1026,10 +1061,10 @@ function bluesky_fetch_notifications(int $uid)
|
|||
foreach ($data->notifications as $notification) {
|
||||
$uri = DI::atpProcessor()->getUri($notification);
|
||||
if (Post::exists(['uri' => $uri, 'uid' => $uid]) || Post::exists(['extid' => $uri, 'uid' => $uid])) {
|
||||
Logger::debug('Notification already processed', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
|
||||
DI::logger()->debug('Notification already processed', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
|
||||
continue;
|
||||
}
|
||||
Logger::debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
|
||||
DI::logger()->debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
|
||||
switch ($notification->reason) {
|
||||
case 'like':
|
||||
$item = DI::atpProcessor()->getHeaderFromPost($notification, $uri, $uid, Conversation::PARCEL_CONNECTOR);
|
||||
|
@ -1039,9 +1074,9 @@ function bluesky_fetch_notifications(int $uid)
|
|||
$item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0);
|
||||
if (!empty($item['thr-parent'])) {
|
||||
$data = Item::insert($item);
|
||||
Logger::debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
|
||||
DI::logger()->debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
|
||||
} else {
|
||||
Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
|
||||
DI::logger()->info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1053,37 +1088,37 @@ function bluesky_fetch_notifications(int $uid)
|
|||
$item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0);
|
||||
if (!empty($item['thr-parent'])) {
|
||||
$data = Item::insert($item);
|
||||
Logger::debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
|
||||
DI::logger()->debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
|
||||
} else {
|
||||
Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
|
||||
DI::logger()->info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'follow':
|
||||
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, $uid);
|
||||
Logger::debug('New follower', ['uid' => $uid, 'nick' => $contact['nick'], 'uri' => $uri]);
|
||||
DI::logger()->debug('New follower', ['uid' => $uid, 'nick' => $contact['nick'], 'uri' => $uri]);
|
||||
break;
|
||||
|
||||
case 'mention':
|
||||
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
|
||||
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_TO, $contact['id'], 0);
|
||||
Logger::debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
|
||||
DI::logger()->debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
|
||||
break;
|
||||
|
||||
case 'reply':
|
||||
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
|
||||
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_COMMENT, $contact['id'], 0);
|
||||
Logger::debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
|
||||
DI::logger()->debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
|
||||
break;
|
||||
|
||||
case 'quote':
|
||||
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
|
||||
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_PUSHED, $contact['id'], 0);
|
||||
Logger::debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
|
||||
DI::logger()->debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
|
||||
break;
|
||||
|
||||
default:
|
||||
Logger::notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]);
|
||||
DI::logger()->notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1114,16 +1149,16 @@ function bluesky_fetch_feed(int $uid, string $feed)
|
|||
$languages = $entry->post->record->langs ?? [];
|
||||
|
||||
if (!Relay::isWantedLanguage($entry->post->record->text, 0, $contact['id'] ?? 0, $languages)) {
|
||||
Logger::debug('Unwanted language detected', ['languages' => $languages, 'text' => $entry->post->record->text]);
|
||||
DI::logger()->debug('Unwanted language detected', ['languages' => $languages, 'text' => $entry->post->record->text]);
|
||||
continue;
|
||||
}
|
||||
$causer = DI::atpActor()->getContactByDID($entry->post->author->did, $uid, 0);
|
||||
$uri_id = bluesky_complete_post($entry->post, $uid, Item::PR_TAG, $causer['id'], Conversation::PARCEL_CONNECTOR);
|
||||
if (!empty($uri_id)) {
|
||||
$stored = Post\Category::storeFileByURIId($uri_id, $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl);
|
||||
Logger::debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]);
|
||||
DI::logger()->debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]);
|
||||
} else {
|
||||
Logger::notice('Post not found', ['entry' => $entry]);
|
||||
DI::logger()->notice('Post not found', ['entry' => $entry]);
|
||||
}
|
||||
if (!empty($entry->reason)) {
|
||||
bluesky_process_reason($entry->reason, DI::atpProcessor()->getUri($entry->post), $uid);
|
||||
|
@ -1139,8 +1174,14 @@ function bluesky_get_feeds(int $uid): array
|
|||
return [];
|
||||
}
|
||||
foreach ($preferences->preferences as $preference) {
|
||||
if ($preference->$type == 'app.bsky.actor.defs#savedFeedsPref') {
|
||||
return $preference->pinned ?? [];
|
||||
if ($preference->$type == 'app.bsky.actor.defs#savedFeedsPrefV2') {
|
||||
$pinned = [];
|
||||
foreach ($preference->items as $item) {
|
||||
if (($item->type == 'feed') && $item->pinned) {
|
||||
$pinned[] = $item->value;
|
||||
}
|
||||
}
|
||||
return $pinned;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
|
||||
function bluesky_feed_run($argv, $argc)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ function bluesky_feed_run($argv, $argc)
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::debug('Importing feed - start', ['user' => $argv[1], 'feed' => $argv[2]]);
|
||||
DI::logger()->debug('Importing feed - start', ['user' => $argv[1], 'feed' => $argv[2]]);
|
||||
bluesky_fetch_feed($argv[1], $argv[2]);
|
||||
Logger::debug('Importing feed - done', ['user' => $argv[1], 'feed' => $argv[2]]);
|
||||
DI::logger()->debug('Importing feed - done', ['user' => $argv[1], 'feed' => $argv[2]]);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
|
||||
function bluesky_notifications_run($argv, $argc)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ function bluesky_notifications_run($argv, $argc)
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::notice('importing notifications - start', ['user' => $argv[1]]);
|
||||
DI::logger()->notice('importing notifications - start', ['user' => $argv[1]]);
|
||||
bluesky_fetch_notifications($argv[1]);
|
||||
Logger::notice('importing notifications - done', ['user' => $argv[1]]);
|
||||
DI::logger()->notice('importing notifications - done', ['user' => $argv[1]]);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
|
||||
function bluesky_timeline_run($argv, $argc)
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ function bluesky_timeline_run($argv, $argc)
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::notice('importing timeline - start', ['user' => $argv[1]]);
|
||||
DI::logger()->notice('importing timeline - start', ['user' => $argv[1]]);
|
||||
bluesky_fetch_timeline($argv[1]);
|
||||
Logger::notice('importing timeline - done', ['user' => $argv[1]]);
|
||||
DI::logger()->notice('importing timeline - done', ['user' => $argv[1]]);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* Author: Mike Macgirvin <mike@macgirvin.com>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
||||
|
|
|
@ -6,11 +6,8 @@
|
|||
* Author: Fabio <https://kirgroup.com/profile/fabrixxm>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -29,7 +26,7 @@ function catavatar_install()
|
|||
Hook::register('addon_settings', __FILE__, 'catavatar_addon_settings');
|
||||
Hook::register('addon_settings_post', __FILE__, 'catavatar_addon_settings_post');
|
||||
|
||||
Logger::notice('registered catavatar');
|
||||
DI::logger()->notice('registered catavatar');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
19
cld/cld.php
19
cld/cld.php
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
|
||||
function cld_install()
|
||||
|
@ -18,7 +17,17 @@ function cld_install()
|
|||
function cld_detect_languages(array &$data)
|
||||
{
|
||||
if (!in_array('cld2', get_loaded_extensions())) {
|
||||
Logger::warning('CLD2 is not installed.');
|
||||
DI::logger()->warning('CLD2 is not installed.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!class_exists('CLD2Detector')) {
|
||||
DI::logger()->warning('CLD2Detector class does not exist.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!class_exists('CLD2Encoding')) {
|
||||
DI::logger()->warning('CLD2Encoding class does not exist.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -43,7 +52,7 @@ function cld_detect_languages(array &$data)
|
|||
}
|
||||
|
||||
if (!$result['is_reliable']) {
|
||||
Logger::debug('Unreliable detection', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
|
||||
DI::logger()->debug('Unreliable detection', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
|
||||
if (($original == $detected) && ($data['detected'][$original] < $result['language_probability'] / 100)) {
|
||||
$data['detected'][$original] = $result['language_probability'] / 100;
|
||||
}
|
||||
|
@ -53,12 +62,12 @@ function cld_detect_languages(array &$data)
|
|||
$available = array_keys(DI::l10n()->getLanguageCodes());
|
||||
|
||||
if (!in_array($detected, $available)) {
|
||||
Logger::debug('Unsupported language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
|
||||
DI::logger()->debug('Unsupported language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($original != $detected) {
|
||||
Logger::debug('Detected different language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
|
||||
DI::logger()->debug('Detected different language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
|
||||
}
|
||||
|
||||
$length = count($data['detected']);
|
||||
|
|
|
@ -169,7 +169,6 @@ class UnitConvertor
|
|||
* @param string name of the source unit from which to convert
|
||||
* @param string name of the target unit to which we are converting
|
||||
* @param integer double precision of the end result
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function convert($value, $from_unit, $to_unit, $precision)
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
|
||||
function convert_install() {
|
||||
|
@ -26,7 +25,7 @@ function convert_content() {
|
|||
// @TODO Let's one day rewrite this to a modern composer package
|
||||
include 'UnitConvertor.php';
|
||||
|
||||
class TP_Converter extends UnitConvertor
|
||||
$conv = new class('en') extends UnitConvertor
|
||||
{
|
||||
public function __construct(string $lang = 'en')
|
||||
{
|
||||
|
@ -43,7 +42,7 @@ function convert_content() {
|
|||
|
||||
private function findBaseUnit($from, $to)
|
||||
{
|
||||
while (list($skey, $sval) = each($this->bases)) {
|
||||
foreach ($this->bases as $skey => $sval) {
|
||||
if ($skey == $from || $to == $skey || in_array($to, $sval) || in_array($from, $sval)) {
|
||||
return $skey;
|
||||
}
|
||||
|
@ -63,7 +62,7 @@ function convert_content() {
|
|||
$cells[] = $cell;
|
||||
|
||||
// We now have the base unit and value now lets produce the table;
|
||||
while (list($key, $val) = each($this->bases[$base_unit])) {
|
||||
foreach ($this->bases[$base_unit] as $val) {
|
||||
$cell ['value'] = $this->convert($value, $from_unit, $val, $precision) . ' ' . $val;
|
||||
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : '';
|
||||
$cells[] = $cell;
|
||||
|
@ -86,9 +85,7 @@ function convert_content() {
|
|||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
$conv = new TP_Converter('en');
|
||||
};
|
||||
|
||||
$conversions = [
|
||||
'Temperature' => ['base' => 'Celsius',
|
||||
|
@ -176,15 +173,15 @@ function convert_content() {
|
|||
]
|
||||
];
|
||||
|
||||
while (list($key, $val) = each($conversions)) {
|
||||
foreach ($conversions as $key => $val) {
|
||||
$conv->addConversion($val['base'], $val['conv']);
|
||||
$list[$key][] = $val['base'];
|
||||
while (list($ukey, $uval) = each($val['conv'])) {
|
||||
foreach ($val['conv'] as $ukey => $uval) {
|
||||
$list[$key][] = $ukey;
|
||||
}
|
||||
}
|
||||
|
||||
$o .= '<h3>Unit Conversions</h3>';
|
||||
$o = '<h3>Unit Conversions</h3>';
|
||||
|
||||
if (isset($_POST['from_unit']) && isset($_POST['value'])) {
|
||||
$o .= ($conv->getTable(intval($_POST['value']), $_POST['from_unit'], $_POST['to_unit'], 5)) . '</p>';
|
||||
|
@ -202,10 +199,9 @@ function convert_content() {
|
|||
$o .= '<input name="value" type="text" id="value" value="' . $value . '" size="10" maxlength="10" />';
|
||||
$o .= '<select name="from_unit" size="12">';
|
||||
|
||||
reset($list);
|
||||
while(list($key, $val) = each($list)) {
|
||||
foreach ($list as $key => $val) {
|
||||
$o .= "\n\t<optgroup label=\"$key\">";
|
||||
while(list($ukey, $uval) = each($val)) {
|
||||
foreach ($val as $ukey => $uval) {
|
||||
$selected = (($uval == $_POST['from_unit']) ? ' selected="selected" ' : '');
|
||||
$o .= "\n\t\t<option value=\"$uval\" $selected >$uval</option>";
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* Author: Peter Liebetrau <https://socivitas/profile/peerteer>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
|
|
@ -29,10 +29,10 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti
|
|||
$now = new DateTime();
|
||||
|
||||
if (!is_null($cached)) {
|
||||
$cdate = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'last');
|
||||
$cdate = (int) DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'last');
|
||||
$cached = unserialize($cached);
|
||||
|
||||
if ($cdate + $cachetime > $now->getTimestamp()) {
|
||||
if ($cdate + (int) $cachetime > $now->getTimestamp()) {
|
||||
return $cached;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ class Diaspora_Connection {
|
|||
}
|
||||
|
||||
$this->cookiejar = tempnam(System::getTempPath(), 'cookies');
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
|
|
|
@ -9,6 +9,8 @@ use Friendica\Core\System;
|
|||
|
||||
class Diasphp {
|
||||
private $cookiejar;
|
||||
private $token_regex;
|
||||
private $pod;
|
||||
|
||||
function __construct($pod) {
|
||||
$this->token_regex = '/content="(.*?)" name="csrf-token/';
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
|
||||
require_once 'addon/diaspora/Diaspora_Connection.php';
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -187,7 +185,7 @@ function diaspora_send(array &$b)
|
|||
{
|
||||
$hostname = DI::baseUrl()->getHost();
|
||||
|
||||
Logger::notice('diaspora_send: invoked');
|
||||
DI::logger()->notice('diaspora_send: invoked');
|
||||
|
||||
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
||||
return;
|
||||
|
@ -211,14 +209,14 @@ function diaspora_send(array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
Logger::info('diaspora_send: prepare posting');
|
||||
DI::logger()->info('diaspora_send: prepare posting');
|
||||
|
||||
$handle = DI::pConfig()->get($b['uid'], 'diaspora', 'handle');
|
||||
$password = DI::pConfig()->get($b['uid'], 'diaspora', 'password');
|
||||
$aspect = DI::pConfig()->get($b['uid'], 'diaspora', 'aspect');
|
||||
|
||||
if ($handle && $password) {
|
||||
Logger::info('diaspora_send: all values seem to be okay');
|
||||
DI::logger()->info('diaspora_send: all values seem to be okay');
|
||||
|
||||
$title = $b['title'];
|
||||
$body = $b['body'];
|
||||
|
@ -249,20 +247,20 @@ function diaspora_send(array &$b)
|
|||
require_once "addon/diaspora/diasphp.php";
|
||||
|
||||
try {
|
||||
Logger::info('diaspora_send: prepare');
|
||||
DI::logger()->info('diaspora_send: prepare');
|
||||
$conn = new Diaspora_Connection($handle, $password);
|
||||
Logger::info('diaspora_send: try to log in ' . $handle);
|
||||
DI::logger()->info('diaspora_send: try to log in ' . $handle);
|
||||
$conn->logIn();
|
||||
Logger::info('diaspora_send: try to send ' . $body);
|
||||
DI::logger()->info('diaspora_send: try to send ' . $body);
|
||||
|
||||
$conn->provider = $hostname;
|
||||
$conn->postStatusMessage($body, $aspect);
|
||||
|
||||
Logger::notice('diaspora_send: success');
|
||||
DI::logger()->notice('diaspora_send: success');
|
||||
} catch (Exception $e) {
|
||||
Logger::notice("diaspora_send: Error submitting the post: " . $e->getMessage());
|
||||
DI::logger()->notice("diaspora_send: Error submitting the post: " . $e->getMessage());
|
||||
|
||||
Logger::info('diaspora_send: requeueing ' . $b['uid']);
|
||||
DI::logger()->info('diaspora_send: requeueing ' . $b['uid']);
|
||||
|
||||
Worker::defer();
|
||||
}
|
||||
|
|
|
@ -8,10 +8,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\Markdown;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -80,13 +78,13 @@ function discourse_email_getmessage(&$message)
|
|||
// We do assume that all Discourse servers are running with SSL
|
||||
if (preg_match('=topic/(.*\d)/(.*\d)@(.*)=', $message['item']['uri'], $matches) &&
|
||||
discourse_fetch_post_from_api($message, $matches[2], $matches[3])) {
|
||||
Logger::info('Fetched comment via API (message-id mode)', ['host' => $matches[3], 'topic' => $matches[1], 'post' => $matches[2]]);
|
||||
DI::logger()->info('Fetched comment via API (message-id mode)', ['host' => $matches[3], 'topic' => $matches[1], 'post' => $matches[2]]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (preg_match('=topic/(.*\d)@(.*)=', $message['item']['uri'], $matches) &&
|
||||
discourse_fetch_topic_from_api($message, 'https://' . $matches[2], $matches[1], 1)) {
|
||||
Logger::info('Fetched starting post via API (message-id mode)', ['host' => $matches[2], 'topic' => $matches[1]]);
|
||||
DI::logger()->info('Fetched starting post via API (message-id mode)', ['host' => $matches[2], 'topic' => $matches[1]]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -96,16 +94,16 @@ function discourse_email_getmessage(&$message)
|
|||
}
|
||||
|
||||
if (empty($message['item']['plink']) || !preg_match('=(http.*)/t/.*/(.*\d)/(.*\d)=', $message['item']['plink'], $matches)) {
|
||||
Logger::info('This is no Discourse post');
|
||||
DI::logger()->info('This is no Discourse post');
|
||||
return;
|
||||
}
|
||||
|
||||
if (discourse_fetch_topic_from_api($message, $matches[1], $matches[2], $matches[3])) {
|
||||
Logger::info('Fetched post via API (plink mode)', ['host' => $matches[1], 'topic' => $matches[2], 'id' => $matches[3]]);
|
||||
DI::logger()->info('Fetched post via API (plink mode)', ['host' => $matches[1], 'topic' => $matches[2], 'id' => $matches[3]]);
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::info('Fallback mode', ['plink' => $message['item']['plink']]);
|
||||
DI::logger()->info('Fallback mode', ['plink' => $message['item']['plink']]);
|
||||
// Search in the HTML part for the discourse entry and the author profile
|
||||
if (!empty($message['html'])) {
|
||||
$message = discourse_get_html($message);
|
||||
|
@ -122,7 +120,7 @@ function discourse_fetch_post($host, $topic, $pid)
|
|||
$url = $host . '/t/' . $topic . '/' . $pid . '.json';
|
||||
$curlResult = DI::httpClient()->get($url);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
Logger::info('No success', ['url' => $url]);
|
||||
DI::logger()->info('No success', ['url' => $url]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -134,11 +132,11 @@ function discourse_fetch_post($host, $topic, $pid)
|
|||
/// @todo Possibly fetch missing posts here
|
||||
continue;
|
||||
}
|
||||
Logger::info('Got post data from topic', $post);
|
||||
DI::logger()->info('Got post data from topic', $post);
|
||||
return $post;
|
||||
}
|
||||
|
||||
Logger::info('Post not found', ['host' => $host, 'topic' => $topic, 'pid' => $pid]);
|
||||
DI::logger()->info('Post not found', ['host' => $host, 'topic' => $topic, 'pid' => $pid]);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -170,7 +168,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host)
|
|||
|
||||
$message = discourse_process_post($message, $data, $hostaddr);
|
||||
|
||||
Logger::info('Got API data', $message);
|
||||
DI::logger()->info('Got API data', $message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -203,7 +201,7 @@ function discourse_get_user($post, $hostaddr)
|
|||
$contact['url'] = $hostaddr . '/u/' . $contact['nick'];
|
||||
$contact['nurl'] = Strings::normaliseLink($contact['url']);
|
||||
$contact['baseurl'] = $hostaddr;
|
||||
Logger::info('Contact', $contact);
|
||||
DI::logger()->info('Contact', $contact);
|
||||
$contact['id'] = Contact::getIdForURL($contact['url'], 0, false, $contact);
|
||||
if (!empty($contact['id'])) {
|
||||
$avatar = $contact['photo'];
|
||||
|
@ -269,11 +267,11 @@ function discourse_get_html($message)
|
|||
$div = $doc2->importNode($result->item(0), true);
|
||||
$doc2->appendChild($div);
|
||||
$message['html'] = $doc2->saveHTML();
|
||||
Logger::info('Found html body', ['html' => $message['html']]);
|
||||
DI::logger()->info('Found html body', ['html' => $message['html']]);
|
||||
|
||||
$profile = discourse_get_profile($xpath);
|
||||
if (!empty($profile['url'])) {
|
||||
Logger::info('Found profile', $profile);
|
||||
DI::logger()->info('Found profile', $profile);
|
||||
$message['item']['author-id'] = Contact::getIdForURL($profile['url'], 0, false, $profile);
|
||||
$message['item']['author-link'] = $profile['url'];
|
||||
$message['item']['author-name'] = $profile['name'];
|
||||
|
@ -289,21 +287,21 @@ function discourse_get_text($message)
|
|||
$text = str_replace("\r", '', $text);
|
||||
$pos = strpos($text, "\n---\n");
|
||||
if ($pos == 0) {
|
||||
Logger::info('No separator found', ['text' => $text]);
|
||||
DI::logger()->info('No separator found', ['text' => $text]);
|
||||
return $message;
|
||||
}
|
||||
|
||||
$message['text'] = trim(substr($text, 0, $pos));
|
||||
|
||||
Logger::info('Found text body', ['text' => $message['text']]);
|
||||
DI::logger()->info('Found text body', ['text' => $message['text']]);
|
||||
|
||||
$message['text'] = Markdown::toBBCode($message['text']);
|
||||
|
||||
$text = substr($text, $pos);
|
||||
Logger::info('Found footer', ['text' => $text]);
|
||||
DI::logger()->info('Found footer', ['text' => $text]);
|
||||
if (preg_match('=\((http.*/t/.*/.*\d/.*\d)\)=', $text, $link)) {
|
||||
$message['item']['plink'] = $link[1];
|
||||
Logger::info('Found plink', ['plink' => $message['item']['plink']]);
|
||||
DI::logger()->info('Found plink', ['plink' => $message['item']['plink']]);
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,8 @@
|
|||
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -186,12 +184,12 @@ function dwpost_send(array &$b)
|
|||
|
||||
EOT;
|
||||
|
||||
Logger::debug('dwpost: data: ' . $xml);
|
||||
DI::logger()->debug('dwpost: data: ' . $xml);
|
||||
|
||||
if ($dw_blog !== 'test') {
|
||||
$x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
|
||||
}
|
||||
|
||||
Logger::info('posted to dreamwidth: ' . ($x) ? $x : '');
|
||||
DI::logger()->info('posted to dreamwidth: ' . ($x) ? $x : '');
|
||||
}
|
||||
}
|
||||
|
|
2
fancybox/.gitignore
vendored
Normal file
2
fancybox/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/dist/
|
||||
/test/
|
27
fancybox/CHANGELOG.md
Normal file
27
fancybox/CHANGELOG.md
Normal file
|
@ -0,0 +1,27 @@
|
|||
### Version 1.05
|
||||
|
||||
* Added ALT and TITLE of original IMG to fancybox popup.
|
||||
|
||||
### Version 1.04
|
||||
|
||||
* Update supporting upcoming imnagegrid in posts
|
||||
|
||||
### Version 1.03
|
||||
|
||||
* imgages in body-attach with title / alt attribute get them removed while adding fancy attributes
|
||||
* Added fancybox to image inlined in posts. Un-hooked the old lightbox from frio and vier and excahnged that with fancybox hooks.
|
||||
* Excluded images in "type-link" divs from being "fancied" as they have no images but pages linked to.
|
||||
|
||||
### Version 1.02
|
||||
|
||||
* [MrPetovan](https://github.com/MrPetovan) optimized my noob regular expression code.
|
||||
|
||||
### Version 1.01
|
||||
|
||||
* One gallery for each post
|
||||
* All media attached to a post are added to the posts gallery.
|
||||
* Loop scrolling: You can step from last media to first and vice versa.
|
||||
### Version 1.00
|
||||
|
||||
* First test version released.
|
||||
* One fancybox per page displaying first media of each post.
|
19
fancybox/README.md
Normal file
19
fancybox/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Post image gallery using fancybox
|
||||
|
||||
Addon author: [Grischa Brockhaus](https://brockha.us)
|
||||
|
||||
## Description
|
||||
|
||||
This addon loads all media attachments of a post into a "fancybox" instead of linking directly to the media.
|
||||
|
||||
Each post gets its own attachment library, when there are more than one media attached you can scroll through them.
|
||||
|
||||
## Licenses
|
||||
|
||||
### Fancybox Library
|
||||
|
||||
This AddOn is using the jQuery library [fancybox](https://github.com/fancyapps/fancybox).
|
||||
|
||||
The fancyBox libryry is licensed under the GPLv3 license for all open source applications. A commercial license is required for all commercial applications (including sites, themes and apps you plan to sell).
|
||||
|
||||
[Read more about fancyBox license](https://github.com/fancyapps/fancybox).
|
62
fancybox/asset/fancybox/README.md
Normal file
62
fancybox/asset/fancybox/README.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
# fancyBox 3.5.7
|
||||
|
||||
jQuery lightbox script for displaying images, videos and more.
|
||||
Touch enabled, responsive and fully customizable.
|
||||
|
||||
See the [project page](http://fancyapps.com/fancybox/3/) for documentation and a demonstration.
|
||||
|
||||
Follow [@thefancyapps](//twitter.com/thefancyapps) for updates.
|
||||
|
||||
|
||||
## Quick start
|
||||
|
||||
1\. Add latest jQuery and fancyBox files
|
||||
|
||||
```html
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||
|
||||
<link href="/path/to/jquery.fancybox.min.css" rel="stylesheet">
|
||||
<script src="/path/to/jquery.fancybox.min.js"></script>
|
||||
```
|
||||
|
||||
|
||||
2\. Create links
|
||||
|
||||
```html
|
||||
<a data-fancybox="gallery" href="big_1.jpg">
|
||||
<img src="small_1.jpg">
|
||||
</a>
|
||||
|
||||
<a data-fancybox="gallery" href="big_2.jpg">
|
||||
<img src="small_2.jpg">
|
||||
</a>
|
||||
```
|
||||
|
||||
|
||||
3\. Enjoy!
|
||||
|
||||
|
||||
## License
|
||||
|
||||
fancyBox is licensed under the [GPLv3](http://choosealicense.com/licenses/gpl-3.0) license for all open source applications.
|
||||
A commercial license is required for all commercial applications (including sites, themes and apps you plan to sell).
|
||||
|
||||
[Read more about fancyBox license](http://fancyapps.com/fancybox/3/#license).
|
||||
|
||||
## Bugs and feature requests
|
||||
|
||||
If you find a bug, please report it [here on Github](https://github.com/fancyapps/fancybox/issues).
|
||||
|
||||
Guidelines for bug reports:
|
||||
|
||||
1. Use the GitHub issue search — check if the issue has already been reported.
|
||||
2. Check if the issue has been fixed — try to reproduce it using the latest master or development branch in the repository.
|
||||
3. Isolate the problem — create a reduced test case and a live example. You can use CodePen to fork any demo found on documentation to use it as a template.
|
||||
|
||||
A good bug report shouldn't leave others needing to chase you up for more information.
|
||||
Please try to be as detailed as possible in your report.
|
||||
|
||||
|
||||
Feature requests are welcome. Please look for existing ones and use GitHub's "reactions" feature to vote.
|
||||
|
||||
Please do not use the issue tracker for personal support requests - use Stack Overflow ([fancybox-3](http://stackoverflow.com/questions/tagged/fancybox-3) tag) instead.
|
13
fancybox/asset/fancybox/fancybox.config.js
Normal file
13
fancybox/asset/fancybox/fancybox.config.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
$(document).ready(function() {
|
||||
$.fancybox.defaults.loop = "true";
|
||||
// this disables the colorbox hook found in frio/js/modal.js:34
|
||||
$("body").off("click", ".wall-item-body a img");
|
||||
|
||||
// Adds ALT/TITLE text to fancybox
|
||||
$('a[data-fancybox').fancybox({
|
||||
afterLoad : function(instance, current) {
|
||||
current.$image.attr('alt', current.opts.$orig.find('img').attr('alt') );
|
||||
current.$image.attr('title', current.opts.$orig.find('img').attr('title') );
|
||||
}
|
||||
});
|
||||
});
|
895
fancybox/asset/fancybox/jquery.fancybox.css
vendored
Normal file
895
fancybox/asset/fancybox/jquery.fancybox.css
vendored
Normal file
|
@ -0,0 +1,895 @@
|
|||
body.compensate-for-scrollbar {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fancybox-active {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.fancybox-is-hidden {
|
||||
left: -9999px;
|
||||
margin: 0;
|
||||
position: absolute !important;
|
||||
top: -9999px;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.fancybox-container {
|
||||
-webkit-backface-visibility: hidden;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
outline: none;
|
||||
position: fixed;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
top: 0;
|
||||
-ms-touch-action: manipulation;
|
||||
touch-action: manipulation;
|
||||
transform: translateZ(0);
|
||||
width: 100%;
|
||||
z-index: 99992;
|
||||
}
|
||||
|
||||
.fancybox-container * {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.fancybox-outer,
|
||||
.fancybox-inner,
|
||||
.fancybox-bg,
|
||||
.fancybox-stage {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.fancybox-outer {
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.fancybox-bg {
|
||||
background: rgb(30, 30, 30);
|
||||
opacity: 0;
|
||||
transition-duration: inherit;
|
||||
transition-property: opacity;
|
||||
transition-timing-function: cubic-bezier(.47, 0, .74, .71);
|
||||
}
|
||||
|
||||
.fancybox-is-open .fancybox-bg {
|
||||
opacity: .9;
|
||||
transition-timing-function: cubic-bezier(.22, .61, .36, 1);
|
||||
}
|
||||
|
||||
.fancybox-infobar,
|
||||
.fancybox-toolbar,
|
||||
.fancybox-caption,
|
||||
.fancybox-navigation .fancybox-button {
|
||||
direction: ltr;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
transition: opacity .25s ease, visibility 0s ease .25s;
|
||||
visibility: hidden;
|
||||
z-index: 99997;
|
||||
}
|
||||
|
||||
.fancybox-show-infobar .fancybox-infobar,
|
||||
.fancybox-show-toolbar .fancybox-toolbar,
|
||||
.fancybox-show-caption .fancybox-caption,
|
||||
.fancybox-show-nav .fancybox-navigation .fancybox-button {
|
||||
opacity: 1;
|
||||
transition: opacity .25s ease 0s, visibility 0s ease 0s;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.fancybox-infobar {
|
||||
color: #ccc;
|
||||
font-size: 13px;
|
||||
-webkit-font-smoothing: subpixel-antialiased;
|
||||
height: 44px;
|
||||
left: 0;
|
||||
line-height: 44px;
|
||||
min-width: 44px;
|
||||
mix-blend-mode: difference;
|
||||
padding: 0 10px;
|
||||
pointer-events: none;
|
||||
top: 0;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.fancybox-toolbar {
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.fancybox-stage {
|
||||
direction: ltr;
|
||||
overflow: visible;
|
||||
transform: translateZ(0);
|
||||
z-index: 99994;
|
||||
}
|
||||
|
||||
.fancybox-is-open .fancybox-stage {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fancybox-slide {
|
||||
-webkit-backface-visibility: hidden;
|
||||
/* Using without prefix would break IE11 */
|
||||
display: none;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
outline: none;
|
||||
overflow: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 44px;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
top: 0;
|
||||
transition-property: transform, opacity;
|
||||
white-space: normal;
|
||||
width: 100%;
|
||||
z-index: 99994;
|
||||
}
|
||||
|
||||
.fancybox-slide::before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
font-size: 0;
|
||||
height: 100%;
|
||||
vertical-align: middle;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.fancybox-is-sliding .fancybox-slide,
|
||||
.fancybox-slide--previous,
|
||||
.fancybox-slide--current,
|
||||
.fancybox-slide--next {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.fancybox-slide--image {
|
||||
overflow: hidden;
|
||||
padding: 44px 0;
|
||||
}
|
||||
|
||||
.fancybox-slide--image::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.fancybox-slide--html {
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.fancybox-content {
|
||||
background: #fff;
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding: 44px;
|
||||
position: relative;
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.fancybox-slide--image .fancybox-content {
|
||||
animation-timing-function: cubic-bezier(.5, 0, .14, 1);
|
||||
-webkit-backface-visibility: hidden;
|
||||
background: transparent;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 100%;
|
||||
left: 0;
|
||||
max-width: none;
|
||||
overflow: visible;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
-ms-transform-origin: top left;
|
||||
transform-origin: top left;
|
||||
transition-property: transform, opacity;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
z-index: 99995;
|
||||
}
|
||||
|
||||
.fancybox-can-zoomOut .fancybox-content {
|
||||
cursor: zoom-out;
|
||||
}
|
||||
|
||||
.fancybox-can-zoomIn .fancybox-content {
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
.fancybox-can-swipe .fancybox-content,
|
||||
.fancybox-can-pan .fancybox-content {
|
||||
cursor: -webkit-grab;
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
.fancybox-is-grabbing .fancybox-content {
|
||||
cursor: -webkit-grabbing;
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
.fancybox-container [data-selectable='true'] {
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.fancybox-image,
|
||||
.fancybox-spaceball {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
height: 100%;
|
||||
left: 0;
|
||||
margin: 0;
|
||||
max-height: none;
|
||||
max-width: none;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fancybox-spaceball {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.fancybox-slide--video .fancybox-content,
|
||||
.fancybox-slide--map .fancybox-content,
|
||||
.fancybox-slide--pdf .fancybox-content,
|
||||
.fancybox-slide--iframe .fancybox-content {
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fancybox-slide--video .fancybox-content {
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.fancybox-slide--map .fancybox-content {
|
||||
background: #e5e3df;
|
||||
}
|
||||
|
||||
.fancybox-slide--iframe .fancybox-content {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.fancybox-video,
|
||||
.fancybox-iframe {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
display: block;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Fix iOS */
|
||||
.fancybox-iframe {
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.fancybox-error {
|
||||
background: #fff;
|
||||
cursor: default;
|
||||
max-width: 400px;
|
||||
padding: 40px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fancybox-error p {
|
||||
color: #444;
|
||||
font-size: 16px;
|
||||
line-height: 20px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
|
||||
.fancybox-button {
|
||||
background: rgba(30, 30, 30, .6);
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
height: 44px;
|
||||
margin: 0;
|
||||
padding: 10px;
|
||||
position: relative;
|
||||
transition: color .2s;
|
||||
vertical-align: top;
|
||||
visibility: inherit;
|
||||
width: 44px;
|
||||
}
|
||||
|
||||
.fancybox-button,
|
||||
.fancybox-button:visited,
|
||||
.fancybox-button:link {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.fancybox-button:hover {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.fancybox-button:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.fancybox-button.fancybox-focus {
|
||||
outline: 1px dotted;
|
||||
}
|
||||
|
||||
.fancybox-button[disabled],
|
||||
.fancybox-button[disabled]:hover {
|
||||
color: #888;
|
||||
cursor: default;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Fix IE11 */
|
||||
.fancybox-button div {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.fancybox-button svg {
|
||||
display: block;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fancybox-button svg path {
|
||||
fill: currentColor;
|
||||
stroke-width: 0;
|
||||
}
|
||||
|
||||
.fancybox-button--play svg:nth-child(2),
|
||||
.fancybox-button--fsenter svg:nth-child(2) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.fancybox-button--pause svg:nth-child(1),
|
||||
.fancybox-button--fsexit svg:nth-child(1) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.fancybox-progress {
|
||||
background: #ff5268;
|
||||
height: 2px;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
-ms-transform: scaleX(0);
|
||||
transform: scaleX(0);
|
||||
-ms-transform-origin: 0;
|
||||
transform-origin: 0;
|
||||
transition-property: transform;
|
||||
transition-timing-function: linear;
|
||||
z-index: 99998;
|
||||
}
|
||||
|
||||
/* Close button on the top right corner of html content */
|
||||
|
||||
.fancybox-close-small {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
color: #ccc;
|
||||
cursor: pointer;
|
||||
opacity: .8;
|
||||
padding: 8px;
|
||||
position: absolute;
|
||||
right: -12px;
|
||||
top: -44px;
|
||||
z-index: 401;
|
||||
}
|
||||
|
||||
.fancybox-close-small:hover {
|
||||
color: #fff;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.fancybox-slide--html .fancybox-close-small {
|
||||
color: currentColor;
|
||||
padding: 10px;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.fancybox-slide--image.fancybox-is-scaling .fancybox-content {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fancybox-is-scaling .fancybox-close-small,
|
||||
.fancybox-is-zoomable.fancybox-can-pan .fancybox-close-small {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Navigation arrows */
|
||||
|
||||
.fancybox-navigation .fancybox-button {
|
||||
background-clip: content-box;
|
||||
height: 100px;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
top: calc(50% - 50px);
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
.fancybox-navigation .fancybox-button div {
|
||||
padding: 7px;
|
||||
}
|
||||
|
||||
.fancybox-navigation .fancybox-button--arrow_left {
|
||||
left: 0;
|
||||
left: env(safe-area-inset-left);
|
||||
padding: 31px 26px 31px 6px;
|
||||
}
|
||||
|
||||
.fancybox-navigation .fancybox-button--arrow_right {
|
||||
padding: 31px 6px 31px 26px;
|
||||
right: 0;
|
||||
right: env(safe-area-inset-right);
|
||||
}
|
||||
|
||||
/* Caption */
|
||||
|
||||
.fancybox-caption {
|
||||
background: linear-gradient(to top,
|
||||
rgba(0, 0, 0, .85) 0%,
|
||||
rgba(0, 0, 0, .3) 50%,
|
||||
rgba(0, 0, 0, .15) 65%,
|
||||
rgba(0, 0, 0, .075) 75.5%,
|
||||
rgba(0, 0, 0, .037) 82.85%,
|
||||
rgba(0, 0, 0, .019) 88%,
|
||||
rgba(0, 0, 0, 0) 100%);
|
||||
bottom: 0;
|
||||
color: #eee;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
left: 0;
|
||||
line-height: 1.5;
|
||||
padding: 75px 44px 25px 44px;
|
||||
pointer-events: none;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
z-index: 99996;
|
||||
}
|
||||
|
||||
@supports (padding: max(0px)) {
|
||||
.fancybox-caption {
|
||||
padding: 75px max(44px, env(safe-area-inset-right)) max(25px, env(safe-area-inset-bottom)) max(44px, env(safe-area-inset-left));
|
||||
}
|
||||
}
|
||||
|
||||
.fancybox-caption--separate {
|
||||
margin-top: -50px;
|
||||
}
|
||||
|
||||
.fancybox-caption__body {
|
||||
max-height: 50vh;
|
||||
overflow: auto;
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.fancybox-caption a,
|
||||
.fancybox-caption a:link,
|
||||
.fancybox-caption a:visited {
|
||||
color: #ccc;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.fancybox-caption a:hover {
|
||||
color: #fff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* Loading indicator */
|
||||
|
||||
.fancybox-loading {
|
||||
animation: fancybox-rotate 1s linear infinite;
|
||||
background: transparent;
|
||||
border: 4px solid #888;
|
||||
border-bottom-color: #fff;
|
||||
border-radius: 50%;
|
||||
height: 50px;
|
||||
left: 50%;
|
||||
margin: -25px 0 0 -25px;
|
||||
opacity: .7;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 50px;
|
||||
z-index: 99999;
|
||||
}
|
||||
|
||||
@keyframes fancybox-rotate {
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Transition effects */
|
||||
|
||||
.fancybox-animated {
|
||||
transition-timing-function: cubic-bezier(0, 0, .25, 1);
|
||||
}
|
||||
|
||||
/* transitionEffect: slide */
|
||||
|
||||
.fancybox-fx-slide.fancybox-slide--previous {
|
||||
opacity: 0;
|
||||
transform: translate3d(-100%, 0, 0);
|
||||
}
|
||||
|
||||
.fancybox-fx-slide.fancybox-slide--next {
|
||||
opacity: 0;
|
||||
transform: translate3d(100%, 0, 0);
|
||||
}
|
||||
|
||||
.fancybox-fx-slide.fancybox-slide--current {
|
||||
opacity: 1;
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
|
||||
/* transitionEffect: fade */
|
||||
|
||||
.fancybox-fx-fade.fancybox-slide--previous,
|
||||
.fancybox-fx-fade.fancybox-slide--next {
|
||||
opacity: 0;
|
||||
transition-timing-function: cubic-bezier(.19, 1, .22, 1);
|
||||
}
|
||||
|
||||
.fancybox-fx-fade.fancybox-slide--current {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* transitionEffect: zoom-in-out */
|
||||
|
||||
.fancybox-fx-zoom-in-out.fancybox-slide--previous {
|
||||
opacity: 0;
|
||||
transform: scale3d(1.5, 1.5, 1.5);
|
||||
}
|
||||
|
||||
.fancybox-fx-zoom-in-out.fancybox-slide--next {
|
||||
opacity: 0;
|
||||
transform: scale3d(.5, .5, .5);
|
||||
}
|
||||
|
||||
.fancybox-fx-zoom-in-out.fancybox-slide--current {
|
||||
opacity: 1;
|
||||
transform: scale3d(1, 1, 1);
|
||||
}
|
||||
|
||||
/* transitionEffect: rotate */
|
||||
|
||||
.fancybox-fx-rotate.fancybox-slide--previous {
|
||||
opacity: 0;
|
||||
-ms-transform: rotate(-360deg);
|
||||
transform: rotate(-360deg);
|
||||
}
|
||||
|
||||
.fancybox-fx-rotate.fancybox-slide--next {
|
||||
opacity: 0;
|
||||
-ms-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
|
||||
.fancybox-fx-rotate.fancybox-slide--current {
|
||||
opacity: 1;
|
||||
-ms-transform: rotate(0deg);
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
/* transitionEffect: circular */
|
||||
|
||||
.fancybox-fx-circular.fancybox-slide--previous {
|
||||
opacity: 0;
|
||||
transform: scale3d(0, 0, 0) translate3d(-100%, 0, 0);
|
||||
}
|
||||
|
||||
.fancybox-fx-circular.fancybox-slide--next {
|
||||
opacity: 0;
|
||||
transform: scale3d(0, 0, 0) translate3d(100%, 0, 0);
|
||||
}
|
||||
|
||||
.fancybox-fx-circular.fancybox-slide--current {
|
||||
opacity: 1;
|
||||
transform: scale3d(1, 1, 1) translate3d(0, 0, 0);
|
||||
}
|
||||
|
||||
/* transitionEffect: tube */
|
||||
|
||||
.fancybox-fx-tube.fancybox-slide--previous {
|
||||
transform: translate3d(-100%, 0, 0) scale(.1) skew(-10deg);
|
||||
}
|
||||
|
||||
.fancybox-fx-tube.fancybox-slide--next {
|
||||
transform: translate3d(100%, 0, 0) scale(.1) skew(10deg);
|
||||
}
|
||||
|
||||
.fancybox-fx-tube.fancybox-slide--current {
|
||||
transform: translate3d(0, 0, 0) scale(1);
|
||||
}
|
||||
|
||||
/* Styling for Small-Screen Devices */
|
||||
@media all and (max-height: 576px) {
|
||||
.fancybox-slide {
|
||||
padding-left: 6px;
|
||||
padding-right: 6px;
|
||||
}
|
||||
|
||||
.fancybox-slide--image {
|
||||
padding: 6px 0;
|
||||
}
|
||||
|
||||
.fancybox-close-small {
|
||||
right: -6px;
|
||||
}
|
||||
|
||||
.fancybox-slide--image .fancybox-close-small {
|
||||
background: #4e4e4e;
|
||||
color: #f2f4f6;
|
||||
height: 36px;
|
||||
opacity: 1;
|
||||
padding: 6px;
|
||||
right: 0;
|
||||
top: 0;
|
||||
width: 36px;
|
||||
}
|
||||
|
||||
.fancybox-caption {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
@supports (padding: max(0px)) {
|
||||
.fancybox-caption {
|
||||
padding-left: max(12px, env(safe-area-inset-left));
|
||||
padding-right: max(12px, env(safe-area-inset-right));
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Share */
|
||||
|
||||
.fancybox-share {
|
||||
background: #f4f4f4;
|
||||
border-radius: 3px;
|
||||
max-width: 90%;
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fancybox-share h1 {
|
||||
color: #222;
|
||||
font-size: 35px;
|
||||
font-weight: 700;
|
||||
margin: 0 0 20px 0;
|
||||
}
|
||||
|
||||
.fancybox-share p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.fancybox-share__button {
|
||||
border: 0;
|
||||
border-radius: 3px;
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
line-height: 40px;
|
||||
margin: 0 5px 10px 5px;
|
||||
min-width: 130px;
|
||||
padding: 0 15px;
|
||||
text-decoration: none;
|
||||
transition: all .2s;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.fancybox-share__button:visited,
|
||||
.fancybox-share__button:link {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.fancybox-share__button:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.fancybox-share__button--fb {
|
||||
background: #3b5998;
|
||||
}
|
||||
|
||||
.fancybox-share__button--fb:hover {
|
||||
background: #344e86;
|
||||
}
|
||||
|
||||
.fancybox-share__button--pt {
|
||||
background: #bd081d;
|
||||
}
|
||||
|
||||
.fancybox-share__button--pt:hover {
|
||||
background: #aa0719;
|
||||
}
|
||||
|
||||
.fancybox-share__button--tw {
|
||||
background: #1da1f2;
|
||||
}
|
||||
|
||||
.fancybox-share__button--tw:hover {
|
||||
background: #0d95e8;
|
||||
}
|
||||
|
||||
.fancybox-share__button svg {
|
||||
height: 25px;
|
||||
margin-right: 7px;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
vertical-align: middle;
|
||||
width: 25px;
|
||||
}
|
||||
|
||||
.fancybox-share__button svg path {
|
||||
fill: #fff;
|
||||
}
|
||||
|
||||
.fancybox-share__input {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #d7d7d7;
|
||||
border-radius: 0;
|
||||
color: #5d5b5b;
|
||||
font-size: 14px;
|
||||
margin: 10px 0 0 0;
|
||||
outline: none;
|
||||
padding: 10px 15px;
|
||||
width: 100%;
|
||||
}
|
||||
/* Thumbs */
|
||||
|
||||
.fancybox-thumbs {
|
||||
background: #ddd;
|
||||
bottom: 0;
|
||||
display: none;
|
||||
margin: 0;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
-ms-overflow-style: -ms-autohiding-scrollbar;
|
||||
padding: 2px 2px 4px 2px;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
top: 0;
|
||||
width: 212px;
|
||||
z-index: 99995;
|
||||
}
|
||||
|
||||
.fancybox-thumbs-x {
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.fancybox-show-thumbs .fancybox-thumbs {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.fancybox-show-thumbs .fancybox-inner {
|
||||
right: 212px;
|
||||
}
|
||||
|
||||
.fancybox-thumbs__list {
|
||||
font-size: 0;
|
||||
height: 100%;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fancybox-thumbs-x .fancybox-thumbs__list {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fancybox-thumbs-y .fancybox-thumbs__list::-webkit-scrollbar {
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
.fancybox-thumbs-y .fancybox-thumbs__list::-webkit-scrollbar-track {
|
||||
background: #fff;
|
||||
border-radius: 10px;
|
||||
box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
|
||||
}
|
||||
|
||||
.fancybox-thumbs-y .fancybox-thumbs__list::-webkit-scrollbar-thumb {
|
||||
background: #2a2a2a;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.fancybox-thumbs__list a {
|
||||
-webkit-backface-visibility: hidden;
|
||||
backface-visibility: hidden;
|
||||
background-color: rgba(0, 0, 0, .1);
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
cursor: pointer;
|
||||
float: left;
|
||||
height: 75px;
|
||||
margin: 2px;
|
||||
max-height: calc(100% - 8px);
|
||||
max-width: calc(50% - 4px);
|
||||
outline: none;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.fancybox-thumbs__list a::before {
|
||||
border: 6px solid #ff5268;
|
||||
bottom: 0;
|
||||
content: '';
|
||||
left: 0;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
transition: all .2s cubic-bezier(.25, .46, .45, .94);
|
||||
z-index: 99991;
|
||||
}
|
||||
|
||||
.fancybox-thumbs__list a:focus::before {
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
.fancybox-thumbs__list a.fancybox-thumbs-active::before {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Styling for Small-Screen Devices */
|
||||
@media all and (max-width: 576px) {
|
||||
.fancybox-thumbs {
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
.fancybox-show-thumbs .fancybox-inner {
|
||||
right: 110px;
|
||||
}
|
||||
|
||||
.fancybox-thumbs__list a {
|
||||
max-width: calc(100% - 10px);
|
||||
}
|
||||
}
|
5632
fancybox/asset/fancybox/jquery.fancybox.js
vendored
Normal file
5632
fancybox/asset/fancybox/jquery.fancybox.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
fancybox/asset/fancybox/jquery.fancybox.min.css
vendored
Normal file
1
fancybox/asset/fancybox/jquery.fancybox.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
13
fancybox/asset/fancybox/jquery.fancybox.min.js
vendored
Normal file
13
fancybox/asset/fancybox/jquery.fancybox.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
15
fancybox/createrelease
Executable file
15
fancybox/createrelease
Executable file
|
@ -0,0 +1,15 @@
|
|||
MODULE=fancybox
|
||||
|
||||
cd ..
|
||||
|
||||
# old releases not needed anymore
|
||||
mkdir -p $MODULE/dist
|
||||
rm $MODULE/dist/*
|
||||
|
||||
# create release for actual version
|
||||
zip -r9 $MODULE/dist/release.zip $MODULE/* -x $MODULE/dist/\* -x $MODULE/test/\* $MODULE/createrelease
|
||||
|
||||
echo dist/release.zip created.
|
||||
|
||||
cd $MODULE
|
||||
|
60
fancybox/fancybox.php
Normal file
60
fancybox/fancybox.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* Name: Fancybox
|
||||
* Description: Open media attachments of posts into a fancybox overlay.
|
||||
* Version: 1.05
|
||||
* Author: Grischa Brockhaus <grischa@brockha.us>
|
||||
* Status: Unsupported
|
||||
*/
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
||||
function fancybox_install()
|
||||
{
|
||||
Hook::register('head', __FILE__, 'fancybox_head');
|
||||
Hook::register('footer', __FILE__, 'fancybox_footer');
|
||||
Hook::register('prepare_body_final', __FILE__, 'fancybox_render');
|
||||
}
|
||||
|
||||
function fancybox_head(string &$b)
|
||||
{
|
||||
DI::page()->registerStylesheet(__DIR__ . '/asset/fancybox/jquery.fancybox.min.css');
|
||||
}
|
||||
|
||||
function fancybox_footer(string &$str)
|
||||
{
|
||||
DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/jquery.fancybox.min.js');
|
||||
DI::page()->registerFooterScript(__DIR__ . '/asset/fancybox/fancybox.config.js');
|
||||
}
|
||||
|
||||
function fancybox_render(array &$b){
|
||||
$gallery = 'gallery-' . $b['item']['uri-id'] ?? random_int(1000000, 10000000);
|
||||
|
||||
// performWithEscapedBlocks escapes block defined with 2nd par pattern that won't be processed.
|
||||
// We don't want to touch images in class="type-link":
|
||||
$b['html'] = \Friendica\Util\Strings::performWithEscapedBlocks(
|
||||
$b['html'],
|
||||
'#<div class="type-link">.*?</div>#s',
|
||||
function ($text) use ($gallery) {
|
||||
// This processes images inlined in posts
|
||||
// Frio / Vier hooks für lightbox are un-hooked in fancybox-config.js. So this works for them, too!
|
||||
//if (!in_array(DI::appHelper()->getCurrentTheme(),['vier','frio']))
|
||||
$text = preg_replace(
|
||||
'#<a[^>]*href="([^"]*)"[^>]*>(<img[^>]*src="[^"]*"[^>]*>)</a>#',
|
||||
'<a data-fancybox="' . $gallery . '" href="$1">$2</a>',
|
||||
$text);
|
||||
|
||||
// Local content images attached:
|
||||
$text = preg_replace_callback(
|
||||
'#<div class="(body-attach|imagegrid-column)">.*?</div>#s',
|
||||
function ($matches) use ($gallery) {
|
||||
return str_replace('<a href', '<a data-fancybox="' . $gallery . '" href', $matches[0]);
|
||||
},
|
||||
$text
|
||||
);
|
||||
|
||||
return $text;
|
||||
}
|
||||
);
|
||||
}
|
|
@ -7,9 +7,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
||||
|
@ -18,7 +16,7 @@ function fromapp_install()
|
|||
Hook::register('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook');
|
||||
Hook::register('addon_settings', 'addon/fromapp/fromapp.php', 'fromapp_settings');
|
||||
Hook::register('addon_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post');
|
||||
Logger::notice("installed fromapp");
|
||||
DI::logger()->notice("installed fromapp");
|
||||
}
|
||||
|
||||
function fromapp_settings_post($post)
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
||||
|
@ -52,25 +50,25 @@ function geocoordinates_resolve_item(array &$item)
|
|||
$s = DI::httpClient()->fetch('https://api.opencagedata.com/geocode/v1/json?q=' . $coords[0] . ',' . $coords[1] . '&key=' . $key . '&language=' . $language);
|
||||
|
||||
if (!$s) {
|
||||
Logger::info('API could not be queried');
|
||||
DI::logger()->info('API could not be queried');
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_decode($s);
|
||||
|
||||
if ($data->status->code != '200') {
|
||||
Logger::info('API returned error ' . $data->status->code . ' ' . $data->status->message);
|
||||
DI::logger()->info('API returned error ' . $data->status->code . ' ' . $data->status->message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (($data->total_results == 0) || (count($data->results) == 0)) {
|
||||
Logger::info('No results found for coordinates ' . $item['coord']);
|
||||
DI::logger()->info('No results found for coordinates ' . $item['coord']);
|
||||
return;
|
||||
}
|
||||
|
||||
$item['location'] = $data->results[0]->formatted;
|
||||
|
||||
Logger::info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']);
|
||||
DI::logger()->info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']);
|
||||
|
||||
if ($item['location'] != '') {
|
||||
DI::cache()->set('geocoordinates:' . $language.':' . $coords[0] . '-' . $coords[1], $item['location']);
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
|
@ -35,7 +33,7 @@ function geonames_install()
|
|||
|
||||
function geonames_load_config(ConfigFileManager $loader)
|
||||
{
|
||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('geonames'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('geonames'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
}
|
||||
|
||||
function geonames_post_hook(array &$item)
|
||||
|
@ -46,7 +44,7 @@ function geonames_post_hook(array &$item)
|
|||
* - The profile owner must have allowed our addon
|
||||
*/
|
||||
|
||||
Logger::notice('geonames invoked');
|
||||
DI::logger()->notice('geonames invoked');
|
||||
|
||||
if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */
|
||||
return;
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Notification;
|
||||
|
@ -21,7 +19,7 @@ function gnot_install()
|
|||
Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
|
||||
Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
|
||||
|
||||
Logger::notice("installed gnot");
|
||||
DI::logger()->notice("installed gnot");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,15 +7,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
|
||||
function googlemaps_install()
|
||||
{
|
||||
Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
||||
|
||||
Logger::notice('installed googlemaps');
|
||||
DI::logger()->notice('installed googlemaps');
|
||||
}
|
||||
|
||||
function googlemaps_location(&$item)
|
||||
|
|
|
@ -6,15 +6,11 @@
|
|||
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
/**
|
||||
* Installs the addon hook
|
||||
|
@ -23,12 +19,12 @@ function gravatar_install() {
|
|||
Hook::register('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config');
|
||||
Hook::register('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup');
|
||||
|
||||
Logger::notice("registered gravatar in avatar_lookup hook");
|
||||
DI::logger()->notice("registered gravatar in avatar_lookup hook");
|
||||
}
|
||||
|
||||
function gravatar_load_config(ConfigFileManager $loader)
|
||||
{
|
||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('gravatar'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('gravatar'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
* Note: Please use Circle Text instead
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* Author: Hypolite Petovan <hypolite@mrpetovan.com>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
||||
|
@ -18,7 +17,7 @@ function highlightjs_install()
|
|||
|
||||
function highlightjs_head(string &$str)
|
||||
{
|
||||
if (DI::app()->getCurrentTheme() == 'frio') {
|
||||
if (DI::appHelper()->getCurrentTheme() == 'frio') {
|
||||
$style = 'bootstrap';
|
||||
} else {
|
||||
$style = 'default';
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
* Version: 0.1
|
||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Content\PageInfo;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -87,16 +85,16 @@ function ifttt_post()
|
|||
|
||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
|
||||
if (!DBA::isResult($user)) {
|
||||
Logger::info('User ' . $nickname . ' not found.');
|
||||
DI::logger()->info('User ' . $nickname . ' not found.');
|
||||
return;
|
||||
}
|
||||
|
||||
$uid = $user['uid'];
|
||||
|
||||
Logger::info('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true));
|
||||
DI::logger()->info('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true));
|
||||
|
||||
if (!isset($_REQUEST['key'])) {
|
||||
Logger::notice('No key found.');
|
||||
DI::logger()->notice('No key found.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -104,7 +102,7 @@ function ifttt_post()
|
|||
|
||||
// Check the key
|
||||
if ($key != DI::pConfig()->get($uid, 'ifttt', 'key')) {
|
||||
Logger::info('Invalid key for user ' . $uid);
|
||||
DI::logger()->info('Invalid key for user ' . $uid);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,7 +113,7 @@ function ifttt_post()
|
|||
}
|
||||
|
||||
if (!in_array($item['type'], ['status', 'link', 'photo'])) {
|
||||
Logger::info('Unknown item type ' . $item['type']);
|
||||
DI::logger()->info('Unknown item type ' . $item['type']);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,8 @@
|
|||
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -179,11 +177,11 @@ function ijpost_send(array &$b)
|
|||
|
||||
EOT;
|
||||
|
||||
Logger::debug('ijpost: data: ' . $xml);
|
||||
DI::logger()->debug('ijpost: data: ' . $xml);
|
||||
|
||||
if ($ij_blog !== 'test') {
|
||||
$x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
|
||||
}
|
||||
Logger::info('posted to insanejournal: ' . $x ? $x : '');
|
||||
DI::logger()->info('posted to insanejournal: ' . $x ? $x : '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,8 @@
|
|||
* License: 3-clause BSD license
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
|
@ -21,7 +19,7 @@ function impressum_install()
|
|||
Hook::register('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
|
||||
Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
|
||||
Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
|
||||
Logger::notice("installed impressum Addon");
|
||||
DI::logger()->notice("installed impressum Addon");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,7 +54,7 @@ function impressum_footer(string &$body)
|
|||
|
||||
function impressum_load_config(ConfigFileManager $loader)
|
||||
{
|
||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('impressum'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('impressum'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
}
|
||||
|
||||
function impressum_show(string &$body)
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ function invidious_settings(array &$data)
|
|||
|
||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/invidious/');
|
||||
$html = Renderer::replaceMacros($t, [
|
||||
'$enabled' => ['enabled', DI::l10n()->t('Replace Youtube links with links to an Invidious server'), $enabled, DI::l10n()->t('If enabled, Youtube links are replaced with the links to the specified Invidious server.')],
|
||||
'$server' => ['server', DI::l10n()->t('Invidious server'), $server, DI::l10n()->t('See %s for a list of available Invidious servers.', '<a href="https://api.invidious.io/">https://api.invidious.io/</a>')],
|
||||
'$enabled' => ['invidious-enabled', DI::l10n()->t('Replace Youtube links with links to an Invidious server'), $enabled, DI::l10n()->t('If enabled, Youtube links are replaced with the links to the specified Invidious server.')],
|
||||
'$server' => ['invidious-server', DI::l10n()->t('Invidious server'), $server, DI::l10n()->t('See %s for a list of available Invidious servers.', '<a href="https://api.invidious.io/">https://api.invidious.io/</a>')],
|
||||
]);
|
||||
|
||||
$data = [
|
||||
|
@ -71,9 +71,9 @@ function invidious_settings_post(array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'enabled', (bool)$_POST['enabled']);
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'enabled', (bool)$_POST['invidious-enabled']);
|
||||
|
||||
$server = trim($_POST['server'], " \n\r\t\v\x00/");
|
||||
$server = trim($_POST['invidious-server'], " \n\r\t\v\x00/");
|
||||
if ($server != DI::config()->get('invidious', 'server', INVIDIOUS_DEFAULT) && !empty($server)) {
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'server', $server);
|
||||
} else {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* Author: Tobias Diekershoff <https://f.diekershoff.de/u/tobias>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
|
|
@ -105,7 +105,7 @@ class qqFileUploader {
|
|||
|
||||
private function toBytes(string $str): int
|
||||
{
|
||||
$val = trim($str);
|
||||
$val = (int) trim($str);
|
||||
$last = strtolower($str[strlen($str) - 1]);
|
||||
|
||||
switch($last) {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
usleep(100000);
|
||||
|
||||
$fileName;
|
||||
$fileSize;
|
||||
$fileName = '';
|
||||
$fileSize = 0;;
|
||||
|
||||
if (isset($_GET['qqfile'])){
|
||||
$fileName = $_GET['qqfile'];
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
sleep(4);
|
||||
|
||||
$fileName;
|
||||
$fileName = '';
|
||||
|
||||
if (isset($_GET['qqfile'])){
|
||||
$fileName = $_GET['qqfile'];
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
usleep(300);
|
||||
|
||||
$fileName;
|
||||
$fileName = '';
|
||||
|
||||
if (isset($_GET['qqfile'])){
|
||||
$fileName = $_GET['qqfile'];
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Util\Images;
|
||||
|
@ -60,7 +59,7 @@ function js_upload_post_init(array &$b)
|
|||
// max file size in bytes
|
||||
$sizeLimit = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
|
||||
|
||||
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
|
||||
$uploader = new js_upload_qqFileUploader($allowedExtensions, $sizeLimit);
|
||||
|
||||
$result = $uploader->handleUpload();
|
||||
|
||||
|
@ -68,7 +67,7 @@ function js_upload_post_init(array &$b)
|
|||
$js_upload_jsonresponse = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
|
||||
|
||||
if (isset($result['error'])) {
|
||||
Logger::info('mod/photos.php: photos_post(): error uploading photo: ' . $result['error']);
|
||||
DI::logger()->info('mod/photos.php: photos_post(): error uploading photo: ' . $result['error']);
|
||||
echo json_encode($result);
|
||||
exit();
|
||||
}
|
||||
|
@ -91,7 +90,7 @@ function js_upload_post_end(int &$b)
|
|||
{
|
||||
global $js_upload_jsonresponse;
|
||||
|
||||
Logger::notice('upload_post_end');
|
||||
DI::logger()->notice('upload_post_end');
|
||||
if (!empty($js_upload_jsonresponse)) {
|
||||
echo $js_upload_jsonresponse;
|
||||
exit();
|
||||
|
@ -101,7 +100,7 @@ function js_upload_post_end(int &$b)
|
|||
/**
|
||||
* Handle file uploads via XMLHttpRequest
|
||||
*/
|
||||
class qqUploadedFileXhr
|
||||
class js_upload_qqUploadedFileXhr
|
||||
{
|
||||
private $pathnm = '';
|
||||
|
||||
|
@ -155,7 +154,7 @@ class qqUploadedFileXhr
|
|||
/**
|
||||
* Handle file uploads via regular form post (uses the $_FILES array)
|
||||
*/
|
||||
class qqUploadedFileForm
|
||||
class js_upload_qqUploadedFileForm
|
||||
{
|
||||
/**
|
||||
* Save the file to the specified path
|
||||
|
@ -183,10 +182,14 @@ class qqUploadedFileForm
|
|||
}
|
||||
}
|
||||
|
||||
class qqFileUploader
|
||||
class js_upload_qqFileUploader
|
||||
{
|
||||
private $allowedExtensions;
|
||||
private $sizeLimit;
|
||||
|
||||
/**
|
||||
* @var js_upload_qqUploadedFileXhr|js_upload_qqUploadedFileForm|false
|
||||
*/
|
||||
private $file;
|
||||
|
||||
function __construct(array $allowedExtensions = [], $sizeLimit)
|
||||
|
@ -197,9 +200,9 @@ class qqFileUploader
|
|||
$this->sizeLimit = $sizeLimit;
|
||||
|
||||
if (isset($_GET['qqfile'])) {
|
||||
$this->file = new qqUploadedFileXhr();
|
||||
$this->file = new js_upload_qqUploadedFileXhr();
|
||||
} elseif (isset($_FILES['qqfile'])) {
|
||||
$this->file = new qqUploadedFileForm();
|
||||
$this->file = new js_upload_qqUploadedFileForm();
|
||||
} else {
|
||||
$this->file = false;
|
||||
}
|
||||
|
@ -234,7 +237,7 @@ class qqFileUploader
|
|||
$filename = $pathinfo['filename'];
|
||||
|
||||
if (!isset($pathinfo['extension'])) {
|
||||
Logger::warning('extension isn\'t set.', ['filename' => $filename]);
|
||||
DI::logger()->warning('extension isn\'t set.', ['filename' => $filename]);
|
||||
}
|
||||
$ext = $pathinfo['extension'] ?? '';
|
||||
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
* Author: Ryan <https://verya.pe/profile/ryan>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -38,7 +36,7 @@ function keycloakpassword_request($client_id, $secret, $url, $params = [])
|
|||
$res = curl_exec($ch);
|
||||
|
||||
if (curl_errno($ch)) {
|
||||
Logger::error(curl_error($ch));
|
||||
DI::logger()->error(curl_error($ch));
|
||||
}
|
||||
curl_close($ch);
|
||||
|
||||
|
@ -92,7 +90,7 @@ function keycloakpassword_authenticate(array &$b)
|
|||
$client_id,
|
||||
$secret,
|
||||
$endpoint . '/logout',
|
||||
[ 'refresh_token' => res['refresh_token'] ]
|
||||
[ 'refresh_token' => $res['refresh_token'] ]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
*"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin Majere
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
||||
|
@ -32,7 +30,7 @@ function krynn_install()
|
|||
Hook::register('addon_settings', 'addon/krynn/krynn.php', 'krynn_settings');
|
||||
Hook::register('addon_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post');
|
||||
|
||||
Logger::notice("installed krynn");
|
||||
DI::logger()->notice("installed krynn");
|
||||
}
|
||||
|
||||
function krynn_post_hook(&$item)
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* License: MIT
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
|
@ -100,8 +99,8 @@ function langfilter_addon_settings_post(array &$b)
|
|||
|
||||
function langfilter_prepare_body_content_filter(&$hook_data)
|
||||
{
|
||||
$logged_user = DI::userSession()->getLocalUserId();
|
||||
if (!$logged_user) {
|
||||
$uid = $hook_data['uid'] ?? DI::userSession()->getLocalUserId();
|
||||
if (!$uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -113,8 +112,8 @@ function langfilter_prepare_body_content_filter(&$hook_data)
|
|||
}
|
||||
|
||||
// Don't filter if language filter is disabled
|
||||
if (!DI::pConfig()->get($logged_user, 'langfilter', 'enable',
|
||||
!DI::pConfig()->get($logged_user, 'langfilter', 'disable'))
|
||||
if (!DI::pConfig()->get($uid, 'langfilter', 'enable',
|
||||
!DI::pConfig()->get($uid, 'langfilter', 'disable'))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
@ -128,7 +127,7 @@ function langfilter_prepare_body_content_filter(&$hook_data)
|
|||
$naked_body = preg_replace('#\s+#', ' ', trim($naked_body));
|
||||
|
||||
// Don't filter if body lenght is below minimum
|
||||
$minlen = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'minlength', 32);
|
||||
$minlen = DI::pConfig()->get($uid, 'langfilter', 'minlength', 32);
|
||||
if (!$minlen) {
|
||||
$minlen = 32;
|
||||
}
|
||||
|
@ -137,8 +136,8 @@ function langfilter_prepare_body_content_filter(&$hook_data)
|
|||
return;
|
||||
}
|
||||
|
||||
$read_languages_string = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'languages');
|
||||
$minconfidence = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'langfilter', 'minconfidence');
|
||||
$read_languages_string = DI::pConfig()->get($uid, 'langfilter', 'languages');
|
||||
$minconfidence = DI::pConfig()->get($uid, 'langfilter', 'minconfidence');
|
||||
|
||||
// Don't filter if no spoken languages are configured
|
||||
if (!$read_languages_string) {
|
||||
|
@ -148,6 +147,8 @@ function langfilter_prepare_body_content_filter(&$hook_data)
|
|||
|
||||
$iso639 = new Matriphe\ISO639\ISO639;
|
||||
|
||||
$confidence = null;
|
||||
|
||||
// Extract the language of the post
|
||||
if (!empty($hook_data['item']['language'])) {
|
||||
$languages = json_decode($hook_data['item']['language'], true);
|
||||
|
|
|
@ -29,9 +29,7 @@
|
|||
* The configuration options for this module are described in the config/ldapauth.config.php file
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
|
@ -45,7 +43,7 @@ function ldapauth_install()
|
|||
|
||||
function ldapauth_load_config(ConfigFileManager $loader)
|
||||
{
|
||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('ldapauth'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('ldapauth'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
}
|
||||
|
||||
function ldapauth_hook_authenticate(array &$b)
|
||||
|
@ -70,54 +68,54 @@ function ldapauth_authenticate($username, $password)
|
|||
$ldap_autocreateaccount_nameattribute = DI::config()->get('ldapauth', 'ldap_autocreateaccount_nameattribute');
|
||||
|
||||
if (!extension_loaded('ldap') || !strlen($ldap_server)) {
|
||||
Logger::error('Addon not configured or missing php-ldap extension', ['extension_loaded' => extension_loaded('ldap'), 'server' => $ldap_server]);
|
||||
DI::logger()->error('Addon not configured or missing php-ldap extension', ['extension_loaded' => extension_loaded('ldap'), 'server' => $ldap_server]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!strlen($password)) {
|
||||
Logger::error('Empty password disallowed', ['provided_password_length' => strlen($password)]);
|
||||
DI::logger()->error('Empty password disallowed', ['provided_password_length' => strlen($password)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$connect = @ldap_connect($ldap_server);
|
||||
if ($connect === false) {
|
||||
Logger::warning('Could not connect to LDAP server', ['server' => $ldap_server]);
|
||||
DI::logger()->warning('Could not connect to LDAP server', ['server' => $ldap_server]);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||
@ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
|
||||
if ((@ldap_bind($connect, $ldap_binddn, $ldap_bindpw)) === false) {
|
||||
Logger::warning('Could not bind to LDAP server', ['server' => $ldap_server, 'binddn' => $ldap_binddn, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
|
||||
DI::logger()->warning('Could not bind to LDAP server', ['server' => $ldap_server, 'binddn' => $ldap_binddn, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = @ldap_search($connect, $ldap_searchdn, $ldap_userattr . '=' . $username);
|
||||
if (!$res) {
|
||||
Logger::notice('LDAP user not found.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
|
||||
DI::logger()->notice('LDAP user not found.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$id = @ldap_first_entry($connect, $res);
|
||||
if (!$id) {
|
||||
Logger::notice('Could not retrieve first LDAP entry.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
|
||||
DI::logger()->notice('Could not retrieve first LDAP entry.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$dn = @ldap_get_dn($connect, $id);
|
||||
if (!@ldap_bind($connect, $dn, $password)) {
|
||||
Logger::notice('Could not authenticate LDAP user with provided password', ['errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
|
||||
DI::logger()->notice('Could not authenticate LDAP user with provided password', ['errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strlen($ldap_group) && @ldap_compare($connect, $ldap_group, 'member', $dn) !== true) {
|
||||
$errno = @ldap_errno($connect);
|
||||
if ($errno === 32) {
|
||||
Logger::notice('LDAP Access Control Group does not exist', ['errno' => $errno, 'error' => ldap_error($connect)]);
|
||||
DI::logger()->notice('LDAP Access Control Group does not exist', ['errno' => $errno, 'error' => ldap_error($connect)]);
|
||||
} elseif ($errno === 16) {
|
||||
Logger::notice('LDAP membership attribute does not exist in access control group', ['errno' => $errno, 'error' => ldap_error($connect)]);
|
||||
DI::logger()->notice('LDAP membership attribute does not exist in access control group', ['errno' => $errno, 'error' => ldap_error($connect)]);
|
||||
} else {
|
||||
Logger::notice('LDAP user isn\'t part of the authorized group', ['dn' => $dn]);
|
||||
DI::logger()->notice('LDAP user isn\'t part of the authorized group', ['dn' => $dn]);
|
||||
}
|
||||
|
||||
@ldap_close($connect);
|
||||
|
@ -141,7 +139,7 @@ function ldapauth_authenticate($username, $password)
|
|||
$authentication = User::getAuthenticationInfo($username);
|
||||
return User::getById($authentication['uid']);
|
||||
} catch (Exception $e) {
|
||||
Logger::notice('LDAP authentication error: ' . $e->getMessage());
|
||||
DI::logger()->notice('LDAP authentication error: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +147,7 @@ function ldapauth_authenticate($username, $password)
|
|||
function ldap_createaccount($username, $password, $email, $name)
|
||||
{
|
||||
if (!strlen($email) || !strlen($name)) {
|
||||
Logger::notice('Could not create local user from LDAP data, no email or nickname provided');
|
||||
DI::logger()->notice('Could not create local user from LDAP data, no email or nickname provided');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -161,10 +159,10 @@ function ldap_createaccount($username, $password, $email, $name)
|
|||
'password' => $password,
|
||||
'verified' => 1
|
||||
]);
|
||||
Logger::info('Local user created from LDAP data', ['username' => $username, 'name' => $name]);
|
||||
DI::logger()->info('Local user created from LDAP data', ['username' => $username, 'name' => $name]);
|
||||
return $user;
|
||||
} catch (Exception $ex) {
|
||||
Logger::error('Could not create local user from LDAP data', ['username' => $username, 'exception' => $ex->getMessage()]);
|
||||
DI::logger()->error('Could not create local user from LDAP data', ['username' => $username, 'exception' => $ex->getMessage()]);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
|
||||
function leistungsschutzrecht_install()
|
||||
|
@ -149,7 +147,7 @@ function leistungsschutzrecht_is_member_site(string $url): bool
|
|||
$cleanedurlpart = explode('%', $urldata['host']);
|
||||
|
||||
$hostname = explode('.', $cleanedurlpart[0]);
|
||||
if (empty($hostname)) {
|
||||
if ($hostname === false || $hostname === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -169,7 +167,7 @@ function leistungsschutzrecht_cron($b)
|
|||
if ($last) {
|
||||
$next = $last + 86400;
|
||||
if ($next > time()) {
|
||||
Logger::notice('poll intervall not reached');
|
||||
DI::logger()->notice('poll intervall not reached');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
* Author: Tony Baldwin <https://free-haven.org/u/tony>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -131,7 +129,7 @@ function libertree_post_local(array &$b)
|
|||
|
||||
function libertree_send(array &$b)
|
||||
{
|
||||
Logger::notice('libertree_send: invoked');
|
||||
DI::logger()->notice('libertree_send: invoked');
|
||||
|
||||
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
||||
return;
|
||||
|
@ -197,6 +195,6 @@ function libertree_send(array &$b)
|
|||
];
|
||||
|
||||
$result = DI::httpClient()->post($ltree_blog, $params)->getBodyString();
|
||||
Logger::notice('libertree: ' . $result);
|
||||
DI::logger()->notice('libertree: ' . $result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ class Services_Libravatar
|
|||
*
|
||||
* @param array $options Array of options for getUrl()
|
||||
*
|
||||
* @return void
|
||||
* @return array
|
||||
* @throws Exception When an invalid option is used
|
||||
*/
|
||||
protected function checkOptionsArray($options)
|
||||
|
@ -361,7 +361,7 @@ class Services_Libravatar
|
|||
protected function domainGet($identifier)
|
||||
{
|
||||
if ($identifier === null) {
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
|
||||
// What are we, email or openid? Split ourself up and get the
|
||||
|
@ -401,9 +401,8 @@ class Services_Libravatar
|
|||
*/
|
||||
protected function srvGet($domain, $https = false)
|
||||
{
|
||||
|
||||
// Are we going secure? Set up a fallback too.
|
||||
if (isset($https) && $https === true) {
|
||||
if ($https === true) {
|
||||
$subdomain = '_avatars-sec._tcp.';
|
||||
$fallback = 'seccdn.';
|
||||
} else {
|
||||
|
@ -426,6 +425,7 @@ class Services_Libravatar
|
|||
|
||||
$top = $srv[0];
|
||||
$sum = 0;
|
||||
$pri = [];
|
||||
|
||||
// Try to adhere to RFC2782's weighting algorithm, page 3
|
||||
// "arrange all SRV RRs (that have not been ordered yet) in any order,
|
||||
|
@ -462,6 +462,8 @@ class Services_Libravatar
|
|||
return $v['target'];
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,10 +6,7 @@
|
|||
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
|
@ -21,12 +18,12 @@ function libravatar_install()
|
|||
{
|
||||
Hook::register('load_config', 'addon/libravatar/libravatar.php', 'libravatar_load_config');
|
||||
Hook::register('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup');
|
||||
Logger::notice("registered libravatar in avatar_lookup hook");
|
||||
DI::logger()->notice("registered libravatar in avatar_lookup hook");
|
||||
}
|
||||
|
||||
function libravatar_load_config(ConfigFileManager $loader)
|
||||
{
|
||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('libravatar'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('libravatar'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +70,9 @@ function libravatar_addon_admin(string &$o)
|
|||
'pagan' => DI::l10n()->t('retro adventure game character'),
|
||||
];
|
||||
|
||||
if (Addon::isEnabled('gravatar')) {
|
||||
$addonHelper = DI::addonHelper();
|
||||
|
||||
if ($addonHelper->isAddonEnabled('gravatar')) {
|
||||
$o = '<h5>' .DI::l10n()->t('Information') .'</h5><p>' .DI::l10n()->t('Gravatar addon is installed. Please disable the Gravatar addon.<br>The Libravatar addon will fall back to Gravatar if nothing was found at Libravatar.') .'</p><br><br>';
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,8 @@
|
|||
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -201,12 +199,14 @@ function ljpost_send(array &$b)
|
|||
</methodCall>
|
||||
EOT;
|
||||
|
||||
Logger::debug('ljpost: data: ' . $xml);
|
||||
DI::logger()->debug('ljpost: data: ' . $xml);
|
||||
|
||||
$x = '';
|
||||
|
||||
if ($lj_blog !== 'test') {
|
||||
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
|
||||
}
|
||||
|
||||
Logger::info('posted to livejournal: ' . ($x) ? $x : '');
|
||||
DI::logger()->info('posted to livejournal: ' . $x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -32,7 +31,7 @@ function mailstream_install()
|
|||
Hook::register('post_remote_end', 'addon/mailstream/mailstream.php', 'mailstream_post_hook');
|
||||
Hook::register('mailstream_send_hook', 'addon/mailstream/mailstream.php', 'mailstream_send_hook');
|
||||
|
||||
Logger::info("installed mailstream");
|
||||
DI::logger()->info("installed mailstream");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,7 +85,7 @@ function mailstream_generate_id(string $uri): string
|
|||
$host = DI::baseUrl()->getHost();
|
||||
$resource = hash('md5', $uri);
|
||||
$message_id = "<" . $resource . "@" . $host . ">";
|
||||
Logger::debug('generated message ID', ['id' => $message_id, 'uri' => $uri]);
|
||||
DI::logger()->debug('generated message ID', ['id' => $message_id, 'uri' => $uri]);
|
||||
return $message_id;
|
||||
}
|
||||
|
||||
|
@ -95,20 +94,20 @@ function mailstream_send_hook(array $data)
|
|||
$criteria = array('uid' => $data['uid'], 'contact-id' => $data['contact-id'], 'uri' => $data['uri']);
|
||||
$item = Post::selectFirst([], $criteria);
|
||||
if (empty($item)) {
|
||||
Logger::error('could not find item');
|
||||
DI::logger()->error('could not find item');
|
||||
return;
|
||||
}
|
||||
|
||||
$user = User::getById($item['uid']);
|
||||
if (empty($user)) {
|
||||
Logger::error('could not find user', ['uid' => $item['uid']]);
|
||||
DI::logger()->error('could not find user', ['uid' => $item['uid']]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mailstream_send($data['message_id'], $item, $user)) {
|
||||
Logger::debug('send failed, will retry', $data);
|
||||
DI::logger()->debug('send failed, will retry', $data);
|
||||
if (!Worker::defer()) {
|
||||
Logger::error('failed and could not defer', $data);
|
||||
DI::logger()->error('failed and could not defer', $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,32 +123,32 @@ function mailstream_send_hook(array $data)
|
|||
function mailstream_post_hook(array &$item)
|
||||
{
|
||||
if ($item['uid'] === 0) {
|
||||
Logger::debug('mailstream: root user, skipping item ' . $item['id']);
|
||||
DI::logger()->debug('mailstream: root user, skipping item ' . $item['id']);
|
||||
return;
|
||||
}
|
||||
if (!DI::pConfig()->get($item['uid'], 'mailstream', 'enabled')) {
|
||||
Logger::debug('mailstream: not enabled.', ['item' => $item['id'], ' uid ' => $item['uid']]);
|
||||
DI::logger()->debug('mailstream: not enabled.', ['item' => $item['id'], ' uid ' => $item['uid']]);
|
||||
return;
|
||||
}
|
||||
if (!$item['contact-id']) {
|
||||
Logger::debug('no contact-id', ['item' => $item['id']]);
|
||||
DI::logger()->debug('no contact-id', ['item' => $item['id']]);
|
||||
return;
|
||||
}
|
||||
if (!$item['uri']) {
|
||||
Logger::debug('no uri', ['item' => $item['id']]);
|
||||
DI::logger()->debug('no uri', ['item' => $item['id']]);
|
||||
return;
|
||||
}
|
||||
if ($item['verb'] == Activity::ANNOUNCE) {
|
||||
Logger::debug('ignoring announce', ['item' => $item['id']]);
|
||||
DI::logger()->debug('ignoring announce', ['item' => $item['id']]);
|
||||
return;
|
||||
}
|
||||
if (DI::pConfig()->get($item['uid'], 'mailstream', 'nolikes')) {
|
||||
if ($item['verb'] == Activity::LIKE) {
|
||||
Logger::debug('ignoring like', ['item' => $item['id']]);
|
||||
DI::logger()->debug('ignoring like', ['item' => $item['id']]);
|
||||
return;
|
||||
}
|
||||
if ($item['verb'] == Activity::DISLIKE) {
|
||||
Logger::debug('ignoring dislike', ['item' => $item['id']]);
|
||||
DI::logger()->debug('ignoring dislike', ['item' => $item['id']]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +179,7 @@ function mailstream_post_hook(array &$item)
|
|||
function mailstream_do_images(array &$item, array &$attachments)
|
||||
{
|
||||
if (!DI::pConfig()->get($item['uid'], 'mailstream', 'attachimg')) {
|
||||
return;
|
||||
return $attachments;
|
||||
}
|
||||
|
||||
$attachments = [];
|
||||
|
@ -200,7 +199,7 @@ function mailstream_do_images(array &$item, array &$attachments)
|
|||
try {
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::DEFAULT, [HttpClientOptions::COOKIEJAR => $cookiejar]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
Logger::debug('mailstream: fetch image url failed', [
|
||||
DI::logger()->debug('mailstream: fetch image url failed', [
|
||||
'url' => $url,
|
||||
'item_id' => $item['id'],
|
||||
'return_code' => $curlResult->getReturnCode()
|
||||
|
@ -208,7 +207,7 @@ function mailstream_do_images(array &$item, array &$attachments)
|
|||
continue;
|
||||
}
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Logger::error('exception fetching url', ['url' => $url, 'item_id' => $item['id']]);
|
||||
DI::logger()->error('exception fetching url', ['url' => $url, 'item_id' => $item['id']]);
|
||||
continue;
|
||||
}
|
||||
$attachments[$url] = [
|
||||
|
@ -309,7 +308,7 @@ function mailstream_subject(array $item): string
|
|||
}
|
||||
$contact = Contact::selectFirst([], ['id' => $item['contact-id'], 'uid' => $item['uid']]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
Logger::error('no contact', [
|
||||
DI::logger()->error('no contact', [
|
||||
'item' => $item['id'],
|
||||
'plink' => $item['plink'],
|
||||
'contact id' => $item['contact-id'],
|
||||
|
@ -351,16 +350,16 @@ function mailstream_subject(array $item): string
|
|||
function mailstream_send(string $message_id, array $item, array $user): bool
|
||||
{
|
||||
if (!is_array($item)) {
|
||||
Logger::error('item is empty', ['message_id' => $message_id]);
|
||||
DI::logger()->error('item is empty', ['message_id' => $message_id]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$item['visible']) {
|
||||
Logger::debug('item not yet visible', ['item uri' => $item['uri']]);
|
||||
DI::logger()->debug('item not yet visible', ['item uri' => $item['uri']]);
|
||||
return false;
|
||||
}
|
||||
if (!$message_id) {
|
||||
Logger::error('no message ID supplied', ['item uri' => $item['uri'], 'user email' => $user['email']]);
|
||||
DI::logger()->error('no message ID supplied', ['item uri' => $item['uri'], 'user email' => $user['email']]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -378,7 +377,7 @@ function mailstream_send(string $message_id, array $item, array $user): bool
|
|||
if (!$address) {
|
||||
$address = $user['email'];
|
||||
}
|
||||
$mail = new PHPmailer();
|
||||
$mail = new PHPMailer();
|
||||
try {
|
||||
$mail->XMailer = 'Friendica Mailstream Addon';
|
||||
$mail->SetFrom($frommail, mailstream_sender($item));
|
||||
|
@ -418,15 +417,15 @@ function mailstream_send(string $message_id, array $item, array $user): bool
|
|||
if (!$mail->Send()) {
|
||||
throw new Exception($mail->ErrorInfo);
|
||||
}
|
||||
Logger::debug('sent message', [
|
||||
DI::logger()->debug('sent message', [
|
||||
'message ID' => $mail->MessageID,
|
||||
'subject' => $mail->Subject,
|
||||
'address' => $address
|
||||
]);
|
||||
} catch (phpmailerException $e) {
|
||||
Logger::debug('PHPMailer exception sending message', ['id' => $message_id, 'error' => $e->errorMessage()]);
|
||||
DI::logger()->debug('PHPMailer exception sending message', ['id' => $message_id, 'error' => $e->errorMessage()]);
|
||||
} catch (Exception $e) {
|
||||
Logger::debug('exception sending message', ['id' => $message_id, 'error' => $e->getMessage()]);
|
||||
DI::logger()->debug('exception sending message', ['id' => $message_id, 'error' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -2690,10 +2690,10 @@ class PHPMailer
|
|||
if (!is_readable($path)) {
|
||||
throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
|
||||
}
|
||||
$magic_quotes = get_magic_quotes_runtime();
|
||||
$magic_quotes = false;
|
||||
if ($magic_quotes) {
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
|
||||
set_magic_quotes_runtime(false);
|
||||
//set_magic_quotes_runtime(false);
|
||||
} else {
|
||||
//Doesn't exist in PHP 5.4, but we don't need to check because
|
||||
//get_magic_quotes_runtime always returns false in 5.4+
|
||||
|
@ -2705,7 +2705,7 @@ class PHPMailer
|
|||
$file_buffer = $this->encodeString($file_buffer, $encoding);
|
||||
if ($magic_quotes) {
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
|
||||
set_magic_quotes_runtime($magic_quotes);
|
||||
//set_magic_quotes_runtime($magic_quotes);
|
||||
} else {
|
||||
ini_set('magic_quotes_runtime', $magic_quotes);
|
||||
}
|
||||
|
@ -3286,7 +3286,7 @@ class PHPMailer
|
|||
$result = 'localhost.localdomain';
|
||||
if (!empty($this->Hostname)) {
|
||||
$result = $this->Hostname;
|
||||
} elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
|
||||
} elseif (!empty($_SERVER['SERVER_NAME'])) {
|
||||
$result = $_SERVER['SERVER_NAME'];
|
||||
} elseif (function_exists('gethostname') && gethostname() !== false) {
|
||||
$result = gethostname();
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* Version: 0.1
|
||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Content\Text\Markdown;
|
||||
use Friendica\Core\Renderer;
|
||||
|
@ -27,7 +26,7 @@ function markdown_addon_settings(array &$data)
|
|||
|
||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/');
|
||||
$html = Renderer::replaceMacros($t, [
|
||||
'$enabled' => ['enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
|
||||
'$enabled' => ['markdown-enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
|
||||
]);
|
||||
|
||||
$data = [
|
||||
|
@ -43,7 +42,7 @@ function markdown_addon_settings_post(array &$b)
|
|||
return;
|
||||
}
|
||||
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['enabled']));
|
||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['markdown-enabled']));
|
||||
}
|
||||
|
||||
function markdown_post_local_start(&$request) {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
* License: 3-clause BSD license
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
* Status: Unsupported
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
function membersince_install()
|
||||
|
@ -17,9 +17,25 @@ function membersince_install()
|
|||
Hook::register('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
|
||||
}
|
||||
|
||||
function membersince_display(array &$b)
|
||||
/**
|
||||
* @param array|string|null $b
|
||||
* @return void
|
||||
*/
|
||||
function membersince_display(&$b)
|
||||
{
|
||||
if (DI::app()->getCurrentTheme() == 'frio') {
|
||||
$uid = DI::userSession()->getLocalUserId();
|
||||
|
||||
if ($uid === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$user = User::getById($uid, ['register_date']);
|
||||
|
||||
if ($user === false || !array_key_exists('register_date', $user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DI::appHelper()->getCurrentTheme() == 'frio') {
|
||||
// Works in Frio.
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadHTML(mb_convert_encoding($b, 'HTML-ENTITIES', 'UTF-8'));
|
||||
|
@ -39,7 +55,7 @@ function membersince_display(array &$b)
|
|||
$label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted');
|
||||
|
||||
// The div for the register date of the profile owner.
|
||||
$entry = $doc->createElement('div', DateTimeFormat::local(DI::app()->profile['register_date']));
|
||||
$entry = $doc->createElement('div', DateTimeFormat::local($user['register_date']));
|
||||
$entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry');
|
||||
|
||||
$div->appendChild($hr);
|
||||
|
@ -47,9 +63,9 @@ function membersince_display(array &$b)
|
|||
$div->appendChild($entry);
|
||||
$elm->parentNode->insertBefore($div, $elm->nextSibling);
|
||||
|
||||
$b = $doc->saveHTML();
|
||||
$b = (string) $doc->saveHTML();
|
||||
} else {
|
||||
// Works in Vier.
|
||||
$b = preg_replace('/<\/dl>/', "</dl>\n\n\n<dl id=\"aprofile-membersince\" class=\"aprofile\">\n<dt>" . DI::l10n()->t('Member since:') . "</dt>\n<dd>" . DateTimeFormat::local(DI::app()->profile['register_date']) . "</dd>\n</dl>", $b, 1);
|
||||
$b = preg_replace('/<\/dl>/', "</dl>\n\n\n<dl id=\"aprofile-membersince\" class=\"aprofile\">\n<dt>" . DI::l10n()->t('Member since:') . "</dt>\n<dd>" . DateTimeFormat::local($user['register_date']) . "</dd>\n</dl>", $b, 1);
|
||||
}
|
||||
}
|
||||
|
|
4
monolog/README.md
Normal file
4
monolog/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Monolog Addon
|
||||
|
||||
A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)).
|
||||
There are just Friendica additions inside the src directory.
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Name: Monolog
|
||||
* Description: A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)). There are just Friendica additions inside the src directory
|
||||
* Version: 1.0
|
||||
* Description: A Logging framework with lots of additions, customized for Friendica.
|
||||
* Version: 1.1
|
||||
* Author: Philipp Holzer
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,8 @@ namespace Friendica\Addon\monolog\src\Factory;
|
|||
|
||||
use Friendica\Addon\monolog\src\Monolog\IntrospectionProcessor;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Logger\Factory\AbstractLoggerTypeFactory;
|
||||
use Friendica\Core\Logger\Capability\IHaveCallIntrospections;
|
||||
use Friendica\Core\Logger\Factory\LoggerFactory;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
|
@ -16,32 +17,49 @@ use Psr\Log\LogLevel;
|
|||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
class Monolog extends AbstractLoggerTypeFactory
|
||||
final class MonologFactory implements LoggerFactory
|
||||
{
|
||||
public function create(IManageConfigValues $config, string $loglevel = null): LoggerInterface
|
||||
private IHaveCallIntrospections $introspection;
|
||||
|
||||
private IManageConfigValues $config;
|
||||
|
||||
public function __construct(IHaveCallIntrospections $introspection, IManageConfigValues $config)
|
||||
{
|
||||
$this->introspection = $introspection;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a PSR-3 Logger instance.
|
||||
*
|
||||
* Calling this method multiple times with the same parameters SHOULD return the same object.
|
||||
*
|
||||
* @param \Psr\Log\LogLevel::* $logLevel The log level
|
||||
* @param \Friendica\Core\Logger\Capability\LogChannel::* $logChannel The log channel
|
||||
*/
|
||||
public function createLogger(string $logLevel, string $logChannel): LoggerInterface
|
||||
{
|
||||
$loggerTimeZone = new \DateTimeZone('UTC');
|
||||
|
||||
$logger = new Logger($this->channel);
|
||||
$logger = new Logger($logChannel);
|
||||
$logger->setTimezone($loggerTimeZone);
|
||||
$logger->pushProcessor(new PsrLogMessageProcessor());
|
||||
$logger->pushProcessor(new ProcessIdProcessor());
|
||||
$logger->pushProcessor(new UidProcessor());
|
||||
$logger->pushProcessor(new IntrospectionProcessor($this->introspection, LogLevel::DEBUG));
|
||||
|
||||
$logfile = $config->get('system', 'logfile');
|
||||
$logfile = $this->config->get('system', 'logfile');
|
||||
|
||||
// just add a stream in case it's either writable or not file
|
||||
if (is_writable($logfile)) {
|
||||
$loglevel = $loglevel ?? static::mapLegacyConfigDebugLevel($config->get('system', 'loglevel'));
|
||||
$loglevel = Logger::toMonologLevel($loglevel);
|
||||
$logLevel = Logger::toMonologLevel($logLevel);
|
||||
|
||||
// fallback to notice if an invalid loglevel is set
|
||||
if (!is_int($loglevel)) {
|
||||
$loglevel = LogLevel::NOTICE;
|
||||
if (!is_int($logLevel)) {
|
||||
$logLevel = LogLevel::NOTICE;
|
||||
}
|
||||
|
||||
$fileHandler = new StreamHandler($logfile, $loglevel);
|
||||
$fileHandler = new StreamHandler($logfile, $logLevel);
|
||||
|
||||
$formatter = new LineFormatter("%datetime% %channel% [%level_name%]: %message% %context% %extra%\n");
|
||||
$fileHandler->setFormatter($formatter);
|
|
@ -20,10 +20,8 @@
|
|||
*/
|
||||
|
||||
return [
|
||||
\Monolog\Logger::class => [
|
||||
'instanceOf' => \Friendica\Addon\monolog\src\Factory\Monolog::class,
|
||||
'call' => [
|
||||
['create', [], \Dice\Dice::CHAIN_CALL],
|
||||
],
|
||||
\Friendica\Core\Logger\Factory\LoggerFactory::class => [
|
||||
'instanceOf' => \Friendica\Addon\monolog\src\Factory\MonologFactory::class,
|
||||
'call' => null,
|
||||
],
|
||||
];
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2023, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
return [
|
||||
\Psr\Log\LoggerInterface::class => [
|
||||
\Monolog\Logger::class => ['monolog'],
|
||||
],
|
||||
];
|
|
@ -8,7 +8,6 @@
|
|||
* Status: Deprecated
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
* Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
|
||||
***/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\User;
|
||||
|
@ -17,7 +15,7 @@ use Friendica\Model\User;
|
|||
function newmemberwidget_install()
|
||||
{
|
||||
Hook::register( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
|
||||
Logger::notice('newmemberwidget installed');
|
||||
DI::logger()->notice('newmemberwidget installed');
|
||||
}
|
||||
|
||||
function newmemberwidget_network_mod_init ($b)
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
||||
|
@ -46,19 +44,19 @@ function nominatim_resolve_item(array &$item)
|
|||
|
||||
$s = DI::httpClient()->fetch('https://nominatim.openstreetmap.org/reverse?lat=' . $coords[0] . '&lon=' . $coords[1] . '&format=json&addressdetails=0&accept-language=' . $language);
|
||||
if (empty($s)) {
|
||||
Logger::info('API could not be queried');
|
||||
DI::logger()->info('API could not be queried');
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_decode($s, true);
|
||||
if (empty($data['display_name'])) {
|
||||
Logger::info('No results found for coordinates', ['coordinates' => $item['coord'], 'data' => $data]);
|
||||
DI::logger()->info('No results found for coordinates', ['coordinates' => $item['coord'], 'data' => $data]);
|
||||
return;
|
||||
}
|
||||
|
||||
$item['location'] = $data['display_name'];
|
||||
|
||||
Logger::info('Got location', ['lat' => $coords[0], 'long' => $coords[1], 'location' => $item['location']]);
|
||||
DI::logger()->info('Got location', ['lat' => $coords[0], 'long' => $coords[1], 'location' => $item['location']]);
|
||||
|
||||
if (!empty($item['location'])) {
|
||||
DI::cache()->set('nominatim:' . $language . ':' . $coords[0] . '-' . $coords[1], $item['location']);
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
*/
|
||||
|
||||
use Friendica\Addon\notifyall\NotifyAllEmail;
|
||||
use Friendica\App;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
||||
|
@ -59,7 +57,7 @@ function notifyall_post()
|
|||
|
||||
$notifyEmail = new NotifyAllEmail(DI::l10n(), DI::config(), DI::baseUrl(), $text);
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
foreach (DBA::toArray($recipients) as $recipient) {
|
||||
DI::emailer()->send($notifyEmail->withRecipient($recipient['email']));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
@ -105,12 +104,13 @@ function nsfw_addon_settings_post(array &$b)
|
|||
function nsfw_prepare_body_content_filter(&$hook_data)
|
||||
{
|
||||
$words = null;
|
||||
if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'nsfw', 'disable')) {
|
||||
$uid = $hook_data['uid'] ?? DI::userSession()->getLocalUserId();
|
||||
if (DI::pConfig()->get($uid, 'nsfw', 'disable')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
$words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'nsfw', 'words');
|
||||
if ($uid) {
|
||||
$words = DI::pConfig()->get($uid, 'nsfw', 'words');
|
||||
}
|
||||
|
||||
if ($words) {
|
||||
|
@ -120,6 +120,8 @@ function nsfw_prepare_body_content_filter(&$hook_data)
|
|||
}
|
||||
|
||||
$found = false;
|
||||
$tag_search = false;
|
||||
|
||||
if (count($word_list)) {
|
||||
$body = $hook_data['item']['title'] . "\n" . nsfw_extract_photos($hook_data['item']['body']);
|
||||
|
||||
|
@ -129,17 +131,16 @@ function nsfw_prepare_body_content_filter(&$hook_data)
|
|||
continue;
|
||||
}
|
||||
|
||||
$tag_search = false;
|
||||
switch ($word[0]) {
|
||||
case '/'; // Regular expression
|
||||
$found = @preg_match($word, $body);
|
||||
break;
|
||||
case '#': // Hashtag-only search
|
||||
$tag_search = true;
|
||||
$found = nsfw_find_word_in_item_tags($hook_data['item']['hashtags'], substr($word, 1));
|
||||
$found = nsfw_find_word_in_item_tags($hook_data['item']['hashtags'] ?? [], substr($word, 1));
|
||||
break;
|
||||
default:
|
||||
$found = strpos($body, $word) !== false || nsfw_find_word_in_item_tags($hook_data['item']['tags'], $word);
|
||||
$found = strpos($body, $word) !== false || nsfw_find_word_in_item_tags($hook_data['item']['tags'] ?? [], $word);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
||||
|
@ -17,7 +15,7 @@ function numfriends_install() {
|
|||
Hook::register('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
|
||||
Hook::register('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
|
||||
|
||||
Logger::notice("installed numfriends");
|
||||
DI::logger()->notice("installed numfriends");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Cache\Enum\Duration;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
|
@ -32,12 +30,12 @@ function openstreetmap_install()
|
|||
Hook::register('Map::getCoordinates', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_get_coordinates');
|
||||
Hook::register('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader');
|
||||
|
||||
Logger::notice("installed openstreetmap");
|
||||
DI::logger()->notice("installed openstreetmap");
|
||||
}
|
||||
|
||||
function openstreetmap_load_config(ConfigFileManager $loader)
|
||||
{
|
||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('openstreetmap'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('openstreetmap'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
}
|
||||
|
||||
function openstreetmap_alterheader(&$navHtml)
|
||||
|
@ -155,8 +153,8 @@ function openstreetmap_generate_map(array &$b)
|
|||
$lat = $b['lat']; // round($b['lat'], 5);
|
||||
$lon = $b['lon']; // round($b['lon'], 5);
|
||||
|
||||
Logger::debug('lat: ' . $lat);
|
||||
Logger::debug('lon: ' . $lon);
|
||||
DI::logger()->debug('lat: ' . $lat);
|
||||
DI::logger()->debug('lon: ' . $lon);
|
||||
|
||||
$cardlink = '<a href="' . $tmsserver;
|
||||
|
||||
|
@ -174,7 +172,7 @@ function openstreetmap_generate_map(array &$b)
|
|||
$b['html'] .= '<br/>' . $cardlink;
|
||||
}
|
||||
|
||||
Logger::debug('generate_map: ' . $b['html']);
|
||||
DI::logger()->debug('generate_map: ' . $b['html']);
|
||||
}
|
||||
|
||||
function openstreetmap_addon_admin(string &$o)
|
||||
|
|
|
@ -8,12 +8,7 @@
|
|||
*/
|
||||
|
||||
use Friendica\DI;
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\User;
|
||||
|
@ -22,7 +17,7 @@ function opmlexport_install()
|
|||
{
|
||||
Hook::register('addon_settings', __FILE__, 'opmlexport_addon_settings');
|
||||
Hook::register('addon_settings_post', __FILE__, 'opmlexport_addon_settings_post');
|
||||
Logger::notice('installed opmlexport Addon');
|
||||
DI::logger()->notice('installed opmlexport Addon');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
|
20
phpmailer/composer.lock
generated
20
phpmailer/composer.lock
generated
|
@ -8,16 +8,16 @@
|
|||
"packages": [
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
"version": "v6.9.1",
|
||||
"version": "v6.10.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||
"reference": "039de174cd9c17a8389754d3b877a2ed22743e18"
|
||||
"reference": "bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/039de174cd9c17a8389754d3b877a2ed22743e18",
|
||||
"reference": "039de174cd9c17a8389754d3b877a2ed22743e18",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144",
|
||||
"reference": "bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -75,24 +75,28 @@
|
|||
}
|
||||
],
|
||||
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
|
||||
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.10.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/Synchro",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-11-25T22:23:28+00:00"
|
||||
"time": "2025-04-24T15:19:31+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"stability-flags": {},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": ">=7.0"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "1.1.0"
|
||||
"platform-dev": {},
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* Maintainer: Hypolite Petovan <hypolite@friendica.mrpetovan.com>
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
use Friendica\Object\EMail\IEmail;
|
||||
|
@ -25,14 +24,18 @@ function phpmailer_install()
|
|||
|
||||
function phpmailer_load_config(ConfigFileManager $loader)
|
||||
{
|
||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('phpmailer'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('phpmailer'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IEmail $email
|
||||
* @param null|IEmail $email
|
||||
*/
|
||||
function phpmailer_emailer_send_prepare(IEmail &$email)
|
||||
function phpmailer_emailer_send_prepare(?IEmail &$email)
|
||||
{
|
||||
if ($email === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Passing `true` enables exceptions
|
||||
$mailer = new PHPMailer(true);
|
||||
try {
|
||||
|
|
18
phpmailer/vendor/autoload.php
vendored
18
phpmailer/vendor/autoload.php
vendored
|
@ -2,6 +2,24 @@
|
|||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, $err);
|
||||
} elseif (!headers_sent()) {
|
||||
echo $err;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
$err,
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitPhpMailerAddon::getLoader();
|
||||
|
|
176
phpmailer/vendor/composer/ClassLoader.php
vendored
176
phpmailer/vendor/composer/ClassLoader.php
vendored
|
@ -37,26 +37,81 @@ namespace Composer\Autoload;
|
|||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see http://www.php-fig.org/psr/psr-0/
|
||||
* @see http://www.php-fig.org/psr/psr-4/
|
||||
* @see https://www.php-fig.org/psr/psr-0/
|
||||
* @see https://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/** @var \Closure(string):void */
|
||||
private static $includeFile;
|
||||
|
||||
/** @var string|null */
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
/**
|
||||
* @var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array<string, list<string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* List of PSR-0 prefixes
|
||||
*
|
||||
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
||||
*
|
||||
* @var array<string, array<string, list<string>>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
/** @var bool */
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
/** @var bool */
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var string|null */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var array<string, self>
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param string|null $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
self::initializeIncludeClosure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
|
@ -66,28 +121,42 @@ class ClassLoader
|
|||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> Array of classname => path
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
* @param array<string, string> $classMap Class to filename map
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
|
@ -103,21 +172,24 @@ class ClassLoader
|
|||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 root directories
|
||||
* @param list<string>|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
$paths = (array) $paths;
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
$paths
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -126,19 +198,19 @@ class ClassLoader
|
|||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
$this->prefixesPsr0[$first][$prefix] = $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
$paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -148,24 +220,27 @@ class ClassLoader
|
|||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param list<string>|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
$paths = (array) $paths;
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
$paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
|
@ -175,18 +250,18 @@ class ClassLoader
|
|||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
$this->prefixDirsPsr4[$prefix] = $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
$paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +271,9 @@ class ClassLoader
|
|||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
* @param list<string>|string $paths The PSR-0 base directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
|
@ -212,9 +289,11 @@ class ClassLoader
|
|||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param list<string>|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
|
@ -234,6 +313,8 @@ class ClassLoader
|
|||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
|
@ -256,6 +337,8 @@ class ClassLoader
|
|||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
|
@ -276,6 +359,8 @@ class ClassLoader
|
|||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
|
@ -296,33 +381,55 @@ class ClassLoader
|
|||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
|
||||
if (null === $this->vendorDir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($prepend) {
|
||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||
} else {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
|
||||
if (null !== $this->vendorDir) {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
* @return true|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
$includeFile = self::$includeFile;
|
||||
$includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -367,6 +474,21 @@ class ClassLoader
|
|||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
||||
*
|
||||
* @return array<string, self>
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
return self::$registeredLoaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $ext
|
||||
* @return string|false
|
||||
*/
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
|
@ -432,14 +554,26 @@ class ClassLoader
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private static function initializeIncludeClosure()
|
||||
{
|
||||
if (self::$includeFile !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
self::$includeFile = \Closure::bind(static function($file) {
|
||||
include $file;
|
||||
}, null, null);
|
||||
}
|
||||
}
|
||||
|
|
359
phpmailer/vendor/composer/InstalledVersions.php
vendored
Normal file
359
phpmailer/vendor/composer/InstalledVersions.php
vendored
Normal file
|
@ -0,0 +1,359 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Composer\Semver\VersionParser;
|
||||
|
||||
/**
|
||||
* This class is copied in every Composer installed project and available to all
|
||||
*
|
||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||
*
|
||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class InstalledVersions
|
||||
{
|
||||
/**
|
||||
* @var mixed[]|null
|
||||
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
||||
*/
|
||||
private static $installed;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
private static $canGetVendors;
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
private static $installedByVendor = array();
|
||||
|
||||
/**
|
||||
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackages()
|
||||
{
|
||||
$packages = array();
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
$packages[] = array_keys($installed['versions']);
|
||||
}
|
||||
|
||||
if (1 === \count($packages)) {
|
||||
return $packages[0];
|
||||
}
|
||||
|
||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all package names with a specific type e.g. 'library'
|
||||
*
|
||||
* @param string $type
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackagesByType($type)
|
||||
{
|
||||
$packagesByType = array();
|
||||
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
foreach ($installed['versions'] as $name => $package) {
|
||||
if (isset($package['type']) && $package['type'] === $type) {
|
||||
$packagesByType[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $packagesByType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package is installed
|
||||
*
|
||||
* This also returns true if the package name is provided or replaced by another package
|
||||
*
|
||||
* @param string $packageName
|
||||
* @param bool $includeDevRequirements
|
||||
* @return bool
|
||||
*/
|
||||
public static function isInstalled($packageName, $includeDevRequirements = true)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package satisfies a version constraint
|
||||
*
|
||||
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
||||
*
|
||||
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
||||
*
|
||||
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
||||
* @param string $packageName
|
||||
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
||||
* @return bool
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints((string) $constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a version constraint representing all the range(s) which are installed for a given package
|
||||
*
|
||||
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
||||
* whether a given version of a package is installed, and not just whether it exists
|
||||
*
|
||||
* @param string $packageName
|
||||
* @return string Version constraint usable with composer/semver
|
||||
*/
|
||||
public static function getVersionRanges($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ranges = array();
|
||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||
}
|
||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||
}
|
||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||
}
|
||||
|
||||
return implode(' || ', $ranges);
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getPrettyVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
||||
*/
|
||||
public static function getReference($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['reference'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
||||
*/
|
||||
public static function getInstallPath($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
||||
*/
|
||||
public static function getRootPackage()
|
||||
{
|
||||
$installed = self::getInstalled();
|
||||
|
||||
return $installed[0]['root'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw installed.php data for custom implementations
|
||||
*
|
||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||
* @return array[]
|
||||
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
||||
*/
|
||||
public static function getRawData()
|
||||
{
|
||||
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = include __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
return self::$installed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||
*
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
public static function getAllRawData()
|
||||
{
|
||||
return self::getInstalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets you reload the static array from another file
|
||||
*
|
||||
* This is only useful for complex integrations in which a project needs to use
|
||||
* this class but then also needs to execute another project's autoloader in process,
|
||||
* and wants to ensure both projects have access to their version of installed.php.
|
||||
*
|
||||
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
||||
* the data it needs from this class, then call reload() with
|
||||
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
||||
* the project in which it runs can then also use this class safely, without
|
||||
* interference between PHPUnit's dependencies and the project's dependencies.
|
||||
*
|
||||
* @param array[] $data A vendor/composer/installed.php data set
|
||||
* @return void
|
||||
*
|
||||
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
||||
*/
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
private static function getInstalled()
|
||||
{
|
||||
if (null === self::$canGetVendors) {
|
||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||
}
|
||||
|
||||
$installed = array();
|
||||
|
||||
if (self::$canGetVendors) {
|
||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require $vendorDir.'/composer/installed.php';
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require __DIR__ . '/installed.php';
|
||||
self::$installed = $required;
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$installed !== array()) {
|
||||
$installed[] = self::$installed;
|
||||
}
|
||||
|
||||
return $installed;
|
||||
}
|
||||
}
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
'PHPMailer\\PHPMailer\\DSNConfigurator' => $vendorDir . '/phpmailer/phpmailer/src/DSNConfigurator.php',
|
||||
'PHPMailer\\PHPMailer\\Exception' => $vendorDir . '/phpmailer/phpmailer/src/Exception.php',
|
||||
'PHPMailer\\PHPMailer\\OAuth' => $vendorDir . '/phpmailer/phpmailer/src/OAuth.php',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
|
|
2
phpmailer/vendor/composer/autoload_psr4.php
vendored
2
phpmailer/vendor/composer/autoload_psr4.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
|
|
25
phpmailer/vendor/composer/autoload_real.php
vendored
25
phpmailer/vendor/composer/autoload_real.php
vendored
|
@ -22,31 +22,14 @@ class ComposerAutoloaderInitPhpMailerAddon
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
require __DIR__ . '/platform_check.php';
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitPhpMailerAddon', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitPhpMailerAddon', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require_once __DIR__ . '/autoload_static.php';
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitPhpMailerAddon::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ class ComposerStaticInitPhpMailerAddon
|
|||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
'PHPMailer\\PHPMailer\\DSNConfigurator' => __DIR__ . '/..' . '/phpmailer/phpmailer/src/DSNConfigurator.php',
|
||||
'PHPMailer\\PHPMailer\\Exception' => __DIR__ . '/..' . '/phpmailer/phpmailer/src/Exception.php',
|
||||
'PHPMailer\\PHPMailer\\OAuth' => __DIR__ . '/..' . '/phpmailer/phpmailer/src/OAuth.php',
|
||||
|
|
27
phpmailer/vendor/composer/installed.json
vendored
27
phpmailer/vendor/composer/installed.json
vendored
|
@ -1,17 +1,18 @@
|
|||
[
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "phpmailer/phpmailer",
|
||||
"version": "v6.9.1",
|
||||
"version_normalized": "6.9.1.0",
|
||||
"version": "v6.10.0",
|
||||
"version_normalized": "6.10.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPMailer/PHPMailer.git",
|
||||
"reference": "039de174cd9c17a8389754d3b877a2ed22743e18"
|
||||
"reference": "bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/039de174cd9c17a8389754d3b877a2ed22743e18",
|
||||
"reference": "039de174cd9c17a8389754d3b877a2ed22743e18",
|
||||
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144",
|
||||
"reference": "bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -41,7 +42,7 @@
|
|||
"symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)",
|
||||
"thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication"
|
||||
},
|
||||
"time": "2023-11-25T22:23:28+00:00",
|
||||
"time": "2025-04-24T15:19:31+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
@ -71,11 +72,19 @@
|
|||
}
|
||||
],
|
||||
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
|
||||
"support": {
|
||||
"issues": "https://github.com/PHPMailer/PHPMailer/issues",
|
||||
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.10.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/Synchro",
|
||||
"type": "github"
|
||||
}
|
||||
]
|
||||
],
|
||||
"install-path": "../phpmailer/phpmailer"
|
||||
}
|
||||
],
|
||||
"dev": true,
|
||||
"dev-package-names": []
|
||||
}
|
||||
]
|
||||
|
|
32
phpmailer/vendor/composer/installed.php
vendored
Normal file
32
phpmailer/vendor/composer/installed.php
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php return array(
|
||||
'root' => array(
|
||||
'name' => 'friendica-addons/phpmailer',
|
||||
'pretty_version' => 'dev-2025.07-rc',
|
||||
'version' => 'dev-2025.07-rc',
|
||||
'reference' => '715f70032330ad14f710284104c8593c7800e125',
|
||||
'type' => 'friendica-addon',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'dev' => true,
|
||||
),
|
||||
'versions' => array(
|
||||
'friendica-addons/phpmailer' => array(
|
||||
'pretty_version' => 'dev-2025.07-rc',
|
||||
'version' => 'dev-2025.07-rc',
|
||||
'reference' => '715f70032330ad14f710284104c8593c7800e125',
|
||||
'type' => 'friendica-addon',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'phpmailer/phpmailer' => array(
|
||||
'pretty_version' => 'v6.10.0',
|
||||
'version' => '6.10.0.0',
|
||||
'reference' => 'bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpmailer/phpmailer',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
),
|
||||
);
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue