forked from friendica/friendica-addons
Compare commits
154 commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
|
5f557ed0ab | ||
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 |
117 changed files with 1008 additions and 979 deletions
|
@ -1,6 +1,6 @@
|
||||||
skip_clone: true
|
skip_clone: true
|
||||||
|
|
||||||
pipeline:
|
steps:
|
||||||
clone_friendica_base:
|
clone_friendica_base:
|
||||||
image: alpine/git
|
image: alpine/git
|
||||||
commands:
|
commands:
|
||||||
|
@ -56,6 +56,10 @@ pipeline:
|
||||||
- /tmp/drone-cache:/tmp/cache
|
- /tmp/drone-cache:/tmp/cache
|
||||||
when:
|
when:
|
||||||
event: pull_request
|
event: pull_request
|
||||||
|
phpstan:
|
||||||
|
image: friendicaci/php8.3:php8.3.3
|
||||||
|
commands:
|
||||||
|
- ./bin/composer.phar run phpstan;
|
||||||
check:
|
check:
|
||||||
image: friendicaci/php-cs
|
image: friendicaci/php-cs
|
||||||
commands:
|
commands:
|
||||||
|
|
|
@ -5,7 +5,7 @@ labels:
|
||||||
|
|
||||||
skip_clone: true
|
skip_clone: true
|
||||||
|
|
||||||
pipeline:
|
steps:
|
||||||
clone_friendica_base:
|
clone_friendica_base:
|
||||||
image: alpine/git
|
image: alpine/git
|
||||||
commands:
|
commands:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
skip_clone: true
|
skip_clone: true
|
||||||
|
|
||||||
pipeline:
|
steps:
|
||||||
clone_friendica_base:
|
clone_friendica_base:
|
||||||
image: alpine/git
|
image: alpine/git
|
||||||
commands:
|
commands:
|
||||||
|
|
|
@ -17,7 +17,7 @@ labels:
|
||||||
|
|
||||||
skip_clone: true
|
skip_clone: true
|
||||||
|
|
||||||
pipeline:
|
steps:
|
||||||
clone_friendica_base:
|
clone_friendica_base:
|
||||||
image: alpine/git
|
image: alpine/git
|
||||||
commands:
|
commands:
|
||||||
|
|
|
@ -5,7 +5,7 @@ labels:
|
||||||
|
|
||||||
skip_clone: true
|
skip_clone: true
|
||||||
|
|
||||||
pipeline:
|
steps:
|
||||||
clone_friendica_base:
|
clone_friendica_base:
|
||||||
image: alpine/git
|
image: alpine/git
|
||||||
commands:
|
commands:
|
||||||
|
|
|
@ -33,16 +33,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Content\Text\Markdown;
|
use Friendica\Content\Text\Markdown;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Database\DBStructure;
|
use Friendica\Database\DBStructure;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Tag;
|
use Friendica\Model\Tag;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -64,7 +61,7 @@ function advancedcontentfilter_install()
|
||||||
Hook::add('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
|
Hook::add('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
|
||||||
DBStructure::performUpdate();
|
DBStructure::performUpdate();
|
||||||
|
|
||||||
Logger::notice('installed advancedcontentfilter');
|
DI::logger()->notice('installed advancedcontentfilter');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -192,9 +189,30 @@ function advancedcontentfilter_init()
|
||||||
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'api') {
|
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'api') {
|
||||||
$slim = \Slim\Factory\AppFactory::create();
|
$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();
|
$slim->run();
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
@ -252,7 +270,7 @@ function advancedcontentfilter_content()
|
||||||
'rule_expression' => DI::l10n()->t('Rule Expression'),
|
'rule_expression' => DI::l10n()->t('Rule Expression'),
|
||||||
'cancel' => DI::l10n()->t('Cancel'),
|
'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()])),
|
'$rules' => DBA::toArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => DI::userSession()->getLocalUserId()])),
|
||||||
'$form_security_token' => BaseModule::getFormSecurityToken()
|
'$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>
|
* Author: Fabio <https://kirgroup.com/profile/fabrixxm>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -28,7 +26,7 @@ function birdavatar_install()
|
||||||
Hook::register('addon_settings', __FILE__, 'birdavatar_addon_settings');
|
Hook::register('addon_settings', __FILE__, 'birdavatar_addon_settings');
|
||||||
Hook::register('addon_settings_post', __FILE__, 'birdavatar_addon_settings_post');
|
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.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -78,7 +76,7 @@ function blackout_redirect ($b)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( $date1 <= $now ) && ( $now <= $date2 )) {
|
if (( $date1 <= $now ) && ( $now <= $date2 )) {
|
||||||
Logger::notice('redirecting user to blackout page');
|
DI::logger()->notice('redirecting user to blackout page');
|
||||||
System::externalRedirect($myurl);
|
System::externalRedirect($myurl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Jaybizzle\CrawlerDetect\CrawlerDetect;
|
use Jaybizzle\CrawlerDetect\CrawlerDetect;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Network\HTTPException\ForbiddenException;
|
use Friendica\Network\HTTPException\ForbiddenException;
|
||||||
|
@ -70,7 +69,7 @@ function blockbot_init_1()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($parts)) {
|
if (empty($parts)) {
|
||||||
Logger::debug('Known frontend found - accept', $logdata);
|
DI::logger()->debug('Known frontend found - accept', $logdata);
|
||||||
if ($isCrawler) {
|
if ($isCrawler) {
|
||||||
blockbot_save('badly-parsed-agents', $_SERVER['HTTP_USER_AGENT']);
|
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']);
|
blockbot_log_activitypub($_SERVER['REQUEST_URI'], $_SERVER['HTTP_USER_AGENT']);
|
||||||
|
|
||||||
if (blockbot_is_crawler($parts)) {
|
if (blockbot_is_crawler($parts)) {
|
||||||
Logger::debug('Crawler found - reject', $logdata);
|
DI::logger()->debug('Crawler found - reject', $logdata);
|
||||||
blockbot_reject();
|
blockbot_reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_searchbot($parts)) {
|
if (blockbot_is_searchbot($parts)) {
|
||||||
Logger::debug('Search bot found - reject', $logdata);
|
DI::logger()->debug('Search bot found - reject', $logdata);
|
||||||
blockbot_reject();
|
blockbot_reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_unwanted($parts)) {
|
if (blockbot_is_unwanted($parts)) {
|
||||||
Logger::debug('Uncategorized unwanted agent found - reject', $logdata);
|
DI::logger()->debug('Uncategorized unwanted agent found - reject', $logdata);
|
||||||
blockbot_reject();
|
blockbot_reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_security_checker($parts)) {
|
if (blockbot_is_security_checker($parts)) {
|
||||||
if (!DI::config()->get('blockbot', 'security_checker')) {
|
if (!DI::config()->get('blockbot', 'security_checker')) {
|
||||||
Logger::debug('Security checker found - reject', $logdata);
|
DI::logger()->debug('Security checker found - reject', $logdata);
|
||||||
blockbot_reject();
|
blockbot_reject();
|
||||||
}
|
}
|
||||||
Logger::debug('Security checker found - accept', $logdata);
|
DI::logger()->debug('Security checker found - accept', $logdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_social_media($parts)) {
|
if (blockbot_is_social_media($parts)) {
|
||||||
Logger::debug('Social media service found - accept', $logdata);
|
DI::logger()->debug('Social media service found - accept', $logdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_fediverse_client($parts)) {
|
if (blockbot_is_fediverse_client($parts)) {
|
||||||
Logger::debug('Fediverse client found - accept', $logdata);
|
DI::logger()->debug('Fediverse client found - accept', $logdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_feed_reader($parts)) {
|
if (blockbot_is_feed_reader($parts)) {
|
||||||
Logger::debug('Feed reader found - accept', $logdata);
|
DI::logger()->debug('Feed reader found - accept', $logdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_fediverse_tool($parts)) {
|
if (blockbot_is_fediverse_tool($parts)) {
|
||||||
Logger::debug('Fediverse tool found - accept', $logdata);
|
DI::logger()->debug('Fediverse tool found - accept', $logdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_service_agent($parts)) {
|
if (blockbot_is_service_agent($parts)) {
|
||||||
Logger::debug('Service agent found - accept', $logdata);
|
DI::logger()->debug('Service agent found - accept', $logdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_monitor($parts)) {
|
if (blockbot_is_monitor($parts)) {
|
||||||
Logger::debug('Monitoring service found - accept', $logdata);
|
DI::logger()->debug('Monitoring service found - accept', $logdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_validator($parts)) {
|
if (blockbot_is_validator($parts)) {
|
||||||
Logger::debug('Validation service found - accept', $logdata);
|
DI::logger()->debug('Validation service found - accept', $logdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockbot_is_good_tool($parts)) {
|
if (blockbot_is_good_tool($parts)) {
|
||||||
Logger::debug('Uncategorized helpful service found - accept', $logdata);
|
DI::logger()->debug('Uncategorized helpful service found - accept', $logdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,10 +146,10 @@ function blockbot_init_1()
|
||||||
if (blockbot_is_http_library($parts)) {
|
if (blockbot_is_http_library($parts)) {
|
||||||
blockbot_check_login_attempt($_SERVER['REQUEST_URI'], $logdata);
|
blockbot_check_login_attempt($_SERVER['REQUEST_URI'], $logdata);
|
||||||
if (!DI::config()->get('blockbot', 'http_libraries')) {
|
if (!DI::config()->get('blockbot', 'http_libraries')) {
|
||||||
Logger::debug('HTTP Library found - reject', $logdata);
|
DI::logger()->debug('HTTP Library found - reject', $logdata);
|
||||||
blockbot_reject();
|
blockbot_reject();
|
||||||
}
|
}
|
||||||
Logger::debug('HTTP Library found - accept', $logdata);
|
DI::logger()->debug('HTTP Library found - accept', $logdata);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,12 +160,12 @@ function blockbot_init_1()
|
||||||
|
|
||||||
if (!$isCrawler) {
|
if (!$isCrawler) {
|
||||||
blockbot_save('good-agents', $_SERVER['HTTP_USER_AGENT']);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockbot_save('bad-agents', $_SERVER['HTTP_USER_AGENT']);
|
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();
|
blockbot_reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +208,7 @@ function blockbot_log_activitypub(string $url, string $agent)
|
||||||
blockbot_save('activitypub-inbox-agents', $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);
|
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)
|
function blockbot_check_login_attempt(string $url, array $logdata)
|
||||||
{
|
{
|
||||||
if (in_array(trim(parse_url($url, PHP_URL_PATH), '/'), ['login', 'lostpass', 'register'])) {
|
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();
|
blockbot_reject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,7 +442,7 @@ function blockbot_is_monitor(array $parts): bool
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Services in the centralized and decentralized social media environment
|
* Services in the centralized and decentralized social media environment
|
||||||
*
|
*
|
||||||
* @param array $parts
|
* @param array $parts
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
|
|
@ -30,7 +30,6 @@ use Friendica\Content\Text\Plaintext;
|
||||||
use Friendica\Core\Cache\Enum\Duration;
|
use Friendica\Core\Cache\Enum\Duration;
|
||||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
|
@ -73,7 +72,7 @@ function bluesky_install()
|
||||||
|
|
||||||
function bluesky_load_config(ConfigFileManager $loader)
|
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)
|
function bluesky_check_item_notification(array &$notification_data)
|
||||||
|
@ -106,16 +105,16 @@ function bluesky_item_by_link(array &$hookData)
|
||||||
if (empty($did)) {
|
if (empty($did)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::debug('Found bluesky post', ['uri' => $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];
|
$uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2];
|
||||||
} else {
|
} else {
|
||||||
$uri = $hookData['uri'];
|
$uri = $hookData['uri'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = DI::atpProcessor()->fetchMissingPost($uri, $hookData['uid'], Item::PR_FETCHED, 0, 0);
|
$uri = DI::atpProcessor()->fetchMissingPost($uri, $hookData['uid'], Item::PR_FETCHED, 0, 0);
|
||||||
Logger::debug('Got post', ['uri' => $uri]);
|
DI::logger()->debug('Got post', ['uri' => $uri]);
|
||||||
if (!empty($uri)) {
|
if (!empty($uri)) {
|
||||||
$item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]);
|
$item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]);
|
||||||
if (!empty($item['id'])) {
|
if (!empty($item['id'])) {
|
||||||
|
@ -138,7 +137,7 @@ function bluesky_follow(array &$hook_data)
|
||||||
return;
|
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']]]);
|
$contact = DBA::selectFirst('contact', [], ['network' => Protocol::BLUESKY, 'url' => $hook_data['url'], 'uid' => [0, $hook_data['uid']]]);
|
||||||
if (empty($contact)) {
|
if (empty($contact)) {
|
||||||
return;
|
return;
|
||||||
|
@ -159,7 +158,7 @@ function bluesky_follow(array &$hook_data)
|
||||||
$activity = DI::atProtocol()->XRPCPost($hook_data['uid'], 'com.atproto.repo.createRecord', $post);
|
$activity = DI::atProtocol()->XRPCPost($hook_data['uid'], 'com.atproto.repo.createRecord', $post);
|
||||||
if (!empty($activity->uri)) {
|
if (!empty($activity->uri)) {
|
||||||
$hook_data['contact'] = $contact;
|
$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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +212,7 @@ function bluesky_block(array &$hook_data)
|
||||||
if ($ucid) {
|
if ($ucid) {
|
||||||
Contact::remove($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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,11 +420,11 @@ function bluesky_cron()
|
||||||
if ($last) {
|
if ($last) {
|
||||||
$next = $last + ($poll_interval * 60);
|
$next = $last + ($poll_interval * 60);
|
||||||
if ($next > time()) {
|
if ($next > time()) {
|
||||||
Logger::notice('poll interval not reached');
|
DI::logger()->notice('poll interval not reached');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Logger::notice('cron_start');
|
DI::logger()->notice('cron_start');
|
||||||
|
|
||||||
$abandon_days = intval(DI::config()->get('system', 'account_abandon_days'));
|
$abandon_days = intval(DI::config()->get('system', 'account_abandon_days'));
|
||||||
if ($abandon_days < 1) {
|
if ($abandon_days < 1) {
|
||||||
|
@ -437,19 +436,19 @@ function bluesky_cron()
|
||||||
$pconfigs = DBA::selectToArray('pconfig', [], ["`cat` = ? AND `k` IN (?, ?) AND `v`", 'bluesky', 'import', 'import_feeds']);
|
$pconfigs = DBA::selectToArray('pconfig', [], ["`cat` = ? AND `k` IN (?, ?) AND `v`", 'bluesky', 'import', 'import_feeds']);
|
||||||
foreach ($pconfigs as $pconfig) {
|
foreach ($pconfigs as $pconfig) {
|
||||||
if (empty(DI::atProtocol()->getUserDid($pconfig['uid']))) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($abandon_days != 0) {
|
if ($abandon_days != 0) {
|
||||||
if (!DBA::exists('user', ["`uid` = ? AND `login_date` >= ?", $pconfig['uid'], $abandon_limit])) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh the token now, so that it doesn't need to be refreshed in parallel by the following workers
|
// 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']);
|
DI::atProtocol()->getUserToken($pconfig['uid']);
|
||||||
|
|
||||||
$last_sync = DI::pConfig()->get($pconfig['uid'], 'bluesky', 'last_contact_sync');
|
$last_sync = DI::pConfig()->get($pconfig['uid'], 'bluesky', 'last_contact_sync');
|
||||||
|
@ -463,32 +462,32 @@ function bluesky_cron()
|
||||||
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_timeline.php', $pconfig['uid']);
|
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')) {
|
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']);
|
$feeds = bluesky_get_feeds($pconfig['uid']);
|
||||||
foreach ($feeds as $feed) {
|
foreach ($feeds as $feed) {
|
||||||
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_feed.php', $pconfig['uid'], $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());
|
DI::keyValue()->set('bluesky_last_poll', time());
|
||||||
|
|
||||||
$last_clean = DI::keyValue()->get('bluesky_last_clean');
|
$last_clean = DI::keyValue()->get('bluesky_last_clean');
|
||||||
if (empty($last_clean) || ($last_clean + 86400 < time())) {
|
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]);
|
$contacts = DBA::select('account-user-view', ['id', 'pid'], ["`network` = ? AND `uid` != ? AND `rel` = ?", Protocol::BLUESKY, 0, Contact::NOTHING]);
|
||||||
while ($contact = DBA::fetch($contacts)) {
|
while ($contact = DBA::fetch($contacts)) {
|
||||||
Worker::add(Worker::PRIORITY_LOW, 'MergeContact', $contact['pid'], $contact['id'], 0);
|
Worker::add(Worker::PRIORITY_LOW, 'MergeContact', $contact['pid'], $contact['id'], 0);
|
||||||
}
|
}
|
||||||
DBA::close($contacts);
|
DBA::close($contacts);
|
||||||
DI::keyValue()->set('bluesky_last_clean', time());
|
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)
|
function bluesky_hook_fork(array &$b)
|
||||||
|
@ -508,7 +507,7 @@ function bluesky_hook_fork(array &$b)
|
||||||
if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) {
|
if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) {
|
||||||
// Don't post if it isn't a reply to a bluesky post
|
// 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])) {
|
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;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -555,12 +554,12 @@ function bluesky_send(array &$b)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($b['gravity'] != Item::GRAVITY_PARENT) {
|
if ($b['gravity'] != Item::GRAVITY_PARENT) {
|
||||||
Logger::debug('Got comment', ['item' => $b]);
|
DI::logger()->debug('Got comment', ['item' => $b]);
|
||||||
|
|
||||||
if ($b['deleted']) {
|
if ($b['deleted']) {
|
||||||
$uri = DI::atpProcessor()->getUriClass($b['uri']);
|
$uri = DI::atpProcessor()->getUriClass($b['uri']);
|
||||||
if (empty($uri)) {
|
if (empty($uri)) {
|
||||||
Logger::debug('Not a bluesky post', ['uri' => $b['uri']]);
|
DI::logger()->debug('Not a bluesky post', ['uri' => $b['uri']]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bluesky_delete_post($b['uri'], $b['uid']);
|
bluesky_delete_post($b['uri'], $b['uid']);
|
||||||
|
@ -571,12 +570,12 @@ function bluesky_send(array &$b)
|
||||||
$parent = DI::atpProcessor()->getUriClass($b['thr-parent']);
|
$parent = DI::atpProcessor()->getUriClass($b['thr-parent']);
|
||||||
|
|
||||||
if (empty($root) || empty($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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($b['gravity'] == Item::GRAVITY_COMMENT) {
|
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);
|
bluesky_create_post($b, $root, $parent);
|
||||||
return;
|
return;
|
||||||
} elseif (in_array($b['verb'], [Activity::LIKE, Activity::ANNOUNCE])) {
|
} elseif (in_array($b['verb'], [Activity::LIKE, Activity::ANNOUNCE])) {
|
||||||
|
@ -603,6 +602,8 @@ function bluesky_create_activity(array $item, stdClass $parent = null)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$post = [];
|
||||||
|
|
||||||
if ($item['verb'] == Activity::LIKE) {
|
if ($item['verb'] == Activity::LIKE) {
|
||||||
$record = [
|
$record = [
|
||||||
'subject' => $parent,
|
'subject' => $parent,
|
||||||
|
@ -633,10 +634,10 @@ function bluesky_create_activity(array $item, stdClass $parent = null)
|
||||||
if (empty($activity->uri)) {
|
if (empty($activity->uri)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Logger::debug('Activity done', ['return' => $activity]);
|
DI::logger()->debug('Activity done', ['return' => $activity]);
|
||||||
$uri = DI::atpProcessor()->getUri($activity);
|
$uri = DI::atpProcessor()->getUri($activity);
|
||||||
Item::update(['extid' => $uri], ['guid' => $item['guid']]);
|
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)
|
function bluesky_create_post(array $item, stdClass $root = null, stdClass $parent = null)
|
||||||
|
@ -720,14 +721,14 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Logger::debug('Posting done', ['return' => $parent]);
|
DI::logger()->debug('Posting done', ['return' => $parent]);
|
||||||
if (empty($root)) {
|
if (empty($root)) {
|
||||||
$root = $parent;
|
$root = $parent;
|
||||||
}
|
}
|
||||||
if (($key == 0) && ($item['gravity'] != Item::GRAVITY_PARENT)) {
|
if (($key == 0) && ($item['gravity'] != Item::GRAVITY_PARENT)) {
|
||||||
$uri = DI::atpProcessor()->getUri($parent);
|
$uri = DI::atpProcessor()->getUri($parent);
|
||||||
Item::update(['extid' => $uri], ['guid' => $item['guid']]);
|
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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,20 +898,20 @@ function bluesky_upload_blob(int $uid, array $photo): ?stdClass
|
||||||
$new_size = strlen($content);
|
$new_size = strlen($content);
|
||||||
|
|
||||||
if (($size != 0) && ($new_size == 0) && ($retrial == 0)) {
|
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);
|
$content = Photo::getImageForPhoto($photo);
|
||||||
} else {
|
} 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)]]);
|
$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)) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item::incrementOutbound(Protocol::BLUESKY);
|
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;
|
return $data->blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -918,11 +919,11 @@ function bluesky_delete_post(string $uri, int $uid)
|
||||||
{
|
{
|
||||||
$parts = DI::atpProcessor()->getUriParts($uri);
|
$parts = DI::atpProcessor()->getUriParts($uri);
|
||||||
if (empty($parts)) {
|
if (empty($parts)) {
|
||||||
Logger::debug('No uri delected', ['uri' => $uri]);
|
DI::logger()->debug('No uri delected', ['uri' => $uri]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DI::atProtocol()->XRPCPost($uid, 'com.atproto.repo.deleteRecord', $parts);
|
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)
|
function bluesky_fetch_timeline(int $uid)
|
||||||
|
@ -1024,10 +1025,10 @@ function bluesky_fetch_notifications(int $uid)
|
||||||
foreach ($data->notifications as $notification) {
|
foreach ($data->notifications as $notification) {
|
||||||
$uri = DI::atpProcessor()->getUri($notification);
|
$uri = DI::atpProcessor()->getUri($notification);
|
||||||
if (Post::exists(['uri' => $uri, 'uid' => $uid]) || Post::exists(['extid' => $uri, 'uid' => $uid])) {
|
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;
|
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) {
|
switch ($notification->reason) {
|
||||||
case 'like':
|
case 'like':
|
||||||
$item = DI::atpProcessor()->getHeaderFromPost($notification, $uri, $uid, Conversation::PARCEL_CONNECTOR);
|
$item = DI::atpProcessor()->getHeaderFromPost($notification, $uri, $uid, Conversation::PARCEL_CONNECTOR);
|
||||||
|
@ -1037,9 +1038,9 @@ function bluesky_fetch_notifications(int $uid)
|
||||||
$item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0);
|
$item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0);
|
||||||
if (!empty($item['thr-parent'])) {
|
if (!empty($item['thr-parent'])) {
|
||||||
$data = Item::insert($item);
|
$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 {
|
} 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;
|
break;
|
||||||
|
|
||||||
|
@ -1051,37 +1052,37 @@ function bluesky_fetch_notifications(int $uid)
|
||||||
$item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0);
|
$item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0);
|
||||||
if (!empty($item['thr-parent'])) {
|
if (!empty($item['thr-parent'])) {
|
||||||
$data = Item::insert($item);
|
$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 {
|
} 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;
|
break;
|
||||||
|
|
||||||
case 'follow':
|
case 'follow':
|
||||||
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, $uid);
|
$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;
|
break;
|
||||||
|
|
||||||
case 'mention':
|
case 'mention':
|
||||||
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
|
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
|
||||||
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_TO, $contact['id'], 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;
|
break;
|
||||||
|
|
||||||
case 'reply':
|
case 'reply':
|
||||||
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
|
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
|
||||||
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_COMMENT, $contact['id'], 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;
|
break;
|
||||||
|
|
||||||
case 'quote':
|
case 'quote':
|
||||||
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
|
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
|
||||||
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_PUSHED, $contact['id'], 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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Logger::notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]);
|
DI::logger()->notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1112,16 +1113,16 @@ function bluesky_fetch_feed(int $uid, string $feed)
|
||||||
$languages = $entry->post->record->langs ?? [];
|
$languages = $entry->post->record->langs ?? [];
|
||||||
|
|
||||||
if (!Relay::isWantedLanguage($entry->post->record->text, 0, $contact['id'] ?? 0, $languages)) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
$causer = DI::atpActor()->getContactByDID($entry->post->author->did, $uid, 0);
|
$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);
|
$uri_id = bluesky_complete_post($entry->post, $uid, Item::PR_TAG, $causer['id'], Conversation::PARCEL_CONNECTOR);
|
||||||
if (!empty($uri_id)) {
|
if (!empty($uri_id)) {
|
||||||
$stored = Post\Category::storeFileByURIId($uri_id, $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl);
|
$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 {
|
} else {
|
||||||
Logger::notice('Post not found', ['entry' => $entry]);
|
DI::logger()->notice('Post not found', ['entry' => $entry]);
|
||||||
}
|
}
|
||||||
if (!empty($entry->reason)) {
|
if (!empty($entry->reason)) {
|
||||||
bluesky_process_reason($entry->reason, DI::atpProcessor()->getUri($entry->post), $uid);
|
bluesky_process_reason($entry->reason, DI::atpProcessor()->getUri($entry->post), $uid);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\DI;
|
||||||
|
|
||||||
function bluesky_feed_run($argv, $argc)
|
function bluesky_feed_run($argv, $argc)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ function bluesky_feed_run($argv, $argc)
|
||||||
return;
|
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]);
|
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
|
<?php
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\DI;
|
||||||
|
|
||||||
function bluesky_notifications_run($argv, $argc)
|
function bluesky_notifications_run($argv, $argc)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ function bluesky_notifications_run($argv, $argc)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::notice('importing notifications - start', ['user' => $argv[1]]);
|
DI::logger()->notice('importing notifications - start', ['user' => $argv[1]]);
|
||||||
bluesky_fetch_notifications($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
|
<?php
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\DI;
|
||||||
|
|
||||||
function bluesky_timeline_run($argv, $argc)
|
function bluesky_timeline_run($argv, $argc)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ function bluesky_timeline_run($argv, $argc)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::notice('importing timeline - start', ['user' => $argv[1]]);
|
DI::logger()->notice('importing timeline - start', ['user' => $argv[1]]);
|
||||||
bluesky_fetch_timeline($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>
|
* Author: Mike Macgirvin <mike@macgirvin.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -16,7 +15,7 @@ function calc_install() {
|
||||||
|
|
||||||
function calc_app_menu(array &$b)
|
function calc_app_menu(array &$b)
|
||||||
{
|
{
|
||||||
$b['app_menu'][] = '<div class="app-title"><a href="calc">Calculator</a></div>';
|
$b['app_menu'][] = '<div class="app-title"><a href="calc">Calculator</a></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -296,7 +295,7 @@ $o .= <<< EOT
|
||||||
<h3>Calculator</h3>
|
<h3>Calculator</h3>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<table>
|
<table>
|
||||||
<tbody><tr><td>
|
<tbody><tr><td>
|
||||||
<table bgcolor="#af9999" border="1">
|
<table bgcolor="#af9999" border="1">
|
||||||
<tbody><tr><td>
|
<tbody><tr><td>
|
||||||
<table border="1" cellpadding="2" cellspacing="2">
|
<table border="1" cellpadding="2" cellspacing="2">
|
||||||
|
@ -323,7 +322,7 @@ $o .= <<< EOT
|
||||||
<td><input name="multiplication" value=" * " onclick="multiplyNumbers()" type="button"></td>
|
<td><input name="multiplication" value=" * " onclick="multiplyNumbers()" type="button"></td>
|
||||||
</tr><tr align="left" valign="middle">
|
</tr><tr align="left" valign="middle">
|
||||||
<td><input name="zero" value=" 0 " onclick="addDisplay(0)" type="button"></td>
|
<td><input name="zero" value=" 0 " onclick="addDisplay(0)" type="button"></td>
|
||||||
<td><input name="pi" value=" Pi " onclick="addDisplay(Math.PI)" type="button"> </td>
|
<td><input name="pi" value=" Pi " onclick="addDisplay(Math.PI)" type="button"> </td>
|
||||||
<td><input name="dot" value=" . " onclick='addDisplay(".")' type="button"></td>
|
<td><input name="dot" value=" . " onclick='addDisplay(".")' type="button"></td>
|
||||||
<td><input name="division" value=" / " onclick="divideNumbers()" type="button"></td>
|
<td><input name="division" value=" / " onclick="divideNumbers()" type="button"></td>
|
||||||
</tr><tr align="left" valign="middle">
|
</tr><tr align="left" valign="middle">
|
||||||
|
@ -345,13 +344,13 @@ $o .= <<< EOT
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<TD VALIGN=top>
|
<TD VALIGN=top>
|
||||||
<B>NOTE:</B> All sine and cosine calculations are
|
<B>NOTE:</B> All sine and cosine calculations are
|
||||||
<br>done in radians. Remember to convert first
|
<br>done in radians. Remember to convert first
|
||||||
<br>if using degrees.
|
<br>if using degrees.
|
||||||
</TD>
|
</TD>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</td></tr></tbody></table>
|
</td></tr></tbody></table>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,8 @@
|
||||||
* Author: Fabio <https://kirgroup.com/profile/fabrixxm>
|
* Author: Fabio <https://kirgroup.com/profile/fabrixxm>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Worker;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
@ -29,7 +26,7 @@ function catavatar_install()
|
||||||
Hook::register('addon_settings', __FILE__, 'catavatar_addon_settings');
|
Hook::register('addon_settings', __FILE__, 'catavatar_addon_settings');
|
||||||
Hook::register('addon_settings_post', __FILE__, 'catavatar_addon_settings_post');
|
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\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
function cld_install()
|
function cld_install()
|
||||||
|
@ -18,7 +17,17 @@ function cld_install()
|
||||||
function cld_detect_languages(array &$data)
|
function cld_detect_languages(array &$data)
|
||||||
{
|
{
|
||||||
if (!in_array('cld2', get_loaded_extensions())) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +52,7 @@ function cld_detect_languages(array &$data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$result['is_reliable']) {
|
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)) {
|
if (($original == $detected) && ($data['detected'][$original] < $result['language_probability'] / 100)) {
|
||||||
$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());
|
$available = array_keys(DI::l10n()->getLanguageCodes());
|
||||||
|
|
||||||
if (!in_array($detected, $available)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($original != $detected) {
|
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']);
|
$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 source unit from which to convert
|
||||||
* @param string name of the target unit to which we are converting
|
* @param string name of the target unit to which we are converting
|
||||||
* @param integer double precision of the end result
|
* @param integer double precision of the end result
|
||||||
* @return void
|
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function convert($value, $from_unit, $to_unit, $precision)
|
function convert($value, $from_unit, $to_unit, $precision)
|
||||||
|
@ -280,4 +279,4 @@ class UnitConvertor
|
||||||
} // end func getConvSpecs
|
} // end func getConvSpecs
|
||||||
|
|
||||||
} // end class UnitConvertor
|
} // end class UnitConvertor
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
|
|
||||||
function convert_install() {
|
function convert_install() {
|
||||||
|
@ -26,7 +25,7 @@ function convert_content() {
|
||||||
// @TODO Let's one day rewrite this to a modern composer package
|
// @TODO Let's one day rewrite this to a modern composer package
|
||||||
include 'UnitConvertor.php';
|
include 'UnitConvertor.php';
|
||||||
|
|
||||||
class TP_Converter extends UnitConvertor
|
$conv = new class('en') extends UnitConvertor
|
||||||
{
|
{
|
||||||
public function __construct(string $lang = 'en')
|
public function __construct(string $lang = 'en')
|
||||||
{
|
{
|
||||||
|
@ -43,7 +42,7 @@ function convert_content() {
|
||||||
|
|
||||||
private function findBaseUnit($from, $to)
|
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)) {
|
if ($skey == $from || $to == $skey || in_array($to, $sval) || in_array($from, $sval)) {
|
||||||
return $skey;
|
return $skey;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +62,7 @@ function convert_content() {
|
||||||
$cells[] = $cell;
|
$cells[] = $cell;
|
||||||
|
|
||||||
// We now have the base unit and value now lets produce the table;
|
// 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 ['value'] = $this->convert($value, $from_unit, $val, $precision) . ' ' . $val;
|
||||||
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : '';
|
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : '';
|
||||||
$cells[] = $cell;
|
$cells[] = $cell;
|
||||||
|
@ -86,9 +85,7 @@ function convert_content() {
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
$conv = new TP_Converter('en');
|
|
||||||
|
|
||||||
$conversions = [
|
$conversions = [
|
||||||
'Temperature' => ['base' => 'Celsius',
|
'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']);
|
$conv->addConversion($val['base'], $val['conv']);
|
||||||
$list[$key][] = $val['base'];
|
$list[$key][] = $val['base'];
|
||||||
while (list($ukey, $uval) = each($val['conv'])) {
|
foreach ($val['conv'] as $ukey => $uval) {
|
||||||
$list[$key][] = $ukey;
|
$list[$key][] = $ukey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$o .= '<h3>Unit Conversions</h3>';
|
$o = '<h3>Unit Conversions</h3>';
|
||||||
|
|
||||||
if (isset($_POST['from_unit']) && isset($_POST['value'])) {
|
if (isset($_POST['from_unit']) && isset($_POST['value'])) {
|
||||||
$o .= ($conv->getTable(intval($_POST['value']), $_POST['from_unit'], $_POST['to_unit'], 5)) . '</p>';
|
$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 .= '<input name="value" type="text" id="value" value="' . $value . '" size="10" maxlength="10" />';
|
||||||
$o .= '<select name="from_unit" size="12">';
|
$o .= '<select name="from_unit" size="12">';
|
||||||
|
|
||||||
reset($list);
|
foreach ($list as $key => $val) {
|
||||||
while(list($key, $val) = each($list)) {
|
|
||||||
$o .= "\n\t<optgroup label=\"$key\">";
|
$o .= "\n\t<optgroup label=\"$key\">";
|
||||||
while(list($ukey, $uval) = each($val)) {
|
foreach ($val as $ukey => $uval) {
|
||||||
$selected = (($uval == $_POST['from_unit']) ? ' selected="selected" ' : '');
|
$selected = (($uval == $_POST['from_unit']) ? ' selected="selected" ' : '');
|
||||||
$o .= "\n\t\t<option value=\"$uval\" $selected >$uval</option>";
|
$o .= "\n\t\t<option value=\"$uval\" $selected >$uval</option>";
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
* Author: Peter Liebetrau <https://socivitas/profile/peerteer>
|
* Author: Peter Liebetrau <https://socivitas/profile/peerteer>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
|
@ -29,10 +29,10 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti
|
||||||
$now = new DateTime();
|
$now = new DateTime();
|
||||||
|
|
||||||
if (!is_null($cached)) {
|
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);
|
$cached = unserialize($cached);
|
||||||
|
|
||||||
if ($cdate + $cachetime > $now->getTimestamp()) {
|
if ($cdate + (int) $cachetime > $now->getTimestamp()) {
|
||||||
return $cached;
|
return $cached;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ use Friendica\Core\System;
|
||||||
|
|
||||||
class Diasphp {
|
class Diasphp {
|
||||||
private $cookiejar;
|
private $cookiejar;
|
||||||
|
private $token_regex;
|
||||||
|
private $pod;
|
||||||
|
|
||||||
function __construct($pod) {
|
function __construct($pod) {
|
||||||
$this->token_regex = '/content="(.*?)" name="csrf-token/';
|
$this->token_regex = '/content="(.*?)" name="csrf-token/';
|
||||||
|
|
|
@ -9,10 +9,8 @@
|
||||||
|
|
||||||
require_once 'addon/diaspora/Diaspora_Connection.php';
|
require_once 'addon/diaspora/Diaspora_Connection.php';
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
|
@ -187,7 +185,7 @@ function diaspora_send(array &$b)
|
||||||
{
|
{
|
||||||
$hostname = DI::baseUrl()->getHost();
|
$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'])) {
|
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
|
@ -211,14 +209,14 @@ function diaspora_send(array &$b)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::info('diaspora_send: prepare posting');
|
DI::logger()->info('diaspora_send: prepare posting');
|
||||||
|
|
||||||
$handle = DI::pConfig()->get($b['uid'], 'diaspora', 'handle');
|
$handle = DI::pConfig()->get($b['uid'], 'diaspora', 'handle');
|
||||||
$password = DI::pConfig()->get($b['uid'], 'diaspora', 'password');
|
$password = DI::pConfig()->get($b['uid'], 'diaspora', 'password');
|
||||||
$aspect = DI::pConfig()->get($b['uid'], 'diaspora', 'aspect');
|
$aspect = DI::pConfig()->get($b['uid'], 'diaspora', 'aspect');
|
||||||
|
|
||||||
if ($handle && $password) {
|
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'];
|
$title = $b['title'];
|
||||||
$body = $b['body'];
|
$body = $b['body'];
|
||||||
|
@ -249,20 +247,20 @@ function diaspora_send(array &$b)
|
||||||
require_once "addon/diaspora/diasphp.php";
|
require_once "addon/diaspora/diasphp.php";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Logger::info('diaspora_send: prepare');
|
DI::logger()->info('diaspora_send: prepare');
|
||||||
$conn = new Diaspora_Connection($handle, $password);
|
$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();
|
$conn->logIn();
|
||||||
Logger::info('diaspora_send: try to send ' . $body);
|
DI::logger()->info('diaspora_send: try to send ' . $body);
|
||||||
|
|
||||||
$conn->provider = $hostname;
|
$conn->provider = $hostname;
|
||||||
$conn->postStatusMessage($body, $aspect);
|
$conn->postStatusMessage($body, $aspect);
|
||||||
|
|
||||||
Logger::notice('diaspora_send: success');
|
DI::logger()->notice('diaspora_send: success');
|
||||||
} catch (Exception $e) {
|
} 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();
|
Worker::defer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Text\Markdown;
|
use Friendica\Content\Text\Markdown;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
@ -80,13 +78,13 @@ function discourse_email_getmessage(&$message)
|
||||||
// We do assume that all Discourse servers are running with SSL
|
// We do assume that all Discourse servers are running with SSL
|
||||||
if (preg_match('=topic/(.*\d)/(.*\d)@(.*)=', $message['item']['uri'], $matches) &&
|
if (preg_match('=topic/(.*\d)/(.*\d)@(.*)=', $message['item']['uri'], $matches) &&
|
||||||
discourse_fetch_post_from_api($message, $matches[2], $matches[3])) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('=topic/(.*\d)@(.*)=', $message['item']['uri'], $matches) &&
|
if (preg_match('=topic/(.*\d)@(.*)=', $message['item']['uri'], $matches) &&
|
||||||
discourse_fetch_topic_from_api($message, 'https://' . $matches[2], $matches[1], 1)) {
|
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;
|
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)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (discourse_fetch_topic_from_api($message, $matches[1], $matches[2], $matches[3])) {
|
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;
|
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
|
// Search in the HTML part for the discourse entry and the author profile
|
||||||
if (!empty($message['html'])) {
|
if (!empty($message['html'])) {
|
||||||
$message = discourse_get_html($message);
|
$message = discourse_get_html($message);
|
||||||
|
@ -122,7 +120,7 @@ function discourse_fetch_post($host, $topic, $pid)
|
||||||
$url = $host . '/t/' . $topic . '/' . $pid . '.json';
|
$url = $host . '/t/' . $topic . '/' . $pid . '.json';
|
||||||
$curlResult = DI::httpClient()->get($url);
|
$curlResult = DI::httpClient()->get($url);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
Logger::info('No success', ['url' => $url]);
|
DI::logger()->info('No success', ['url' => $url]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,11 +132,11 @@ function discourse_fetch_post($host, $topic, $pid)
|
||||||
/// @todo Possibly fetch missing posts here
|
/// @todo Possibly fetch missing posts here
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Logger::info('Got post data from topic', $post);
|
DI::logger()->info('Got post data from topic', $post);
|
||||||
return $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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +168,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host)
|
||||||
|
|
||||||
$message = discourse_process_post($message, $data, $hostaddr);
|
$message = discourse_process_post($message, $data, $hostaddr);
|
||||||
|
|
||||||
Logger::info('Got API data', $message);
|
DI::logger()->info('Got API data', $message);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +201,7 @@ function discourse_get_user($post, $hostaddr)
|
||||||
$contact['url'] = $hostaddr . '/u/' . $contact['nick'];
|
$contact['url'] = $hostaddr . '/u/' . $contact['nick'];
|
||||||
$contact['nurl'] = Strings::normaliseLink($contact['url']);
|
$contact['nurl'] = Strings::normaliseLink($contact['url']);
|
||||||
$contact['baseurl'] = $hostaddr;
|
$contact['baseurl'] = $hostaddr;
|
||||||
Logger::info('Contact', $contact);
|
DI::logger()->info('Contact', $contact);
|
||||||
$contact['id'] = Contact::getIdForURL($contact['url'], 0, false, $contact);
|
$contact['id'] = Contact::getIdForURL($contact['url'], 0, false, $contact);
|
||||||
if (!empty($contact['id'])) {
|
if (!empty($contact['id'])) {
|
||||||
$avatar = $contact['photo'];
|
$avatar = $contact['photo'];
|
||||||
|
@ -269,11 +267,11 @@ function discourse_get_html($message)
|
||||||
$div = $doc2->importNode($result->item(0), true);
|
$div = $doc2->importNode($result->item(0), true);
|
||||||
$doc2->appendChild($div);
|
$doc2->appendChild($div);
|
||||||
$message['html'] = $doc2->saveHTML();
|
$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);
|
$profile = discourse_get_profile($xpath);
|
||||||
if (!empty($profile['url'])) {
|
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-id'] = Contact::getIdForURL($profile['url'], 0, false, $profile);
|
||||||
$message['item']['author-link'] = $profile['url'];
|
$message['item']['author-link'] = $profile['url'];
|
||||||
$message['item']['author-name'] = $profile['name'];
|
$message['item']['author-name'] = $profile['name'];
|
||||||
|
@ -289,21 +287,21 @@ function discourse_get_text($message)
|
||||||
$text = str_replace("\r", '', $text);
|
$text = str_replace("\r", '', $text);
|
||||||
$pos = strpos($text, "\n---\n");
|
$pos = strpos($text, "\n---\n");
|
||||||
if ($pos == 0) {
|
if ($pos == 0) {
|
||||||
Logger::info('No separator found', ['text' => $text]);
|
DI::logger()->info('No separator found', ['text' => $text]);
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
$message['text'] = trim(substr($text, 0, $pos));
|
$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']);
|
$message['text'] = Markdown::toBBCode($message['text']);
|
||||||
|
|
||||||
$text = substr($text, $pos);
|
$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)) {
|
if (preg_match('=\((http.*/t/.*/.*\d/.*\d)\)=', $text, $link)) {
|
||||||
$message['item']['plink'] = $link[1];
|
$message['item']['plink'] = $link[1];
|
||||||
Logger::info('Found plink', ['plink' => $message['item']['plink']]);
|
DI::logger()->info('Found plink', ['plink' => $message['item']['plink']]);
|
||||||
}
|
}
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,8 @@
|
||||||
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
@ -186,12 +184,12 @@ function dwpost_send(array &$b)
|
||||||
|
|
||||||
EOT;
|
EOT;
|
||||||
|
|
||||||
Logger::debug('dwpost: data: ' . $xml);
|
DI::logger()->debug('dwpost: data: ' . $xml);
|
||||||
|
|
||||||
if ($dw_blog !== 'test') {
|
if ($dw_blog !== 'test') {
|
||||||
$x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
|
$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 : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
* Status: Unsupported
|
* Status: Unsupported
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ function fancybox_render(array &$b){
|
||||||
function ($text) use ($gallery) {
|
function ($text) use ($gallery) {
|
||||||
// This processes images inlined in posts
|
// 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!
|
// Frio / Vier hooks für lightbox are un-hooked in fancybox-config.js. So this works for them, too!
|
||||||
//if (!in_array(DI::app()->getCurrentTheme(),['vier','frio']))
|
//if (!in_array(DI::appHelper()->getCurrentTheme(),['vier','frio']))
|
||||||
$text = preg_replace(
|
$text = preg_replace(
|
||||||
'#<a[^>]*href="([^"]*)"[^>]*>(<img[^>]*src="[^"]*"[^>]*>)</a>#',
|
'#<a[^>]*href="([^"]*)"[^>]*>(<img[^>]*src="[^"]*"[^>]*>)</a>#',
|
||||||
'<a data-fancybox="' . $gallery . '" href="$1">$2</a>',
|
'<a data-fancybox="' . $gallery . '" href="$1">$2</a>',
|
||||||
|
|
|
@ -7,9 +7,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -18,7 +16,7 @@ function fromapp_install()
|
||||||
Hook::register('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook');
|
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', 'addon/fromapp/fromapp.php', 'fromapp_settings');
|
||||||
Hook::register('addon_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post');
|
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)
|
function fromapp_settings_post($post)
|
||||||
|
@ -76,6 +74,6 @@ function fromapp_post_hook(&$item)
|
||||||
|
|
||||||
$apps = explode(',', $app);
|
$apps = explode(',', $app);
|
||||||
$item['app'] = trim($apps[mt_rand(0, count($apps)-1)]);
|
$item['app'] = trim($apps[mt_rand(0, count($apps)-1)]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,7 @@
|
||||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
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);
|
$s = DI::httpClient()->fetch('https://api.opencagedata.com/geocode/v1/json?q=' . $coords[0] . ',' . $coords[1] . '&key=' . $key . '&language=' . $language);
|
||||||
|
|
||||||
if (!$s) {
|
if (!$s) {
|
||||||
Logger::info('API could not be queried');
|
DI::logger()->info('API could not be queried');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = json_decode($s);
|
$data = json_decode($s);
|
||||||
|
|
||||||
if ($data->status->code != '200') {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($data->total_results == 0) || (count($data->results) == 0)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['location'] = $data->results[0]->formatted;
|
$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'] != '') {
|
if ($item['location'] != '') {
|
||||||
DI::cache()->set('geocoordinates:' . $language.':' . $coords[0] . '-' . $coords[1], $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>
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||||
|
@ -35,7 +33,7 @@ function geonames_install()
|
||||||
|
|
||||||
function geonames_load_config(ConfigFileManager $loader)
|
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)
|
function geonames_post_hook(array &$item)
|
||||||
|
@ -46,7 +44,7 @@ function geonames_post_hook(array &$item)
|
||||||
* - The profile owner must have allowed our addon
|
* - 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 */
|
if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -4,13 +4,11 @@
|
||||||
* Description: Thread email comment notifications on Gmail and anonymise them
|
* Description: Thread email comment notifications on Gmail and anonymise them
|
||||||
* Version: 1.0
|
* Version: 1.0
|
||||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Notification;
|
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('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
|
||||||
Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
|
Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
|
||||||
|
|
||||||
Logger::notice("installed gnot");
|
DI::logger()->notice("installed gnot");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +36,7 @@ function gnot_settings_post($post) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from the Addon Setting form.
|
* Called from the Addon Setting form.
|
||||||
* Add our own settings info to the page.
|
* Add our own settings info to the page.
|
||||||
*/
|
*/
|
||||||
function gnot_settings(array &$data)
|
function gnot_settings(array &$data)
|
||||||
|
|
|
@ -7,15 +7,14 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\DI;
|
||||||
|
|
||||||
function googlemaps_install()
|
function googlemaps_install()
|
||||||
{
|
{
|
||||||
Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
||||||
|
|
||||||
Logger::notice('installed googlemaps');
|
DI::logger()->notice('installed googlemaps');
|
||||||
}
|
}
|
||||||
|
|
||||||
function googlemaps_location(&$item)
|
function googlemaps_location(&$item)
|
||||||
|
|
|
@ -6,15 +6,11 @@
|
||||||
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
|
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||||
use Friendica\Util\Strings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs the addon hook
|
* Installs the addon hook
|
||||||
|
@ -23,12 +19,12 @@ function gravatar_install() {
|
||||||
Hook::register('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config');
|
Hook::register('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config');
|
||||||
Hook::register('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup');
|
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)
|
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
|
* Note: Please use Circle Text instead
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* Author: Hypolite Petovan <hypolite@mrpetovan.com>
|
* Author: Hypolite Petovan <hypolite@mrpetovan.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ function highlightjs_install()
|
||||||
|
|
||||||
function highlightjs_head(string &$str)
|
function highlightjs_head(string &$str)
|
||||||
{
|
{
|
||||||
if (DI::app()->getCurrentTheme() == 'frio') {
|
if (DI::appHelper()->getCurrentTheme() == 'frio') {
|
||||||
$style = 'bootstrap';
|
$style = 'bootstrap';
|
||||||
} else {
|
} else {
|
||||||
$style = 'default';
|
$style = 'default';
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
* Version: 0.1
|
* Version: 0.1
|
||||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||||
*/
|
*/
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\PageInfo;
|
use Friendica\Content\PageInfo;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
@ -87,16 +85,16 @@ function ifttt_post()
|
||||||
|
|
||||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
|
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
|
||||||
if (!DBA::isResult($user)) {
|
if (!DBA::isResult($user)) {
|
||||||
Logger::info('User ' . $nickname . ' not found.');
|
DI::logger()->info('User ' . $nickname . ' not found.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uid = $user['uid'];
|
$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'])) {
|
if (!isset($_REQUEST['key'])) {
|
||||||
Logger::notice('No key found.');
|
DI::logger()->notice('No key found.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +102,7 @@ function ifttt_post()
|
||||||
|
|
||||||
// Check the key
|
// Check the key
|
||||||
if ($key != DI::pConfig()->get($uid, 'ifttt', '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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +113,7 @@ function ifttt_post()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($item['type'], ['status', 'link', 'photo'])) {
|
if (!in_array($item['type'], ['status', 'link', 'photo'])) {
|
||||||
Logger::info('Unknown item type ' . $item['type']);
|
DI::logger()->info('Unknown item type ' . $item['type']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,8 @@
|
||||||
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
@ -179,11 +177,11 @@ function ijpost_send(array &$b)
|
||||||
|
|
||||||
EOT;
|
EOT;
|
||||||
|
|
||||||
Logger::debug('ijpost: data: ' . $xml);
|
DI::logger()->debug('ijpost: data: ' . $xml);
|
||||||
|
|
||||||
if ($ij_blog !== 'test') {
|
if ($ij_blog !== 'test') {
|
||||||
$x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
|
$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
|
* License: 3-clause BSD license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
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('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
|
||||||
Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
|
Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
|
||||||
Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
|
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)
|
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)
|
function impressum_show(string &$body)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
|
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ function invidious_settings(array &$data)
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/invidious/');
|
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/invidious/');
|
||||||
$html = Renderer::replaceMacros($t, [
|
$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.')],
|
'$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' => ['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>')],
|
'$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 = [
|
$data = [
|
||||||
|
@ -71,9 +71,9 @@ function invidious_settings_post(array &$b)
|
||||||
return;
|
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)) {
|
if ($server != DI::config()->get('invidious', 'server', INVIDIOUS_DEFAULT) && !empty($server)) {
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'server', $server);
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'server', $server);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
* Author: Tobias Diekershoff <https://f.diekershoff.de/u/tobias>
|
* Author: Tobias Diekershoff <https://f.diekershoff.de/u/tobias>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
|
@ -77,10 +77,10 @@ class qqFileUploader {
|
||||||
public function __construct(array $allowedExtensions = [], $sizeLimit = 10485760)
|
public function __construct(array $allowedExtensions = [], $sizeLimit = 10485760)
|
||||||
{
|
{
|
||||||
$allowedExtensions = array_map('strtolower', $allowedExtensions);
|
$allowedExtensions = array_map('strtolower', $allowedExtensions);
|
||||||
|
|
||||||
$this->allowedExtensions = $allowedExtensions;
|
$this->allowedExtensions = $allowedExtensions;
|
||||||
$this->sizeLimit = $sizeLimit;
|
$this->sizeLimit = $sizeLimit;
|
||||||
|
|
||||||
$this->checkServerSettings();
|
$this->checkServerSettings();
|
||||||
|
|
||||||
if (isset($_GET['qqfile'])) {
|
if (isset($_GET['qqfile'])) {
|
||||||
|
@ -88,7 +88,7 @@ class qqFileUploader {
|
||||||
} elseif (isset($_FILES['qqfile'])) {
|
} elseif (isset($_FILES['qqfile'])) {
|
||||||
$this->file = new qqUploadedFileForm();
|
$this->file = new qqUploadedFileForm();
|
||||||
} else {
|
} else {
|
||||||
$this->file = false;
|
$this->file = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ class qqFileUploader {
|
||||||
|
|
||||||
private function toBytes(string $str): int
|
private function toBytes(string $str): int
|
||||||
{
|
{
|
||||||
$val = trim($str);
|
$val = (int) trim($str);
|
||||||
$last = strtolower($str[strlen($str) - 1]);
|
$last = strtolower($str[strlen($str) - 1]);
|
||||||
|
|
||||||
switch($last) {
|
switch($last) {
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
|
|
||||||
$fileName;
|
$fileName = '';
|
||||||
$fileSize;
|
$fileSize = 0;;
|
||||||
|
|
||||||
if (isset($_GET['qqfile'])){
|
if (isset($_GET['qqfile'])){
|
||||||
$fileName = $_GET['qqfile'];
|
$fileName = $_GET['qqfile'];
|
||||||
|
|
||||||
// xhr request
|
// xhr request
|
||||||
$headers = apache_request_headers();
|
$headers = apache_request_headers();
|
||||||
$fileSize = (int)$headers['Content-Length'];
|
$fileSize = (int)$headers['Content-Length'];
|
||||||
|
@ -34,13 +34,13 @@ if ($fileSize > 9 * 1024){
|
||||||
die ('{error: "server-error file size is bigger than 9kB"}');
|
die ('{error: "server-error file size is bigger than 9kB"}');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($_GET)){
|
if (count($_GET)){
|
||||||
array_merge($_GET, array('fileName'=>$fileName));
|
array_merge($_GET, array('fileName'=>$fileName));
|
||||||
|
|
||||||
$response = array_merge($_GET, array('success'=>true, 'fileName'=>$fileName));
|
$response = array_merge($_GET, array('success'=>true, 'fileName'=>$fileName));
|
||||||
|
|
||||||
// to pass data through iframe you will need to encode all html tags
|
// to pass data through iframe you will need to encode all html tags
|
||||||
echo htmlspecialchars(json_encode($response), ENT_NOQUOTES);
|
echo htmlspecialchars(json_encode($response), ENT_NOQUOTES);
|
||||||
} else {
|
} else {
|
||||||
die ('{error: "server-error query params not passed"}');
|
die ('{error: "server-error query params not passed"}');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
sleep(4);
|
sleep(4);
|
||||||
|
|
||||||
$fileName;
|
$fileName = '';
|
||||||
|
|
||||||
if (isset($_GET['qqfile'])){
|
if (isset($_GET['qqfile'])){
|
||||||
$fileName = $_GET['qqfile'];
|
$fileName = $_GET['qqfile'];
|
||||||
|
|
||||||
// xhr request
|
// xhr request
|
||||||
$headers = apache_request_headers();
|
$headers = apache_request_headers();
|
||||||
if ((int)$headers['Content-Length'] == 0){
|
if ((int)$headers['Content-Length'] == 0){
|
||||||
|
@ -14,7 +14,7 @@ if (isset($_GET['qqfile'])){
|
||||||
}
|
}
|
||||||
} elseif (isset($_FILES['qqfile'])){
|
} elseif (isset($_FILES['qqfile'])){
|
||||||
$fileName = basename($_FILES['qqfile']['name']);
|
$fileName = basename($_FILES['qqfile']['name']);
|
||||||
|
|
||||||
// form request
|
// form request
|
||||||
if ($_FILES['qqfile']['size'] == 0){
|
if ($_FILES['qqfile']['size'] == 0){
|
||||||
die ('{error: "file size is zero"}');
|
die ('{error: "file size is zero"}');
|
||||||
|
@ -25,7 +25,7 @@ if (isset($_GET['qqfile'])){
|
||||||
|
|
||||||
if (count($_GET)){
|
if (count($_GET)){
|
||||||
$_GET['success'] = true;
|
$_GET['success'] = true;
|
||||||
echo json_encode(array_merge($_GET));
|
echo json_encode(array_merge($_GET));
|
||||||
} else {
|
} else {
|
||||||
die ('{error: "query params not passed"}');
|
die ('{error: "query params not passed"}');
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
usleep(300);
|
usleep(300);
|
||||||
|
|
||||||
$fileName;
|
$fileName = '';
|
||||||
|
|
||||||
if (isset($_GET['qqfile'])){
|
if (isset($_GET['qqfile'])){
|
||||||
$fileName = $_GET['qqfile'];
|
$fileName = $_GET['qqfile'];
|
||||||
|
|
||||||
// xhr request
|
// xhr request
|
||||||
$headers = apache_request_headers();
|
$headers = apache_request_headers();
|
||||||
if ((int)$headers['Content-Length'] == 0){
|
if ((int)$headers['Content-Length'] == 0){
|
||||||
|
@ -14,7 +14,7 @@ if (isset($_GET['qqfile'])){
|
||||||
}
|
}
|
||||||
} elseif (isset($_FILES['qqfile'])){
|
} elseif (isset($_FILES['qqfile'])){
|
||||||
$fileName = basename($_FILES['qqfile']['name']);
|
$fileName = basename($_FILES['qqfile']['name']);
|
||||||
|
|
||||||
// form request
|
// form request
|
||||||
if ($_FILES['qqfile']['size'] == 0){
|
if ($_FILES['qqfile']['size'] == 0){
|
||||||
die ('{error: "file size is zero"}');
|
die ('{error: "file size is zero"}');
|
||||||
|
@ -25,7 +25,7 @@ if (isset($_GET['qqfile'])){
|
||||||
|
|
||||||
if (count($_GET)){
|
if (count($_GET)){
|
||||||
//return query params
|
//return query params
|
||||||
echo json_encode(array_merge($_GET, array('fileName'=>$fileName)));
|
echo json_encode(array_merge($_GET, array('fileName'=>$fileName)));
|
||||||
} else {
|
} else {
|
||||||
die ('{error: "query params not passed"}');
|
die ('{error: "query params not passed"}');
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Util\Images;
|
use Friendica\Util\Images;
|
||||||
|
@ -60,7 +59,7 @@ function js_upload_post_init(array &$b)
|
||||||
// max file size in bytes
|
// max file size in bytes
|
||||||
$sizeLimit = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
|
$sizeLimit = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
|
||||||
|
|
||||||
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
|
$uploader = new js_upload_qqFileUploader($allowedExtensions, $sizeLimit);
|
||||||
|
|
||||||
$result = $uploader->handleUpload();
|
$result = $uploader->handleUpload();
|
||||||
|
|
||||||
|
@ -68,7 +67,7 @@ function js_upload_post_init(array &$b)
|
||||||
$js_upload_jsonresponse = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
|
$js_upload_jsonresponse = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
|
||||||
|
|
||||||
if (isset($result['error'])) {
|
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);
|
echo json_encode($result);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
@ -91,7 +90,7 @@ function js_upload_post_end(int &$b)
|
||||||
{
|
{
|
||||||
global $js_upload_jsonresponse;
|
global $js_upload_jsonresponse;
|
||||||
|
|
||||||
Logger::notice('upload_post_end');
|
DI::logger()->notice('upload_post_end');
|
||||||
if (!empty($js_upload_jsonresponse)) {
|
if (!empty($js_upload_jsonresponse)) {
|
||||||
echo $js_upload_jsonresponse;
|
echo $js_upload_jsonresponse;
|
||||||
exit();
|
exit();
|
||||||
|
@ -101,7 +100,7 @@ function js_upload_post_end(int &$b)
|
||||||
/**
|
/**
|
||||||
* Handle file uploads via XMLHttpRequest
|
* Handle file uploads via XMLHttpRequest
|
||||||
*/
|
*/
|
||||||
class qqUploadedFileXhr
|
class js_upload_qqUploadedFileXhr
|
||||||
{
|
{
|
||||||
private $pathnm = '';
|
private $pathnm = '';
|
||||||
|
|
||||||
|
@ -155,7 +154,7 @@ class qqUploadedFileXhr
|
||||||
/**
|
/**
|
||||||
* Handle file uploads via regular form post (uses the $_FILES array)
|
* Handle file uploads via regular form post (uses the $_FILES array)
|
||||||
*/
|
*/
|
||||||
class qqUploadedFileForm
|
class js_upload_qqUploadedFileForm
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Save the file to the specified path
|
* Save the file to the specified path
|
||||||
|
@ -183,10 +182,14 @@ class qqUploadedFileForm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class qqFileUploader
|
class js_upload_qqFileUploader
|
||||||
{
|
{
|
||||||
private $allowedExtensions;
|
private $allowedExtensions;
|
||||||
private $sizeLimit;
|
private $sizeLimit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var js_upload_qqUploadedFileXhr|js_upload_qqUploadedFileForm
|
||||||
|
*/
|
||||||
private $file;
|
private $file;
|
||||||
|
|
||||||
function __construct(array $allowedExtensions = [], $sizeLimit)
|
function __construct(array $allowedExtensions = [], $sizeLimit)
|
||||||
|
@ -197,9 +200,9 @@ class qqFileUploader
|
||||||
$this->sizeLimit = $sizeLimit;
|
$this->sizeLimit = $sizeLimit;
|
||||||
|
|
||||||
if (isset($_GET['qqfile'])) {
|
if (isset($_GET['qqfile'])) {
|
||||||
$this->file = new qqUploadedFileXhr();
|
$this->file = new js_upload_qqUploadedFileXhr();
|
||||||
} elseif (isset($_FILES['qqfile'])) {
|
} elseif (isset($_FILES['qqfile'])) {
|
||||||
$this->file = new qqUploadedFileForm();
|
$this->file = new js_upload_qqUploadedFileForm();
|
||||||
} else {
|
} else {
|
||||||
$this->file = false;
|
$this->file = false;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +237,7 @@ class qqFileUploader
|
||||||
$filename = $pathinfo['filename'];
|
$filename = $pathinfo['filename'];
|
||||||
|
|
||||||
if (!isset($pathinfo['extension'])) {
|
if (!isset($pathinfo['extension'])) {
|
||||||
Logger::warning('extension isn\'t set.', ['filename' => $filename]);
|
DI::logger()->warning('extension isn\'t set.', ['filename' => $filename]);
|
||||||
}
|
}
|
||||||
$ext = $pathinfo['extension'] ?? '';
|
$ext = $pathinfo['extension'] ?? '';
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,7 @@
|
||||||
* Author: Ryan <https://verya.pe/profile/ryan>
|
* Author: Ryan <https://verya.pe/profile/ryan>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -38,7 +36,7 @@ function keycloakpassword_request($client_id, $secret, $url, $params = [])
|
||||||
$res = curl_exec($ch);
|
$res = curl_exec($ch);
|
||||||
|
|
||||||
if (curl_errno($ch)) {
|
if (curl_errno($ch)) {
|
||||||
Logger::error(curl_error($ch));
|
DI::logger()->error(curl_error($ch));
|
||||||
}
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
|
@ -92,7 +90,7 @@ function keycloakpassword_authenticate(array &$b)
|
||||||
$client_id,
|
$client_id,
|
||||||
$secret,
|
$secret,
|
||||||
$endpoint . '/logout',
|
$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
|
*"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin Majere
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -32,7 +30,7 @@ function krynn_install()
|
||||||
Hook::register('addon_settings', 'addon/krynn/krynn.php', 'krynn_settings');
|
Hook::register('addon_settings', 'addon/krynn/krynn.php', 'krynn_settings');
|
||||||
Hook::register('addon_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post');
|
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)
|
function krynn_post_hook(&$item)
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
* License: MIT
|
* License: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
@ -148,6 +147,8 @@ function langfilter_prepare_body_content_filter(&$hook_data)
|
||||||
|
|
||||||
$iso639 = new Matriphe\ISO639\ISO639;
|
$iso639 = new Matriphe\ISO639\ISO639;
|
||||||
|
|
||||||
|
$confidence = null;
|
||||||
|
|
||||||
// Extract the language of the post
|
// Extract the language of the post
|
||||||
if (!empty($hook_data['item']['language'])) {
|
if (!empty($hook_data['item']['language'])) {
|
||||||
$languages = json_decode($hook_data['item']['language'], true);
|
$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
|
* 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\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -45,7 +43,7 @@ function ldapauth_install()
|
||||||
|
|
||||||
function ldapauth_load_config(ConfigFileManager $loader)
|
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)
|
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');
|
$ldap_autocreateaccount_nameattribute = DI::config()->get('ldapauth', 'ldap_autocreateaccount_nameattribute');
|
||||||
|
|
||||||
if (!extension_loaded('ldap') || !strlen($ldap_server)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strlen($password)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$connect = @ldap_connect($ldap_server);
|
$connect = @ldap_connect($ldap_server);
|
||||||
if ($connect === false) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
|
@ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||||
@ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
|
@ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
|
||||||
if ((@ldap_bind($connect, $ldap_binddn, $ldap_bindpw)) === false) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = @ldap_search($connect, $ldap_searchdn, $ldap_userattr . '=' . $username);
|
$res = @ldap_search($connect, $ldap_searchdn, $ldap_userattr . '=' . $username);
|
||||||
if (!$res) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = @ldap_first_entry($connect, $res);
|
$id = @ldap_first_entry($connect, $res);
|
||||||
if (!$id) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dn = @ldap_get_dn($connect, $id);
|
$dn = @ldap_get_dn($connect, $id);
|
||||||
if (!@ldap_bind($connect, $dn, $password)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($ldap_group) && @ldap_compare($connect, $ldap_group, 'member', $dn) !== true) {
|
if (strlen($ldap_group) && @ldap_compare($connect, $ldap_group, 'member', $dn) !== true) {
|
||||||
$errno = @ldap_errno($connect);
|
$errno = @ldap_errno($connect);
|
||||||
if ($errno === 32) {
|
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) {
|
} 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 {
|
} 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);
|
@ldap_close($connect);
|
||||||
|
@ -141,7 +139,7 @@ function ldapauth_authenticate($username, $password)
|
||||||
$authentication = User::getAuthenticationInfo($username);
|
$authentication = User::getAuthenticationInfo($username);
|
||||||
return User::getById($authentication['uid']);
|
return User::getById($authentication['uid']);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Logger::notice('LDAP authentication error: ' . $e->getMessage());
|
DI::logger()->notice('LDAP authentication error: ' . $e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +147,7 @@ function ldapauth_authenticate($username, $password)
|
||||||
function ldap_createaccount($username, $password, $email, $name)
|
function ldap_createaccount($username, $password, $email, $name)
|
||||||
{
|
{
|
||||||
if (!strlen($email) || !strlen($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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,10 +159,10 @@ function ldap_createaccount($username, $password, $email, $name)
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
'verified' => 1
|
'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;
|
return $user;
|
||||||
} catch (Exception $ex) {
|
} 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;
|
return false;
|
||||||
|
|
|
@ -6,9 +6,7 @@
|
||||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
function leistungsschutzrecht_install()
|
function leistungsschutzrecht_install()
|
||||||
|
@ -149,7 +147,7 @@ function leistungsschutzrecht_is_member_site(string $url): bool
|
||||||
$cleanedurlpart = explode('%', $urldata['host']);
|
$cleanedurlpart = explode('%', $urldata['host']);
|
||||||
|
|
||||||
$hostname = explode('.', $cleanedurlpart[0]);
|
$hostname = explode('.', $cleanedurlpart[0]);
|
||||||
if (empty($hostname)) {
|
if ($hostname === false || $hostname === '') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +167,7 @@ function leistungsschutzrecht_cron($b)
|
||||||
if ($last) {
|
if ($last) {
|
||||||
$next = $last + 86400;
|
$next = $last + 86400;
|
||||||
if ($next > time()) {
|
if ($next > time()) {
|
||||||
Logger::notice('poll intervall not reached');
|
DI::logger()->notice('poll intervall not reached');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
* Author: Tony Baldwin <https://free-haven.org/u/tony>
|
* Author: Tony Baldwin <https://free-haven.org/u/tony>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -131,7 +129,7 @@ function libertree_post_local(array &$b)
|
||||||
|
|
||||||
function libertree_send(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'])) {
|
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
|
||||||
return;
|
return;
|
||||||
|
@ -197,6 +195,6 @@ function libertree_send(array &$b)
|
||||||
];
|
];
|
||||||
|
|
||||||
$result = DI::httpClient()->post($ltree_blog, $params)->getBodyString();
|
$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()
|
* @param array $options Array of options for getUrl()
|
||||||
*
|
*
|
||||||
* @return void
|
* @return array
|
||||||
* @throws Exception When an invalid option is used
|
* @throws Exception When an invalid option is used
|
||||||
*/
|
*/
|
||||||
protected function checkOptionsArray($options)
|
protected function checkOptionsArray($options)
|
||||||
|
@ -401,9 +401,8 @@ class Services_Libravatar
|
||||||
*/
|
*/
|
||||||
protected function srvGet($domain, $https = false)
|
protected function srvGet($domain, $https = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Are we going secure? Set up a fallback too.
|
// Are we going secure? Set up a fallback too.
|
||||||
if (isset($https) && $https === true) {
|
if ($https === true) {
|
||||||
$subdomain = '_avatars-sec._tcp.';
|
$subdomain = '_avatars-sec._tcp.';
|
||||||
$fallback = 'seccdn.';
|
$fallback = 'seccdn.';
|
||||||
} else {
|
} else {
|
||||||
|
@ -426,6 +425,7 @@ class Services_Libravatar
|
||||||
|
|
||||||
$top = $srv[0];
|
$top = $srv[0];
|
||||||
$sum = 0;
|
$sum = 0;
|
||||||
|
$pri = [];
|
||||||
|
|
||||||
// Try to adhere to RFC2782's weighting algorithm, page 3
|
// Try to adhere to RFC2782's weighting algorithm, page 3
|
||||||
// "arrange all SRV RRs (that have not been ordered yet) in any order,
|
// "arrange all SRV RRs (that have not been ordered yet) in any order,
|
||||||
|
@ -462,6 +462,8 @@ class Services_Libravatar
|
||||||
return $v['target'];
|
return $v['target'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
|
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||||
|
@ -21,12 +19,12 @@ function libravatar_install()
|
||||||
{
|
{
|
||||||
Hook::register('load_config', 'addon/libravatar/libravatar.php', 'libravatar_load_config');
|
Hook::register('load_config', 'addon/libravatar/libravatar.php', 'libravatar_load_config');
|
||||||
Hook::register('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup');
|
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)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,10 +8,8 @@
|
||||||
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
* Author: Cat Gray <https://free-haven.org/profile/catness>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
|
@ -201,12 +199,14 @@ function ljpost_send(array &$b)
|
||||||
</methodCall>
|
</methodCall>
|
||||||
EOT;
|
EOT;
|
||||||
|
|
||||||
Logger::debug('ljpost: data: ' . $xml);
|
DI::logger()->debug('ljpost: data: ' . $xml);
|
||||||
|
|
||||||
|
$x = '';
|
||||||
|
|
||||||
if ($lj_blog !== 'test') {
|
if ($lj_blog !== 'test') {
|
||||||
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
|
$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\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
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('post_remote_end', 'addon/mailstream/mailstream.php', 'mailstream_post_hook');
|
||||||
Hook::register('mailstream_send_hook', 'addon/mailstream/mailstream.php', 'mailstream_send_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();
|
$host = DI::baseUrl()->getHost();
|
||||||
$resource = hash('md5', $uri);
|
$resource = hash('md5', $uri);
|
||||||
$message_id = "<" . $resource . "@" . $host . ">";
|
$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;
|
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']);
|
$criteria = array('uid' => $data['uid'], 'contact-id' => $data['contact-id'], 'uri' => $data['uri']);
|
||||||
$item = Post::selectFirst([], $criteria);
|
$item = Post::selectFirst([], $criteria);
|
||||||
if (empty($item)) {
|
if (empty($item)) {
|
||||||
Logger::error('could not find item');
|
DI::logger()->error('could not find item');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::getById($item['uid']);
|
$user = User::getById($item['uid']);
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
Logger::error('could not find user', ['uid' => $item['uid']]);
|
DI::logger()->error('could not find user', ['uid' => $item['uid']]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mailstream_send($data['message_id'], $item, $user)) {
|
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()) {
|
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)
|
function mailstream_post_hook(array &$item)
|
||||||
{
|
{
|
||||||
if ($item['uid'] === 0) {
|
if ($item['uid'] === 0) {
|
||||||
Logger::debug('mailstream: root user, skipping item ' . $item['id']);
|
DI::logger()->debug('mailstream: root user, skipping item ' . $item['id']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!DI::pConfig()->get($item['uid'], 'mailstream', 'enabled')) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (!$item['contact-id']) {
|
if (!$item['contact-id']) {
|
||||||
Logger::debug('no contact-id', ['item' => $item['id']]);
|
DI::logger()->debug('no contact-id', ['item' => $item['id']]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$item['uri']) {
|
if (!$item['uri']) {
|
||||||
Logger::debug('no uri', ['item' => $item['id']]);
|
DI::logger()->debug('no uri', ['item' => $item['id']]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($item['verb'] == Activity::ANNOUNCE) {
|
if ($item['verb'] == Activity::ANNOUNCE) {
|
||||||
Logger::debug('ignoring announce', ['item' => $item['id']]);
|
DI::logger()->debug('ignoring announce', ['item' => $item['id']]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DI::pConfig()->get($item['uid'], 'mailstream', 'nolikes')) {
|
if (DI::pConfig()->get($item['uid'], 'mailstream', 'nolikes')) {
|
||||||
if ($item['verb'] == Activity::LIKE) {
|
if ($item['verb'] == Activity::LIKE) {
|
||||||
Logger::debug('ignoring like', ['item' => $item['id']]);
|
DI::logger()->debug('ignoring like', ['item' => $item['id']]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($item['verb'] == Activity::DISLIKE) {
|
if ($item['verb'] == Activity::DISLIKE) {
|
||||||
Logger::debug('ignoring dislike', ['item' => $item['id']]);
|
DI::logger()->debug('ignoring dislike', ['item' => $item['id']]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +199,7 @@ function mailstream_do_images(array &$item, array &$attachments)
|
||||||
try {
|
try {
|
||||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::DEFAULT, [HttpClientOptions::COOKIEJAR => $cookiejar]);
|
$curlResult = DI::httpClient()->get($url, HttpClientAccept::DEFAULT, [HttpClientOptions::COOKIEJAR => $cookiejar]);
|
||||||
if (!$curlResult->isSuccess()) {
|
if (!$curlResult->isSuccess()) {
|
||||||
Logger::debug('mailstream: fetch image url failed', [
|
DI::logger()->debug('mailstream: fetch image url failed', [
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'item_id' => $item['id'],
|
'item_id' => $item['id'],
|
||||||
'return_code' => $curlResult->getReturnCode()
|
'return_code' => $curlResult->getReturnCode()
|
||||||
|
@ -208,7 +207,7 @@ function mailstream_do_images(array &$item, array &$attachments)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} catch (InvalidArgumentException $e) {
|
} 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;
|
continue;
|
||||||
}
|
}
|
||||||
$attachments[$url] = [
|
$attachments[$url] = [
|
||||||
|
@ -309,7 +308,7 @@ function mailstream_subject(array $item): string
|
||||||
}
|
}
|
||||||
$contact = Contact::selectFirst([], ['id' => $item['contact-id'], 'uid' => $item['uid']]);
|
$contact = Contact::selectFirst([], ['id' => $item['contact-id'], 'uid' => $item['uid']]);
|
||||||
if (!DBA::isResult($contact)) {
|
if (!DBA::isResult($contact)) {
|
||||||
Logger::error('no contact', [
|
DI::logger()->error('no contact', [
|
||||||
'item' => $item['id'],
|
'item' => $item['id'],
|
||||||
'plink' => $item['plink'],
|
'plink' => $item['plink'],
|
||||||
'contact id' => $item['contact-id'],
|
'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
|
function mailstream_send(string $message_id, array $item, array $user): bool
|
||||||
{
|
{
|
||||||
if (!is_array($item)) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$item['visible']) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$message_id) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +377,7 @@ function mailstream_send(string $message_id, array $item, array $user): bool
|
||||||
if (!$address) {
|
if (!$address) {
|
||||||
$address = $user['email'];
|
$address = $user['email'];
|
||||||
}
|
}
|
||||||
$mail = new PHPmailer();
|
$mail = new PHPMailer();
|
||||||
try {
|
try {
|
||||||
$mail->XMailer = 'Friendica Mailstream Addon';
|
$mail->XMailer = 'Friendica Mailstream Addon';
|
||||||
$mail->SetFrom($frommail, mailstream_sender($item));
|
$mail->SetFrom($frommail, mailstream_sender($item));
|
||||||
|
@ -418,15 +417,15 @@ function mailstream_send(string $message_id, array $item, array $user): bool
|
||||||
if (!$mail->Send()) {
|
if (!$mail->Send()) {
|
||||||
throw new Exception($mail->ErrorInfo);
|
throw new Exception($mail->ErrorInfo);
|
||||||
}
|
}
|
||||||
Logger::debug('sent message', [
|
DI::logger()->debug('sent message', [
|
||||||
'message ID' => $mail->MessageID,
|
'message ID' => $mail->MessageID,
|
||||||
'subject' => $mail->Subject,
|
'subject' => $mail->Subject,
|
||||||
'address' => $address
|
'address' => $address
|
||||||
]);
|
]);
|
||||||
} catch (phpmailerException $e) {
|
} 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) {
|
} 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;
|
return true;
|
||||||
|
|
|
@ -2690,10 +2690,10 @@ class PHPMailer
|
||||||
if (!is_readable($path)) {
|
if (!is_readable($path)) {
|
||||||
throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
|
throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
|
||||||
}
|
}
|
||||||
$magic_quotes = get_magic_quotes_runtime();
|
$magic_quotes = false;
|
||||||
if ($magic_quotes) {
|
if ($magic_quotes) {
|
||||||
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
|
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
|
||||||
set_magic_quotes_runtime(false);
|
//set_magic_quotes_runtime(false);
|
||||||
} else {
|
} else {
|
||||||
//Doesn't exist in PHP 5.4, but we don't need to check because
|
//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+
|
//get_magic_quotes_runtime always returns false in 5.4+
|
||||||
|
@ -2705,7 +2705,7 @@ class PHPMailer
|
||||||
$file_buffer = $this->encodeString($file_buffer, $encoding);
|
$file_buffer = $this->encodeString($file_buffer, $encoding);
|
||||||
if ($magic_quotes) {
|
if ($magic_quotes) {
|
||||||
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
|
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
|
||||||
set_magic_quotes_runtime($magic_quotes);
|
//set_magic_quotes_runtime($magic_quotes);
|
||||||
} else {
|
} else {
|
||||||
ini_set('magic_quotes_runtime', $magic_quotes);
|
ini_set('magic_quotes_runtime', $magic_quotes);
|
||||||
}
|
}
|
||||||
|
@ -3286,7 +3286,7 @@ class PHPMailer
|
||||||
$result = 'localhost.localdomain';
|
$result = 'localhost.localdomain';
|
||||||
if (!empty($this->Hostname)) {
|
if (!empty($this->Hostname)) {
|
||||||
$result = $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'];
|
$result = $_SERVER['SERVER_NAME'];
|
||||||
} elseif (function_exists('gethostname') && gethostname() !== false) {
|
} elseif (function_exists('gethostname') && gethostname() !== false) {
|
||||||
$result = gethostname();
|
$result = gethostname();
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
* Version: 0.1
|
* Version: 0.1
|
||||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||||
*/
|
*/
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Content\Text\Markdown;
|
use Friendica\Content\Text\Markdown;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
|
@ -27,7 +26,7 @@ function markdown_addon_settings(array &$data)
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/');
|
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/');
|
||||||
$html = Renderer::replaceMacros($t, [
|
$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 = [
|
$data = [
|
||||||
|
@ -43,7 +42,7 @@ function markdown_addon_settings_post(array &$b)
|
||||||
return;
|
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) {
|
function markdown_post_local_start(&$request) {
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* License: 3-clause BSD license
|
* License: 3-clause BSD license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
* Status: Unsupported
|
* Status: Unsupported
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\User;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
function membersince_install()
|
function membersince_install()
|
||||||
|
@ -19,7 +19,19 @@ function membersince_install()
|
||||||
|
|
||||||
function membersince_display(array &$b)
|
function membersince_display(array &$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.
|
// Works in Frio.
|
||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
$doc->loadHTML(mb_convert_encoding($b, 'HTML-ENTITIES', 'UTF-8'));
|
$doc->loadHTML(mb_convert_encoding($b, 'HTML-ENTITIES', 'UTF-8'));
|
||||||
|
@ -39,7 +51,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');
|
$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.
|
// 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');
|
$entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry');
|
||||||
|
|
||||||
$div->appendChild($hr);
|
$div->appendChild($hr);
|
||||||
|
@ -50,6 +62,6 @@ function membersince_display(array &$b)
|
||||||
$b = $doc->saveHTML();
|
$b = $doc->saveHTML();
|
||||||
} else {
|
} else {
|
||||||
// Works in Vier.
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* Status: Deprecated
|
* Status: Deprecated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
* Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
|
* Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
|
||||||
***/
|
***/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -17,7 +15,7 @@ use Friendica\Model\User;
|
||||||
function newmemberwidget_install()
|
function newmemberwidget_install()
|
||||||
{
|
{
|
||||||
Hook::register( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
|
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)
|
function newmemberwidget_network_mod_init ($b)
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
|
@ -6,9 +6,7 @@
|
||||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
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);
|
$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)) {
|
if (empty($s)) {
|
||||||
Logger::info('API could not be queried');
|
DI::logger()->info('API could not be queried');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = json_decode($s, true);
|
$data = json_decode($s, true);
|
||||||
if (empty($data['display_name'])) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item['location'] = $data['display_name'];
|
$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'])) {
|
if (!empty($item['location'])) {
|
||||||
DI::cache()->set('nominatim:' . $language . ':' . $coords[0] . '-' . $coords[1], $item['location']);
|
DI::cache()->set('nominatim:' . $language . ':' . $coords[0] . '-' . $coords[1], $item['location']);
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Addon\notifyall\NotifyAllEmail;
|
use Friendica\Addon\notifyall\NotifyAllEmail;
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -119,7 +118,9 @@ function nsfw_prepare_body_content_filter(&$hook_data)
|
||||||
$word_list = ['nsfw'];
|
$word_list = ['nsfw'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
|
$tag_search = false;
|
||||||
|
|
||||||
if (count($word_list)) {
|
if (count($word_list)) {
|
||||||
$body = $hook_data['item']['title'] . "\n" . nsfw_extract_photos($hook_data['item']['body']);
|
$body = $hook_data['item']['title'] . "\n" . nsfw_extract_photos($hook_data['item']['body']);
|
||||||
|
|
||||||
|
@ -129,7 +130,6 @@ function nsfw_prepare_body_content_filter(&$hook_data)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tag_search = false;
|
|
||||||
switch ($word[0]) {
|
switch ($word[0]) {
|
||||||
case '/'; // Regular expression
|
case '/'; // Regular expression
|
||||||
$found = @preg_match($word, $body);
|
$found = @preg_match($word, $body);
|
||||||
|
|
|
@ -6,9 +6,7 @@
|
||||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -17,7 +15,7 @@ function numfriends_install() {
|
||||||
Hook::register('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
|
Hook::register('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
|
||||||
Hook::register('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
|
Hook::register('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
|
||||||
|
|
||||||
Logger::notice("installed numfriends");
|
DI::logger()->notice("installed numfriends");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +37,7 @@ function numfriends_settings_post($post) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Called from the Addon Setting form.
|
* Called from the Addon Setting form.
|
||||||
* Add our own settings info to the page.
|
* Add our own settings info to the page.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -50,7 +48,7 @@ function numfriends_settings(array &$data)
|
||||||
}
|
}
|
||||||
|
|
||||||
$numfriends = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'display_friend_count', 24);
|
$numfriends = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'display_friend_count', 24);
|
||||||
|
|
||||||
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/numfriends/');
|
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/numfriends/');
|
||||||
$html = Renderer::replaceMacros($t, [
|
$html = Renderer::replaceMacros($t, [
|
||||||
'$numfriends' => ['numfriends', DI::l10n()->t('How many contacts to display on profile sidebar'), $numfriends],
|
'$numfriends' => ['numfriends', DI::l10n()->t('How many contacts to display on profile sidebar'), $numfriends],
|
||||||
|
|
|
@ -9,10 +9,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Cache\Enum\Duration;
|
use Friendica\Core\Cache\Enum\Duration;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
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('Map::getCoordinates', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_get_coordinates');
|
||||||
Hook::register('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader');
|
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)
|
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)
|
function openstreetmap_alterheader(&$navHtml)
|
||||||
|
@ -155,8 +153,8 @@ function openstreetmap_generate_map(array &$b)
|
||||||
$lat = $b['lat']; // round($b['lat'], 5);
|
$lat = $b['lat']; // round($b['lat'], 5);
|
||||||
$lon = $b['lon']; // round($b['lon'], 5);
|
$lon = $b['lon']; // round($b['lon'], 5);
|
||||||
|
|
||||||
Logger::debug('lat: ' . $lat);
|
DI::logger()->debug('lat: ' . $lat);
|
||||||
Logger::debug('lon: ' . $lon);
|
DI::logger()->debug('lon: ' . $lon);
|
||||||
|
|
||||||
$cardlink = '<a href="' . $tmsserver;
|
$cardlink = '<a href="' . $tmsserver;
|
||||||
|
|
||||||
|
@ -174,7 +172,7 @@ function openstreetmap_generate_map(array &$b)
|
||||||
$b['html'] .= '<br/>' . $cardlink;
|
$b['html'] .= '<br/>' . $cardlink;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::debug('generate_map: ' . $b['html']);
|
DI::logger()->debug('generate_map: ' . $b['html']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openstreetmap_addon_admin(string &$o)
|
function openstreetmap_addon_admin(string &$o)
|
||||||
|
|
|
@ -8,12 +8,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
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\Core\Protocol;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -22,7 +17,7 @@ function opmlexport_install()
|
||||||
{
|
{
|
||||||
Hook::register('addon_settings', __FILE__, 'opmlexport_addon_settings');
|
Hook::register('addon_settings', __FILE__, 'opmlexport_addon_settings');
|
||||||
Hook::register('addon_settings_post', __FILE__, 'opmlexport_addon_settings_post');
|
Hook::register('addon_settings_post', __FILE__, 'opmlexport_addon_settings_post');
|
||||||
Logger::notice('installed opmlexport Addon');
|
DI::logger()->notice('installed opmlexport Addon');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,9 @@
|
||||||
* Version: 1.1
|
* Version: 1.1
|
||||||
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
|
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
|
||||||
* Hauke Altmann <https://snarl.de/profile/tugelblend>
|
* Hauke Altmann <https://snarl.de/profile/tugelblend>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
* Maintainer: Hypolite Petovan <hypolite@friendica.mrpetovan.com>
|
* Maintainer: Hypolite Petovan <hypolite@friendica.mrpetovan.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Object\EMail\IEmail;
|
use Friendica\Object\EMail\IEmail;
|
||||||
|
@ -25,7 +24,7 @@ function phpmailer_install()
|
||||||
|
|
||||||
function phpmailer_load_config(ConfigFileManager $loader)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,9 +35,7 @@
|
||||||
* setting.
|
* setting.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||||
|
@ -46,12 +44,12 @@ function piwik_install() {
|
||||||
Hook::register('load_config', 'addon/piwik/piwik.php', 'piwik_load_config');
|
Hook::register('load_config', 'addon/piwik/piwik.php', 'piwik_load_config');
|
||||||
Hook::register('page_end', 'addon/piwik/piwik.php', 'piwik_analytics');
|
Hook::register('page_end', 'addon/piwik/piwik.php', 'piwik_analytics');
|
||||||
|
|
||||||
Logger::notice("installed piwik addon");
|
DI::logger()->notice("installed piwik addon");
|
||||||
}
|
}
|
||||||
|
|
||||||
function piwik_load_config(ConfigFileManager $loader)
|
function piwik_load_config(ConfigFileManager $loader)
|
||||||
{
|
{
|
||||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('piwik'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('piwik'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
function piwik_analytics(string &$b)
|
function piwik_analytics(string &$b)
|
||||||
|
@ -76,7 +74,7 @@ function piwik_analytics(string &$b)
|
||||||
* Add the Piwik tracking code for the site.
|
* Add the Piwik tracking code for the site.
|
||||||
* If async is set to true use asynchronous tracking
|
* If async is set to true use asynchronous tracking
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$scriptAsyncValue = $async ? 'true' : 'false';
|
$scriptAsyncValue = $async ? 'true' : 'false';
|
||||||
$scriptPhpEndpoint = $shortendpoint ? 'js/' : 'piwik.php';
|
$scriptPhpEndpoint = $shortendpoint ? 'js/' : 'piwik.php';
|
||||||
$scriptJsEndpoint = $shortendpoint ? 'js/' : 'piwik.js';
|
$scriptJsEndpoint = $shortendpoint ? 'js/' : 'piwik.js';
|
||||||
|
|
|
@ -7,9 +7,7 @@
|
||||||
* Author: Tony Baldwin <https://free-haven.org/profile/tony>
|
* Author: Tony Baldwin <https://free-haven.org/profile/tony>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -29,7 +27,7 @@ function planets_install()
|
||||||
Hook::register('addon_settings', 'addon/planets/planets.php', 'planets_settings');
|
Hook::register('addon_settings', 'addon/planets/planets.php', 'planets_settings');
|
||||||
Hook::register('addon_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
|
Hook::register('addon_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
|
||||||
|
|
||||||
Logger::notice("installed planets");
|
DI::logger()->notice("installed planets");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +38,7 @@ function planets_install()
|
||||||
*/
|
*/
|
||||||
function planets_post_hook(&$item)
|
function planets_post_hook(&$item)
|
||||||
{
|
{
|
||||||
Logger::notice('planets invoked');
|
DI::logger()->notice('planets invoked');
|
||||||
|
|
||||||
if (!DI::userSession()->getLocalUserId()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
/* non-zero if this is a logged in user of this system */
|
/* non-zero if this is a logged in user of this system */
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace phpnut;
|
namespace phpnut;
|
||||||
|
|
||||||
|
use CURLFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* phpnut.php
|
* phpnut.php
|
||||||
* pnut.io PHP library
|
* pnut.io PHP library
|
||||||
|
@ -99,10 +101,14 @@ class phpnut
|
||||||
// if processing stream_markers or any fast stream, decrease $sleepFor
|
// if processing stream_markers or any fast stream, decrease $sleepFor
|
||||||
public $streamingSleepFor = 20000;
|
public $streamingSleepFor = 20000;
|
||||||
|
|
||||||
|
private $_clientId;
|
||||||
|
|
||||||
|
private $_clientSecret;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an phpnut PHP object with the specified client ID and
|
* Constructs an phpnut PHP object with the specified client ID and
|
||||||
* client secret.
|
* client secret.
|
||||||
* @param string $client_id The client ID you received from pnut.io when
|
* @param string $client_id_or_token The client ID you received from pnut.io when
|
||||||
* creating your app.
|
* creating your app.
|
||||||
* @param string $client_secret The client secret you received from
|
* @param string $client_secret The client secret you received from
|
||||||
* pnut.io when creating your app.
|
* pnut.io when creating your app.
|
||||||
|
@ -155,14 +161,14 @@ class phpnut
|
||||||
* or not access to your app. Usually you would place this as a link for
|
* or not access to your app. Usually you would place this as a link for
|
||||||
* the user to client, or a redirect to send them to the auth URL.
|
* the user to client, or a redirect to send them to the auth URL.
|
||||||
* Also can be called after authentication for additional scopes
|
* Also can be called after authentication for additional scopes
|
||||||
* @param string $callbackUri Where you want the user to be directed
|
* @param string $callback_uri Where you want the user to be directed
|
||||||
* after authenticating with pnut.io. This must be one of the URIs
|
* after authenticating with pnut.io. This must be one of the URIs
|
||||||
* allowed by your pnut.io application settings.
|
* allowed by your pnut.io application settings.
|
||||||
* @param array $scope An array of scopes (permissions) you wish to obtain
|
* @param array $scope An array of scopes (permissions) you wish to obtain
|
||||||
* from the user. If you don't specify anything, you'll only receive
|
* from the user. If you don't specify anything, you'll only receive
|
||||||
* access to the user's basic profile (the default).
|
* access to the user's basic profile (the default).
|
||||||
*/
|
*/
|
||||||
public function getAuthUrl(?string $callback_uri=null, array|string|null $scope=null): string
|
public function getAuthUrl(?string $callback_uri=null, array $scope=null): string
|
||||||
{
|
{
|
||||||
if (empty($this->_clientId)) {
|
if (empty($this->_clientId)) {
|
||||||
throw new phpnutException('You must specify your pnut client ID');
|
throw new phpnutException('You must specify your pnut client ID');
|
||||||
|
@ -256,8 +262,10 @@ class phpnut
|
||||||
/**
|
/**
|
||||||
* Check the scope of current token to see if it has required scopes
|
* Check the scope of current token to see if it has required scopes
|
||||||
* has to be done after a check
|
* has to be done after a check
|
||||||
|
*
|
||||||
|
* @return int|array
|
||||||
*/
|
*/
|
||||||
public function checkScopes(array $app_scopes): int|array
|
public function checkScopes(array $app_scopes)
|
||||||
{
|
{
|
||||||
if (count($this->_scopes) === 0) {
|
if (count($this->_scopes) === 0) {
|
||||||
return -1; // _scope is empty
|
return -1; // _scope is empty
|
||||||
|
@ -303,7 +311,7 @@ class phpnut
|
||||||
{
|
{
|
||||||
return $this->httpReq('delete', "{$this->_baseUrl}token");
|
return $this->httpReq('delete', "{$this->_baseUrl}token");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve an app access token from the app.net API. This allows you
|
* Retrieve an app access token from the app.net API. This allows you
|
||||||
* to access the API without going through the user access flow if you
|
* to access the API without going through the user access flow if you
|
||||||
|
@ -314,7 +322,7 @@ class phpnut
|
||||||
* @return string The app access token
|
* @return string The app access token
|
||||||
*/
|
*/
|
||||||
public function getAppAccessToken()
|
public function getAppAccessToken()
|
||||||
{
|
{
|
||||||
if (empty($this->_clientId) || empty($this->_clientSecret)) {
|
if (empty($this->_clientId) || empty($this->_clientSecret)) {
|
||||||
throw new phpnutException('You must specify your Pnut client ID and client secret');
|
throw new phpnutException('You must specify your Pnut client ID and client secret');
|
||||||
}
|
}
|
||||||
|
@ -450,8 +458,10 @@ class phpnut
|
||||||
/**
|
/**
|
||||||
* Internal function to handle all
|
* Internal function to handle all
|
||||||
* HTTP requests (POST,PUT,GET,DELETE)
|
* HTTP requests (POST,PUT,GET,DELETE)
|
||||||
|
*
|
||||||
|
* @param string|array $params
|
||||||
*/
|
*/
|
||||||
protected function httpReq(string $act, string $req, string|array $params=[], string $contentType='application/x-www-form-urlencoded')
|
protected function httpReq(string $act, string $req, $params = [], string $contentType='application/x-www-form-urlencoded')
|
||||||
{
|
{
|
||||||
$ch = curl_init($req);
|
$ch = curl_init($req);
|
||||||
$headers = [];
|
$headers = [];
|
||||||
|
@ -520,7 +530,7 @@ class phpnut
|
||||||
} else {
|
} else {
|
||||||
throw new phpnutException($response['error']);
|
throw new phpnutException($response['error']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// look for response migration errors
|
// look for response migration errors
|
||||||
elseif (isset($response['meta'], $response['meta']['error_message'])) {
|
elseif (isset($response['meta'], $response['meta']['error_message'])) {
|
||||||
|
@ -588,7 +598,7 @@ class phpnut
|
||||||
{
|
{
|
||||||
return $this->_last_request;
|
return $this->_last_request;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastResponse()
|
public function getLastResponse()
|
||||||
{
|
{
|
||||||
return $this->_last_response;
|
return $this->_last_response;
|
||||||
|
@ -738,7 +748,7 @@ class phpnut
|
||||||
* Delete a Post. The current user must be the same user who created the Post.
|
* Delete a Post. The current user must be the same user who created the Post.
|
||||||
* It returns the deleted Post on success.
|
* It returns the deleted Post on success.
|
||||||
* @param integer $post_id The ID of the post to delete
|
* @param integer $post_id The ID of the post to delete
|
||||||
* @param array An associative array representing the post that was deleted
|
* @return array An associative array representing the post that was deleted
|
||||||
*/
|
*/
|
||||||
public function deletePost(int $post_id)
|
public function deletePost(int $post_id)
|
||||||
{
|
{
|
||||||
|
@ -752,7 +762,7 @@ class phpnut
|
||||||
* Retrieve the Posts that are 'in reply to' a specific Post.
|
* Retrieve the Posts that are 'in reply to' a specific Post.
|
||||||
* @param integer $post_id The ID of the post you want to retrieve replies for.
|
* @param integer $post_id The ID of the post you want to retrieve replies for.
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function getPostThread(int $post_id, array $params=[])
|
public function getPostThread(int $post_id, array $params=[])
|
||||||
{
|
{
|
||||||
|
@ -767,7 +777,7 @@ class phpnut
|
||||||
* Retrieve revisions of a post. Currently only one can be created.
|
* Retrieve revisions of a post. Currently only one can be created.
|
||||||
* @param integer $post_id The ID of the post you want to retrieve previous revisions of.
|
* @param integer $post_id The ID of the post you want to retrieve previous revisions of.
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function getPostRevisions(int $post_id, array $params=[])
|
public function getPostRevisions(int $post_id, array $params=[])
|
||||||
{
|
{
|
||||||
|
@ -781,13 +791,13 @@ class phpnut
|
||||||
/**
|
/**
|
||||||
* Get the most recent Posts created by a specific User in reverse
|
* Get the most recent Posts created by a specific User in reverse
|
||||||
* chronological order (most recent first).
|
* chronological order (most recent first).
|
||||||
* @param mixed $user_id Either the ID of the user you wish to retrieve posts by,
|
* @param string|int $user_id $user_id Either the ID of the user you wish to retrieve posts by,
|
||||||
* or the string "me", which will retrieve posts for the user you're authenticated
|
* or the string "me", which will retrieve posts for the user you're authenticated
|
||||||
* as.
|
* as.
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function getUserPosts(string|int $user_id='me', array $params=[])
|
public function getUserPosts($user_id = 'me', array $params=[])
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'get',
|
'get',
|
||||||
|
@ -799,13 +809,13 @@ class phpnut
|
||||||
/**
|
/**
|
||||||
* Get the most recent Posts mentioning by a specific User in reverse
|
* Get the most recent Posts mentioning by a specific User in reverse
|
||||||
* chronological order (newest first).
|
* chronological order (newest first).
|
||||||
* @param mixed $user_id Either the ID of the user who is being mentioned, or
|
* @param string|int $user_id Either the ID of the user who is being mentioned, or
|
||||||
* the string "me", which will retrieve posts for the user you're authenticated
|
* the string "me", which will retrieve posts for the user you're authenticated
|
||||||
* as.
|
* as.
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function getUserMentions(string|int $user_id='me', array $params=[])
|
public function getUserMentions($user_id='me', array $params=[])
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'get',
|
'get',
|
||||||
|
@ -817,7 +827,7 @@ class phpnut
|
||||||
/**
|
/**
|
||||||
* Get the currently authenticated user's recent messages
|
* Get the currently authenticated user's recent messages
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function getUserMessages(array $params=[])
|
public function getUserMessages(array $params=[])
|
||||||
{
|
{
|
||||||
|
@ -832,7 +842,7 @@ class phpnut
|
||||||
* Return the 20 most recent posts from the current User and
|
* Return the 20 most recent posts from the current User and
|
||||||
* the Users they follow.
|
* the Users they follow.
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function getUserStream(array $params=[])
|
public function getUserStream(array $params=[])
|
||||||
{
|
{
|
||||||
|
@ -847,7 +857,7 @@ class phpnut
|
||||||
* Retrieve a list of all public Posts on pnut.io, often referred to as the
|
* Retrieve a list of all public Posts on pnut.io, often referred to as the
|
||||||
* global stream.
|
* global stream.
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function getPublicPosts(array $params=[])
|
public function getPublicPosts(array $params=[])
|
||||||
{
|
{
|
||||||
|
@ -860,7 +870,7 @@ class phpnut
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a list of "explore" streams
|
* Retrieve a list of "explore" streams
|
||||||
* @return An array of associative arrays, each representing a single explore stream.
|
* @return array An array of associative arrays, each representing a single explore stream.
|
||||||
*/
|
*/
|
||||||
public function getPostExploreStreams()
|
public function getPostExploreStreams()
|
||||||
{
|
{
|
||||||
|
@ -874,7 +884,7 @@ class phpnut
|
||||||
* Retrieve a list of posts from an "explore" stream on pnut.io.
|
* Retrieve a list of posts from an "explore" stream on pnut.io.
|
||||||
* @param string $slug [<description>]
|
* @param string $slug [<description>]
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function getPostExploreStream(string $slug, array $params=[])
|
public function getPostExploreStream(string $slug, array $params=[])
|
||||||
{
|
{
|
||||||
|
@ -916,10 +926,11 @@ class phpnut
|
||||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||||
* and include_post_raw.
|
* and include_post_raw.
|
||||||
* See https://github.com/phpnut/api-spec/blob/master/resources/posts.md#general-parameters
|
* See https://github.com/phpnut/api-spec/blob/master/resources/posts.md#general-parameters
|
||||||
|
* @param string|int $user_id
|
||||||
* @return array An array of associative arrays, each representing a single
|
* @return array An array of associative arrays, each representing a single
|
||||||
* user who has bookmarked a post
|
* user who has bookmarked a post
|
||||||
*/
|
*/
|
||||||
public function getBookmarked(string|int $user_id='me', array $params=[])
|
public function getBookmarked($user_id='me', array $params=[])
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'get',
|
'get',
|
||||||
|
@ -967,7 +978,7 @@ class phpnut
|
||||||
/**
|
/**
|
||||||
* Repost an existing Post object.
|
* Repost an existing Post object.
|
||||||
* @param integer $post_id The id of the post
|
* @param integer $post_id The id of the post
|
||||||
* @return the reposted post
|
* @return mixed the reposted post
|
||||||
*/
|
*/
|
||||||
public function repost(int $post_id)
|
public function repost(int $post_id)
|
||||||
{
|
{
|
||||||
|
@ -980,7 +991,7 @@ class phpnut
|
||||||
/**
|
/**
|
||||||
* Delete a post that the user has reposted.
|
* Delete a post that the user has reposted.
|
||||||
* @param integer $post_id The id of the post
|
* @param integer $post_id The id of the post
|
||||||
* @return the un-reposted post
|
* @return mixed the un-reposted post
|
||||||
*/
|
*/
|
||||||
public function deleteRepost(int $post_id)
|
public function deleteRepost(int $post_id)
|
||||||
{
|
{
|
||||||
|
@ -997,7 +1008,7 @@ class phpnut
|
||||||
* This will likely change as the API evolves, as of this writing allowed keys
|
* This will likely change as the API evolves, as of this writing allowed keys
|
||||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||||
* include_directed_posts, and include_raw.
|
* include_directed_posts, and include_raw.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function searchHashtags(string $hashtag, array $params=[])
|
public function searchHashtags(string $hashtag, array $params=[])
|
||||||
{
|
{
|
||||||
|
@ -1044,7 +1055,7 @@ class phpnut
|
||||||
* This will likely change as the API evolves, as of this writing allowed keys
|
* This will likely change as the API evolves, as of this writing allowed keys
|
||||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||||
* and include_post_raw.
|
* and include_post_raw.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function getUserPersonalStream(array $params=[])
|
public function getUserPersonalStream(array $params=[])
|
||||||
{
|
{
|
||||||
|
@ -1063,7 +1074,7 @@ class phpnut
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the 20 most recent Posts from the current User's personalized stream
|
* Return the 20 most recent Posts from the current User's personalized stream
|
||||||
* and mentions stream merged into one stream.
|
* and mentions stream merged into one stream.
|
||||||
|
@ -1071,7 +1082,7 @@ class phpnut
|
||||||
* This will likely change as the API evolves, as of this writing allowed keys
|
* This will likely change as the API evolves, as of this writing allowed keys
|
||||||
* are: count, before_id, since_id, include_muted, include_deleted,
|
* are: count, before_id, since_id, include_muted, include_deleted,
|
||||||
* include_directed_posts, and include_raw.
|
* include_directed_posts, and include_raw.
|
||||||
* @return An array of associative arrays, each representing a single post.
|
* @return array An array of associative arrays, each representing a single post.
|
||||||
*/
|
*/
|
||||||
public function getUserUnifiedStream(array $params=[])
|
public function getUserUnifiedStream(array $params=[])
|
||||||
{
|
{
|
||||||
|
@ -1096,14 +1107,14 @@ class phpnut
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a specific user object.
|
* Returns a specific user object.
|
||||||
* @param mixed $user_id The ID of the user you want to retrieve, or the string "@-username", or the string
|
* @param string|int $user_id The ID of the user you want to retrieve, or the string "@-username", or the string
|
||||||
* "me" to retrieve data for the users you're currently authenticated as.
|
* "me" to retrieve data for the users you're currently authenticated as.
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
* This will likely change as the API evolves, as of this writing allowed keys
|
* This will likely change as the API evolves, as of this writing allowed keys
|
||||||
* are: include_raw|include_user_raw.
|
* are: include_raw|include_user_raw.
|
||||||
* @return array An associative array representing the user data.
|
* @return array An associative array representing the user data.
|
||||||
*/
|
*/
|
||||||
public function getUser(string|int $user_id='me', array $params=[])
|
public function getUser($user_id='me', array $params=[])
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'get',
|
'get',
|
||||||
|
@ -1131,10 +1142,10 @@ class phpnut
|
||||||
/**
|
/**
|
||||||
* Add the specified user ID to the list of users followed.
|
* Add the specified user ID to the list of users followed.
|
||||||
* Returns the User object of the user being followed.
|
* Returns the User object of the user being followed.
|
||||||
* @param integer $user_id The user ID of the user to follow.
|
* @param string|int $user_id The user ID of the user to follow.
|
||||||
* @return array An associative array representing the user you just followed.
|
* @return array An associative array representing the user you just followed.
|
||||||
*/
|
*/
|
||||||
public function followUser(string|int $user_id)
|
public function followUser($user_id)
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'put',
|
'put',
|
||||||
|
@ -1145,10 +1156,10 @@ class phpnut
|
||||||
/**
|
/**
|
||||||
* Removes the specified user ID to the list of users followed.
|
* Removes the specified user ID to the list of users followed.
|
||||||
* Returns the User object of the user being unfollowed.
|
* Returns the User object of the user being unfollowed.
|
||||||
* @param integer $user_id The user ID of the user to unfollow.
|
* @param string|int $user_id The user ID of the user to unfollow.
|
||||||
* @return array An associative array representing the user you just unfollowed.
|
* @return array An associative array representing the user you just unfollowed.
|
||||||
*/
|
*/
|
||||||
public function unfollowUser(string|int $user_id)
|
public function unfollowUser($user_id)
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'delete',
|
'delete',
|
||||||
|
@ -1158,13 +1169,13 @@ class phpnut
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of User objects the specified user is following.
|
* Returns an array of User objects the specified user is following.
|
||||||
* @param mixed $user_id Either the ID of the user being followed, or
|
* @param string|int $user_id Either the ID of the user being followed, or
|
||||||
* the string "me", which will retrieve posts for the user you're authenticated
|
* the string "me", which will retrieve posts for the user you're authenticated
|
||||||
* as.
|
* as.
|
||||||
* @return array An array of associative arrays, each representing a single
|
* @return array An array of associative arrays, each representing a single
|
||||||
* user following $user_id
|
* user following $user_id
|
||||||
*/
|
*/
|
||||||
public function getFollowing(string|int $user_id='me', array $params=[])
|
public function getFollowing($user_id='me', array $params=[])
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'get',
|
'get',
|
||||||
|
@ -1172,31 +1183,31 @@ class phpnut
|
||||||
. $this->buildQueryString($params)
|
. $this->buildQueryString($params)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of User ids the specified user is following.
|
* Returns an array of User ids the specified user is following.
|
||||||
* @param mixed $user_id Either the ID of the user being followed, or
|
* @param string|int $user_id Either the ID of the user being followed, or
|
||||||
* the string "me", which will retrieve posts for the user you're authenticated
|
* the string "me", which will retrieve posts for the user you're authenticated
|
||||||
* as.
|
* as.
|
||||||
* @return array user ids the specified user is following.
|
* @return array user ids the specified user is following.
|
||||||
*/
|
*/
|
||||||
public function getFollowingIDs(string|int $user_id='me')
|
public function getFollowingIDs($user_id='me')
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'get',
|
'get',
|
||||||
"{$this->_baseUrl}users/{$user_id}/following?include_user=0"
|
"{$this->_baseUrl}users/{$user_id}/following?include_user=0"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of User objects for users following the specified user.
|
* Returns an array of User objects for users following the specified user.
|
||||||
* @param mixed $user_id Either the ID of the user being followed, or
|
* @param string|int $user_id Either the ID of the user being followed, or
|
||||||
* the string "me", which will retrieve posts for the user you're authenticated
|
* the string "me", which will retrieve posts for the user you're authenticated
|
||||||
* as.
|
* as.
|
||||||
* @return array An array of associative arrays, each representing a single
|
* @return array An array of associative arrays, each representing a single
|
||||||
* user following $user_id
|
* user following $user_id
|
||||||
*/
|
*/
|
||||||
public function getFollowers(string|int $user_id='me', array $params=[])
|
public function getFollowers($user_id='me', array $params=[])
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'get',
|
'get',
|
||||||
|
@ -1204,15 +1215,15 @@ class phpnut
|
||||||
. $this->buildQueryString($params)
|
. $this->buildQueryString($params)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of User ids for users following the specified user.
|
* Returns an array of User ids for users following the specified user.
|
||||||
* @param mixed $user_id Either the ID of the user being followed, or
|
* @param string|int $user_id Either the ID of the user being followed, or
|
||||||
* the string "me", which will retrieve posts for the user you're authenticated
|
* the string "me", which will retrieve posts for the user you're authenticated
|
||||||
* as.
|
* as.
|
||||||
* @return array user ids for users following the specified user
|
* @return array user ids for users following the specified user
|
||||||
*/
|
*/
|
||||||
public function getFollowersIDs(string|int $user_id='me')
|
public function getFollowersIDs($user_id='me')
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'get',
|
'get',
|
||||||
|
@ -1236,9 +1247,9 @@ class phpnut
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mute a user
|
* Mute a user
|
||||||
* @param integer $user_id The user ID to mute
|
* @param string|int $user_id The user ID to mute
|
||||||
*/
|
*/
|
||||||
public function muteUser(string|int $user_id)
|
public function muteUser($user_id)
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'put',
|
'put',
|
||||||
|
@ -1248,9 +1259,9 @@ class phpnut
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unmute a user
|
* Unmute a user
|
||||||
* @param integer $user_id The user ID to unmute
|
* @param string|int $user_id The user ID to unmute
|
||||||
*/
|
*/
|
||||||
public function unmuteUser(string|int $user_id)
|
public function unmuteUser($user_id)
|
||||||
{
|
{
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'delete',
|
'delete',
|
||||||
|
@ -1285,10 +1296,10 @@ class phpnut
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List the users who match a specific search term
|
* List the users who match a specific search term
|
||||||
* @param string $search The search query. Supports @username or #tag searches as
|
* @param string $query The search query. Supports @username or #tag searches as
|
||||||
* well as normal search terms. Searches username, display name, bio information.
|
* well as normal search terms. Searches username, display name, bio information.
|
||||||
* Does not search posts.
|
* Does not search posts.
|
||||||
* @return array An array of associative arrays, each representing one user.
|
* @return array|false An array of associative arrays, each representing one user.
|
||||||
*/
|
*/
|
||||||
public function searchUsers(array $params=[], string $query='')
|
public function searchUsers(array $params=[], string $query='')
|
||||||
{
|
{
|
||||||
|
@ -1328,12 +1339,14 @@ class phpnut
|
||||||
*/
|
*/
|
||||||
protected function updateUserImage(string $image, string $which='avatar')
|
protected function updateUserImage(string $image, string $which='avatar')
|
||||||
{
|
{
|
||||||
|
$mimeType = '';
|
||||||
|
|
||||||
$test = @getimagesize($image);
|
$test = @getimagesize($image);
|
||||||
if ($test && array_key_exists('mime', $test)) {
|
if ($test && array_key_exists('mime', $test)) {
|
||||||
$mimeType = $test['mime'];
|
$mimeType = $test['mime'];
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
$which => new CurlFile($image, $mimeType)
|
$which => new CURLFile($image, $mimeType)
|
||||||
];
|
];
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'post-raw',
|
'post-raw',
|
||||||
|
@ -1445,10 +1458,10 @@ class phpnut
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get an existing private message channel between multiple users
|
* get an existing private message channel between multiple users
|
||||||
* @param mixed $users Can be a comma- or space-separated string, or an array.
|
* @param string|array $users Can be a comma- or space-separated string, or an array.
|
||||||
* Usernames with @-symbol, or user ids.
|
* Usernames with @-symbol, or user ids.
|
||||||
*/
|
*/
|
||||||
public function getExistingPM(string|array $users, array $params=[])
|
public function getExistingPM($users, array $params=[])
|
||||||
{
|
{
|
||||||
if (is_string($users)) {
|
if (is_string($users)) {
|
||||||
$users = explode(',', str_replace(' ', ',', $users));
|
$users = explode(',', str_replace(' ', ',', $users));
|
||||||
|
@ -1561,7 +1574,7 @@ class phpnut
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a list of "explore" streams
|
* Retrieve a list of "explore" streams
|
||||||
* @return An array of associative arrays, each representing a single explore stream.
|
* @return array An array of associative arrays, each representing a single explore stream.
|
||||||
*/
|
*/
|
||||||
public function getChannelExploreStreams()
|
public function getChannelExploreStreams()
|
||||||
{
|
{
|
||||||
|
@ -1575,7 +1588,7 @@ class phpnut
|
||||||
* Retrieve a list of channels from an "explore" stream on pnut.io.
|
* Retrieve a list of channels from an "explore" stream on pnut.io.
|
||||||
* @param string $slug [<description>]
|
* @param string $slug [<description>]
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
* @return An array of associative arrays, each representing a single channel.
|
* @return array An array of associative arrays, each representing a single channel.
|
||||||
*/
|
*/
|
||||||
public function getChannelExploreStream(string $slug, array $params=[])
|
public function getChannelExploreStream(string $slug, array $params=[])
|
||||||
{
|
{
|
||||||
|
@ -1585,7 +1598,7 @@ class phpnut
|
||||||
. $this->buildQueryString($params)
|
. $this->buildQueryString($params)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mark channel inactive
|
* mark channel inactive
|
||||||
*/
|
*/
|
||||||
|
@ -1685,11 +1698,11 @@ class phpnut
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create message
|
* create message
|
||||||
* @param $channelid numeric or "pm" for auto-channel (type=io.pnut.core.pm)
|
* @param string|int $channelid numeric or "pm" for auto-channel (type=io.pnut.core.pm)
|
||||||
* @param array $data array('text'=>'YOUR_MESSAGE') If a type=io.pnut.core.pm, then "destinations" key can be set to address as an array of people to send this PM too
|
* @param array $data array('text'=>'YOUR_MESSAGE') If a type=io.pnut.core.pm, then "destinations" key can be set to address as an array of people to send this PM too
|
||||||
* @param array $params query parameters
|
* @param array $params query parameters
|
||||||
*/
|
*/
|
||||||
public function createMessage(string|int $channelid, array $data, array $params=[])
|
public function createMessage($channelid, array $data, array $params=[])
|
||||||
{
|
{
|
||||||
if (isset($data['destinations'])) {
|
if (isset($data['destinations'])) {
|
||||||
if (is_string($data['destinations'])) {
|
if (is_string($data['destinations'])) {
|
||||||
|
@ -1802,16 +1815,16 @@ class phpnut
|
||||||
public function createFile($file, array $data, array $params=[])
|
public function createFile($file, array $data, array $params=[])
|
||||||
{
|
{
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
throw new PhpnutException('You must specify a path to a file');
|
throw new phpnutException('You must specify a path to a file');
|
||||||
}
|
}
|
||||||
if (!file_exists($file)) {
|
if (!file_exists($file)) {
|
||||||
throw new PhpnutException('File path specified does not exist');
|
throw new phpnutException('File path specified does not exist');
|
||||||
}
|
}
|
||||||
if (!is_readable($file)) {
|
if (!is_readable($file)) {
|
||||||
throw new PhpnutException('File path specified is not readable');
|
throw new phpnutException('File path specified is not readable');
|
||||||
}
|
}
|
||||||
if (!array_key_exists('type', $data) || !$data['type']) {
|
if (!array_key_exists('type', $data) || !$data['type']) {
|
||||||
throw new PhpnutException('Type is required when creating a file');
|
throw new phpnutException('Type is required when creating a file');
|
||||||
}
|
}
|
||||||
if (!array_key_exists('name', $data)) {
|
if (!array_key_exists('name', $data)) {
|
||||||
$data['name'] = basename($file);
|
$data['name'] = basename($file);
|
||||||
|
@ -1823,7 +1836,7 @@ class phpnut
|
||||||
$mimeType = null;
|
$mimeType = null;
|
||||||
}
|
}
|
||||||
if (!array_key_exists('kind', $data)) {
|
if (!array_key_exists('kind', $data)) {
|
||||||
$test = @getimagesize($path);
|
$test = @getimagesize($file);
|
||||||
if ($test && array_key_exists('mime', $test)) {
|
if ($test && array_key_exists('mime', $test)) {
|
||||||
$data['kind'] = 'image';
|
$data['kind'] = 'image';
|
||||||
if (!$mimeType) {
|
if (!$mimeType) {
|
||||||
|
@ -1840,7 +1853,7 @@ class phpnut
|
||||||
finfo_close($finfo);
|
finfo_close($finfo);
|
||||||
}
|
}
|
||||||
if (!$mimeType) {
|
if (!$mimeType) {
|
||||||
throw new PhpnutException('Unable to determine mime type of file, try specifying it explicitly');
|
throw new phpnutException('Unable to determine mime type of file, try specifying it explicitly');
|
||||||
}
|
}
|
||||||
$data['content'] = new \CurlFile($file, $mimeType);
|
$data['content'] = new \CurlFile($file, $mimeType);
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
|
@ -2001,7 +2014,7 @@ class phpnut
|
||||||
$json = json_encode($data);
|
$json = json_encode($data);
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'post',
|
'post',
|
||||||
$this->_baseUrl.'polls?'.$this->buildQueryString($params),
|
$this->_baseUrl.'polls?'.$this->buildQueryString($params),
|
||||||
$json,
|
$json,
|
||||||
'application/json'
|
'application/json'
|
||||||
);
|
);
|
||||||
|
@ -2010,7 +2023,7 @@ class phpnut
|
||||||
/**
|
/**
|
||||||
* Responds to a poll.
|
* Responds to a poll.
|
||||||
* @param integer $poll_id The ID of the poll to respond to
|
* @param integer $poll_id The ID of the poll to respond to
|
||||||
* @param array list of positions for the poll response
|
* @param array $positions list of positions for the poll response
|
||||||
* @param array $params An associative array of optional general parameters.
|
* @param array $params An associative array of optional general parameters.
|
||||||
*/
|
*/
|
||||||
public function respondToPoll(int $poll_id, array $positions, array $params=[])
|
public function respondToPoll(int $poll_id, array $positions, array $params=[])
|
||||||
|
@ -2019,7 +2032,7 @@ class phpnut
|
||||||
return $this->httpReq(
|
return $this->httpReq(
|
||||||
'put',
|
'put',
|
||||||
$this->_baseUrl.'polls/'.urlencode($poll_id).'/response?'.$this->buildQueryString($params),
|
$this->_baseUrl.'polls/'.urlencode($poll_id).'/response?'.$this->buildQueryString($params),
|
||||||
$json,
|
$json,
|
||||||
'application/json'
|
'application/json'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2085,8 +2098,6 @@ class phpnut
|
||||||
* List the polls that match a specific search term
|
* List the polls that match a specific search term
|
||||||
* @param array $params a list of filter, search query, and general Poll parameters
|
* @param array $params a list of filter, search query, and general Poll parameters
|
||||||
* see: https://docs.pnut.io/resources/channels/search
|
* see: https://docs.pnut.io/resources/channels/search
|
||||||
* @param string $query The search query. Supports
|
|
||||||
* normal search terms.
|
|
||||||
* @return array An array of associative arrays, each representing one poll.
|
* @return array An array of associative arrays, each representing one poll.
|
||||||
* or false on error
|
* or false on error
|
||||||
*/
|
*/
|
||||||
|
@ -2118,7 +2129,7 @@ class phpnut
|
||||||
$params
|
$params
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get User Information
|
* Get User Information
|
||||||
*/
|
*/
|
||||||
|
@ -2129,7 +2140,7 @@ class phpnut
|
||||||
"{$this->_baseUrl}token"
|
"{$this->_baseUrl}token"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Application Authorized User IDs
|
* Get Application Authorized User IDs
|
||||||
*/
|
*/
|
||||||
|
@ -2147,7 +2158,7 @@ class phpnut
|
||||||
$params
|
$params
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Application Authorized User Tokens
|
* Get Application Authorized User Tokens
|
||||||
*/
|
*/
|
||||||
|
@ -2166,14 +2177,12 @@ class phpnut
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers your function (or an array of object and method) to be called
|
* Registers your function (or an array of object and method) to be called
|
||||||
* whenever an event is received via an open pnut.io stream. Your function
|
* whenever an event is received via an open pnut.io stream. Your function
|
||||||
* will receive a single parameter, which is the object wrapper containing
|
* will receive a single parameter, which is the object wrapper containing
|
||||||
* the meta and data.
|
* the meta and data.
|
||||||
* @param mixed A PHP callback (either a string containing the function name,
|
* @param mixed $function A PHP callback (either a string containing the function name,
|
||||||
* or an array where the first element is the class/object and the second
|
* or an array where the first element is the class/object and the second
|
||||||
* is the method).
|
* is the method).
|
||||||
*/
|
*/
|
||||||
|
@ -2181,7 +2190,7 @@ class phpnut
|
||||||
{
|
{
|
||||||
$this->_streamCallback = $function;
|
$this->_streamCallback = $function;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a stream that's been created for this user/app and starts sending
|
* Opens a stream that's been created for this user/app and starts sending
|
||||||
* events/objects to your defined callback functions. You must define at
|
* events/objects to your defined callback functions. You must define at
|
||||||
|
@ -2231,10 +2240,9 @@ class phpnut
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the currently open stream.
|
* Close the currently open stream.
|
||||||
* @return true;
|
|
||||||
*/
|
*/
|
||||||
public function closeStream(): void
|
public function closeStream(): void
|
||||||
{
|
{
|
||||||
|
@ -2251,7 +2259,7 @@ class phpnut
|
||||||
$this->_currentStream = null;
|
$this->_currentStream = null;
|
||||||
$this->_multiStream = null;
|
$this->_multiStream = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all streams for the current access token.
|
* Retrieve all streams for the current access token.
|
||||||
* @return array An array of stream definitions.
|
* @return array An array of stream definitions.
|
||||||
|
@ -2263,7 +2271,7 @@ class phpnut
|
||||||
"{$this->_baseUrl}streams"
|
"{$this->_baseUrl}streams"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a single stream specified by a stream ID. The stream must have been
|
* Returns a single stream specified by a stream ID. The stream must have been
|
||||||
* created with the current access token.
|
* created with the current access token.
|
||||||
|
@ -2276,7 +2284,7 @@ class phpnut
|
||||||
$this->_baseUrl.'streams/'.urlencode($streamId)
|
$this->_baseUrl.'streams/'.urlencode($streamId)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a stream for the current app access token.
|
* Creates a stream for the current app access token.
|
||||||
*
|
*
|
||||||
|
@ -2307,7 +2315,7 @@ class phpnut
|
||||||
);
|
);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update stream for the current app access token
|
* Update stream for the current app access token
|
||||||
*
|
*
|
||||||
|
@ -2338,7 +2346,7 @@ class phpnut
|
||||||
);
|
);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a stream if you no longer need it.
|
* Deletes a stream if you no longer need it.
|
||||||
*
|
*
|
||||||
|
@ -2352,7 +2360,7 @@ class phpnut
|
||||||
$this->_baseUrl.'streams/'.urlencode($streamId)
|
$this->_baseUrl.'streams/'.urlencode($streamId)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all streams created by the current access token.
|
* Deletes all streams created by the current access token.
|
||||||
*/
|
*/
|
||||||
|
@ -2363,7 +2371,7 @@ class phpnut
|
||||||
"{$this->_baseUrl}streams"
|
"{$this->_baseUrl}streams"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal function used to process incoming chunks from the stream. This is only
|
* Internal function used to process incoming chunks from the stream. This is only
|
||||||
* public because it needs to be accessed by CURL. Do not call or use this function
|
* public because it needs to be accessed by CURL. Do not call or use this function
|
||||||
|
@ -2394,7 +2402,7 @@ class phpnut
|
||||||
}
|
}
|
||||||
return strlen($data);
|
return strlen($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a long lived HTTP connection to the pnut.io servers, and sends data
|
* Opens a long lived HTTP connection to the pnut.io servers, and sends data
|
||||||
* received to the httpStreamReceive function. As a general rule you should not
|
* received to the httpStreamReceive function. As a general rule you should not
|
||||||
|
@ -2426,7 +2434,7 @@ class phpnut
|
||||||
$this->_lastStreamActivity = time();
|
$this->_lastStreamActivity = time();
|
||||||
curl_multi_add_handle($this->_multiStream, $this->_currentStream);
|
curl_multi_add_handle($this->_multiStream, $this->_currentStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reconnectStream(): void
|
public function reconnectStream(): void
|
||||||
{
|
{
|
||||||
$this->closeStream();
|
$this->closeStream();
|
||||||
|
@ -2442,12 +2450,12 @@ class phpnut
|
||||||
}
|
}
|
||||||
$this->httpStream('get', $this->_streamUrl);
|
$this->httpStream('get', $this->_streamUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process an open stream for x microseconds, then return. This is useful if you want
|
* Process an open stream for x microseconds, then return. This is useful if you want
|
||||||
* to be doing other things while processing the stream. If you just want to
|
* to be doing other things while processing the stream. If you just want to
|
||||||
* consume the stream without other actions, you can call processForever() instead.
|
* consume the stream without other actions, you can call processForever() instead.
|
||||||
* @param float @microseconds The number of microseconds to process for before
|
* @param null|float $microseconds The number of microseconds to process for before
|
||||||
* returning. There are 1,000,000 microseconds in a second.
|
* returning. There are 1,000,000 microseconds in a second.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -2487,7 +2495,7 @@ class phpnut
|
||||||
}
|
}
|
||||||
} while ($timeSoFar+$sleepFor < $microseconds);
|
} while ($timeSoFar+$sleepFor < $microseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process an open stream forever. This function will never return, if you
|
* Process an open stream forever. This function will never return, if you
|
||||||
* want to perform other actions while consuming the stream, you should use
|
* want to perform other actions while consuming the stream, you should use
|
||||||
|
|
|
@ -14,7 +14,6 @@ use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Content\Text\Plaintext;
|
use Friendica\Content\Text\Plaintext;
|
||||||
use Friendica\Core\Config\Util\ConfigFileManager;
|
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -76,7 +75,7 @@ function pnut_connect()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$token = $nut->getAccessToken($callback_url);
|
$token = $nut->getAccessToken($callback_url);
|
||||||
Logger::debug('Got Token', [$token]);
|
DI::logger()->debug('Got Token', [$token]);
|
||||||
$o = DI::l10n()->t('You are now authenticated with pnut.io.');
|
$o = DI::l10n()->t('You are now authenticated with pnut.io.');
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pnut', 'access_token', $token);
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pnut', 'access_token', $token);
|
||||||
} catch (phpnutException $e) {
|
} catch (phpnutException $e) {
|
||||||
|
@ -90,7 +89,7 @@ function pnut_connect()
|
||||||
|
|
||||||
function pnut_load_config(ConfigFileManager $loader)
|
function pnut_load_config(ConfigFileManager $loader)
|
||||||
{
|
{
|
||||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('pnut'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('pnut'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pnut_addon_admin(string &$o)
|
function pnut_addon_admin(string &$o)
|
||||||
|
@ -266,8 +265,8 @@ function pnut_post_hook(array &$b)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::notice('PNUT post invoked', ['id' => $b['id'], 'guid' => $b['guid'], 'plink' => $b['plink']]);
|
DI::logger()->notice('PNUT post invoked', ['id' => $b['id'], 'guid' => $b['guid'], 'plink' => $b['plink']]);
|
||||||
Logger::debug('PNUT array', $b);
|
DI::logger()->debug('PNUT array', $b);
|
||||||
|
|
||||||
$token = DI::pConfig()->get($b['uid'], 'pnut', 'access_token');
|
$token = DI::pConfig()->get($b['uid'], 'pnut', 'access_token');
|
||||||
$nut = new phpnut\phpnut($token);
|
$nut = new phpnut\phpnut($token);
|
||||||
|
@ -276,7 +275,7 @@ function pnut_post_hook(array &$b)
|
||||||
$text = $msgarr['text'];
|
$text = $msgarr['text'];
|
||||||
$raw = [];
|
$raw = [];
|
||||||
|
|
||||||
Logger::debug('PNUT msgarr', $msgarr);
|
DI::logger()->debug('PNUT msgarr', $msgarr);
|
||||||
|
|
||||||
if (count($msgarr['parts']) > 1) {
|
if (count($msgarr['parts']) > 1) {
|
||||||
$tstamp = time();
|
$tstamp = time();
|
||||||
|
@ -292,23 +291,23 @@ function pnut_post_hook(array &$b)
|
||||||
if ($msgarr['type'] == 'photo') {
|
if ($msgarr['type'] == 'photo') {
|
||||||
$fileraw = ['type' => 'dev.mcmillian.friendica.image', 'kind' => 'image', 'is_public' => true];
|
$fileraw = ['type' => 'dev.mcmillian.friendica.image', 'kind' => 'image', 'is_public' => true];
|
||||||
foreach ($msgarr['images'] as $image) {
|
foreach ($msgarr['images'] as $image) {
|
||||||
Logger::debug('PNUT image', $image);
|
DI::logger()->debug('PNUT image', $image);
|
||||||
|
|
||||||
if (!empty($image['id'])) {
|
if (!empty($image['id'])) {
|
||||||
$photo = Photo::selectFirst([], ['id' => $image['id']]);
|
$photo = Photo::selectFirst([], ['id' => $image['id']]);
|
||||||
Logger::debug('PNUT selectFirst');
|
DI::logger()->debug('PNUT selectFirst');
|
||||||
} else {
|
} else {
|
||||||
$photo = Photo::createPhotoForExternalResource($image['url']);
|
$photo = Photo::createPhotoForExternalResource($image['url']);
|
||||||
Logger::debug('PNUT createPhotoForExternalResource');
|
DI::logger()->debug('PNUT createPhotoForExternalResource');
|
||||||
}
|
}
|
||||||
$picturedata = Photo::getImageForPhoto($photo);
|
$picturedata = Photo::getImageForPhoto($photo);
|
||||||
|
|
||||||
Logger::debug('PNUT photo', $photo);
|
DI::logger()->debug('PNUT photo', $photo);
|
||||||
$picurefile = tempnam(System::getTempPath(), 'pnut');
|
$picurefile = tempnam(System::getTempPath(), 'pnut');
|
||||||
file_put_contents($picurefile, $picturedata);
|
file_put_contents($picurefile, $picturedata);
|
||||||
Logger::debug('PNUT got file?', ['filename' => $picurefile]);
|
DI::logger()->debug('PNUT got file?', ['filename' => $picurefile]);
|
||||||
$imagefile = $nut->createFile($picurefile, $fileraw);
|
$imagefile = $nut->createFile($picurefile, $fileraw);
|
||||||
Logger::debug('PNUT file', ['pnutimagefile' => $imagefile]);
|
DI::logger()->debug('PNUT file', ['pnutimagefile' => $imagefile]);
|
||||||
unlink($picurefile);
|
unlink($picurefile);
|
||||||
|
|
||||||
$raw['io.pnut.core.oembed'][] = ['+io.pnut.core.file' => ['file_id' => $imagefile['id'], 'file_token' => $imagefile['file_token'], 'format' => 'oembed']];
|
$raw['io.pnut.core.oembed'][] = ['+io.pnut.core.file' => ['file_id' => $imagefile['id'], 'file_token' => $imagefile['file_token'], 'format' => 'oembed']];
|
||||||
|
@ -318,5 +317,5 @@ function pnut_post_hook(array &$b)
|
||||||
$raw['io.pnut.core.crosspost'][] = ['canonical_url' => $b['plink']];
|
$raw['io.pnut.core.crosspost'][] = ['canonical_url' => $b['plink']];
|
||||||
$nut->createPost($text, ['raw' => $raw]);
|
$nut->createPost($text, ['raw' => $raw]);
|
||||||
|
|
||||||
Logger::debug('PNUT post complete', ['id' => $b['id'], 'text' => $text, 'raw' => $raw]);
|
DI::logger()->debug('PNUT post complete', ['id' => $b['id'], 'text' => $text, 'raw' => $raw]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
|
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -29,7 +27,7 @@ function public_server_install()
|
||||||
|
|
||||||
function public_server_load_config(ConfigFileManager $loader)
|
function public_server_load_config(ConfigFileManager $loader)
|
||||||
{
|
{
|
||||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('public_server'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('public_server'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
function public_server_register_account($b)
|
function public_server_register_account($b)
|
||||||
|
@ -48,7 +46,7 @@ function public_server_register_account($b)
|
||||||
|
|
||||||
function public_server_cron($b)
|
function public_server_cron($b)
|
||||||
{
|
{
|
||||||
Logger::notice("public_server: cron start");
|
DI::logger()->notice("public_server: cron start");
|
||||||
|
|
||||||
$users = DBA::selectToArray('user', [], ["`account_expires_on` > ? AND `account_expires_on` < ?
|
$users = DBA::selectToArray('user', [], ["`account_expires_on` > ? AND `account_expires_on` < ?
|
||||||
AND `expire_notification_sent` <= ?", DBA::NULL_DATETIME, DateTimeFormat::utc('now + 5 days'), DBA::NULL_DATETIME]);
|
AND `expire_notification_sent` <= ?", DBA::NULL_DATETIME, DateTimeFormat::utc('now + 5 days'), DBA::NULL_DATETIME]);
|
||||||
|
@ -97,7 +95,7 @@ function public_server_cron($b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::notice("public_server: cron end");
|
DI::logger()->notice("public_server: cron end");
|
||||||
}
|
}
|
||||||
|
|
||||||
function public_server_enotify(array &$b)
|
function public_server_enotify(array &$b)
|
||||||
|
|
|
@ -109,9 +109,11 @@ class http_class
|
||||||
var $connected_port = -1;
|
var $connected_port = -1;
|
||||||
var $connected_ssl = 0;
|
var $connected_ssl = 0;
|
||||||
|
|
||||||
|
private $content_length_set;
|
||||||
|
|
||||||
/* Private methods - DO NOT CALL */
|
/* Private methods - DO NOT CALL */
|
||||||
|
|
||||||
Function Tokenize($string,$separator="")
|
private function Tokenize($string,$separator="")
|
||||||
{
|
{
|
||||||
if(!strcmp($separator,""))
|
if(!strcmp($separator,""))
|
||||||
{
|
{
|
||||||
|
@ -135,18 +137,18 @@ class http_class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function CookieEncode($value, $name)
|
private function CookieEncode($value, $name)
|
||||||
{
|
{
|
||||||
return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value));
|
return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value));
|
||||||
}
|
}
|
||||||
|
|
||||||
Function SetError($error, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
|
private function SetError($error, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
|
||||||
{
|
{
|
||||||
$this->error_code = $error_code;
|
$this->error_code = $error_code;
|
||||||
return($this->error=$error);
|
return($this->error=$error);
|
||||||
}
|
}
|
||||||
|
|
||||||
Function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
|
private function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
|
||||||
{
|
{
|
||||||
if(IsSet($php_error_message)
|
if(IsSet($php_error_message)
|
||||||
&& strlen($php_error_message))
|
&& strlen($php_error_message))
|
||||||
|
@ -154,7 +156,7 @@ class http_class
|
||||||
return($this->SetError($error, $error_code));
|
return($this->SetError($error, $error_code));
|
||||||
}
|
}
|
||||||
|
|
||||||
Function SetDataAccessError($error,$check_connection=0)
|
private function SetDataAccessError($error,$check_connection=0)
|
||||||
{
|
{
|
||||||
$this->error=$error;
|
$this->error=$error;
|
||||||
$this->error_code = HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE;
|
$this->error_code = HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE;
|
||||||
|
@ -174,7 +176,7 @@ class http_class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function OutputDebug($message)
|
private function OutputDebug($message)
|
||||||
{
|
{
|
||||||
if($this->log_debug)
|
if($this->log_debug)
|
||||||
error_log($message);
|
error_log($message);
|
||||||
|
@ -188,7 +190,7 @@ class http_class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function GetLine()
|
private function GetLine()
|
||||||
{
|
{
|
||||||
for($line="";;)
|
for($line="";;)
|
||||||
{
|
{
|
||||||
|
@ -227,7 +229,7 @@ class http_class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function PutLine($line)
|
private function PutLine($line)
|
||||||
{
|
{
|
||||||
if($this->debug)
|
if($this->debug)
|
||||||
$this->OutputDebug("C $line");
|
$this->OutputDebug("C $line");
|
||||||
|
@ -239,7 +241,7 @@ class http_class
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Function PutData($data)
|
private function PutData($data)
|
||||||
{
|
{
|
||||||
if(strlen($data))
|
if(strlen($data))
|
||||||
{
|
{
|
||||||
|
@ -254,7 +256,7 @@ class http_class
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Function FlushData()
|
private function FlushData()
|
||||||
{
|
{
|
||||||
if(!fflush($this->connection))
|
if(!fflush($this->connection))
|
||||||
{
|
{
|
||||||
|
@ -264,7 +266,7 @@ class http_class
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Function ReadChunkSize()
|
private function ReadChunkSize()
|
||||||
{
|
{
|
||||||
if($this->remaining_chunk==0)
|
if($this->remaining_chunk==0)
|
||||||
{
|
{
|
||||||
|
@ -289,7 +291,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function ReadBytes($length)
|
private function ReadBytes($length)
|
||||||
{
|
{
|
||||||
if($this->use_curl)
|
if($this->use_curl)
|
||||||
{
|
{
|
||||||
|
@ -356,7 +358,7 @@ class http_class
|
||||||
return($bytes);
|
return($bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
Function EndOfInput()
|
private function EndOfInput()
|
||||||
{
|
{
|
||||||
if($this->use_curl)
|
if($this->use_curl)
|
||||||
return($this->read_response>=strlen($this->response));
|
return($this->read_response>=strlen($this->response));
|
||||||
|
@ -367,7 +369,7 @@ class http_class
|
||||||
return(feof($this->connection));
|
return(feof($this->connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Resolve($domain, &$ip, $server_type)
|
private function Resolve($domain, &$ip, $server_type)
|
||||||
{
|
{
|
||||||
if(preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/',$domain))
|
if(preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/',$domain))
|
||||||
$ip=$domain;
|
$ip=$domain;
|
||||||
|
@ -385,7 +387,7 @@ class http_class
|
||||||
return('');
|
return('');
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP')
|
private function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP')
|
||||||
{
|
{
|
||||||
$domain=$host_name;
|
$domain=$host_name;
|
||||||
$port = $host_port;
|
$port = $host_port;
|
||||||
|
@ -552,7 +554,7 @@ class http_class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Disconnect()
|
private function Disconnect()
|
||||||
{
|
{
|
||||||
if($this->debug)
|
if($this->debug)
|
||||||
$this->OutputDebug("Disconnected from ".$this->connected_host);
|
$this->OutputDebug("Disconnected from ".$this->connected_host);
|
||||||
|
@ -569,7 +571,7 @@ class http_class
|
||||||
|
|
||||||
/* Public methods */
|
/* Public methods */
|
||||||
|
|
||||||
Function GetRequestArguments($url, &$arguments)
|
public function GetRequestArguments($url, &$arguments)
|
||||||
{
|
{
|
||||||
$this->error = '';
|
$this->error = '';
|
||||||
$this->error_code = HTTP_CLIENT_ERROR_NO_ERROR;
|
$this->error_code = HTTP_CLIENT_ERROR_NO_ERROR;
|
||||||
|
@ -621,7 +623,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Open($arguments)
|
public function Open($arguments)
|
||||||
{
|
{
|
||||||
if(strlen($this->error))
|
if(strlen($this->error))
|
||||||
return($this->error);
|
return($this->error);
|
||||||
|
@ -750,7 +752,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Close($force = 0)
|
public function Close($force = 0)
|
||||||
{
|
{
|
||||||
if($this->state=="Disconnected")
|
if($this->state=="Disconnected")
|
||||||
return("1 already disconnected");
|
return("1 already disconnected");
|
||||||
|
@ -767,7 +769,7 @@ class http_class
|
||||||
return($this->Disconnect());
|
return($this->Disconnect());
|
||||||
}
|
}
|
||||||
|
|
||||||
Function PickCookies(&$cookies,$secure)
|
private function PickCookies(&$cookies,$secure)
|
||||||
{
|
{
|
||||||
if(IsSet($this->cookies[$secure]))
|
if(IsSet($this->cookies[$secure]))
|
||||||
{
|
{
|
||||||
|
@ -803,7 +805,7 @@ class http_class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function GetFileDefinition($file, &$definition)
|
private function GetFileDefinition($file, &$definition)
|
||||||
{
|
{
|
||||||
$name="";
|
$name="";
|
||||||
if(IsSet($file["FileName"]))
|
if(IsSet($file["FileName"]))
|
||||||
|
@ -990,9 +992,6 @@ class http_class
|
||||||
if(GetType($length=@filesize($file["FileName"]))!="integer")
|
if(GetType($length=@filesize($file["FileName"]))!="integer")
|
||||||
{
|
{
|
||||||
$error="it was not possible to determine the length of the file ".$file["FileName"];
|
$error="it was not possible to determine the length of the file ".$file["FileName"];
|
||||||
if(IsSet($php_errormsg)
|
|
||||||
&& strlen($php_errormsg))
|
|
||||||
$error.=": ".$php_errormsg;
|
|
||||||
if(!file_exists($file["FileName"]))
|
if(!file_exists($file["FileName"]))
|
||||||
$error="it was not possible to access the file ".$file["FileName"];
|
$error="it was not possible to access the file ".$file["FileName"];
|
||||||
return($error);
|
return($error);
|
||||||
|
@ -1007,7 +1006,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function ConnectFromProxy($arguments, &$headers)
|
private function ConnectFromProxy($arguments, &$headers)
|
||||||
{
|
{
|
||||||
if(!$this->PutLine('CONNECT '.$this->host_name.':'.($this->host_port ? $this->host_port : 443).' HTTP/1.0')
|
if(!$this->PutLine('CONNECT '.$this->host_name.':'.($this->host_port ? $this->host_port : 443).' HTTP/1.0')
|
||||||
|| (strlen($this->user_agent)
|
|| (strlen($this->user_agent)
|
||||||
|
@ -1052,7 +1051,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function SendRequest($arguments)
|
public function SendRequest($arguments)
|
||||||
{
|
{
|
||||||
if(strlen($this->error))
|
if(strlen($this->error))
|
||||||
return($this->error);
|
return($this->error);
|
||||||
|
@ -1440,7 +1439,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0)
|
private function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0)
|
||||||
{
|
{
|
||||||
if(strlen($this->error))
|
if(strlen($this->error))
|
||||||
return($this->error);
|
return($this->error);
|
||||||
|
@ -1472,7 +1471,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function SendRequestBody($data, $end_of_data)
|
private function SendRequestBody($data, $end_of_data)
|
||||||
{
|
{
|
||||||
if(strlen($this->error))
|
if(strlen($this->error))
|
||||||
return($this->error);
|
return($this->error);
|
||||||
|
@ -1508,7 +1507,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function ReadReplyHeadersResponse(&$headers)
|
private function ReadReplyHeadersResponse(&$headers)
|
||||||
{
|
{
|
||||||
$headers=array();
|
$headers=array();
|
||||||
if(strlen($this->error))
|
if(strlen($this->error))
|
||||||
|
@ -1635,7 +1634,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Redirect(&$headers)
|
private function Redirect(&$headers)
|
||||||
{
|
{
|
||||||
if($this->follow_redirect)
|
if($this->follow_redirect)
|
||||||
{
|
{
|
||||||
|
@ -1678,7 +1677,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation)
|
private function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation)
|
||||||
{
|
{
|
||||||
if($proxy)
|
if($proxy)
|
||||||
{
|
{
|
||||||
|
@ -1697,9 +1696,10 @@ class http_class
|
||||||
if(IsSet($headers[$authenticate_header])
|
if(IsSet($headers[$authenticate_header])
|
||||||
&& $this->sasl_authenticate)
|
&& $this->sasl_authenticate)
|
||||||
{
|
{
|
||||||
if(function_exists("class_exists")
|
if(!class_exists('sasl_client_class'))
|
||||||
&& !class_exists("sasl_client_class"))
|
{
|
||||||
return($this->SetError("the SASL client class needs to be loaded to be able to authenticate".($proxy ? " with the proxy server" : "")." and access this site", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
return($this->SetError("the SASL client class needs to be loaded to be able to authenticate".($proxy ? " with the proxy server" : "")." and access this site", HTTP_CLIENT_ERROR_INVALID_PARAMETERS));
|
||||||
|
}
|
||||||
if(GetType($headers[$authenticate_header])=="array")
|
if(GetType($headers[$authenticate_header])=="array")
|
||||||
$authenticate=$headers[$authenticate_header];
|
$authenticate=$headers[$authenticate_header];
|
||||||
else
|
else
|
||||||
|
@ -1719,7 +1719,7 @@ class http_class
|
||||||
else
|
else
|
||||||
$mechanisms[]=$mechanism;
|
$mechanisms[]=$mechanism;
|
||||||
}
|
}
|
||||||
$sasl=new sasl_client_class;
|
$sasl=new \sasl_client_class();
|
||||||
if(IsSet($user))
|
if(IsSet($user))
|
||||||
$sasl->SetCredential("user",$user);
|
$sasl->SetCredential("user",$user);
|
||||||
if(IsSet($password))
|
if(IsSet($password))
|
||||||
|
@ -1731,6 +1731,8 @@ class http_class
|
||||||
$sasl->SetCredential("uri",$this->request_uri);
|
$sasl->SetCredential("uri",$this->request_uri);
|
||||||
$sasl->SetCredential("method",$this->request_method);
|
$sasl->SetCredential("method",$this->request_method);
|
||||||
$sasl->SetCredential("session",$this->session);
|
$sasl->SetCredential("session",$this->session);
|
||||||
|
$message = '';
|
||||||
|
$interactions = [];
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
$status=$sasl->Start($mechanisms,$message,$interactions);
|
$status=$sasl->Start($mechanisms,$message,$interactions);
|
||||||
|
@ -1906,8 +1908,8 @@ class http_class
|
||||||
}
|
}
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function ReadReplyHeaders(&$headers)
|
public function ReadReplyHeaders(&$headers)
|
||||||
{
|
{
|
||||||
if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
|
if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
|
||||||
return($error);
|
return($error);
|
||||||
|
@ -1938,7 +1940,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function ReadReplyBody(&$body,$length)
|
private function ReadReplyBody(&$body,$length)
|
||||||
{
|
{
|
||||||
$body="";
|
$body="";
|
||||||
if(strlen($this->error))
|
if(strlen($this->error))
|
||||||
|
@ -1980,7 +1982,7 @@ class http_class
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Function ReadWholeReplyBody(&$body)
|
public function ReadWholeReplyBody(&$body)
|
||||||
{
|
{
|
||||||
$body = '';
|
$body = '';
|
||||||
for(;;)
|
for(;;)
|
||||||
|
@ -1993,7 +1995,7 @@ class http_class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0)
|
private function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0)
|
||||||
{
|
{
|
||||||
$now=gmdate("Y-m-d H-i-s");
|
$now=gmdate("Y-m-d H-i-s");
|
||||||
$cookies=array();
|
$cookies=array();
|
||||||
|
@ -2034,17 +2036,17 @@ class http_class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function SavePersistentCookies(&$cookies, $domain='', $secure_only=0)
|
private function SavePersistentCookies(&$cookies, $domain='', $secure_only=0)
|
||||||
{
|
{
|
||||||
$this->SaveCookies($cookies, $domain, $secure_only, 1);
|
$this->SaveCookies($cookies, $domain, $secure_only, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Function GetPersistentCookies(&$cookies, $domain='', $secure_only=0)
|
private function GetPersistentCookies(&$cookies, $domain='', $secure_only=0)
|
||||||
{
|
{
|
||||||
$this->SavePersistentCookies($cookies, $domain, $secure_only);
|
$this->SavePersistentCookies($cookies, $domain, $secure_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
Function RestoreCookies($cookies, $clear=1)
|
private function RestoreCookies($cookies, $clear=1)
|
||||||
{
|
{
|
||||||
$new_cookies=($clear ? array() : $this->cookies);
|
$new_cookies=($clear ? array() : $this->cookies);
|
||||||
for($secure_cookies=0, Reset($cookies); $secure_cookies<count($cookies); Next($cookies), $secure_cookies++)
|
for($secure_cookies=0, Reset($cookies); $secure_cookies<count($cookies); Next($cookies), $secure_cookies++)
|
||||||
|
|
|
@ -6,12 +6,10 @@
|
||||||
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
|
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Content\Text\HTML;
|
use Friendica\Content\Text\HTML;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
|
@ -108,7 +106,7 @@ function pumpio_registerclient($host)
|
||||||
$params['logo_url'] = DI::baseUrl() . '/images/friendica-256.png';
|
$params['logo_url'] = DI::baseUrl() . '/images/friendica-256.png';
|
||||||
$params['redirect_uris'] = DI::baseUrl() . '/pumpio/connect';
|
$params['redirect_uris'] = DI::baseUrl() . '/pumpio/connect';
|
||||||
|
|
||||||
Logger::info('pumpio_registerclient: ' . $url . ' parameters', $params);
|
DI::logger()->info('pumpio_registerclient: ' . $url . ' parameters', $params);
|
||||||
|
|
||||||
// @TODO Rewrite this to our own HTTP client
|
// @TODO Rewrite this to our own HTTP client
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
|
@ -123,10 +121,10 @@ function pumpio_registerclient($host)
|
||||||
|
|
||||||
if ($curl_info['http_code'] == '200') {
|
if ($curl_info['http_code'] == '200') {
|
||||||
$values = json_decode($s);
|
$values = json_decode($s);
|
||||||
Logger::info('pumpio_registerclient: success ', (array)$values);
|
DI::logger()->info('pumpio_registerclient: success ', (array)$values);
|
||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
Logger::info('pumpio_registerclient: failed: ', $curl_info);
|
DI::logger()->info('pumpio_registerclient: failed: ', $curl_info);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -139,7 +137,7 @@ function pumpio_connect()
|
||||||
$hostname = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'host');
|
$hostname = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'host');
|
||||||
|
|
||||||
if ((($consumer_key == '') || ($consumer_secret == '')) && ($hostname != '')) {
|
if ((($consumer_key == '') || ($consumer_secret == '')) && ($hostname != '')) {
|
||||||
Logger::notice('pumpio_connect: register client');
|
DI::logger()->notice('pumpio_connect: register client');
|
||||||
$clientdata = pumpio_registerclient($hostname);
|
$clientdata = pumpio_registerclient($hostname);
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key', $clientdata->client_id);
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key', $clientdata->client_id);
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret', $clientdata->client_secret);
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret', $clientdata->client_secret);
|
||||||
|
@ -147,11 +145,11 @@ function pumpio_connect()
|
||||||
$consumer_key = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key');
|
$consumer_key = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key');
|
||||||
$consumer_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret');
|
$consumer_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret');
|
||||||
|
|
||||||
Logger::info('pumpio_connect: ckey: ' . $consumer_key . ' csecrect: ' . $consumer_secret);
|
DI::logger()->info('pumpio_connect: ckey: ' . $consumer_key . ' csecrect: ' . $consumer_secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($consumer_key == '') || ($consumer_secret == '')) {
|
if (($consumer_key == '') || ($consumer_secret == '')) {
|
||||||
Logger::notice('pumpio_connect: '.sprintf('Unable to register the client at the pump.io server "%s".', $hostname));
|
DI::logger()->notice('pumpio_connect: '.sprintf('Unable to register the client at the pump.io server "%s".', $hostname));
|
||||||
|
|
||||||
return DI::l10n()->t("Unable to register the client at the pump.io server '%s'.", $hostname);
|
return DI::l10n()->t("Unable to register the client at the pump.io server '%s'.", $hostname);
|
||||||
}
|
}
|
||||||
|
@ -180,7 +178,7 @@ function pumpio_connect()
|
||||||
if (($success = $client->Initialize())) {
|
if (($success = $client->Initialize())) {
|
||||||
if (($success = $client->Process())) {
|
if (($success = $client->Process())) {
|
||||||
if (strlen($client->access_token)) {
|
if (strlen($client->access_token)) {
|
||||||
Logger::info('pumpio_connect: otoken: ' . $client->access_token . ', osecrect: ' . $client->access_token_secret);
|
DI::logger()->info('pumpio_connect: otoken: ' . $client->access_token . ', osecrect: ' . $client->access_token_secret);
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token', $client->access_token);
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token', $client->access_token);
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token_secret', $client->access_token_secret);
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'oauth_token_secret', $client->access_token_secret);
|
||||||
}
|
}
|
||||||
|
@ -192,11 +190,11 @@ function pumpio_connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
Logger::notice('pumpio_connect: authenticated');
|
DI::logger()->notice('pumpio_connect: authenticated');
|
||||||
$o = DI::l10n()->t('You are now authenticated to pumpio.');
|
$o = DI::l10n()->t('You are now authenticated to pumpio.');
|
||||||
$o .= '<br /><a href="' . DI::baseUrl() . '/settings/connectors">' . DI::l10n()->t('return to the connector page') . '</a>';
|
$o .= '<br /><a href="' . DI::baseUrl() . '/settings/connectors">' . DI::l10n()->t('return to the connector page') . '</a>';
|
||||||
} else {
|
} else {
|
||||||
Logger::notice('pumpio_connect: could not connect');
|
DI::logger()->notice('pumpio_connect: could not connect');
|
||||||
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
|
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +318,7 @@ function pumpio_settings_post(array &$b)
|
||||||
|
|
||||||
function pumpio_load_config(ConfigFileManager $loader)
|
function pumpio_load_config(ConfigFileManager $loader)
|
||||||
{
|
{
|
||||||
DI::app()->getConfigCache()->load($loader->loadAddonConfig('pumpio'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('pumpio'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_hook_fork(array &$b)
|
function pumpio_hook_fork(array &$b)
|
||||||
|
@ -346,7 +344,7 @@ function pumpio_hook_fork(array &$b)
|
||||||
if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) {
|
if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) {
|
||||||
// Don't fork if it isn't a reply to a pump.io post
|
// Don't fork if it isn't a reply to a pump.io post
|
||||||
if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
|
if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
|
||||||
Logger::notice('No pump.io parent found for item ' . $post['id']);
|
DI::logger()->notice('No pump.io parent found for item ' . $post['id']);
|
||||||
$b['execute'] = false;
|
$b['execute'] = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -390,7 +388,7 @@ function pumpio_send(array &$b)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::debug('pumpio_send: parameter ', $b);
|
DI::logger()->debug('pumpio_send: parameter ', $b);
|
||||||
|
|
||||||
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b));
|
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b));
|
||||||
|
|
||||||
|
@ -400,7 +398,7 @@ function pumpio_send(array &$b)
|
||||||
$orig_post = Post::selectFirst([], $condition);
|
$orig_post = Post::selectFirst([], $condition);
|
||||||
|
|
||||||
if (!DBA::isResult($orig_post)) {
|
if (!DBA::isResult($orig_post)) {
|
||||||
Logger::notice('pumpio_send: no pumpio post ' . $b['parent']);
|
DI::logger()->notice('pumpio_send: no pumpio post ' . $b['parent']);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$iscomment = true;
|
$iscomment = true;
|
||||||
|
@ -410,7 +408,7 @@ function pumpio_send(array &$b)
|
||||||
|
|
||||||
$receiver = pumpio_getreceiver($b);
|
$receiver = pumpio_getreceiver($b);
|
||||||
|
|
||||||
Logger::notice('pumpio_send: receiver ', $receiver);
|
DI::logger()->notice('pumpio_send: receiver ', $receiver);
|
||||||
|
|
||||||
if (!count($receiver) && ($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'pumpio')) {
|
if (!count($receiver) && ($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'pumpio')) {
|
||||||
return;
|
return;
|
||||||
|
@ -544,13 +542,13 @@ function pumpio_send(array &$b)
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_id = $user->object->id;
|
$post_id = $user->object->id;
|
||||||
Logger::notice('pumpio_send ' . $username . ': success ' . $post_id);
|
DI::logger()->notice('pumpio_send ' . $username . ': success ' . $post_id);
|
||||||
if ($post_id && $iscomment) {
|
if ($post_id && $iscomment) {
|
||||||
Logger::notice('pumpio_send ' . $username . ': Update extid ' . $post_id . ' for post id ' . $b['id']);
|
DI::logger()->notice('pumpio_send ' . $username . ': Update extid ' . $post_id . ' for post id ' . $b['id']);
|
||||||
Item::update(['extid' => $post_id], ['id' => $b['id']]);
|
Item::update(['extid' => $post_id], ['id' => $b['id']]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger::notice('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
|
DI::logger()->notice('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
|
||||||
Worker::defer();
|
Worker::defer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,6 +580,8 @@ function pumpio_action(int $uid, string $uri, string $action, string $content =
|
||||||
$uri = $orig_post['uri'];
|
$uri = $orig_post['uri'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$objectType = '';
|
||||||
|
|
||||||
if (($orig_post['object-type'] != '') && (strstr($orig_post['object-type'], ActivityNamespace::ACTIVITY_SCHEMA))) {
|
if (($orig_post['object-type'] != '') && (strstr($orig_post['object-type'], ActivityNamespace::ACTIVITY_SCHEMA))) {
|
||||||
$objectType = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post['object-type']);
|
$objectType = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post['object-type']);
|
||||||
} elseif (strstr($uri, '/api/comment/')) {
|
} elseif (strstr($uri, '/api/comment/')) {
|
||||||
|
@ -618,9 +618,9 @@ function pumpio_action(int $uid, string $uri, string $action, string $content =
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
Logger::notice('pumpio_action '.$username.' '.$action.': success '.$uri);
|
DI::logger()->notice('pumpio_action '.$username.' '.$action.': success '.$uri);
|
||||||
} else {
|
} else {
|
||||||
Logger::notice('pumpio_action '.$username.' '.$action.': general error: '.$uri);
|
DI::logger()->notice('pumpio_action '.$username.' '.$action.': general error: '.$uri);
|
||||||
Worker::defer();
|
Worker::defer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -638,15 +638,15 @@ function pumpio_sync()
|
||||||
if ($last) {
|
if ($last) {
|
||||||
$next = $last + ($poll_interval * 60);
|
$next = $last + ($poll_interval * 60);
|
||||||
if ($next > time()) {
|
if ($next > time()) {
|
||||||
Logger::notice('pumpio: poll intervall not reached');
|
DI::logger()->notice('pumpio: poll intervall not reached');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Logger::notice('pumpio: cron_start');
|
DI::logger()->notice('pumpio: cron_start');
|
||||||
|
|
||||||
$pconfigs = DBA::selectToArray('pconfig', ['uid'], ['cat' => 'pumpio', 'k' => 'mirror', 'v' => '1']);
|
$pconfigs = DBA::selectToArray('pconfig', ['uid'], ['cat' => 'pumpio', 'k' => 'mirror', 'v' => '1']);
|
||||||
foreach ($pconfigs as $rr) {
|
foreach ($pconfigs as $rr) {
|
||||||
Logger::notice('pumpio: mirroring user '.$rr['uid']);
|
DI::logger()->notice('pumpio: mirroring user '.$rr['uid']);
|
||||||
pumpio_fetchtimeline($rr['uid']);
|
pumpio_fetchtimeline($rr['uid']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,12 +661,12 @@ function pumpio_sync()
|
||||||
foreach ($pconfigs as $rr) {
|
foreach ($pconfigs as $rr) {
|
||||||
if ($abandon_days != 0) {
|
if ($abandon_days != 0) {
|
||||||
if (DBA::exists('user', ["uid = ? AND `login_date` >= ?", $rr['uid'], $abandon_limit])) {
|
if (DBA::exists('user', ["uid = ? AND `login_date` >= ?", $rr['uid'], $abandon_limit])) {
|
||||||
Logger::notice('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
|
DI::logger()->notice('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::notice('pumpio: importing timeline from user '.$rr['uid']);
|
DI::logger()->notice('pumpio: importing timeline from user '.$rr['uid']);
|
||||||
pumpio_fetchinbox($rr['uid']);
|
pumpio_fetchinbox($rr['uid']);
|
||||||
|
|
||||||
// check for new contacts once a day
|
// check for new contacts once a day
|
||||||
|
@ -683,7 +683,7 @@ function pumpio_sync()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::notice('pumpio: cron_end');
|
DI::logger()->notice('pumpio: cron_end');
|
||||||
|
|
||||||
DI::keyValue()->set('pumpio_last_poll', time());
|
DI::keyValue()->set('pumpio_last_poll', time());
|
||||||
}
|
}
|
||||||
|
@ -728,7 +728,7 @@ function pumpio_fetchtimeline(int $uid)
|
||||||
|
|
||||||
$url = 'https://'.$hostname.'/api/user/'.$username.'/feed/major';
|
$url = 'https://'.$hostname.'/api/user/'.$username.'/feed/major';
|
||||||
|
|
||||||
Logger::notice('pumpio: fetching for user ' . $uid . ' ' . $url . ' C:' . $client->client_id . ' CS:' . $client->client_secret . ' T:' . $client->access_token . ' TS:' . $client->access_token_secret);
|
DI::logger()->notice('pumpio: fetching for user ' . $uid . ' ' . $url . ' C:' . $client->client_id . ' CS:' . $client->client_secret . ' T:' . $client->access_token . ' TS:' . $client->access_token_secret);
|
||||||
|
|
||||||
$useraddr = $username.'@'.$hostname;
|
$useraddr = $username.'@'.$hostname;
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ function pumpio_fetchtimeline(int $uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
Logger::notice('pumpio: error fetching posts for user ' . $uid . ' ' . $useraddr . ' ', $user);
|
DI::logger()->notice('pumpio: error fetching posts for user ' . $uid . ' ' . $useraddr . ' ', $user);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,11 +800,11 @@ function pumpio_fetchtimeline(int $uid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::notice('pumpio: posting for user ' . $uid);
|
DI::logger()->notice('pumpio: posting for user ' . $uid);
|
||||||
|
|
||||||
Item::insert($postarray, true);
|
Item::insert($postarray, true);
|
||||||
|
|
||||||
Logger::notice('pumpio: posting done - user ' . $uid);
|
DI::logger()->notice('pumpio: posting done - user ' . $uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -827,6 +827,7 @@ function pumpio_dounlike(int $uid, array $self, $post, string $own_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
$contactid = 0;
|
$contactid = 0;
|
||||||
|
$contact = [];
|
||||||
|
|
||||||
if (Strings::compareLink($post->actor->url, $own_id)) {
|
if (Strings::compareLink($post->actor->url, $own_id)) {
|
||||||
$contactid = $self['id'];
|
$contactid = $self['id'];
|
||||||
|
@ -844,16 +845,16 @@ function pumpio_dounlike(int $uid, array $self, $post, string $own_id)
|
||||||
Item::markForDeletion(['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
|
Item::markForDeletion(['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]);
|
||||||
|
|
||||||
if (DBA::isResult($contact)) {
|
if (DBA::isResult($contact)) {
|
||||||
Logger::notice('pumpio_dounlike: unliked existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
|
DI::logger()->notice('pumpio_dounlike: unliked existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
|
||||||
} else {
|
} else {
|
||||||
Logger::notice('pumpio_dounlike: not found. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' Url ' . $orig_post['uri']);
|
DI::logger()->notice('pumpio_dounlike: not found. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' Url ' . $orig_post['uri']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcompletion = true)
|
function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcompletion = true)
|
||||||
{
|
{
|
||||||
if (empty($post->object->id)) {
|
if (empty($post->object->id)) {
|
||||||
Logger::info('Got empty like: '.print_r($post, true));
|
DI::logger()->info('Got empty like: '.print_r($post, true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -898,7 +899,7 @@ function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcomp
|
||||||
];
|
];
|
||||||
|
|
||||||
if (Post::exists($condition)) {
|
if (Post::exists($condition)) {
|
||||||
Logger::notice('pumpio_dolike: found existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
|
DI::logger()->notice('pumpio_dolike: found existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -932,7 +933,7 @@ function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcomp
|
||||||
|
|
||||||
$ret = Item::insert($likedata);
|
$ret = Item::insert($likedata);
|
||||||
|
|
||||||
Logger::notice('pumpio_dolike: ' . $ret . ' User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
|
DI::logger()->notice('pumpio_dolike: ' . $ret . ' User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_get_contact($uid, $contact, $no_insert = false)
|
function pumpio_get_contact($uid, $contact, $no_insert = false)
|
||||||
|
@ -1403,7 +1404,7 @@ function pumpio_fetchallcomments($uid, $id)
|
||||||
$hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
|
$hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
|
||||||
$username = DI::pConfig()->get($uid, 'pumpio', 'user');
|
$username = DI::pConfig()->get($uid, 'pumpio', 'user');
|
||||||
|
|
||||||
Logger::notice('pumpio_fetchallcomments: completing comment for user ' . $uid . ' post id ' . $id);
|
DI::logger()->notice('pumpio_fetchallcomments: completing comment for user ' . $uid . ' post id ' . $id);
|
||||||
|
|
||||||
$own_id = 'https://' . $hostname . '/' . $username;
|
$own_id = 'https://' . $hostname . '/' . $username;
|
||||||
|
|
||||||
|
@ -1428,7 +1429,9 @@ function pumpio_fetchallcomments($uid, $id)
|
||||||
$client->access_token = $otoken;
|
$client->access_token = $otoken;
|
||||||
$client->access_token_secret = $osecret;
|
$client->access_token_secret = $osecret;
|
||||||
|
|
||||||
Logger::notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url);
|
DI::logger()->notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url);
|
||||||
|
|
||||||
|
$item = new \stdClass();
|
||||||
|
|
||||||
if (pumpio_reachable($url)) {
|
if (pumpio_reachable($url)) {
|
||||||
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError' => true], $item);
|
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError' => true], $item);
|
||||||
|
@ -1491,7 +1494,7 @@ function pumpio_fetchallcomments($uid, $id)
|
||||||
|
|
||||||
$post->object = $item;
|
$post->object = $item;
|
||||||
|
|
||||||
Logger::notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', json_decode(json_encode($post), true));
|
DI::logger()->notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', json_decode(json_encode($post), true));
|
||||||
pumpio_dopost($client, $uid, $self, $post, $own_id, false);
|
pumpio_dopost($client, $uid, $self, $post, $own_id, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
function pumpio_sync_run(array $argv, int $argc) {
|
function pumpio_sync_run(array $argv, int $argc) {
|
||||||
|
@ -8,7 +8,7 @@ function pumpio_sync_run(array $argv, int $argc) {
|
||||||
if (function_exists('sys_getloadavg')) {
|
if (function_exists('sys_getloadavg')) {
|
||||||
$load = sys_getloadavg();
|
$load = sys_getloadavg();
|
||||||
if (intval($load[0]) > DI::config()->get('system', 'maxloadavg', 50)) {
|
if (intval($load[0]) > DI::config()->get('system', 'maxloadavg', 50)) {
|
||||||
Logger::notice('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.');
|
DI::logger()->notice('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
|
@ -19,9 +19,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -41,7 +39,7 @@ function randplace_install()
|
||||||
Hook::register('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings');
|
Hook::register('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings');
|
||||||
Hook::register('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
|
Hook::register('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
|
||||||
|
|
||||||
Logger::notice("installed randplace");
|
DI::logger()->notice("installed randplace");
|
||||||
}
|
}
|
||||||
|
|
||||||
function randplace_uninstall()
|
function randplace_uninstall()
|
||||||
|
@ -51,7 +49,7 @@ function randplace_uninstall()
|
||||||
*
|
*
|
||||||
* Except hooks, they are all unregistered automatically and don't need to be unregistered manually.
|
* Except hooks, they are all unregistered automatically and don't need to be unregistered manually.
|
||||||
*/
|
*/
|
||||||
Logger::notice("removed randplace");
|
DI::logger()->notice("removed randplace");
|
||||||
}
|
}
|
||||||
|
|
||||||
function randplace_post_hook(&$item)
|
function randplace_post_hook(&$item)
|
||||||
|
@ -62,7 +60,7 @@ function randplace_post_hook(&$item)
|
||||||
* - A status post by a profile owner
|
* - A status post by a profile owner
|
||||||
* - The profile owner must have allowed our addon
|
* - The profile owner must have allowed our addon
|
||||||
*/
|
*/
|
||||||
Logger::notice('randplace invoked');
|
DI::logger()->notice('randplace invoked');
|
||||||
|
|
||||||
if (!DI::userSession()->getLocalUserId()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
/* non-zero if this is a logged in user of this system */
|
/* non-zero if this is a logged in user of this system */
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
namespace Friendica\Addon\ratioed;
|
namespace Friendica\Addon\ratioed;
|
||||||
|
|
||||||
use Friendica\Content\Pager;
|
use Friendica\Content\Pager;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
use Friendica\Model\Verb;
|
||||||
use Friendica\Module\Moderation\Users\Active;
|
use Friendica\Module\Moderation\Users\Active;
|
||||||
|
use Friendica\Protocol\Activity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements the "Behaviour" panel in Moderation/Users
|
* This class implements the "Behaviour" panel in Moderation/Users
|
||||||
|
@ -24,38 +25,17 @@ class RatioedPanel extends Active
|
||||||
return Renderer::replaceMacros($template, array('$config' => DI::baseUrl() . '/settings/addon'));
|
return Renderer::replaceMacros($template, array('$config' => DI::baseUrl() . '/settings/addon'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = $this->parameters['action'] ?? '';
|
|
||||||
$uid = $this->parameters['uid'] ?? 0;
|
$uid = $this->parameters['uid'] ?? 0;
|
||||||
|
$user = [];
|
||||||
|
|
||||||
if ($uid) {
|
if ($uid) {
|
||||||
$user = User::getById($uid, ['username', 'blocked']);
|
$user = User::getById($uid, ['username', 'blocked']);
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->systemMessages->addNotice($this->t('User not found'));
|
$this->systemMessages->addNotice($this->t('User not found'));
|
||||||
$this->baseUrl->redirect('moderation/users');
|
$this->baseUrl->redirect('ratioed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($action) {
|
|
||||||
case 'delete':
|
|
||||||
if ($this->session->getLocalUserId() != $uid) {
|
|
||||||
self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't');
|
|
||||||
// delete user
|
|
||||||
User::remove($uid);
|
|
||||||
|
|
||||||
$this->systemMessages->addNotice($this->t('User "%s" deleted', $user['username']));
|
|
||||||
} else {
|
|
||||||
$this->systemMessages->addNotice($this->t('You can\'t remove yourself'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->baseUrl->redirect('moderation/users/active');
|
|
||||||
break;
|
|
||||||
case 'block':
|
|
||||||
self::checkFormSecurityTokenRedirectOnError('moderation/users/active', 'moderation_users_active', 't');
|
|
||||||
User::block($uid);
|
|
||||||
$this->systemMessages->addNotice($this->t('User "%s" blocked', $user['username']));
|
|
||||||
$this->baseUrl->redirect('moderation/users/active');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$pager = new Pager($this->l10n, $this->args->getQueryString(), 100);
|
$pager = new Pager($this->l10n, $this->args->getQueryString(), 100);
|
||||||
|
|
||||||
$valid_orders = [
|
$valid_orders = [
|
||||||
|
@ -68,9 +48,9 @@ class RatioedPanel extends Active
|
||||||
];
|
];
|
||||||
|
|
||||||
$order = 'last-item';
|
$order = 'last-item';
|
||||||
$order_direction = '-';
|
$order_direction = '+';
|
||||||
if (!empty($request['o'])) {
|
if (!empty($_REQUEST['o'])) {
|
||||||
$new_order = $request['o'];
|
$new_order = $_REQUEST['o'];
|
||||||
if ($new_order[0] === '-') {
|
if ($new_order[0] === '-') {
|
||||||
$order_direction = '-';
|
$order_direction = '-';
|
||||||
$new_order = substr($new_order, 1);
|
$new_order = substr($new_order, 1);
|
||||||
|
@ -96,6 +76,11 @@ class RatioedPanel extends Active
|
||||||
$this->t('Comments last 24h'),
|
$this->t('Comments last 24h'),
|
||||||
$this->t('Reactions last 24h'),
|
$this->t('Reactions last 24h'),
|
||||||
$this->t('Ratio last 24h'),
|
$this->t('Ratio last 24h'),
|
||||||
|
$this->t('Replies last month'),
|
||||||
|
$this->t('Reply likes'),
|
||||||
|
$this->t('Respondee likes'),
|
||||||
|
$this->t('OP likes'),
|
||||||
|
$this->t('Reply guy score'),
|
||||||
];
|
];
|
||||||
$field_names = [
|
$field_names = [
|
||||||
'name',
|
'name',
|
||||||
|
@ -108,6 +93,11 @@ class RatioedPanel extends Active
|
||||||
'comments',
|
'comments',
|
||||||
'reactions',
|
'reactions',
|
||||||
'ratio',
|
'ratio',
|
||||||
|
'reply_count',
|
||||||
|
'reply_likes',
|
||||||
|
'reply_respondee_likes',
|
||||||
|
'reply_op_likes',
|
||||||
|
'reply_guy_score',
|
||||||
];
|
];
|
||||||
$th_users = array_map(null, $header_titles, $valid_orders, $field_names);
|
$th_users = array_map(null, $header_titles, $valid_orders, $field_names);
|
||||||
|
|
||||||
|
@ -146,9 +136,130 @@ class RatioedPanel extends Active
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getReplyGuyRow($contact_uid)
|
||||||
|
{
|
||||||
|
$like_vid = Verb::getID(Activity::LIKE);
|
||||||
|
$post_vid = Verb::getID(Activity::POST);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is a complicated query.
|
||||||
|
*
|
||||||
|
* The innermost select retrieves a chain of four posts: an
|
||||||
|
* original post, a target comment (possibly deep down in the
|
||||||
|
* thread), a reply from our user, and a like for that reply.
|
||||||
|
* If there's no like, we still want to count the reply, so we
|
||||||
|
* use an outer join.
|
||||||
|
*
|
||||||
|
* The second select adds "points" for different kinds of
|
||||||
|
* likes. The outermost select then counts up these points,
|
||||||
|
* and the number of distinct replies.
|
||||||
|
*/
|
||||||
|
$reply_guy_result = DBA::p('
|
||||||
|
SELECT
|
||||||
|
COUNT(distinct reply_id) AS replies_total,
|
||||||
|
SUM(like_point) AS like_total,
|
||||||
|
SUM(target_like_point) AS target_like_total,
|
||||||
|
SUM(original_like_point) AS original_like_total
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
reply_id,
|
||||||
|
like_date,
|
||||||
|
like_date IS NOT NULL AS like_point,
|
||||||
|
like_author = target_author AS target_like_point,
|
||||||
|
like_author = original_author AS original_like_point
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
original_post.`uri-id` AS original_id,
|
||||||
|
original_post.`author-id` AS original_author,
|
||||||
|
original_post.created AS original_date,
|
||||||
|
target_post.`uri-id` AS target_id,
|
||||||
|
target_post.`author-id` AS target_author,
|
||||||
|
target_post.created AS target_date,
|
||||||
|
reply_post.`uri-id` AS reply_id,
|
||||||
|
reply_post.`author-id` AS reply_author,
|
||||||
|
reply_post.created AS reply_date,
|
||||||
|
like_post.`uri-id` AS like_id,
|
||||||
|
like_post.`author-id` AS like_author,
|
||||||
|
like_post.created AS like_date
|
||||||
|
FROM
|
||||||
|
post AS original_post
|
||||||
|
JOIN
|
||||||
|
post AS target_post
|
||||||
|
ON
|
||||||
|
original_post.`uri-id` = target_post.`parent-uri-id`
|
||||||
|
JOIN
|
||||||
|
post AS reply_post
|
||||||
|
ON
|
||||||
|
target_post.`uri-id` = reply_post.`thr-parent-id` AND
|
||||||
|
reply_post.`author-id` = ? AND
|
||||||
|
reply_post.`author-id` != target_post.`author-id` AND
|
||||||
|
reply_post.`author-id` != original_post.`author-id` AND
|
||||||
|
reply_post.`uri-id` != reply_post.`thr-parent-id` AND
|
||||||
|
reply_post.vid = ? AND
|
||||||
|
reply_post.created > CURDATE() - INTERVAL 1 MONTH
|
||||||
|
LEFT OUTER JOIN
|
||||||
|
post AS like_post
|
||||||
|
ON
|
||||||
|
reply_post.`uri-id` = like_post.`thr-parent-id` AND
|
||||||
|
like_post.vid = ? AND
|
||||||
|
like_post.`author-id` != reply_post.`author-id`
|
||||||
|
) AS post_meta
|
||||||
|
) AS reply_counts
|
||||||
|
', $contact_uid, $post_vid, $like_vid);
|
||||||
|
return $reply_guy_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/48283297/235936
|
||||||
|
protected function sigFig($value, $digits)
|
||||||
|
{
|
||||||
|
if ($value == 0) {
|
||||||
|
$decimalPlaces = $digits - 1;
|
||||||
|
} elseif ($value < 0) {
|
||||||
|
$decimalPlaces = $digits - floor(log10($value * -1)) - 1;
|
||||||
|
} else {
|
||||||
|
$decimalPlaces = $digits - floor(log10($value)) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$answer = ($decimalPlaces > 0) ?
|
||||||
|
number_format($value, $decimalPlaces) : round($value, $decimalPlaces);
|
||||||
|
return $answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function fillReplyGuyData(&$user)
|
||||||
|
{
|
||||||
|
$reply_guy_result = $this->getReplyGuyRow($user['user_contact_uid']);
|
||||||
|
if (DBA::isResult($reply_guy_result)) {
|
||||||
|
$reply_guy_result_row = DBA::fetch($reply_guy_result);
|
||||||
|
$user['reply_count'] = (int) $reply_guy_result_row['replies_total'] ?? 0;
|
||||||
|
$user['reply_likes'] = (int) $reply_guy_result_row['like_total'] ?? 0;
|
||||||
|
$user['reply_respondee_likes'] = (int) $reply_guy_result_row['target_like_total'] ?? 0;
|
||||||
|
$user['reply_op_likes'] = (int) $reply_guy_result_row['original_like_total'] ?? 0;
|
||||||
|
|
||||||
|
$denominator = $user['reply_likes'] + $user['reply_respondee_likes'] + $user['reply_op_likes'];
|
||||||
|
if ($user['reply_count'] === 0) {
|
||||||
|
$user['reply_guy'] = false;
|
||||||
|
$user['reply_guy_score'] = 0;
|
||||||
|
} elseif ($denominator == 0) {
|
||||||
|
$user['reply_guy'] = true;
|
||||||
|
$user['reply_guy_score'] = '∞';
|
||||||
|
} else {
|
||||||
|
$reply_guy_score = $user['reply_count'] / $denominator;
|
||||||
|
$user['reply_guy'] = $reply_guy_score >= 1.0;
|
||||||
|
$user['reply_guy_score'] = $this->sigFig($reply_guy_score, 2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$user['reply_count'] = "error";
|
||||||
|
$user['reply_likes'] = "error";
|
||||||
|
$user['reply_respondee_likes'] = "error";
|
||||||
|
$user['reply_op_likes'] = "error";
|
||||||
|
$user['reply_guy'] = false;
|
||||||
|
$user['reply_guy_score'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function setupUserCallback(): \Closure
|
protected function setupUserCallback(): \Closure
|
||||||
{
|
{
|
||||||
Logger::debug("ratioed: setupUserCallback");
|
DI::logger()->debug("ratioed: setupUserCallback");
|
||||||
$parentCallback = parent::setupUserCallback();
|
$parentCallback = parent::setupUserCallback();
|
||||||
return function ($user) use ($parentCallback) {
|
return function ($user) use ($parentCallback) {
|
||||||
$blocked_count = DBA::count('user-contact', ['uid' => $user['uid'], 'is-blocked' => 1]);
|
$blocked_count = DBA::count('user-contact', ['uid' => $user['uid'], 'is-blocked' => 1]);
|
||||||
|
@ -158,9 +269,8 @@ class RatioedPanel extends Active
|
||||||
if (DBA::isResult($self_contact_result)) {
|
if (DBA::isResult($self_contact_result)) {
|
||||||
$self_contact_result_row = DBA::fetch($self_contact_result);
|
$self_contact_result_row = DBA::fetch($self_contact_result);
|
||||||
$user['user_contact_uid'] = $self_contact_result_row['user_contact_uid'];
|
$user['user_contact_uid'] = $self_contact_result_row['user_contact_uid'];
|
||||||
}
|
} else {
|
||||||
else {
|
$user['user_contact_uid'] = null;
|
||||||
$user['user_contact_uid'] = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user['user_contact_uid']) {
|
if ($user['user_contact_uid']) {
|
||||||
|
@ -172,34 +282,34 @@ class RatioedPanel extends Active
|
||||||
if ($user['reactions'] > 0) {
|
if ($user['reactions'] > 0) {
|
||||||
$user['ratio'] = number_format($user['comments'] / $user['reactions'], 1, '.', '');
|
$user['ratio'] = number_format($user['comments'] / $user['reactions'], 1, '.', '');
|
||||||
$user['ratioed'] = (float)($user['ratio']) >= 2.0;
|
$user['ratioed'] = (float)($user['ratio']) >= 2.0;
|
||||||
}
|
} else {
|
||||||
else {
|
$user['reactions'] = 0;
|
||||||
if ($user['comments'] == 0) {
|
if ($user['comments'] == 0) {
|
||||||
$user['ratio'] = '0';
|
$user['comments'] = 0;
|
||||||
|
$user['ratio'] = 0;
|
||||||
$user['ratioed'] = false;
|
$user['ratioed'] = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$user['ratio'] = '∞';
|
$user['ratio'] = '∞';
|
||||||
$user['ratioed'] = false;
|
$user['ratioed'] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$user['comments'] = 'error';
|
$user['comments'] = 'error';
|
||||||
$user['reactions'] = 'error';
|
$user['reactions'] = 'error';
|
||||||
$user['ratio'] = 'error';
|
$user['ratio'] = 'error';
|
||||||
$user['ratioed'] = false;
|
$user['ratioed'] = false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$user['comments'] = 'error';
|
$user['comments'] = 'error';
|
||||||
$user['reactions'] = 'error';
|
$user['reactions'] = 'error';
|
||||||
$user['ratio'] = 'error';
|
$user['ratio'] = 'error';
|
||||||
$user['ratioed'] = false;
|
$user['ratioed'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->fillReplyGuyData($user);
|
||||||
|
|
||||||
$user = $parentCallback($user);
|
$user = $parentCallback($user);
|
||||||
Logger::debug("ratioed: setupUserCallback", [
|
DI::logger()->debug("ratioed: setupUserCallback", [
|
||||||
'uid' => $user['uid'],
|
'uid' => $user['uid'],
|
||||||
'blocked_by' => $user['blocked_by'],
|
'blocked_by' => $user['blocked_by'],
|
||||||
'comments' => $user['comments'],
|
'comments' => $user['comments'],
|
||||||
|
|
|
@ -2,13 +2,12 @@
|
||||||
/**
|
/**
|
||||||
* Name: Ratioed
|
* Name: Ratioed
|
||||||
* Description: Additional moderation user table with statistics about user behaviour
|
* Description: Additional moderation user table with statistics about user behaviour
|
||||||
* Version: 0.1
|
* Version: 0.3
|
||||||
* Author: Matthew Exon <http://mat.exon.name>
|
* Author: Matthew Exon <http://mat.exon.name>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Addon\ratioed\RatioedPanel;
|
use Friendica\Addon\ratioed\RatioedPanel;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +17,7 @@ function ratioed_install()
|
||||||
{
|
{
|
||||||
Hook::register('moderation_users_tabs', 'addon/ratioed/ratioed.php', 'ratioed_users_tabs');
|
Hook::register('moderation_users_tabs', 'addon/ratioed/ratioed.php', 'ratioed_users_tabs');
|
||||||
|
|
||||||
Logger::info("ratioed: installed");
|
DI::logger()->info("ratioed: installed");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +33,7 @@ function ratioed_module() {}
|
||||||
* @param array $arr Parameters, including "tabs" which is the list to modify, and "selectedTab", which is the currently selected tab ID
|
* @param array $arr Parameters, including "tabs" which is the list to modify, and "selectedTab", which is the currently selected tab ID
|
||||||
*/
|
*/
|
||||||
function ratioed_users_tabs(array &$arr) {
|
function ratioed_users_tabs(array &$arr) {
|
||||||
Logger::debug("ratioed: users tabs");
|
DI::logger()->debug("ratioed: users tabs");
|
||||||
|
|
||||||
array_push($arr['tabs'], [
|
array_push($arr['tabs'], [
|
||||||
'label' => DI::l10n()->t('Behaviour'),
|
'label' => DI::l10n()->t('Behaviour'),
|
||||||
|
@ -50,7 +49,7 @@ function ratioed_users_tabs(array &$arr) {
|
||||||
* @brief Displays the ratioed tab in the moderation panel
|
* @brief Displays the ratioed tab in the moderation panel
|
||||||
*/
|
*/
|
||||||
function ratioed_content() {
|
function ratioed_content() {
|
||||||
Logger::debug("ratioed: content");
|
DI::logger()->debug("ratioed: content");
|
||||||
|
|
||||||
$ratioed = DI::getDice()->create(RatioedPanel::class, [$_SERVER]);
|
$ratioed = DI::getDice()->create(RatioedPanel::class, [$_SERVER]);
|
||||||
$httpException = DI::getDice()->create(Friendica\Module\Special\HTTPException::class);
|
$httpException = DI::getDice()->create(Friendica\Module\Special\HTTPException::class);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<h2>Ratioed Plugin Help</h2>
|
<h2>Ratioed Plugin Help</h2>
|
||||||
<p>
|
<p>
|
||||||
This plugin provides administrators with additional statistics about
|
This plugin provides moderators with additional statistics about
|
||||||
the behaviour of users. These may be useful as early warning signs
|
the behaviour of users. These may be useful as early warning signs
|
||||||
that warrant more carefully watching the behaviour of a user. They
|
that warrant more carefully watching the behaviour of a user. They
|
||||||
are <em>not</em> suitable as a trigger for instantly blocking,
|
are <em>not</em> suitable as a trigger for instantly blocking,
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
<p>
|
<p>
|
||||||
This plugin allows viewing of an actual ratio, calculated over the
|
This plugin allows viewing of an actual ratio, calculated over the
|
||||||
last 24 hours. This is a useful timeframe for sudden dogpiling
|
last 24 hours. This is a useful timeframe for sudden dogpiling
|
||||||
events that administrators might not otherwise notice. The plugin
|
events that moderators might not otherwise notice. The plugin
|
||||||
also calculates other statistics.
|
also calculates other statistics.
|
||||||
</p>
|
</p>
|
||||||
<h3>Explanation of Statistics</h3>
|
<h3>Explanation of Statistics</h3>
|
||||||
|
@ -68,10 +68,63 @@
|
||||||
24h". It is intended to approximate the traditional ratio as
|
24h". It is intended to approximate the traditional ratio as
|
||||||
understood on Twitter.
|
understood on Twitter.
|
||||||
</p>
|
</p>
|
||||||
|
<h4>Replies last month</h4>
|
||||||
|
<p>
|
||||||
|
This is the number of times the user posted a reply to someone
|
||||||
|
else, on a thread the user did not start, any time in the last
|
||||||
|
month.
|
||||||
|
</p>
|
||||||
|
<h4>Reply likes</h4>
|
||||||
|
<p>
|
||||||
|
This is the number of likes received by the user on their
|
||||||
|
replies to other people's posts in the last month. Replies that
|
||||||
|
receive likes can be assumed to be more of a valuable
|
||||||
|
contribution than replies that do not.
|
||||||
|
</p>
|
||||||
|
<h4>Respondee likes</h4>
|
||||||
|
<p>
|
||||||
|
The number of times in the last month the user replied to
|
||||||
|
someone else's comment and that person then liked the reply.
|
||||||
|
Likes to replies are not necessarily a positive thing, but if
|
||||||
|
the person you're replying to approves the reply, that's a very
|
||||||
|
good sign. Of course it's also common in a debate for neither
|
||||||
|
side to like the other side's comments without that indicating
|
||||||
|
an unhealthy interaction, so interpret this statistic cautiously.
|
||||||
|
</p>
|
||||||
|
<h4>OP likes</h4>
|
||||||
|
<p>
|
||||||
|
The number of times in the last month the user replied on a
|
||||||
|
thread and the original poster that started the thread liked the
|
||||||
|
reply. While there is no formal concept of "ownership" of a
|
||||||
|
thread, conventionally the original poster is assumed to have
|
||||||
|
started the thread for a reason, and making replies that do not
|
||||||
|
fulfil that purpose are bad etiquette. Getting approval from
|
||||||
|
the original poster therefore is a good sign that the user is
|
||||||
|
posting replies that are wanted.
|
||||||
|
</p>
|
||||||
|
<h4>Reply guy score</h4>
|
||||||
|
<p>
|
||||||
|
A <a href="https://en.wikipedia.org/wiki/Reply_guy">"reply
|
||||||
|
guy"</a> is a common Internet phenomenon of people
|
||||||
|
(disproportionately male) posting unwanted comments on other
|
||||||
|
(disproportionately female) people's threads, derailing the
|
||||||
|
conversation. This score loosely quantifies this phenomenon,
|
||||||
|
as the ratio betwen the number of replies and the sum of likes,
|
||||||
|
respondee likes, and OP likes. This formula gives extra weight
|
||||||
|
to particularly relevant likes: a reply to a top-level post that
|
||||||
|
is liked by the original poster scores the maximum of 3
|
||||||
|
"points". A score above 1.0 might indicate cause for concern
|
||||||
|
for moderators.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Since this is indicative of long-term behaviour, the score is
|
||||||
|
calculated over a month instead of 24 hours.
|
||||||
|
</p>
|
||||||
|
</p>
|
||||||
<h3>Performance</h3>
|
<h3>Performance</h3>
|
||||||
<p>
|
<p>
|
||||||
The statistics are computed from scratch each time the page loads.
|
The statistics are computed from scratch each time the page loads.
|
||||||
It's possible that this might put a heavy load on the database. and
|
It's possible that this might put a heavy load on the database, and
|
||||||
the page may take a long time to load.
|
the page may take a long time to load.
|
||||||
</p>
|
</p>
|
||||||
<h3>Extending</h3>
|
<h3>Extending</h3>
|
||||||
|
|
|
@ -2,26 +2,21 @@
|
||||||
<link rel="stylesheet" href="view/theme/frio/css/mod_admin.css?v={{constant('\Friendica\App::VERSION')}}" type="text/css" media="screen"/>
|
<link rel="stylesheet" href="view/theme/frio/css/mod_admin.css?v={{constant('\Friendica\App::VERSION')}}" type="text/css" media="screen"/>
|
||||||
|
|
||||||
<div id="admin-users" class="adminpage generic-page-wrapper">
|
<div id="admin-users" class="adminpage generic-page-wrapper">
|
||||||
<h1>{{$title}} - {{$page}} ({{$count}})</h1>
|
<h1>
|
||||||
<p>
|
{{$title}} - {{$page}} ({{$count}})
|
||||||
<a href="{{$base_url}}/moderation/users/create" class="btn btn-primary"><i class="fa fa-user-plus"></i> {{$h_newuser}}</a>
|
<a href="{{$base_url}}/ratioed/help"><i style="float: right; font-size: 60%" class="fa fa-question-circle fa-fw" aria-hidden="true"></i></a>
|
||||||
</p>
|
</h1>
|
||||||
<form action="{{$baseurl}}/{{$query_string}}" method="post">
|
<form action="{{$baseurl}}/{{$query_string}}" method="post">
|
||||||
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
|
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
|
||||||
<table id="users" class="table table-hover">
|
<table id="users" class="table table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th></th>
|
||||||
<div class="checkbox">
|
|
||||||
<input type="checkbox" id="admin-settings-users-select" class="selecttoggle" data-select-class="users_ckbx"/>
|
|
||||||
<label for="admin-settings-users-select"></label>
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
<th></th>
|
<th></th>
|
||||||
{{foreach $th_users as $k=>$th}}
|
{{foreach $th_users as $k=>$th}}
|
||||||
{{if $k < 2 || $order_users == $th.1 || ($k==5 && !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.4.1])) }}
|
{{if $k < 2 || $order_users == $th.1 || ($k==4 && !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.5.1])) }}
|
||||||
<th class="th-{{$k}}">
|
<th class="th-{{$k}}">
|
||||||
<a href="{{$baseurl}}/moderation/users/active?o={{if $order_direction_users == "+"}}-{{/if}}{{$th.1}}" class="table-order">
|
<a href="{{$baseurl}}/ratioed?o={{if $order_direction_users == "+"}}-{{/if}}{{$th.1}}" class="table-order">
|
||||||
{{if $order_users == $th.1}}
|
{{if $order_users == $th.1}}
|
||||||
{{if $order_direction_users == "+"}}
|
{{if $order_direction_users == "+"}}
|
||||||
↓
|
↓
|
||||||
|
@ -41,17 +36,8 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{foreach $users as $u}}
|
{{foreach $users as $u}}
|
||||||
<tr id="user-{{$u.uid}}" class="{{if $u.ratioed}}blocked{{/if}}">
|
<tr id="user-{{$u.uid}}" class="{{if $u.ratioed || $u.reply_guy}}blocked{{/if}}">
|
||||||
<td>
|
<td></td>
|
||||||
{{if $u.is_deletable}}
|
|
||||||
<div class="checkbox">
|
|
||||||
<input type="checkbox" class="users_ckbx" id="id_user_{{$u.uid}}" name="user[]" value="{{$u.uid}}"/>
|
|
||||||
<label for="id_user_{{$u.uid}}"></label>
|
|
||||||
</div>
|
|
||||||
{{else}}
|
|
||||||
|
|
||||||
{{/if}}
|
|
||||||
</td>
|
|
||||||
<td><img class="avatar-nano" src="{{$u.micro}}" title="{{$u.nickname}}"></td>
|
<td><img class="avatar-nano" src="{{$u.micro}}" title="{{$u.nickname}}"></td>
|
||||||
<td><a href="{{$u.url}}" title="{{$u.nickname}}"> {{$u.name}}</a></td>
|
<td><a href="{{$u.url}}" title="{{$u.nickname}}"> {{$u.name}}</a></td>
|
||||||
<td>{{$u.email}}</td>
|
<td>{{$u.email}}</td>
|
||||||
|
@ -63,11 +49,7 @@
|
||||||
<td>{{$u.login_date}}</td>
|
<td>{{$u.login_date}}</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{if $order_users == $th_users.4.1}}
|
{{if $order_users == $th_users.5.1}}
|
||||||
<td>{{$u.lastitem_date}}</td>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{if !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.4.1]) }}
|
|
||||||
<td>
|
<td>
|
||||||
<i class="fa
|
<i class="fa
|
||||||
{{if $u.page_flags_raw==0}}fa-user{{/if}} {{* PAGE_NORMAL *}}
|
{{if $u.page_flags_raw==0}}fa-user{{/if}} {{* PAGE_NORMAL *}}
|
||||||
|
@ -91,6 +73,10 @@
|
||||||
</td>
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{if !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.5.1]) }}
|
||||||
|
<td>{{$u.lastitem_date}}</td>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
<button type="button" class="btn-link admin-settings-action-link" onclick="return details({{$u.uid}})"><span class="caret"></span></button>
|
<button type="button" class="btn-link admin-settings-action-link" onclick="return details({{$u.uid}})"><span class="caret"></span></button>
|
||||||
</td>
|
</td>
|
||||||
|
@ -135,30 +121,11 @@
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right"></td>
|
||||||
{{if $u.is_deletable}}
|
|
||||||
<a href="{{$baseurl}}/moderation/users/active/block/{{$u.uid}}?t={{$form_security_token}}" class="admin-settings-action-link" title="{{$block}}">
|
|
||||||
<i class="fa fa-ban" aria-hidden="true"></i>
|
|
||||||
</a>
|
|
||||||
<a href="{{$baseurl}}/moderation/users/active/delete/{{$u.uid}}?t={{$form_security_token}}" class="admin-settings-action-link" title="{{$delete}}" onclick="return confirm_delete('{{$confirm_delete}}','{{$u.name}}')">
|
|
||||||
<i class="fa fa-trash" aria-hidden="true"></i>
|
|
||||||
</a>
|
|
||||||
{{else}}
|
|
||||||
|
|
||||||
{{/if}}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{{/foreach}}
|
{{/foreach}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="panel-footer">
|
|
||||||
<button type="submit" name="page_users_block" value="1" class="btn btn-warning">
|
|
||||||
<i class="fa fa-ban" aria-hidden="true"></i> {{$block}}
|
|
||||||
</button>
|
|
||||||
<button type="submit" name="page_users_delete" value="1" class="btn btn-danger" onclick="return confirm_delete('{{$confirm_delete_multi}}')">
|
|
||||||
<i class="fa fa-trash" aria-hidden="true"></i> {{$delete}}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{{$pager nofilter}}
|
{{$pager nofilter}}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
use Friendica\Addon\s3_storage\src\S3Client;
|
use Friendica\Addon\s3_storage\src\S3Client;
|
||||||
use Friendica\Addon\s3_storage\src\S3Config;
|
use Friendica\Addon\s3_storage\src\S3Config;
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@ namespace Friendica\Addon\s3_storage\src;
|
||||||
|
|
||||||
defined('AKEEBAENGINE') or define('AKEEBAENGINE', 1);
|
defined('AKEEBAENGINE') or define('AKEEBAENGINE', 1);
|
||||||
|
|
||||||
use Akeeba\Engine\Postproc\Connector\S3v4\Configuration;
|
use Akeeba\S3\Configuration;
|
||||||
use Akeeba\Engine\Postproc\Connector\S3v4\Connector;
|
use Akeeba\S3\Connector;
|
||||||
use Akeeba\Engine\Postproc\Connector\S3v4\Exception\CannotDeleteFile;
|
use Akeeba\S3\Exception\CannotDeleteFile;
|
||||||
use Akeeba\Engine\Postproc\Connector\S3v4\Input;
|
use Akeeba\S3\Input;
|
||||||
use Friendica\Core\Storage\Capability\ICanWriteToStorage;
|
use Friendica\Core\Storage\Capability\ICanWriteToStorage;
|
||||||
use Friendica\Core\Storage\Exception\StorageException;
|
use Friendica\Core\Storage\Exception\StorageException;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
|
@ -4,8 +4,8 @@ namespace Friendica\Addon\s3_storage\src;
|
||||||
|
|
||||||
defined('AKEEBAENGINE') or define('AKEEBAENGINE', 1);
|
defined('AKEEBAENGINE') or define('AKEEBAENGINE', 1);
|
||||||
|
|
||||||
use Akeeba\Engine\Postproc\Connector\S3v4\Configuration;
|
use Akeeba\S3\Configuration;
|
||||||
use Akeeba\Engine\Postproc\Connector\S3v4\Connector;
|
use Akeeba\S3\Connector;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Storage\Capability\ICanConfigureStorage;
|
use Friendica\Core\Storage\Capability\ICanConfigureStorage;
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2021-05-18 07:23+0200\n"
|
"POT-Creation-Date: 2025-01-17 03:23+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -17,82 +17,82 @@ msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#: saml.php:231
|
#: saml.php:81
|
||||||
|
msgid "managed via SAML authentication"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: saml.php:246
|
||||||
msgid "Settings statement"
|
msgid "Settings statement"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:232
|
|
||||||
msgid ""
|
|
||||||
"A statement on the settings page explaining where the user should go to "
|
|
||||||
"change their e-mail and password. BBCode allowed."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: saml.php:237
|
|
||||||
msgid "IdP ID"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: saml.php:238
|
|
||||||
msgid ""
|
|
||||||
"Identity provider (IdP) entity URI (e.g., https://example.com/auth/realms/"
|
|
||||||
"user)."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: saml.php:242
|
|
||||||
msgid "Client ID"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: saml.php:243
|
|
||||||
msgid "Identifier assigned to client by the identity provider (IdP)."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: saml.php:247
|
#: saml.php:247
|
||||||
msgid "IdP SSO URL"
|
msgid "A statement on the settings page explaining where the user should go to change their e-mail and password. BBCode allowed."
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: saml.php:248
|
|
||||||
msgid "The URL for your identity provider's SSO endpoint."
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:252
|
#: saml.php:252
|
||||||
msgid "IdP SLO request URL"
|
msgid "IdP ID"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:253
|
#: saml.php:253
|
||||||
msgid "The URL for your identity provider's SLO request endpoint."
|
msgid "Identity provider (IdP) entity URI (e.g., https://example.com/auth/realms/user)."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:257
|
#: saml.php:257
|
||||||
msgid "IdP SLO response URL"
|
msgid "Client ID"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:258
|
#: saml.php:258
|
||||||
msgid "The URL for your identity provider's SLO response endpoint."
|
msgid "Identifier assigned to client by the identity provider (IdP)."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:262
|
#: saml.php:262
|
||||||
msgid "SP private key"
|
msgid "IdP SSO URL"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:263
|
#: saml.php:263
|
||||||
msgid "The private key the addon should use to authenticate."
|
msgid "The URL for your identity provider's SSO endpoint."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:267
|
#: saml.php:267
|
||||||
msgid "SP certificate"
|
msgid "IdP SLO request URL"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:268
|
#: saml.php:268
|
||||||
msgid "The certficate for the addon's private key."
|
msgid "The URL for your identity provider's SLO request endpoint."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:272
|
#: saml.php:272
|
||||||
msgid "IdP certificate"
|
msgid "IdP SLO response URL"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:273
|
#: saml.php:273
|
||||||
|
msgid "The URL for your identity provider's SLO response endpoint."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: saml.php:277
|
||||||
|
msgid "SP private key"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: saml.php:278
|
||||||
|
msgid "The private key the addon should use to authenticate."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: saml.php:282
|
||||||
|
msgid "SP certificate"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: saml.php:283
|
||||||
|
msgid "The certficate for the addon's private key."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: saml.php:287
|
||||||
|
msgid "IdP certificate"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: saml.php:288
|
||||||
msgid "The x509 certficate for your identity provider."
|
msgid "The x509 certficate for your identity provider."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: saml.php:276
|
#: saml.php:291
|
||||||
msgid "Save Settings"
|
msgid "Save Settings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
#settings-form > div:first-of-type, #settings-form > h2:first-of-type, #wrapper_mpassword, #wrapper_email { display: none !important; }
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -63,7 +62,7 @@ function saml_metadata()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Logger::error($e->getMessage());
|
DI::logger()->error($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,18 +74,38 @@ function saml_install()
|
||||||
Hook::register('footer', __FILE__, 'saml_footer');
|
Hook::register('footer', __FILE__, 'saml_footer');
|
||||||
}
|
}
|
||||||
|
|
||||||
function saml_head(string &$body)
|
|
||||||
{
|
|
||||||
DI::page()->registerStylesheet(__DIR__ . '/saml.css');
|
|
||||||
}
|
|
||||||
|
|
||||||
function saml_footer(string &$body)
|
function saml_footer(string &$body)
|
||||||
{
|
{
|
||||||
$fragment = addslashes(BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('saml', 'settings_statement')));
|
$fragment = addslashes(BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('saml', 'settings_statement')));
|
||||||
|
$samlhint = DI::l10n()->t('managed via SAML authentication');
|
||||||
$body .= <<<EOL
|
$body .= <<<EOL
|
||||||
<script>
|
<script>
|
||||||
var target=$("#settings-nickname-desc");
|
var target=$("#settings-nickname-desc");
|
||||||
if (target.length) { target.append("<p>$fragment</p>"); }
|
if (target.length) { target.append("<p>$fragment</p>"); }
|
||||||
|
var saml_hint = document.createElement("span");
|
||||||
|
var saml_hint_text = document.createTextNode('$samlhint');
|
||||||
|
saml_hint.appendChild(saml_hint_text);
|
||||||
|
if ( document.getElementById('id_email') != null ) {
|
||||||
|
document.getElementById('id_email').setAttribute('readonly', 'readonly');
|
||||||
|
document.getElementById('id_email').parentNode.insertBefore(saml_hint, document.getElementById('id_email').nextSibling);
|
||||||
|
}
|
||||||
|
// Frio theme
|
||||||
|
if ( document.getElementById('password-settings-collapse') != null ) {
|
||||||
|
document.getElementById('password-settings-collapse').replaceChildren(saml_hint.cloneNode(true));
|
||||||
|
}
|
||||||
|
if ( document.getElementById('id_mpassword_wrapper') != null ) {
|
||||||
|
document.getElementById('id_mpassword_wrapper').parentNode.appendChild(saml_hint.cloneNode(true));
|
||||||
|
document.getElementById('id_mpassword_wrapper').remove();
|
||||||
|
document.getElementById('id_email').nextElementSibling.classList.add('help-block');
|
||||||
|
}
|
||||||
|
// Vier theme
|
||||||
|
if ( document.getElementById('wrapper_mpassword') != null ) {
|
||||||
|
document.getElementById('wrapper_mpassword').remove();
|
||||||
|
document.getElementById('id_email').nextElementSibling.classList.add('field_help');
|
||||||
|
}
|
||||||
|
if ( document.getElementById('wrapper_password') != null ) {
|
||||||
|
document.getElementById('wrapper_password').parentNode.replaceChildren(saml_hint.cloneNode(true));
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
EOL;
|
EOL;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +126,7 @@ function saml_is_configured()
|
||||||
function saml_sso_initiate(string &$body)
|
function saml_sso_initiate(string &$body)
|
||||||
{
|
{
|
||||||
if (!saml_is_configured()) {
|
if (!saml_is_configured()) {
|
||||||
Logger::warning('SAML SSO tried to trigger, but the SAML addon is not configured yet!');
|
DI::logger()->warning('SAML SSO tried to trigger, but the SAML addon is not configured yet!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +155,7 @@ function saml_sso_reply()
|
||||||
|
|
||||||
if (!empty($errors)) {
|
if (!empty($errors)) {
|
||||||
echo 'Errors encountered.';
|
echo 'Errors encountered.';
|
||||||
Logger::error(implode(', ', $errors));
|
DI::logger()->error(implode(', ', $errors));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +180,7 @@ function saml_sso_reply()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($user['uid'])) {
|
if (!empty($user['uid'])) {
|
||||||
DI::auth()->setForUser(DI::app(), $user);
|
DI::auth()->setForUser($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['RelayState']) && Utils::getSelfURL() != $_POST['RelayState']) {
|
if (isset($_POST['RelayState']) && Utils::getSelfURL() != $_POST['RelayState']) {
|
||||||
|
@ -172,7 +191,7 @@ function saml_sso_reply()
|
||||||
function saml_slo_initiate()
|
function saml_slo_initiate()
|
||||||
{
|
{
|
||||||
if (!saml_is_configured()) {
|
if (!saml_is_configured()) {
|
||||||
Logger::warning('SAML SLO tried to trigger, but the SAML addon is not configured yet!');
|
DI::logger()->warning('SAML SLO tried to trigger, but the SAML addon is not configured yet!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +222,7 @@ function saml_slo_reply()
|
||||||
if (empty($errors)) {
|
if (empty($errors)) {
|
||||||
$auth->redirectTo(DI::baseUrl());
|
$auth->redirectTo(DI::baseUrl());
|
||||||
} else {
|
} else {
|
||||||
Logger::error(implode(', ', $errors));
|
DI::logger()->error(implode(', ', $errors));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +315,7 @@ function saml_addon_admin_post()
|
||||||
function saml_create_user($username, $email, $name)
|
function saml_create_user($username, $email, $name)
|
||||||
{
|
{
|
||||||
if (!strlen($email) || !strlen($name)) {
|
if (!strlen($email) || !strlen($name)) {
|
||||||
Logger::error('Could not create user: no email or username given.');
|
DI::logger()->error('Could not create user: no email or username given.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +337,7 @@ function saml_create_user($username, $email, $name)
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Logger::error(
|
DI::logger()->error(
|
||||||
'Exception while creating user',
|
'Exception while creating user',
|
||||||
[
|
[
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
namespace Friendica\Addon\securemail;
|
namespace Friendica\Addon\securemail;
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\App\BaseURL;
|
use Friendica\App\BaseURL;
|
||||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||||
|
|
|
@ -7,9 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Addon\securemail\SecureTestEmail;
|
use Friendica\Addon\securemail\SecureTestEmail;
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Object\EMail\IEmail;
|
use Friendica\Object\EMail\IEmail;
|
||||||
|
@ -23,7 +21,7 @@ function securemail_install()
|
||||||
|
|
||||||
Hook::register('emailer_send_prepare', 'addon/securemail/securemail.php', 'securemail_emailer_send_prepare', 10);
|
Hook::register('emailer_send_prepare', 'addon/securemail/securemail.php', 'securemail_emailer_send_prepare', 10);
|
||||||
|
|
||||||
Logger::notice('installed securemail');
|
DI::logger()->notice('installed securemail');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,8 +30,6 @@ function securemail_install()
|
||||||
* @link https://github.com/friendica/friendica/blob/develop/doc/Addons.md#addon_settings 'addon_settings' hook
|
* @link https://github.com/friendica/friendica/blob/develop/doc/Addons.md#addon_settings 'addon_settings' hook
|
||||||
*
|
*
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
|
||||||
* @see App
|
|
||||||
*/
|
*/
|
||||||
function securemail_settings(array &$data)
|
function securemail_settings(array &$data)
|
||||||
{
|
{
|
||||||
|
@ -67,8 +63,6 @@ function securemail_settings(array &$data)
|
||||||
* @link https://github.com/friendica/friendica/blob/develop/doc/Addons.md#addon_settings_post 'addon_settings_post' hook
|
* @link https://github.com/friendica/friendica/blob/develop/doc/Addons.md#addon_settings_post 'addon_settings_post' hook
|
||||||
*
|
*
|
||||||
* @param array $b hook data
|
* @param array $b hook data
|
||||||
*
|
|
||||||
* @see App
|
|
||||||
*/
|
*/
|
||||||
function securemail_settings_post(array &$b)
|
function securemail_settings_post(array &$b)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +76,7 @@ function securemail_settings_post(array &$b)
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'securemail', 'enable', $enable);
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'securemail', 'enable', $enable);
|
||||||
|
|
||||||
if (!empty($_POST['securemail-test'])) {
|
if (!empty($_POST['securemail-test'])) {
|
||||||
$res = DI::emailer()->send(new SecureTestEmail(DI::app(), DI::config(), DI::pConfig(), DI::baseUrl()));
|
$res = DI::emailer()->send(new SecureTestEmail(DI::config(), DI::pConfig(), DI::baseUrl()));
|
||||||
|
|
||||||
// revert to saved value
|
// revert to saved value
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'securemail', 'enable', $enable);
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'securemail', 'enable', $enable);
|
||||||
|
@ -102,8 +96,6 @@ function securemail_settings_post(array &$b)
|
||||||
* @link https://github.com/friendica/friendica/blob/develop/doc/Addons.md#emailer_send_prepare 'emailer_send_prepare' hook
|
* @link https://github.com/friendica/friendica/blob/develop/doc/Addons.md#emailer_send_prepare 'emailer_send_prepare' hook
|
||||||
*
|
*
|
||||||
* @param IEmail $email Email
|
* @param IEmail $email Email
|
||||||
*
|
|
||||||
* @see App
|
|
||||||
*/
|
*/
|
||||||
function securemail_emailer_send_prepare(IEmail &$email)
|
function securemail_emailer_send_prepare(IEmail &$email)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -79,6 +78,7 @@ function get_body_length($body)
|
||||||
* Checking any possible syntax of the style attribute with xpath is impossible
|
* Checking any possible syntax of the style attribute with xpath is impossible
|
||||||
* So we just get any element with a style attribute, and check them with a regexp
|
* So we just get any element with a style attribute, and check them with a regexp
|
||||||
*/
|
*/
|
||||||
|
/** @var DOMNodeList $xr */
|
||||||
$xr = $xpath->query('//*[@style]');
|
$xr = $xpath->query('//*[@style]');
|
||||||
foreach ($xr as $node) {
|
foreach ($xr as $node) {
|
||||||
if (preg_match('/.*display: *none *;.*/',$node->getAttribute('style'))) {
|
if (preg_match('/.*display: *none *;.*/',$node->getAttribute('style'))) {
|
||||||
|
|
|
@ -7,12 +7,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\L10n;
|
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Database\DBA;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
function showmore_dyn_install()
|
function showmore_dyn_install()
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
* Name: Smiley Pack (Español)
|
* Name: Smiley Pack (Español)
|
||||||
* Description: Pack of smileys that make master too AOLish.
|
* Description: Pack of smileys that make master too AOLish.
|
||||||
* Version: 1.02
|
* Version: 1.02
|
||||||
* Author: Thomas Willingham (based on Mike Macgirvin's Adult Smile template)
|
* Author: Thomas Willingham (based on Mike Macgirvin's Adult Smile template)
|
||||||
* All smileys from sites offering them as Public Domain
|
* All smileys from sites offering them as Public Domain
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -19,7 +18,7 @@ function smiley_pack_smilies_es(array &$b) {
|
||||||
|
|
||||||
#Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever.
|
#Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever.
|
||||||
|
|
||||||
#Be careful with invocation strings. If you have a smiley called foo, and another called foobar, typing :foobar will call foo. Avoid this with clever naming, using ~ instead of :
|
#Be careful with invocation strings. If you have a smiley called foo, and another called foobar, typing :foobar will call foo. Avoid this with clever naming, using ~ instead of :
|
||||||
#when all else fails.
|
#when all else fails.
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +48,7 @@ function smiley_pack_smilies_es(array &$b) {
|
||||||
|
|
||||||
$b['texts'][] = ':vaca';
|
$b['texts'][] = ':vaca';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/cow.gif' . '" alt="' . ':vaca' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/cow.gif' . '" alt="' . ':vaca' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':cangrejo';
|
$b['texts'][] = ':cangrejo';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/crab.gif' . '" alt="' . ':cangrejo' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/crab.gif' . '" alt="' . ':cangrejo' . '" />';
|
||||||
|
|
||||||
|
@ -70,7 +69,7 @@ function smiley_pack_smilies_es(array &$b) {
|
||||||
|
|
||||||
$b['texts'][] = ':caballo';
|
$b['texts'][] = ':caballo';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/horse.gif' . '" alt="' . ':caballo' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/horse.gif' . '" alt="' . ':caballo' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':loro';
|
$b['texts'][] = ':loro';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/parrot.gif' . '" alt="' . ':loro' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/parrot.gif' . '" alt="' . ':loro' . '" />';
|
||||||
|
|
||||||
|
@ -107,7 +106,7 @@ function smiley_pack_smilies_es(array &$b) {
|
||||||
|
|
||||||
$b['texts'][] = ':cuna';
|
$b['texts'][] = ':cuna';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/babycot.gif' . '" alt="' . ':cuna' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/babycot.gif' . '" alt="' . ':cuna' . '" />';
|
||||||
|
|
||||||
|
|
||||||
$b['texts'][] = ':embarazada';
|
$b['texts'][] = ':embarazada';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/pregnant.gif' . '" alt="' . ':embarazada' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/pregnant.gif' . '" alt="' . ':embarazada' . '" />';
|
||||||
|
@ -116,10 +115,10 @@ function smiley_pack_smilies_es(array &$b) {
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/stork.gif' . '" alt="' . ':cigüeña' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/stork.gif' . '" alt="' . ':cigüeña' . '" />';
|
||||||
|
|
||||||
|
|
||||||
#Confused Smileys
|
#Confused Smileys
|
||||||
$b['texts'][] = ':confundido';
|
$b['texts'][] = ':confundido';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/confused/confused.gif' . '" alt="' . ':confundido' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/confused/confused.gif' . '" alt="' . ':confundido' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':encogehombros';
|
$b['texts'][] = ':encogehombros';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/confused/shrug.gif' . '" alt="' . ':encogehombros' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/confused/shrug.gif' . '" alt="' . ':encogehombros' . '" />';
|
||||||
|
|
||||||
|
@ -154,13 +153,13 @@ function smiley_pack_smilies_es(array &$b) {
|
||||||
|
|
||||||
$b['texts'][] = ':diabólico';
|
$b['texts'][] = ':diabólico';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/devil.gif' . '" alt="' . ':diabólico' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/devil.gif' . '" alt="' . ':diabólico' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':adbalancín';
|
$b['texts'][] = ':adbalancín';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/daseesaw.gif' . '" alt="' . ':adbalancín' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/daseesaw.gif' . '" alt="' . ':adbalancín' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':vuelvedemonio';
|
$b['texts'][] = ':vuelvedemonio';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/turnevil.gif' . '" alt="' . ':vuelvedemonio' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/turnevil.gif' . '" alt="' . ':vuelvedemonio' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':santo';
|
$b['texts'][] = ':santo';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/saint.gif' . '" alt="' . ':santo' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/saint.gif' . '" alt="' . ':santo' . '" />';
|
||||||
|
|
||||||
|
@ -242,7 +241,7 @@ function smiley_pack_smilies_es(array &$b) {
|
||||||
|
|
||||||
$b['texts'][] = ':billar';
|
$b['texts'][] = ':billar';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/sport/snooker.gif' . '" alt="' . ':billar' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/sport/snooker.gif' . '" alt="' . ':billar' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':tenis';
|
$b['texts'][] = ':tenis';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/sport/tennis.gif' . '" alt="' . ':tenis' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/sport/tennis.gif' . '" alt="' . ':tenis' . '" />';
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
|
||||||
|
@ -23,7 +22,7 @@ function smiley_pack_fr_smilies(array &$b)
|
||||||
|
|
||||||
#Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever.
|
#Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever.
|
||||||
|
|
||||||
#Be careful with invocation strings. If you have a smiley called foo, and another called foobar, typing :foobar will call foo. Avoid this with clever naming, using ~ instead of :
|
#Be careful with invocation strings. If you have a smiley called foo, and another called foobar, typing :foobar will call foo. Avoid this with clever naming, using ~ instead of :
|
||||||
#when all else fails.
|
#when all else fails.
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ function smiley_pack_fr_smilies(array &$b)
|
||||||
|
|
||||||
$b['texts'][] = ':vache';
|
$b['texts'][] = ':vache';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/cow.gif' . '" alt="' . ':vache' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/cow.gif' . '" alt="' . ':vache' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':crabe';
|
$b['texts'][] = ':crabe';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/crab.gif' . '" alt="' . ':crabe' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/crab.gif' . '" alt="' . ':crabe' . '" />';
|
||||||
|
|
||||||
|
@ -74,7 +73,7 @@ function smiley_pack_fr_smilies(array &$b)
|
||||||
|
|
||||||
$b['texts'][] = ':cheval';
|
$b['texts'][] = ':cheval';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/horse.gif' . '" alt="' . ':cheval' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/horse.gif' . '" alt="' . ':cheval' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':perroquet';
|
$b['texts'][] = ':perroquet';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/parrot.gif' . '" alt="' . ':perroquet' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/animals/parrot.gif' . '" alt="' . ':perroquet' . '" />';
|
||||||
|
|
||||||
|
@ -108,7 +107,7 @@ function smiley_pack_fr_smilies(array &$b)
|
||||||
|
|
||||||
$b['texts'][] = ':litbébé';
|
$b['texts'][] = ':litbébé';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/babycot.gif' . '" alt="' . ':litbébé' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/babycot.gif' . '" alt="' . ':litbébé' . '" />';
|
||||||
|
|
||||||
|
|
||||||
$b['texts'][] = ':enceinte';
|
$b['texts'][] = ':enceinte';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/pregnant.gif' . '" alt="' . ':enceinte' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/pregnant.gif' . '" alt="' . ':enceinte' . '" />';
|
||||||
|
@ -117,10 +116,10 @@ function smiley_pack_fr_smilies(array &$b)
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/stork.gif' . '" alt="' . ':cigogne' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/babies/stork.gif' . '" alt="' . ':cigogne' . '" />';
|
||||||
|
|
||||||
|
|
||||||
#Confused Smileys
|
#Confused Smileys
|
||||||
$b['texts'][] = ':paumé';
|
$b['texts'][] = ':paumé';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/confused/confused.gif' . '" alt="' . ':paumé' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/confused/confused.gif' . '" alt="' . ':paumé' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':hausseépaules';
|
$b['texts'][] = ':hausseépaules';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/confused/shrug.gif' . '" alt="' . ':hausseépaules' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/confused/shrug.gif' . '" alt="' . ':hausseépaules' . '" />';
|
||||||
|
|
||||||
|
@ -152,13 +151,13 @@ function smiley_pack_fr_smilies(array &$b)
|
||||||
|
|
||||||
$b['texts'][] = ':démoniaque';
|
$b['texts'][] = ':démoniaque';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/devil.gif' . '" alt="' . ':démoniaque' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/devil.gif' . '" alt="' . ':démoniaque' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':bascule';
|
$b['texts'][] = ':bascule';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/daseesaw.gif' . '" alt="' . ':bascule' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/daseesaw.gif' . '" alt="' . ':bascule' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':possédé';
|
$b['texts'][] = ':possédé';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/turnevil.gif' . '" alt="' . ':possédé' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/turnevil.gif' . '" alt="' . ':possédé' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':tombe';
|
$b['texts'][] = ':tombe';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/graveside.gif' . '" alt="' . ':tombe' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/devilangel/graveside.gif' . '" alt="' . ':tombe' . '" />';
|
||||||
|
|
||||||
|
@ -225,7 +224,7 @@ function smiley_pack_fr_smilies(array &$b)
|
||||||
|
|
||||||
$b['texts'][] = ':billard';
|
$b['texts'][] = ':billard';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/sport/snooker.gif' . '" alt="' . ':billard' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/sport/snooker.gif' . '" alt="' . ':billard' . '" />';
|
||||||
|
|
||||||
$b['texts'][] = ':équitation';
|
$b['texts'][] = ':équitation';
|
||||||
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/sport/horseriding.gif' . '" alt="' . ':équitation' . '" />';
|
$b['icons'][] = '<img src="' . DI::baseUrl() . '/addon/smiley_pack/icons/sport/horseriding.gif' . '" alt="' . ':équitation' . '" />';
|
||||||
|
|
||||||
|
|
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