Compare commits

..

No commits in common. "develop" and "2024.09-rc" have entirely different histories.

122 changed files with 1007 additions and 1035 deletions

View file

@ -1,6 +1,6 @@
skip_clone: true
steps:
pipeline:
clone_friendica_base:
image: alpine/git
commands:
@ -56,10 +56,6 @@ steps:
- /tmp/drone-cache:/tmp/cache
when:
event: pull_request
phpstan:
image: friendicaci/php8.3:php8.3.3
commands:
- ./bin/composer.phar run phpstan;
check:
image: friendicaci/php-cs
commands:

View file

@ -5,7 +5,7 @@ labels:
skip_clone: true
steps:
pipeline:
clone_friendica_base:
image: alpine/git
commands:

View file

@ -1,6 +1,6 @@
skip_clone: true
steps:
pipeline:
clone_friendica_base:
image: alpine/git
commands:

View file

@ -17,7 +17,7 @@ labels:
skip_clone: true
steps:
pipeline:
clone_friendica_base:
image: alpine/git
commands:

View file

@ -5,7 +5,7 @@ labels:
skip_clone: true
steps:
pipeline:
clone_friendica_base:
image: alpine/git
commands:

View file

@ -33,13 +33,16 @@
*
*/
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Tag;
use Friendica\Model\User;
@ -61,7 +64,7 @@ function advancedcontentfilter_install()
Hook::add('dbstructure_definition' , __FILE__, 'advancedcontentfilter_dbstructure_definition');
DBStructure::performUpdate();
DI::logger()->notice('installed advancedcontentfilter');
Logger::notice('installed advancedcontentfilter');
}
/*
@ -189,30 +192,9 @@ function advancedcontentfilter_init()
if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'api') {
$slim = \Slim\Factory\AppFactory::create();
/**
* 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/middlewares.php';
require __DIR__ . '/src/routes.php';
$slim->run();
exit;
@ -270,7 +252,7 @@ function advancedcontentfilter_content()
'rule_expression' => DI::l10n()->t('Rule Expression'),
'cancel' => DI::l10n()->t('Cancel'),
],
'$current_theme' => DI::appHelper()->getCurrentTheme(),
'$current_theme' => DI::app()->getCurrentTheme(),
'$rules' => DBA::toArray(DBA::select('advancedcontentfilter_rules', [], ['uid' => DI::userSession()->getLocalUserId()])),
'$form_security_token' => BaseModule::getFormSecurityToken()
]);

View file

@ -0,0 +1,32 @@
<?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());

View file

@ -0,0 +1,36 @@
<?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');
});
});

View file

@ -6,7 +6,9 @@
* Author: Fabio <https://kirgroup.com/profile/fabrixxm>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -26,7 +28,7 @@ function birdavatar_install()
Hook::register('addon_settings', __FILE__, 'birdavatar_addon_settings');
Hook::register('addon_settings_post', __FILE__, 'birdavatar_addon_settings_post');
DI::logger()->info('registered birdavatar');
Logger::info('registered birdavatar');
}
/**

View file

@ -44,7 +44,9 @@
* THE SOFTWARE.
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
@ -76,7 +78,7 @@ function blackout_redirect ($b)
}
if (( $date1 <= $now ) && ( $now <= $date2 )) {
DI::logger()->notice('redirecting user to blackout page');
Logger::notice('redirecting user to blackout page');
System::externalRedirect($myurl);
}
}

View file

@ -11,6 +11,7 @@
use Friendica\Core\Hook;
use Friendica\DI;
use Jaybizzle\CrawlerDetect\CrawlerDetect;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Network\HTTPException\ForbiddenException;
@ -69,7 +70,7 @@ function blockbot_init_1()
}
if (empty($parts)) {
DI::logger()->debug('Known frontend found - accept', $logdata);
Logger::debug('Known frontend found - accept', $logdata);
if ($isCrawler) {
blockbot_save('badly-parsed-agents', $_SERVER['HTTP_USER_AGENT']);
}
@ -79,66 +80,66 @@ function blockbot_init_1()
blockbot_log_activitypub($_SERVER['REQUEST_URI'], $_SERVER['HTTP_USER_AGENT']);
if (blockbot_is_crawler($parts)) {
DI::logger()->debug('Crawler found - reject', $logdata);
Logger::debug('Crawler found - reject', $logdata);
blockbot_reject();
}
if (blockbot_is_searchbot($parts)) {
DI::logger()->debug('Search bot found - reject', $logdata);
Logger::debug('Search bot found - reject', $logdata);
blockbot_reject();
}
if (blockbot_is_unwanted($parts)) {
DI::logger()->debug('Uncategorized unwanted agent found - reject', $logdata);
Logger::debug('Uncategorized unwanted agent found - reject', $logdata);
blockbot_reject();
}
if (blockbot_is_security_checker($parts)) {
if (!DI::config()->get('blockbot', 'security_checker')) {
DI::logger()->debug('Security checker found - reject', $logdata);
Logger::debug('Security checker found - reject', $logdata);
blockbot_reject();
}
DI::logger()->debug('Security checker found - accept', $logdata);
Logger::debug('Security checker found - accept', $logdata);
return;
}
if (blockbot_is_social_media($parts)) {
DI::logger()->debug('Social media service found - accept', $logdata);
Logger::debug('Social media service found - accept', $logdata);
return;
}
if (blockbot_is_fediverse_client($parts)) {
DI::logger()->debug('Fediverse client found - accept', $logdata);
Logger::debug('Fediverse client found - accept', $logdata);
return;
}
if (blockbot_is_feed_reader($parts)) {
DI::logger()->debug('Feed reader found - accept', $logdata);
Logger::debug('Feed reader found - accept', $logdata);
return;
}
if (blockbot_is_fediverse_tool($parts)) {
DI::logger()->debug('Fediverse tool found - accept', $logdata);
Logger::debug('Fediverse tool found - accept', $logdata);
return;
}
if (blockbot_is_service_agent($parts)) {
DI::logger()->debug('Service agent found - accept', $logdata);
Logger::debug('Service agent found - accept', $logdata);
return;
}
if (blockbot_is_monitor($parts)) {
DI::logger()->debug('Monitoring service found - accept', $logdata);
Logger::debug('Monitoring service found - accept', $logdata);
return;
}
if (blockbot_is_validator($parts)) {
DI::logger()->debug('Validation service found - accept', $logdata);
Logger::debug('Validation service found - accept', $logdata);
return;
}
if (blockbot_is_good_tool($parts)) {
DI::logger()->debug('Uncategorized helpful service found - accept', $logdata);
Logger::debug('Uncategorized helpful service found - accept', $logdata);
return;
}
@ -146,10 +147,10 @@ function blockbot_init_1()
if (blockbot_is_http_library($parts)) {
blockbot_check_login_attempt($_SERVER['REQUEST_URI'], $logdata);
if (!DI::config()->get('blockbot', 'http_libraries')) {
DI::logger()->debug('HTTP Library found - reject', $logdata);
Logger::debug('HTTP Library found - reject', $logdata);
blockbot_reject();
}
DI::logger()->debug('HTTP Library found - accept', $logdata);
Logger::debug('HTTP Library found - accept', $logdata);
return;
}
@ -160,12 +161,12 @@ function blockbot_init_1()
if (!$isCrawler) {
blockbot_save('good-agents', $_SERVER['HTTP_USER_AGENT']);
DI::logger()->debug('Non-bot user agent detected', $logdata);
Logger::debug('Non-bot user agent detected', $logdata);
return;
}
blockbot_save('bad-agents', $_SERVER['HTTP_USER_AGENT']);
DI::logger()->notice('Possible bot found - reject', $logdata);
Logger::notice('Possible bot found - reject', $logdata);
blockbot_reject();
}
@ -208,7 +209,7 @@ function blockbot_log_activitypub(string $url, string $agent)
blockbot_save('activitypub-inbox-agents', $agent);
}
if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER, false))) {
if (!empty($_SERVER['HTTP_SIGNATURE']) && !empty(HTTPSignature::getSigner('', $_SERVER))) {
blockbot_save('activitypub-signature-agents', $agent);
}
}
@ -216,7 +217,7 @@ function blockbot_log_activitypub(string $url, string $agent)
function blockbot_check_login_attempt(string $url, array $logdata)
{
if (in_array(trim(parse_url($url, PHP_URL_PATH), '/'), ['login', 'lostpass', 'register'])) {
DI::logger()->debug('Login attempt detected - reject', $logdata);
Logger::debug('Login attempt detected - reject', $logdata);
blockbot_reject();
}
}

View file

@ -30,6 +30,7 @@ use Friendica\Content\Text\Plaintext;
use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Worker;
@ -72,7 +73,7 @@ function bluesky_install()
function bluesky_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('bluesky'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('bluesky'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function bluesky_check_item_notification(array &$notification_data)
@ -106,7 +107,7 @@ function bluesky_item_by_link(array &$hookData)
return;
}
DI::logger()->debug('Found bluesky post', ['uri' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]);
Logger::debug('Found bluesky post', ['uri' => $hookData['uri'], 'did' => $did, 'cid' => $matches[2]]);
$uri = 'at://' . $did . '/app.bsky.feed.post/' . $matches[2];
} else {
@ -114,7 +115,7 @@ function bluesky_item_by_link(array &$hookData)
}
$uri = DI::atpProcessor()->fetchMissingPost($uri, $hookData['uid'], Item::PR_FETCHED, 0, 0);
DI::logger()->debug('Got post', ['uri' => $uri]);
Logger::debug('Got post', ['uri' => $uri]);
if (!empty($uri)) {
$item = Post::selectFirst(['id'], ['uri' => $uri, 'uid' => $hookData['uid']]);
if (!empty($item['id'])) {
@ -137,7 +138,7 @@ function bluesky_follow(array &$hook_data)
return;
}
DI::logger()->debug('Check if contact is bluesky', ['data' => $hook_data]);
Logger::debug('Check if contact is bluesky', ['data' => $hook_data]);
$contact = DBA::selectFirst('contact', [], ['network' => Protocol::BLUESKY, 'url' => $hook_data['url'], 'uid' => [0, $hook_data['uid']]]);
if (empty($contact)) {
return;
@ -158,7 +159,7 @@ function bluesky_follow(array &$hook_data)
$activity = DI::atProtocol()->XRPCPost($hook_data['uid'], 'com.atproto.repo.createRecord', $post);
if (!empty($activity->uri)) {
$hook_data['contact'] = $contact;
DI::logger()->debug('Successfully start following', ['url' => $contact['url'], 'uri' => $activity->uri]);
Logger::debug('Successfully start following', ['url' => $contact['url'], 'uri' => $activity->uri]);
}
}
@ -212,7 +213,7 @@ function bluesky_block(array &$hook_data)
if ($ucid) {
Contact::remove($ucid);
}
DI::logger()->debug('Successfully blocked contact', ['url' => $hook_data['contact']['url'], 'uri' => $activity->uri]);
Logger::debug('Successfully blocked contact', ['url' => $hook_data['contact']['url'], 'uri' => $activity->uri]);
}
}
@ -420,11 +421,11 @@ function bluesky_cron()
if ($last) {
$next = $last + ($poll_interval * 60);
if ($next > time()) {
DI::logger()->notice('poll interval not reached');
Logger::notice('poll interval not reached');
return;
}
}
DI::logger()->notice('cron_start');
Logger::notice('cron_start');
$abandon_days = intval(DI::config()->get('system', 'account_abandon_days'));
if ($abandon_days < 1) {
@ -436,19 +437,19 @@ function bluesky_cron()
$pconfigs = DBA::selectToArray('pconfig', [], ["`cat` = ? AND `k` IN (?, ?) AND `v`", 'bluesky', 'import', 'import_feeds']);
foreach ($pconfigs as $pconfig) {
if (empty(DI::atProtocol()->getUserDid($pconfig['uid']))) {
DI::logger()->debug('User has got no valid DID', ['uid' => $pconfig['uid']]);
Logger::debug('User has got no valid DID', ['uid' => $pconfig['uid']]);
continue;
}
if ($abandon_days != 0) {
if (!DBA::exists('user', ["`uid` = ? AND `login_date` >= ?", $pconfig['uid'], $abandon_limit])) {
DI::logger()->notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]);
Logger::notice('abandoned account: timeline from user will not be imported', ['user' => $pconfig['uid']]);
continue;
}
}
// Refresh the token now, so that it doesn't need to be refreshed in parallel by the following workers
DI::logger()->debug('Refresh the token', ['uid' => $pconfig['uid']]);
Logger::debug('Refresh the token', ['uid' => $pconfig['uid']]);
DI::atProtocol()->getUserToken($pconfig['uid']);
$last_sync = DI::pConfig()->get($pconfig['uid'], 'bluesky', 'last_contact_sync');
@ -462,32 +463,32 @@ function bluesky_cron()
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_timeline.php', $pconfig['uid']);
}
if (DI::pConfig()->get($pconfig['uid'], 'bluesky', 'import_feeds')) {
DI::logger()->debug('Fetch feeds for user', ['uid' => $pconfig['uid']]);
Logger::debug('Fetch feeds for user', ['uid' => $pconfig['uid']]);
$feeds = bluesky_get_feeds($pconfig['uid']);
foreach ($feeds as $feed) {
Worker::add(['priority' => Worker::PRIORITY_MEDIUM, 'force_priority' => true], 'addon/bluesky/bluesky_feed.php', $pconfig['uid'], $feed);
}
}
DI::logger()->debug('Polling done for user', ['uid' => $pconfig['uid']]);
Logger::debug('Polling done for user', ['uid' => $pconfig['uid']]);
}
DI::logger()->notice('Polling done for all users');
Logger::notice('Polling done for all users');
DI::keyValue()->set('bluesky_last_poll', time());
$last_clean = DI::keyValue()->get('bluesky_last_clean');
if (empty($last_clean) || ($last_clean + 86400 < time())) {
DI::logger()->notice('Start contact cleanup');
Logger::notice('Start contact cleanup');
$contacts = DBA::select('account-user-view', ['id', 'pid'], ["`network` = ? AND `uid` != ? AND `rel` = ?", Protocol::BLUESKY, 0, Contact::NOTHING]);
while ($contact = DBA::fetch($contacts)) {
Worker::add(Worker::PRIORITY_LOW, 'MergeContact', $contact['pid'], $contact['id'], 0);
}
DBA::close($contacts);
DI::keyValue()->set('bluesky_last_clean', time());
DI::logger()->notice('Contact cleanup done');
Logger::notice('Contact cleanup done');
}
DI::logger()->notice('cron_end');
Logger::notice('cron_end');
}
function bluesky_hook_fork(array &$b)
@ -507,7 +508,7 @@ function bluesky_hook_fork(array &$b)
if (DI::pConfig()->get($post['uid'], 'bluesky', 'import')) {
// Don't post if it isn't a reply to a bluesky post
if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::BLUESKY])) {
DI::logger()->notice('No bluesky parent found', ['item' => $post['id']]);
Logger::notice('No bluesky parent found', ['item' => $post['id']]);
$b['execute'] = false;
return;
}
@ -554,12 +555,12 @@ function bluesky_send(array &$b)
}
if ($b['gravity'] != Item::GRAVITY_PARENT) {
DI::logger()->debug('Got comment', ['item' => $b]);
Logger::debug('Got comment', ['item' => $b]);
if ($b['deleted']) {
$uri = DI::atpProcessor()->getUriClass($b['uri']);
if (empty($uri)) {
DI::logger()->debug('Not a bluesky post', ['uri' => $b['uri']]);
Logger::debug('Not a bluesky post', ['uri' => $b['uri']]);
return;
}
bluesky_delete_post($b['uri'], $b['uid']);
@ -570,12 +571,12 @@ function bluesky_send(array &$b)
$parent = DI::atpProcessor()->getUriClass($b['thr-parent']);
if (empty($root) || empty($parent)) {
DI::logger()->debug('No bluesky post', ['parent' => $b['parent'], 'thr-parent' => $b['thr-parent']]);
Logger::debug('No bluesky post', ['parent' => $b['parent'], 'thr-parent' => $b['thr-parent']]);
return;
}
if ($b['gravity'] == Item::GRAVITY_COMMENT) {
DI::logger()->debug('Posting comment', ['root' => $root, 'parent' => $parent]);
Logger::debug('Posting comment', ['root' => $root, 'parent' => $parent]);
bluesky_create_post($b, $root, $parent);
return;
} elseif (in_array($b['verb'], [Activity::LIKE, Activity::ANNOUNCE])) {
@ -602,8 +603,6 @@ function bluesky_create_activity(array $item, stdClass $parent = null)
return;
}
$post = [];
if ($item['verb'] == Activity::LIKE) {
$record = [
'subject' => $parent,
@ -634,10 +633,10 @@ function bluesky_create_activity(array $item, stdClass $parent = null)
if (empty($activity->uri)) {
return;
}
DI::logger()->debug('Activity done', ['return' => $activity]);
Logger::debug('Activity done', ['return' => $activity]);
$uri = DI::atpProcessor()->getUri($activity);
Item::update(['extid' => $uri], ['guid' => $item['guid']]);
DI::logger()->debug('Set extid', ['id' => $item['id'], 'extid' => $activity]);
Logger::debug('Set extid', ['id' => $item['id'], 'extid' => $activity]);
}
function bluesky_create_post(array $item, stdClass $root = null, stdClass $parent = null)
@ -721,14 +720,14 @@ function bluesky_create_post(array $item, stdClass $root = null, stdClass $paren
}
return;
}
DI::logger()->debug('Posting done', ['return' => $parent]);
Logger::debug('Posting done', ['return' => $parent]);
if (empty($root)) {
$root = $parent;
}
if (($key == 0) && ($item['gravity'] != Item::GRAVITY_PARENT)) {
$uri = DI::atpProcessor()->getUri($parent);
Item::update(['extid' => $uri], ['guid' => $item['guid']]);
DI::logger()->debug('Set extid', ['id' => $item['id'], 'extid' => $uri]);
Logger::debug('Set extid', ['id' => $item['id'], 'extid' => $uri]);
}
}
}
@ -898,20 +897,20 @@ function bluesky_upload_blob(int $uid, array $photo): ?stdClass
$new_size = strlen($content);
if (($size != 0) && ($new_size == 0) && ($retrial == 0)) {
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]);
Logger::warning('Size is empty after resize, uploading original file', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
$content = Photo::getImageForPhoto($photo);
} else {
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]);
Logger::info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
}
$data = DI::atProtocol()->post($uid, '/xrpc/com.atproto.repo.uploadBlob', $content, ['Content-type' => $photo['type'], 'Authorization' => ['Bearer ' . DI::atProtocol()->getUserToken($uid)]]);
if (empty($data) || empty($data->blob)) {
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]);
Logger::info('Uploading failed', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
return null;
}
Item::incrementOutbound(Protocol::BLUESKY);
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]);
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;
}
@ -919,11 +918,11 @@ function bluesky_delete_post(string $uri, int $uid)
{
$parts = DI::atpProcessor()->getUriParts($uri);
if (empty($parts)) {
DI::logger()->debug('No uri delected', ['uri' => $uri]);
Logger::debug('No uri delected', ['uri' => $uri]);
return;
}
DI::atProtocol()->XRPCPost($uid, 'com.atproto.repo.deleteRecord', $parts);
DI::logger()->debug('Deleted', ['parts' => $parts]);
Logger::debug('Deleted', ['parts' => $parts]);
}
function bluesky_fetch_timeline(int $uid)
@ -1025,10 +1024,10 @@ function bluesky_fetch_notifications(int $uid)
foreach ($data->notifications as $notification) {
$uri = DI::atpProcessor()->getUri($notification);
if (Post::exists(['uri' => $uri, 'uid' => $uid]) || Post::exists(['extid' => $uri, 'uid' => $uid])) {
DI::logger()->debug('Notification already processed', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
Logger::debug('Notification already processed', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
continue;
}
DI::logger()->debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
Logger::debug('Process notification', ['uid' => $uid, 'reason' => $notification->reason, 'uri' => $uri, 'indexedAt' => $notification->indexedAt]);
switch ($notification->reason) {
case 'like':
$item = DI::atpProcessor()->getHeaderFromPost($notification, $uri, $uid, Conversation::PARCEL_CONNECTOR);
@ -1038,9 +1037,9 @@ function bluesky_fetch_notifications(int $uid)
$item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0);
if (!empty($item['thr-parent'])) {
$data = Item::insert($item);
DI::logger()->debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
Logger::debug('Got like', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
} else {
DI::logger()->info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
}
break;
@ -1052,37 +1051,37 @@ function bluesky_fetch_notifications(int $uid)
$item['thr-parent'] = DI::atpProcessor()->fetchMissingPost($item['thr-parent'], $uid, Item::PR_FETCHED, $item['contact-id'], 0);
if (!empty($item['thr-parent'])) {
$data = Item::insert($item);
DI::logger()->debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
Logger::debug('Got repost', ['uid' => $uid, 'result' => $data, 'uri' => $uri]);
} else {
DI::logger()->info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
Logger::info('Thread parent not found', ['uid' => $uid, 'parent' => $item['thr-parent'], 'uri' => $uri]);
}
break;
case 'follow':
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, $uid);
DI::logger()->debug('New follower', ['uid' => $uid, 'nick' => $contact['nick'], 'uri' => $uri]);
Logger::debug('New follower', ['uid' => $uid, 'nick' => $contact['nick'], 'uri' => $uri]);
break;
case 'mention':
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_TO, $contact['id'], 0);
DI::logger()->debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
Logger::debug('Got mention', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
break;
case 'reply':
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_COMMENT, $contact['id'], 0);
DI::logger()->debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
Logger::debug('Got reply', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
break;
case 'quote':
$contact = DI::atpActor()->getContactByDID($notification->author->did, $uid, 0);
$result = DI::atpProcessor()->fetchMissingPost($uri, $uid, Item::PR_PUSHED, $contact['id'], 0);
DI::logger()->debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
Logger::debug('Got quote', ['uid' => $uid, 'nick' => $contact['nick'], 'result' => $result, 'uri' => $uri]);
break;
default:
DI::logger()->notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]);
Logger::notice('Unhandled reason', ['reason' => $notification->reason, 'uri' => $uri]);
break;
}
}
@ -1113,16 +1112,16 @@ function bluesky_fetch_feed(int $uid, string $feed)
$languages = $entry->post->record->langs ?? [];
if (!Relay::isWantedLanguage($entry->post->record->text, 0, $contact['id'] ?? 0, $languages)) {
DI::logger()->debug('Unwanted language detected', ['languages' => $languages, 'text' => $entry->post->record->text]);
Logger::debug('Unwanted language detected', ['languages' => $languages, 'text' => $entry->post->record->text]);
continue;
}
$causer = DI::atpActor()->getContactByDID($entry->post->author->did, $uid, 0);
$uri_id = bluesky_complete_post($entry->post, $uid, Item::PR_TAG, $causer['id'], Conversation::PARCEL_CONNECTOR);
if (!empty($uri_id)) {
$stored = Post\Category::storeFileByURIId($uri_id, $uid, Post\Category::SUBCRIPTION, $feedname, $feedurl);
DI::logger()->debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]);
Logger::debug('Stored tag subscription for user', ['uri-id' => $uri_id, 'uid' => $uid, 'name' => $feedname, 'url' => $feedurl, 'stored' => $stored]);
} else {
DI::logger()->notice('Post not found', ['entry' => $entry]);
Logger::notice('Post not found', ['entry' => $entry]);
}
if (!empty($entry->reason)) {
bluesky_process_reason($entry->reason, DI::atpProcessor()->getUri($entry->post), $uid);

View file

@ -1,6 +1,6 @@
<?php
use Friendica\DI;
use Friendica\Core\Logger;
function bluesky_feed_run($argv, $argc)
{
@ -10,7 +10,7 @@ function bluesky_feed_run($argv, $argc)
return;
}
DI::logger()->debug('Importing feed - start', ['user' => $argv[1], 'feed' => $argv[2]]);
Logger::debug('Importing feed - start', ['user' => $argv[1], 'feed' => $argv[2]]);
bluesky_fetch_feed($argv[1], $argv[2]);
DI::logger()->debug('Importing feed - done', ['user' => $argv[1], 'feed' => $argv[2]]);
Logger::debug('Importing feed - done', ['user' => $argv[1], 'feed' => $argv[2]]);
}

View file

@ -1,6 +1,6 @@
<?php
use Friendica\DI;
use Friendica\Core\Logger;
function bluesky_notifications_run($argv, $argc)
{
@ -10,7 +10,7 @@ function bluesky_notifications_run($argv, $argc)
return;
}
DI::logger()->notice('importing notifications - start', ['user' => $argv[1]]);
Logger::notice('importing notifications - start', ['user' => $argv[1]]);
bluesky_fetch_notifications($argv[1]);
DI::logger()->notice('importing notifications - done', ['user' => $argv[1]]);
Logger::notice('importing notifications - done', ['user' => $argv[1]]);
}

View file

@ -1,6 +1,6 @@
<?php
use Friendica\DI;
use Friendica\Core\Logger;
function bluesky_timeline_run($argv, $argc)
{
@ -10,7 +10,7 @@ function bluesky_timeline_run($argv, $argc)
return;
}
DI::logger()->notice('importing timeline - start', ['user' => $argv[1]]);
Logger::notice('importing timeline - start', ['user' => $argv[1]]);
bluesky_fetch_timeline($argv[1]);
DI::logger()->notice('importing timeline - done', ['user' => $argv[1]]);
Logger::notice('importing timeline - done', ['user' => $argv[1]]);
}

View file

@ -6,6 +6,7 @@
* Author: Mike Macgirvin <mike@macgirvin.com>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;

View file

@ -6,6 +6,7 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;

View file

@ -6,8 +6,11 @@
* Author: Fabio <https://kirgroup.com/profile/fabrixxm>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
@ -26,7 +29,7 @@ function catavatar_install()
Hook::register('addon_settings', __FILE__, 'catavatar_addon_settings');
Hook::register('addon_settings_post', __FILE__, 'catavatar_addon_settings_post');
DI::logger()->notice('registered catavatar');
Logger::notice('registered catavatar');
}
/**

View file

@ -7,6 +7,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
function cld_install()
@ -17,17 +18,7 @@ function cld_install()
function cld_detect_languages(array &$data)
{
if (!in_array('cld2', get_loaded_extensions())) {
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.');
Logger::warning('CLD2 is not installed.');
return;
}
@ -52,7 +43,7 @@ function cld_detect_languages(array &$data)
}
if (!$result['is_reliable']) {
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']]);
Logger::debug('Unreliable detection', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
if (($original == $detected) && ($data['detected'][$original] < $result['language_probability'] / 100)) {
$data['detected'][$original] = $result['language_probability'] / 100;
}
@ -62,12 +53,12 @@ function cld_detect_languages(array &$data)
$available = array_keys(DI::l10n()->getLanguageCodes());
if (!in_array($detected, $available)) {
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']]);
Logger::debug('Unsupported language', ['uri-id' => $data['uri-id'], 'original' => $original, 'detected' => $detected, 'name' => $result['language_name'], 'probability' => $result['language_probability'], 'text' => $data['text']]);
return;
}
if ($original != $detected) {
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']]);
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']);

View file

@ -169,6 +169,7 @@ class UnitConvertor
* @param string name of the source unit from which to convert
* @param string name of the target unit to which we are converting
* @param integer double precision of the end result
* @return void
* @access public
*/
function convert($value, $from_unit, $to_unit, $precision)

View file

@ -6,6 +6,7 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Hook;
function convert_install() {
@ -25,7 +26,7 @@ function convert_content() {
// @TODO Let's one day rewrite this to a modern composer package
include 'UnitConvertor.php';
$conv = new class('en') extends UnitConvertor
class TP_Converter extends UnitConvertor
{
public function __construct(string $lang = 'en')
{
@ -42,7 +43,7 @@ function convert_content() {
private function findBaseUnit($from, $to)
{
foreach ($this->bases as $skey => $sval) {
while (list($skey, $sval) = each($this->bases)) {
if ($skey == $from || $to == $skey || in_array($to, $sval) || in_array($from, $sval)) {
return $skey;
}
@ -62,7 +63,7 @@ function convert_content() {
$cells[] = $cell;
// We now have the base unit and value now lets produce the table;
foreach ($this->bases[$base_unit] as $val) {
while (list($key, $val) = each($this->bases[$base_unit])) {
$cell ['value'] = $this->convert($value, $from_unit, $val, $precision) . ' ' . $val;
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? 'framedred' : '';
$cells[] = $cell;
@ -85,7 +86,9 @@ function convert_content() {
return $string;
}
};
}
$conv = new TP_Converter('en');
$conversions = [
'Temperature' => ['base' => 'Celsius',
@ -173,15 +176,15 @@ function convert_content() {
]
];
foreach ($conversions as $key => $val) {
while (list($key, $val) = each($conversions)) {
$conv->addConversion($val['base'], $val['conv']);
$list[$key][] = $val['base'];
foreach ($val['conv'] as $ukey => $uval) {
while (list($ukey, $uval) = each($val['conv'])) {
$list[$key][] = $ukey;
}
}
$o = '<h3>Unit Conversions</h3>';
$o .= '<h3>Unit Conversions</h3>';
if (isset($_POST['from_unit']) && isset($_POST['value'])) {
$o .= ($conv->getTable(intval($_POST['value']), $_POST['from_unit'], $_POST['to_unit'], 5)) . '</p>';
@ -199,9 +202,10 @@ function convert_content() {
$o .= '<input name="value" type="text" id="value" value="' . $value . '" size="10" maxlength="10" />';
$o .= '<select name="from_unit" size="12">';
foreach ($list as $key => $val) {
reset($list);
while(list($key, $val) = each($list)) {
$o .= "\n\t<optgroup label=\"$key\">";
foreach ($val as $ukey => $uval) {
while(list($ukey, $uval) = each($val)) {
$selected = (($uval == $_POST['from_unit']) ? ' selected="selected" ' : '');
$o .= "\n\t\t<option value=\"$uval\" $selected >$uval</option>";
}

View file

@ -7,6 +7,7 @@
* Author: Peter Liebetrau <https://socivitas/profile/peerteer>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;

View file

@ -29,10 +29,10 @@ function getWeather($loc, $units = 'metric', $lang = 'en', $appid = '', $cacheti
$now = new DateTime();
if (!is_null($cached)) {
$cdate = (int) DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'last');
$cdate = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'curweather', 'last');
$cached = unserialize($cached);
if ($cdate + (int) $cachetime > $now->getTimestamp()) {
if ($cdate + $cachetime > $now->getTimestamp()) {
return $cached;
}
}

View file

@ -9,8 +9,6 @@ use Friendica\Core\System;
class Diasphp {
private $cookiejar;
private $token_regex;
private $pod;
function __construct($pod) {
$this->token_regex = '/content="(.*?)" name="csrf-token/';

View file

@ -9,8 +9,10 @@
require_once 'addon/diaspora/Diaspora_Connection.php';
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\Core\Worker;
@ -185,7 +187,7 @@ function diaspora_send(array &$b)
{
$hostname = DI::baseUrl()->getHost();
DI::logger()->notice('diaspora_send: invoked');
Logger::notice('diaspora_send: invoked');
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return;
@ -209,14 +211,14 @@ function diaspora_send(array &$b)
return;
}
DI::logger()->info('diaspora_send: prepare posting');
Logger::info('diaspora_send: prepare posting');
$handle = DI::pConfig()->get($b['uid'], 'diaspora', 'handle');
$password = DI::pConfig()->get($b['uid'], 'diaspora', 'password');
$aspect = DI::pConfig()->get($b['uid'], 'diaspora', 'aspect');
if ($handle && $password) {
DI::logger()->info('diaspora_send: all values seem to be okay');
Logger::info('diaspora_send: all values seem to be okay');
$title = $b['title'];
$body = $b['body'];
@ -247,20 +249,20 @@ function diaspora_send(array &$b)
require_once "addon/diaspora/diasphp.php";
try {
DI::logger()->info('diaspora_send: prepare');
Logger::info('diaspora_send: prepare');
$conn = new Diaspora_Connection($handle, $password);
DI::logger()->info('diaspora_send: try to log in ' . $handle);
Logger::info('diaspora_send: try to log in ' . $handle);
$conn->logIn();
DI::logger()->info('diaspora_send: try to send ' . $body);
Logger::info('diaspora_send: try to send ' . $body);
$conn->provider = $hostname;
$conn->postStatusMessage($body, $aspect);
DI::logger()->notice('diaspora_send: success');
Logger::notice('diaspora_send: success');
} catch (Exception $e) {
DI::logger()->notice("diaspora_send: Error submitting the post: " . $e->getMessage());
Logger::notice("diaspora_send: Error submitting the post: " . $e->getMessage());
DI::logger()->info('diaspora_send: requeueing ' . $b['uid']);
Logger::info('diaspora_send: requeueing ' . $b['uid']);
Worker::defer();
}

View file

@ -8,8 +8,10 @@
*
*/
use Friendica\App;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
@ -78,13 +80,13 @@ function discourse_email_getmessage(&$message)
// We do assume that all Discourse servers are running with SSL
if (preg_match('=topic/(.*\d)/(.*\d)@(.*)=', $message['item']['uri'], $matches) &&
discourse_fetch_post_from_api($message, $matches[2], $matches[3])) {
DI::logger()->info('Fetched comment via API (message-id mode)', ['host' => $matches[3], 'topic' => $matches[1], 'post' => $matches[2]]);
Logger::info('Fetched comment via API (message-id mode)', ['host' => $matches[3], 'topic' => $matches[1], 'post' => $matches[2]]);
return;
}
if (preg_match('=topic/(.*\d)@(.*)=', $message['item']['uri'], $matches) &&
discourse_fetch_topic_from_api($message, 'https://' . $matches[2], $matches[1], 1)) {
DI::logger()->info('Fetched starting post via API (message-id mode)', ['host' => $matches[2], 'topic' => $matches[1]]);
Logger::info('Fetched starting post via API (message-id mode)', ['host' => $matches[2], 'topic' => $matches[1]]);
return;
}
@ -94,16 +96,16 @@ function discourse_email_getmessage(&$message)
}
if (empty($message['item']['plink']) || !preg_match('=(http.*)/t/.*/(.*\d)/(.*\d)=', $message['item']['plink'], $matches)) {
DI::logger()->info('This is no Discourse post');
Logger::info('This is no Discourse post');
return;
}
if (discourse_fetch_topic_from_api($message, $matches[1], $matches[2], $matches[3])) {
DI::logger()->info('Fetched post via API (plink mode)', ['host' => $matches[1], 'topic' => $matches[2], 'id' => $matches[3]]);
Logger::info('Fetched post via API (plink mode)', ['host' => $matches[1], 'topic' => $matches[2], 'id' => $matches[3]]);
return;
}
DI::logger()->info('Fallback mode', ['plink' => $message['item']['plink']]);
Logger::info('Fallback mode', ['plink' => $message['item']['plink']]);
// Search in the HTML part for the discourse entry and the author profile
if (!empty($message['html'])) {
$message = discourse_get_html($message);
@ -120,7 +122,7 @@ function discourse_fetch_post($host, $topic, $pid)
$url = $host . '/t/' . $topic . '/' . $pid . '.json';
$curlResult = DI::httpClient()->get($url);
if (!$curlResult->isSuccess()) {
DI::logger()->info('No success', ['url' => $url]);
Logger::info('No success', ['url' => $url]);
return false;
}
@ -132,11 +134,11 @@ function discourse_fetch_post($host, $topic, $pid)
/// @todo Possibly fetch missing posts here
continue;
}
DI::logger()->info('Got post data from topic', $post);
Logger::info('Got post data from topic', $post);
return $post;
}
DI::logger()->info('Post not found', ['host' => $host, 'topic' => $topic, 'pid' => $pid]);
Logger::info('Post not found', ['host' => $host, 'topic' => $topic, 'pid' => $pid]);
return false;
}
@ -168,7 +170,7 @@ function discourse_fetch_post_from_api(&$message, $post, $host)
$message = discourse_process_post($message, $data, $hostaddr);
DI::logger()->info('Got API data', $message);
Logger::info('Got API data', $message);
return true;
}
@ -201,7 +203,7 @@ function discourse_get_user($post, $hostaddr)
$contact['url'] = $hostaddr . '/u/' . $contact['nick'];
$contact['nurl'] = Strings::normaliseLink($contact['url']);
$contact['baseurl'] = $hostaddr;
DI::logger()->info('Contact', $contact);
Logger::info('Contact', $contact);
$contact['id'] = Contact::getIdForURL($contact['url'], 0, false, $contact);
if (!empty($contact['id'])) {
$avatar = $contact['photo'];
@ -267,11 +269,11 @@ function discourse_get_html($message)
$div = $doc2->importNode($result->item(0), true);
$doc2->appendChild($div);
$message['html'] = $doc2->saveHTML();
DI::logger()->info('Found html body', ['html' => $message['html']]);
Logger::info('Found html body', ['html' => $message['html']]);
$profile = discourse_get_profile($xpath);
if (!empty($profile['url'])) {
DI::logger()->info('Found profile', $profile);
Logger::info('Found profile', $profile);
$message['item']['author-id'] = Contact::getIdForURL($profile['url'], 0, false, $profile);
$message['item']['author-link'] = $profile['url'];
$message['item']['author-name'] = $profile['name'];
@ -287,21 +289,21 @@ function discourse_get_text($message)
$text = str_replace("\r", '', $text);
$pos = strpos($text, "\n---\n");
if ($pos == 0) {
DI::logger()->info('No separator found', ['text' => $text]);
Logger::info('No separator found', ['text' => $text]);
return $message;
}
$message['text'] = trim(substr($text, 0, $pos));
DI::logger()->info('Found text body', ['text' => $message['text']]);
Logger::info('Found text body', ['text' => $message['text']]);
$message['text'] = Markdown::toBBCode($message['text']);
$text = substr($text, $pos);
DI::logger()->info('Found footer', ['text' => $text]);
Logger::info('Found footer', ['text' => $text]);
if (preg_match('=\((http.*/t/.*/.*\d/.*\d)\)=', $text, $link)) {
$message['item']['plink'] = $link[1];
DI::logger()->info('Found plink', ['plink' => $message['item']['plink']]);
Logger::info('Found plink', ['plink' => $message['item']['plink']]);
}
return $message;
}

View file

@ -8,8 +8,10 @@
* Author: Cat Gray <https://free-haven.org/profile/catness>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Item;
@ -184,12 +186,12 @@ function dwpost_send(array &$b)
EOT;
DI::logger()->debug('dwpost: data: ' . $xml);
Logger::debug('dwpost: data: ' . $xml);
if ($dw_blog !== 'test') {
$x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
}
DI::logger()->info('posted to dreamwidth: ' . ($x) ? $x : '');
Logger::info('posted to dreamwidth: ' . ($x) ? $x : '');
}
}

View file

@ -7,6 +7,7 @@
* Status: Unsupported
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -39,7 +40,7 @@ function fancybox_render(array &$b){
function ($text) use ($gallery) {
// This processes images inlined in posts
// Frio / Vier hooks für lightbox are un-hooked in fancybox-config.js. So this works for them, too!
//if (!in_array(DI::appHelper()->getCurrentTheme(),['vier','frio']))
//if (!in_array(DI::app()->getCurrentTheme(),['vier','frio']))
$text = preg_replace(
'#<a[^>]*href="([^"]*)"[^>]*>(<img[^>]*src="[^"]*"[^>]*>)</a>#',
'<a data-fancybox="' . $gallery . '" href="$1">$2</a>',

View file

@ -7,7 +7,9 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -16,7 +18,7 @@ function fromapp_install()
Hook::register('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook');
Hook::register('addon_settings', 'addon/fromapp/fromapp.php', 'fromapp_settings');
Hook::register('addon_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post');
DI::logger()->notice("installed fromapp");
Logger::notice("installed fromapp");
}
function fromapp_settings_post($post)

View file

@ -6,7 +6,9 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -50,25 +52,25 @@ function geocoordinates_resolve_item(array &$item)
$s = DI::httpClient()->fetch('https://api.opencagedata.com/geocode/v1/json?q=' . $coords[0] . ',' . $coords[1] . '&key=' . $key . '&language=' . $language);
if (!$s) {
DI::logger()->info('API could not be queried');
Logger::info('API could not be queried');
return;
}
$data = json_decode($s);
if ($data->status->code != '200') {
DI::logger()->info('API returned error ' . $data->status->code . ' ' . $data->status->message);
Logger::info('API returned error ' . $data->status->code . ' ' . $data->status->message);
return;
}
if (($data->total_results == 0) || (count($data->results) == 0)) {
DI::logger()->info('No results found for coordinates ' . $item['coord']);
Logger::info('No results found for coordinates ' . $item['coord']);
return;
}
$item['location'] = $data->results[0]->formatted;
DI::logger()->info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']);
Logger::info('Got location for coordinates ' . $coords[0] . '-' . $coords[1] . ': ' . $item['location']);
if ($item['location'] != '') {
DI::cache()->set('geocoordinates:' . $language.':' . $coords[0] . '-' . $coords[1], $item['location']);

View file

@ -6,7 +6,9 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -33,7 +35,7 @@ function geonames_install()
function geonames_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('geonames'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('geonames'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function geonames_post_hook(array &$item)
@ -44,7 +46,7 @@ function geonames_post_hook(array &$item)
* - The profile owner must have allowed our addon
*/
DI::logger()->notice('geonames invoked');
Logger::notice('geonames invoked');
if (!DI::userSession()->getLocalUserId()) { /* non-zero if this is a logged in user of this system */
return;

View file

@ -8,7 +8,9 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Notification;
@ -19,7 +21,7 @@ function gnot_install()
Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
DI::logger()->notice("installed gnot");
Logger::notice("installed gnot");
}
/**

View file

@ -7,14 +7,15 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
use Friendica\Core\Logger;
function googlemaps_install()
{
Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
DI::logger()->notice('installed googlemaps');
Logger::notice('installed googlemaps');
}
function googlemaps_location(&$item)

View file

@ -6,11 +6,15 @@
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
*/
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Util\Strings;
/**
* Installs the addon hook
@ -19,12 +23,12 @@ function gravatar_install() {
Hook::register('load_config', 'addon/gravatar/gravatar.php', 'gravatar_load_config');
Hook::register('avatar_lookup', 'addon/gravatar/gravatar.php', 'gravatar_lookup');
DI::logger()->notice("registered gravatar in avatar_lookup hook");
Logger::notice("registered gravatar in avatar_lookup hook");
}
function gravatar_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('gravatar'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('gravatar'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
/**

View file

@ -8,7 +8,9 @@
* Note: Please use Circle Text instead
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;

View file

@ -6,6 +6,7 @@
* Author: Hypolite Petovan <hypolite@mrpetovan.com>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
@ -17,7 +18,7 @@ function highlightjs_install()
function highlightjs_head(string &$str)
{
if (DI::appHelper()->getCurrentTheme() == 'frio') {
if (DI::app()->getCurrentTheme() == 'frio') {
$style = 'bootstrap';
} else {
$style = 'default';

View file

@ -6,8 +6,10 @@
* Version: 0.1
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Content\PageInfo;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
@ -85,16 +87,16 @@ function ifttt_post()
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname]);
if (!DBA::isResult($user)) {
DI::logger()->info('User ' . $nickname . ' not found.');
Logger::info('User ' . $nickname . ' not found.');
return;
}
$uid = $user['uid'];
DI::logger()->info('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true));
Logger::info('Received a post for user ' . $uid . ' from ifttt ' . print_r($_REQUEST, true));
if (!isset($_REQUEST['key'])) {
DI::logger()->notice('No key found.');
Logger::notice('No key found.');
return;
}
@ -102,7 +104,7 @@ function ifttt_post()
// Check the key
if ($key != DI::pConfig()->get($uid, 'ifttt', 'key')) {
DI::logger()->info('Invalid key for user ' . $uid);
Logger::info('Invalid key for user ' . $uid);
return;
}
@ -113,7 +115,7 @@ function ifttt_post()
}
if (!in_array($item['type'], ['status', 'link', 'photo'])) {
DI::logger()->info('Unknown item type ' . $item['type']);
Logger::info('Unknown item type ' . $item['type']);
return;
}

View file

@ -8,8 +8,10 @@
* Author: Cat Gray <https://free-haven.org/profile/catness>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Item;
@ -177,11 +179,11 @@ function ijpost_send(array &$b)
EOT;
DI::logger()->debug('ijpost: data: ' . $xml);
Logger::debug('ijpost: data: ' . $xml);
if ($ij_blog !== 'test') {
$x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
}
DI::logger()->info('posted to insanejournal: ' . $x ? $x : '');
Logger::info('posted to insanejournal: ' . $x ? $x : '');
}
}

View file

@ -7,8 +7,10 @@
* License: 3-clause BSD license
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -19,7 +21,7 @@ function impressum_install()
Hook::register('load_config', 'addon/impressum/impressum.php', 'impressum_load_config');
Hook::register('about_hook', 'addon/impressum/impressum.php', 'impressum_show');
Hook::register('page_end', 'addon/impressum/impressum.php', 'impressum_footer');
DI::logger()->notice("installed impressum Addon");
Logger::notice("installed impressum Addon");
}
/**
@ -54,7 +56,7 @@ function impressum_footer(string &$body)
function impressum_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('impressum'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('impressum'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function impressum_show(string &$body)

View file

@ -6,6 +6,7 @@
* Author: Thomas Willingham <https://kakste.com/profile/beardyunixer>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;

View file

@ -54,8 +54,8 @@ function invidious_settings(array &$data)
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/invidious/');
$html = Renderer::replaceMacros($t, [
'$enabled' => ['invidious-enabled', DI::l10n()->t('Replace Youtube links with links to an Invidious server'), $enabled, DI::l10n()->t('If enabled, Youtube links are replaced with the links to the specified Invidious server.')],
'$server' => ['invidious-server', DI::l10n()->t('Invidious server'), $server, DI::l10n()->t('See %s for a list of available Invidious servers.', '<a href="https://api.invidious.io/">https://api.invidious.io/</a>')],
'$enabled' => ['enabled', DI::l10n()->t('Replace Youtube links with links to an Invidious server'), $enabled, DI::l10n()->t('If enabled, Youtube links are replaced with the links to the specified Invidious server.')],
'$server' => ['server', DI::l10n()->t('Invidious server'), $server, DI::l10n()->t('See %s for a list of available Invidious servers.', '<a href="https://api.invidious.io/">https://api.invidious.io/</a>')],
]);
$data = [
@ -71,9 +71,9 @@ function invidious_settings_post(array &$b)
return;
}
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'enabled', (bool)$_POST['invidious-enabled']);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'enabled', (bool)$_POST['enabled']);
$server = trim($_POST['invidious-server'], " \n\r\t\v\x00/");
$server = trim($_POST['server'], " \n\r\t\v\x00/");
if ($server != DI::config()->get('invidious', 'server', INVIDIOUS_DEFAULT) && !empty($server)) {
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'invidious', 'server', $server);
} else {

View file

@ -7,6 +7,7 @@
* Author: Tobias Diekershoff <https://f.diekershoff.de/u/tobias>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;

View file

@ -105,7 +105,7 @@ class qqFileUploader {
private function toBytes(string $str): int
{
$val = (int) trim($str);
$val = trim($str);
$last = strtolower($str[strlen($str) - 1]);
switch($last) {

View file

@ -2,8 +2,8 @@
usleep(100000);
$fileName = '';
$fileSize = 0;;
$fileName;
$fileSize;
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];

View file

@ -2,7 +2,7 @@
sleep(4);
$fileName = '';
$fileName;
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];

View file

@ -2,7 +2,7 @@
usleep(300);
$fileName = '';
$fileName;
if (isset($_GET['qqfile'])){
$fileName = $_GET['qqfile'];

View file

@ -8,6 +8,7 @@
*/
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Util\Images;
@ -59,7 +60,7 @@ function js_upload_post_init(array &$b)
// max file size in bytes
$sizeLimit = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize'));
$uploader = new js_upload_qqFileUploader($allowedExtensions, $sizeLimit);
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $uploader->handleUpload();
@ -67,7 +68,7 @@ function js_upload_post_init(array &$b)
$js_upload_jsonresponse = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
if (isset($result['error'])) {
DI::logger()->info('mod/photos.php: photos_post(): error uploading photo: ' . $result['error']);
Logger::info('mod/photos.php: photos_post(): error uploading photo: ' . $result['error']);
echo json_encode($result);
exit();
}
@ -90,7 +91,7 @@ function js_upload_post_end(int &$b)
{
global $js_upload_jsonresponse;
DI::logger()->notice('upload_post_end');
Logger::notice('upload_post_end');
if (!empty($js_upload_jsonresponse)) {
echo $js_upload_jsonresponse;
exit();
@ -100,7 +101,7 @@ function js_upload_post_end(int &$b)
/**
* Handle file uploads via XMLHttpRequest
*/
class js_upload_qqUploadedFileXhr
class qqUploadedFileXhr
{
private $pathnm = '';
@ -154,7 +155,7 @@ class js_upload_qqUploadedFileXhr
/**
* Handle file uploads via regular form post (uses the $_FILES array)
*/
class js_upload_qqUploadedFileForm
class qqUploadedFileForm
{
/**
* Save the file to the specified path
@ -182,14 +183,10 @@ class js_upload_qqUploadedFileForm
}
}
class js_upload_qqFileUploader
class qqFileUploader
{
private $allowedExtensions;
private $sizeLimit;
/**
* @var js_upload_qqUploadedFileXhr|js_upload_qqUploadedFileForm
*/
private $file;
function __construct(array $allowedExtensions = [], $sizeLimit)
@ -200,9 +197,9 @@ class js_upload_qqFileUploader
$this->sizeLimit = $sizeLimit;
if (isset($_GET['qqfile'])) {
$this->file = new js_upload_qqUploadedFileXhr();
$this->file = new qqUploadedFileXhr();
} elseif (isset($_FILES['qqfile'])) {
$this->file = new js_upload_qqUploadedFileForm();
$this->file = new qqUploadedFileForm();
} else {
$this->file = false;
}
@ -237,7 +234,7 @@ class js_upload_qqFileUploader
$filename = $pathinfo['filename'];
if (!isset($pathinfo['extension'])) {
DI::logger()->warning('extension isn\'t set.', ['filename' => $filename]);
Logger::warning('extension isn\'t set.', ['filename' => $filename]);
}
$ext = $pathinfo['extension'] ?? '';

View file

@ -6,7 +6,9 @@
* Author: Ryan <https://verya.pe/profile/ryan>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -36,7 +38,7 @@ function keycloakpassword_request($client_id, $secret, $url, $params = [])
$res = curl_exec($ch);
if (curl_errno($ch)) {
DI::logger()->error(curl_error($ch));
Logger::error(curl_error($ch));
}
curl_close($ch);
@ -90,7 +92,7 @@ function keycloakpassword_authenticate(array &$b)
$client_id,
$secret,
$endpoint . '/logout',
[ 'refresh_token' => $res['refresh_token'] ]
[ 'refresh_token' => res['refresh_token'] ]
);
}
}

View file

@ -10,7 +10,9 @@
*"My body was my sacrifice... for my magic. This damage is permanent." - Raistlin Majere
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -30,7 +32,7 @@ function krynn_install()
Hook::register('addon_settings', 'addon/krynn/krynn.php', 'krynn_settings');
Hook::register('addon_settings_post', 'addon/krynn/krynn.php', 'krynn_settings_post');
DI::logger()->notice("installed krynn");
Logger::notice("installed krynn");
}
function krynn_post_hook(&$item)

View file

@ -7,6 +7,7 @@
* License: MIT
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
@ -147,8 +148,6 @@ function langfilter_prepare_body_content_filter(&$hook_data)
$iso639 = new Matriphe\ISO639\ISO639;
$confidence = null;
// Extract the language of the post
if (!empty($hook_data['item']['language'])) {
$languages = json_decode($hook_data['item']['language'], true);

View file

@ -29,7 +29,9 @@
* The configuration options for this module are described in the config/ldapauth.config.php file
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
@ -43,7 +45,7 @@ function ldapauth_install()
function ldapauth_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('ldapauth'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('ldapauth'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function ldapauth_hook_authenticate(array &$b)
@ -68,54 +70,54 @@ function ldapauth_authenticate($username, $password)
$ldap_autocreateaccount_nameattribute = DI::config()->get('ldapauth', 'ldap_autocreateaccount_nameattribute');
if (!extension_loaded('ldap') || !strlen($ldap_server)) {
DI::logger()->error('Addon not configured or missing php-ldap extension', ['extension_loaded' => extension_loaded('ldap'), 'server' => $ldap_server]);
Logger::error('Addon not configured or missing php-ldap extension', ['extension_loaded' => extension_loaded('ldap'), 'server' => $ldap_server]);
return false;
}
if (!strlen($password)) {
DI::logger()->error('Empty password disallowed', ['provided_password_length' => strlen($password)]);
Logger::error('Empty password disallowed', ['provided_password_length' => strlen($password)]);
return false;
}
$connect = @ldap_connect($ldap_server);
if ($connect === false) {
DI::logger()->warning('Could not connect to LDAP server', ['server' => $ldap_server]);
Logger::warning('Could not connect to LDAP server', ['server' => $ldap_server]);
return false;
}
@ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
@ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
if ((@ldap_bind($connect, $ldap_binddn, $ldap_bindpw)) === false) {
DI::logger()->warning('Could not bind to LDAP server', ['server' => $ldap_server, 'binddn' => $ldap_binddn, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
Logger::warning('Could not bind to LDAP server', ['server' => $ldap_server, 'binddn' => $ldap_binddn, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
return false;
}
$res = @ldap_search($connect, $ldap_searchdn, $ldap_userattr . '=' . $username);
if (!$res) {
DI::logger()->notice('LDAP user not found.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
Logger::notice('LDAP user not found.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
return false;
}
$id = @ldap_first_entry($connect, $res);
if (!$id) {
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)]);
Logger::notice('Could not retrieve first LDAP entry.', ['searchdn' => $ldap_searchdn, 'userattr' => $ldap_userattr, 'username' => $username, 'errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
return false;
}
$dn = @ldap_get_dn($connect, $id);
if (!@ldap_bind($connect, $dn, $password)) {
DI::logger()->notice('Could not authenticate LDAP user with provided password', ['errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
Logger::notice('Could not authenticate LDAP user with provided password', ['errno' => ldap_errno($connect), 'error' => ldap_error($connect)]);
return false;
}
if (strlen($ldap_group) && @ldap_compare($connect, $ldap_group, 'member', $dn) !== true) {
$errno = @ldap_errno($connect);
if ($errno === 32) {
DI::logger()->notice('LDAP Access Control Group does not exist', ['errno' => $errno, 'error' => ldap_error($connect)]);
Logger::notice('LDAP Access Control Group does not exist', ['errno' => $errno, 'error' => ldap_error($connect)]);
} elseif ($errno === 16) {
DI::logger()->notice('LDAP membership attribute does not exist in access control group', ['errno' => $errno, 'error' => ldap_error($connect)]);
Logger::notice('LDAP membership attribute does not exist in access control group', ['errno' => $errno, 'error' => ldap_error($connect)]);
} else {
DI::logger()->notice('LDAP user isn\'t part of the authorized group', ['dn' => $dn]);
Logger::notice('LDAP user isn\'t part of the authorized group', ['dn' => $dn]);
}
@ldap_close($connect);
@ -139,7 +141,7 @@ function ldapauth_authenticate($username, $password)
$authentication = User::getAuthenticationInfo($username);
return User::getById($authentication['uid']);
} catch (Exception $e) {
DI::logger()->notice('LDAP authentication error: ' . $e->getMessage());
Logger::notice('LDAP authentication error: ' . $e->getMessage());
return false;
}
}
@ -147,7 +149,7 @@ function ldapauth_authenticate($username, $password)
function ldap_createaccount($username, $password, $email, $name)
{
if (!strlen($email) || !strlen($name)) {
DI::logger()->notice('Could not create local user from LDAP data, no email or nickname provided');
Logger::notice('Could not create local user from LDAP data, no email or nickname provided');
return false;
}
@ -159,10 +161,10 @@ function ldap_createaccount($username, $password, $email, $name)
'password' => $password,
'verified' => 1
]);
DI::logger()->info('Local user created from LDAP data', ['username' => $username, 'name' => $name]);
Logger::info('Local user created from LDAP data', ['username' => $username, 'name' => $name]);
return $user;
} catch (Exception $ex) {
DI::logger()->error('Could not create local user from LDAP data', ['username' => $username, 'exception' => $ex->getMessage()]);
Logger::error('Could not create local user from LDAP data', ['username' => $username, 'exception' => $ex->getMessage()]);
}
return false;

View file

@ -6,7 +6,9 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
function leistungsschutzrecht_install()
@ -147,7 +149,7 @@ function leistungsschutzrecht_is_member_site(string $url): bool
$cleanedurlpart = explode('%', $urldata['host']);
$hostname = explode('.', $cleanedurlpart[0]);
if ($hostname === false || $hostname === '') {
if (empty($hostname)) {
return false;
}
@ -167,7 +169,7 @@ function leistungsschutzrecht_cron($b)
if ($last) {
$next = $last + 86400;
if ($next > time()) {
DI::logger()->notice('poll intervall not reached');
Logger::notice('poll intervall not reached');
return;
}
}

View file

@ -6,8 +6,10 @@
* Author: Tony Baldwin <https://free-haven.org/u/tony>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -129,7 +131,7 @@ function libertree_post_local(array &$b)
function libertree_send(array &$b)
{
DI::logger()->notice('libertree_send: invoked');
Logger::notice('libertree_send: invoked');
if ($b['deleted'] || ($b['private'] == Item::PRIVATE) || ($b['created'] !== $b['edited'])) {
return;
@ -195,6 +197,6 @@ function libertree_send(array &$b)
];
$result = DI::httpClient()->post($ltree_blog, $params)->getBodyString();
DI::logger()->notice('libertree: ' . $result);
Logger::notice('libertree: ' . $result);
}
}

View file

@ -217,7 +217,7 @@ class Services_Libravatar
*
* @param array $options Array of options for getUrl()
*
* @return array
* @return void
* @throws Exception When an invalid option is used
*/
protected function checkOptionsArray($options)
@ -401,8 +401,9 @@ class Services_Libravatar
*/
protected function srvGet($domain, $https = false)
{
// Are we going secure? Set up a fallback too.
if ($https === true) {
if (isset($https) && $https === true) {
$subdomain = '_avatars-sec._tcp.';
$fallback = 'seccdn.';
} else {
@ -425,7 +426,6 @@ class Services_Libravatar
$top = $srv[0];
$sum = 0;
$pri = [];
// Try to adhere to RFC2782's weighting algorithm, page 3
// "arrange all SRV RRs (that have not been ordered yet) in any order,
@ -462,8 +462,6 @@ class Services_Libravatar
return $v['target'];
}
}
return '';
}
/**

View file

@ -6,8 +6,10 @@
* Author: Klaus Weidenbach <http://friendica.dszdw.net/profile/klaus>
*/
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -19,12 +21,12 @@ function libravatar_install()
{
Hook::register('load_config', 'addon/libravatar/libravatar.php', 'libravatar_load_config');
Hook::register('avatar_lookup', 'addon/libravatar/libravatar.php', 'libravatar_lookup');
DI::logger()->notice("registered libravatar in avatar_lookup hook");
Logger::notice("registered libravatar in avatar_lookup hook");
}
function libravatar_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('libravatar'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('libravatar'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
/**

View file

@ -8,8 +8,10 @@
* Author: Cat Gray <https://free-haven.org/profile/catness>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Item;
@ -199,14 +201,12 @@ function ljpost_send(array &$b)
</methodCall>
EOT;
DI::logger()->debug('ljpost: data: ' . $xml);
$x = '';
Logger::debug('ljpost: data: ' . $xml);
if ($lj_blog !== 'test') {
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBodyString();
}
DI::logger()->info('posted to livejournal: ' . $x);
Logger::info('posted to livejournal: ' . ($x) ? $x : '');
}
}

View file

@ -8,6 +8,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Core\Worker;
@ -31,7 +32,7 @@ function mailstream_install()
Hook::register('post_remote_end', 'addon/mailstream/mailstream.php', 'mailstream_post_hook');
Hook::register('mailstream_send_hook', 'addon/mailstream/mailstream.php', 'mailstream_send_hook');
DI::logger()->info("installed mailstream");
Logger::info("installed mailstream");
}
/**
@ -85,7 +86,7 @@ function mailstream_generate_id(string $uri): string
$host = DI::baseUrl()->getHost();
$resource = hash('md5', $uri);
$message_id = "<" . $resource . "@" . $host . ">";
DI::logger()->debug('generated message ID', ['id' => $message_id, 'uri' => $uri]);
Logger::debug('generated message ID', ['id' => $message_id, 'uri' => $uri]);
return $message_id;
}
@ -94,20 +95,20 @@ function mailstream_send_hook(array $data)
$criteria = array('uid' => $data['uid'], 'contact-id' => $data['contact-id'], 'uri' => $data['uri']);
$item = Post::selectFirst([], $criteria);
if (empty($item)) {
DI::logger()->error('could not find item');
Logger::error('could not find item');
return;
}
$user = User::getById($item['uid']);
if (empty($user)) {
DI::logger()->error('could not find user', ['uid' => $item['uid']]);
Logger::error('could not find user', ['uid' => $item['uid']]);
return;
}
if (!mailstream_send($data['message_id'], $item, $user)) {
DI::logger()->debug('send failed, will retry', $data);
Logger::debug('send failed, will retry', $data);
if (!Worker::defer()) {
DI::logger()->error('failed and could not defer', $data);
Logger::error('failed and could not defer', $data);
}
}
}
@ -123,32 +124,32 @@ function mailstream_send_hook(array $data)
function mailstream_post_hook(array &$item)
{
if ($item['uid'] === 0) {
DI::logger()->debug('mailstream: root user, skipping item ' . $item['id']);
Logger::debug('mailstream: root user, skipping item ' . $item['id']);
return;
}
if (!DI::pConfig()->get($item['uid'], 'mailstream', 'enabled')) {
DI::logger()->debug('mailstream: not enabled.', ['item' => $item['id'], ' uid ' => $item['uid']]);
Logger::debug('mailstream: not enabled.', ['item' => $item['id'], ' uid ' => $item['uid']]);
return;
}
if (!$item['contact-id']) {
DI::logger()->debug('no contact-id', ['item' => $item['id']]);
Logger::debug('no contact-id', ['item' => $item['id']]);
return;
}
if (!$item['uri']) {
DI::logger()->debug('no uri', ['item' => $item['id']]);
Logger::debug('no uri', ['item' => $item['id']]);
return;
}
if ($item['verb'] == Activity::ANNOUNCE) {
DI::logger()->debug('ignoring announce', ['item' => $item['id']]);
Logger::debug('ignoring announce', ['item' => $item['id']]);
return;
}
if (DI::pConfig()->get($item['uid'], 'mailstream', 'nolikes')) {
if ($item['verb'] == Activity::LIKE) {
DI::logger()->debug('ignoring like', ['item' => $item['id']]);
Logger::debug('ignoring like', ['item' => $item['id']]);
return;
}
if ($item['verb'] == Activity::DISLIKE) {
DI::logger()->debug('ignoring dislike', ['item' => $item['id']]);
Logger::debug('ignoring dislike', ['item' => $item['id']]);
return;
}
}
@ -199,7 +200,7 @@ function mailstream_do_images(array &$item, array &$attachments)
try {
$curlResult = DI::httpClient()->get($url, HttpClientAccept::DEFAULT, [HttpClientOptions::COOKIEJAR => $cookiejar]);
if (!$curlResult->isSuccess()) {
DI::logger()->debug('mailstream: fetch image url failed', [
Logger::debug('mailstream: fetch image url failed', [
'url' => $url,
'item_id' => $item['id'],
'return_code' => $curlResult->getReturnCode()
@ -207,7 +208,7 @@ function mailstream_do_images(array &$item, array &$attachments)
continue;
}
} catch (InvalidArgumentException $e) {
DI::logger()->error('exception fetching url', ['url' => $url, 'item_id' => $item['id']]);
Logger::error('exception fetching url', ['url' => $url, 'item_id' => $item['id']]);
continue;
}
$attachments[$url] = [
@ -308,7 +309,7 @@ function mailstream_subject(array $item): string
}
$contact = Contact::selectFirst([], ['id' => $item['contact-id'], 'uid' => $item['uid']]);
if (!DBA::isResult($contact)) {
DI::logger()->error('no contact', [
Logger::error('no contact', [
'item' => $item['id'],
'plink' => $item['plink'],
'contact id' => $item['contact-id'],
@ -350,16 +351,16 @@ function mailstream_subject(array $item): string
function mailstream_send(string $message_id, array $item, array $user): bool
{
if (!is_array($item)) {
DI::logger()->error('item is empty', ['message_id' => $message_id]);
Logger::error('item is empty', ['message_id' => $message_id]);
return false;
}
if (!$item['visible']) {
DI::logger()->debug('item not yet visible', ['item uri' => $item['uri']]);
Logger::debug('item not yet visible', ['item uri' => $item['uri']]);
return false;
}
if (!$message_id) {
DI::logger()->error('no message ID supplied', ['item uri' => $item['uri'], 'user email' => $user['email']]);
Logger::error('no message ID supplied', ['item uri' => $item['uri'], 'user email' => $user['email']]);
return true;
}
@ -377,7 +378,7 @@ function mailstream_send(string $message_id, array $item, array $user): bool
if (!$address) {
$address = $user['email'];
}
$mail = new PHPMailer();
$mail = new PHPmailer();
try {
$mail->XMailer = 'Friendica Mailstream Addon';
$mail->SetFrom($frommail, mailstream_sender($item));
@ -417,15 +418,15 @@ function mailstream_send(string $message_id, array $item, array $user): bool
if (!$mail->Send()) {
throw new Exception($mail->ErrorInfo);
}
DI::logger()->debug('sent message', [
Logger::debug('sent message', [
'message ID' => $mail->MessageID,
'subject' => $mail->Subject,
'address' => $address
]);
} catch (phpmailerException $e) {
DI::logger()->debug('PHPMailer exception sending message', ['id' => $message_id, 'error' => $e->errorMessage()]);
Logger::debug('PHPMailer exception sending message', ['id' => $message_id, 'error' => $e->errorMessage()]);
} catch (Exception $e) {
DI::logger()->debug('exception sending message', ['id' => $message_id, 'error' => $e->getMessage()]);
Logger::debug('exception sending message', ['id' => $message_id, 'error' => $e->getMessage()]);
}
return true;

View file

@ -2690,10 +2690,10 @@ class PHPMailer
if (!is_readable($path)) {
throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
}
$magic_quotes = false;
$magic_quotes = get_magic_quotes_runtime();
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
//set_magic_quotes_runtime(false);
set_magic_quotes_runtime(false);
} else {
//Doesn't exist in PHP 5.4, but we don't need to check because
//get_magic_quotes_runtime always returns false in 5.4+
@ -2705,7 +2705,7 @@ class PHPMailer
$file_buffer = $this->encodeString($file_buffer, $encoding);
if ($magic_quotes) {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
//set_magic_quotes_runtime($magic_quotes);
set_magic_quotes_runtime($magic_quotes);
} else {
ini_set('magic_quotes_runtime', $magic_quotes);
}
@ -3286,7 +3286,7 @@ class PHPMailer
$result = 'localhost.localdomain';
if (!empty($this->Hostname)) {
$result = $this->Hostname;
} elseif (!empty($_SERVER['SERVER_NAME'])) {
} elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
$result = $_SERVER['SERVER_NAME'];
} elseif (function_exists('gethostname') && gethostname() !== false) {
$result = gethostname();

View file

@ -5,6 +5,7 @@
* Version: 0.1
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Renderer;
@ -26,7 +27,7 @@ function markdown_addon_settings(array &$data)
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/markdown/');
$html = Renderer::replaceMacros($t, [
'$enabled' => ['markdown-enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
'$enabled' => ['enabled', DI::l10n()->t('Enable Markdown parsing'), $enabled, DI::l10n()->t('If enabled, adds Markdown support to the Compose Post form.')],
]);
$data = [
@ -42,7 +43,7 @@ function markdown_addon_settings_post(array &$b)
return;
}
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['markdown-enabled']));
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'markdown', 'enabled', intval($_POST['enabled']));
}
function markdown_post_local_start(&$request) {

View file

@ -8,6 +8,7 @@
* License: 3-clause BSD license
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;

View file

@ -7,9 +7,9 @@
* Status: Unsupported
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
function membersince_install()
@ -19,19 +19,7 @@ function membersince_install()
function membersince_display(array &$b)
{
$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') {
if (DI::app()->getCurrentTheme() == 'frio') {
// Works in Frio.
$doc = new DOMDocument();
$doc->loadHTML(mb_convert_encoding($b, 'HTML-ENTITIES', 'UTF-8'));
@ -51,7 +39,7 @@ function membersince_display(array &$b)
$label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted');
// The div for the register date of the profile owner.
$entry = $doc->createElement('div', DateTimeFormat::local($user['register_date']));
$entry = $doc->createElement('div', DateTimeFormat::local(DI::app()->profile['register_date']));
$entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry');
$div->appendChild($hr);
@ -62,6 +50,6 @@ function membersince_display(array &$b)
$b = $doc->saveHTML();
} else {
// Works in Vier.
$b = preg_replace('/<\/dl>/', "</dl>\n\n\n<dl id=\"aprofile-membersince\" class=\"aprofile\">\n<dt>" . DI::l10n()->t('Member since:') . "</dt>\n<dd>" . DateTimeFormat::local($user['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(DI::app()->profile['register_date']) . "</dd>\n</dl>", $b, 1);
}
}

View file

@ -1,4 +0,0 @@
# Monolog Addon
A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)).
There are just Friendica additions inside the src directory.

View file

@ -1,7 +1,7 @@
<?php
/*
* Name: Monolog
* Description: A Logging framework with lots of additions, customized for Friendica.
* Version: 1.1
* Description: A Logging framework with lots of additions (see [Monolog](https://github.com/Seldaek/monolog/)). There are just Friendica additions inside the src directory
* Version: 1.0
* Author: Philipp Holzer
*/

View file

@ -4,8 +4,7 @@ namespace Friendica\Addon\monolog\src\Factory;
use Friendica\Addon\monolog\src\Monolog\IntrospectionProcessor;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Logger\Capability\IHaveCallIntrospections;
use Friendica\Core\Logger\Factory\LoggerFactory;
use Friendica\Core\Logger\Factory\AbstractLoggerTypeFactory;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
@ -17,49 +16,32 @@ use Psr\Log\LogLevel;
require_once __DIR__ . '/../../vendor/autoload.php';
final class MonologFactory implements LoggerFactory
class Monolog extends AbstractLoggerTypeFactory
{
private IHaveCallIntrospections $introspection;
private IManageConfigValues $config;
public function __construct(IHaveCallIntrospections $introspection, IManageConfigValues $config)
{
$this->introspection = $introspection;
$this->config = $config;
}
/**
* Creates and returns a PSR-3 Logger instance.
*
* Calling this method multiple times with the same parameters SHOULD return the same object.
*
* @param \Psr\Log\LogLevel::* $logLevel The log level
* @param \Friendica\Core\Logger\Capability\LogChannel::* $logChannel The log channel
*/
public function createLogger(string $logLevel, string $logChannel): LoggerInterface
public function create(IManageConfigValues $config, string $loglevel = null): LoggerInterface
{
$loggerTimeZone = new \DateTimeZone('UTC');
$logger = new Logger($logChannel);
$logger = new Logger($this->channel);
$logger->setTimezone($loggerTimeZone);
$logger->pushProcessor(new PsrLogMessageProcessor());
$logger->pushProcessor(new ProcessIdProcessor());
$logger->pushProcessor(new UidProcessor());
$logger->pushProcessor(new IntrospectionProcessor($this->introspection, LogLevel::DEBUG));
$logfile = $this->config->get('system', 'logfile');
$logfile = $config->get('system', 'logfile');
// just add a stream in case it's either writable or not file
if (is_writable($logfile)) {
$logLevel = Logger::toMonologLevel($logLevel);
$loglevel = $loglevel ?? static::mapLegacyConfigDebugLevel($config->get('system', 'loglevel'));
$loglevel = Logger::toMonologLevel($loglevel);
// fallback to notice if an invalid loglevel is set
if (!is_int($logLevel)) {
$logLevel = LogLevel::NOTICE;
if (!is_int($loglevel)) {
$loglevel = LogLevel::NOTICE;
}
$fileHandler = new StreamHandler($logfile, $logLevel);
$fileHandler = new StreamHandler($logfile, $loglevel);
$formatter = new LineFormatter("%datetime% %channel% [%level_name%]: %message% %context% %extra%\n");
$fileHandler->setFormatter($formatter);

View file

@ -20,7 +20,10 @@
*/
return [
\Friendica\Core\Logger\Factory\LoggerFactory::class => [
'instanceOf' => \Friendica\Addon\monolog\src\Factory\MonologFactory::class,
\Monolog\Logger::class => [
'instanceOf' => \Friendica\Addon\monolog\src\Factory\Monolog::class,
'call' => [
['create', [], \Dice\Dice::CHAIN_CALL],
],
],
];

View file

@ -0,0 +1,26 @@
<?php
/**
* @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
return [
\Psr\Log\LoggerInterface::class => [
\Monolog\Logger::class => ['monolog'],
],
];

View file

@ -8,6 +8,7 @@
* Status: Deprecated
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;

View file

@ -7,6 +7,7 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;

View file

@ -6,8 +6,10 @@
* Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
***/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\User;
@ -15,7 +17,7 @@ use Friendica\Model\User;
function newmemberwidget_install()
{
Hook::register( 'network_mod_init', 'addon/newmemberwidget/newmemberwidget.php', 'newmemberwidget_network_mod_init');
DI::logger()->notice('newmemberwidget installed');
Logger::notice('newmemberwidget installed');
}
function newmemberwidget_network_mod_init ($b)

View file

@ -25,6 +25,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;

View file

@ -6,7 +6,9 @@
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -44,19 +46,19 @@ function nominatim_resolve_item(array &$item)
$s = DI::httpClient()->fetch('https://nominatim.openstreetmap.org/reverse?lat=' . $coords[0] . '&lon=' . $coords[1] . '&format=json&addressdetails=0&accept-language=' . $language);
if (empty($s)) {
DI::logger()->info('API could not be queried');
Logger::info('API could not be queried');
return;
}
$data = json_decode($s, true);
if (empty($data['display_name'])) {
DI::logger()->info('No results found for coordinates', ['coordinates' => $item['coord'], 'data' => $data]);
Logger::info('No results found for coordinates', ['coordinates' => $item['coord'], 'data' => $data]);
return;
}
$item['location'] = $data['display_name'];
DI::logger()->info('Got location', ['lat' => $coords[0], 'long' => $coords[1], 'location' => $item['location']]);
Logger::info('Got location', ['lat' => $coords[0], 'long' => $coords[1], 'location' => $item['location']]);
if (!empty($item['location'])) {
DI::cache()->set('nominatim:' . $language . ':' . $coords[0] . '-' . $coords[1], $item['location']);

View file

@ -9,7 +9,9 @@
*/
use Friendica\Addon\notifyall\NotifyAllEmail;
use Friendica\App;
use Friendica\Database\DBA;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;

View file

@ -8,6 +8,7 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -119,8 +120,6 @@ function nsfw_prepare_body_content_filter(&$hook_data)
}
$found = false;
$tag_search = false;
if (count($word_list)) {
$body = $hook_data['item']['title'] . "\n" . nsfw_extract_photos($hook_data['item']['body']);
@ -130,6 +129,7 @@ function nsfw_prepare_body_content_filter(&$hook_data)
continue;
}
$tag_search = false;
switch ($word[0]) {
case '/'; // Regular expression
$found = @preg_match($word, $body);

View file

@ -6,7 +6,9 @@
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -15,7 +17,7 @@ function numfriends_install() {
Hook::register('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
Hook::register('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
DI::logger()->notice("installed numfriends");
Logger::notice("installed numfriends");
}
/**

View file

@ -9,8 +9,10 @@
*
*/
use Friendica\App;
use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -30,12 +32,12 @@ function openstreetmap_install()
Hook::register('Map::getCoordinates', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_get_coordinates');
Hook::register('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader');
DI::logger()->notice("installed openstreetmap");
Logger::notice("installed openstreetmap");
}
function openstreetmap_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('openstreetmap'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('openstreetmap'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function openstreetmap_alterheader(&$navHtml)
@ -153,8 +155,8 @@ function openstreetmap_generate_map(array &$b)
$lat = $b['lat']; // round($b['lat'], 5);
$lon = $b['lon']; // round($b['lon'], 5);
DI::logger()->debug('lat: ' . $lat);
DI::logger()->debug('lon: ' . $lon);
Logger::debug('lat: ' . $lat);
Logger::debug('lon: ' . $lon);
$cardlink = '<a href="' . $tmsserver;
@ -172,7 +174,7 @@ function openstreetmap_generate_map(array &$b)
$b['html'] .= '<br/>' . $cardlink;
}
DI::logger()->debug('generate_map: ' . $b['html']);
Logger::debug('generate_map: ' . $b['html']);
}
function openstreetmap_addon_admin(string &$o)

View file

@ -8,7 +8,12 @@
*/
use Friendica\DI;
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Network\HTTPException;
use Friendica\Database\DBA;
use Friendica\Core\Renderer;
use Friendica\Core\Protocol;
use Friendica\Model\Contact;
use Friendica\Model\User;
@ -17,7 +22,7 @@ function opmlexport_install()
{
Hook::register('addon_settings', __FILE__, 'opmlexport_addon_settings');
Hook::register('addon_settings_post', __FILE__, 'opmlexport_addon_settings_post');
DI::logger()->notice('installed opmlexport Addon');
Logger::notice('installed opmlexport Addon');
}

View file

@ -8,6 +8,7 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;

View file

@ -7,6 +7,7 @@
* Maintainer: Hypolite Petovan <hypolite@friendica.mrpetovan.com>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;
use Friendica\Object\EMail\IEmail;
@ -24,7 +25,7 @@ function phpmailer_install()
function phpmailer_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('phpmailer'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('phpmailer'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
/**

View file

@ -35,7 +35,9 @@
* setting.
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Core\Config\Util\ConfigFileManager;
@ -44,12 +46,12 @@ function piwik_install() {
Hook::register('load_config', 'addon/piwik/piwik.php', 'piwik_load_config');
Hook::register('page_end', 'addon/piwik/piwik.php', 'piwik_analytics');
DI::logger()->notice("installed piwik addon");
Logger::notice("installed piwik addon");
}
function piwik_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('piwik'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('piwik'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function piwik_analytics(string &$b)

View file

@ -7,7 +7,9 @@
* Author: Tony Baldwin <https://free-haven.org/profile/tony>
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -27,7 +29,7 @@ function planets_install()
Hook::register('addon_settings', 'addon/planets/planets.php', 'planets_settings');
Hook::register('addon_settings_post', 'addon/planets/planets.php', 'planets_settings_post');
DI::logger()->notice("installed planets");
Logger::notice("installed planets");
}
/**
@ -38,7 +40,7 @@ function planets_install()
*/
function planets_post_hook(&$item)
{
DI::logger()->notice('planets invoked');
Logger::notice('planets invoked');
if (!DI::userSession()->getLocalUserId()) {
/* non-zero if this is a logged in user of this system */

View file

@ -2,8 +2,6 @@
namespace phpnut;
use CURLFile;
/**
* phpnut.php
* pnut.io PHP library
@ -101,14 +99,10 @@ class phpnut
// if processing stream_markers or any fast stream, decrease $sleepFor
public $streamingSleepFor = 20000;
private $_clientId;
private $_clientSecret;
/**
* Constructs an phpnut PHP object with the specified client ID and
* client secret.
* @param string $client_id_or_token The client ID you received from pnut.io when
* @param string $client_id The client ID you received from pnut.io when
* creating your app.
* @param string $client_secret The client secret you received from
* pnut.io when creating your app.
@ -161,14 +155,14 @@ class phpnut
* 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.
* Also can be called after authentication for additional scopes
* @param string $callback_uri Where you want the user to be directed
* @param string $callbackUri Where you want the user to be directed
* after authenticating with pnut.io. This must be one of the URIs
* allowed by your pnut.io application settings.
* @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
* access to the user's basic profile (the default).
*/
public function getAuthUrl(?string $callback_uri=null, array $scope=null): string
public function getAuthUrl(?string $callback_uri=null, array|string|null $scope=null): string
{
if (empty($this->_clientId)) {
throw new phpnutException('You must specify your pnut client ID');
@ -262,10 +256,8 @@ class phpnut
/**
* Check the scope of current token to see if it has required scopes
* has to be done after a check
*
* @return int|array
*/
public function checkScopes(array $app_scopes)
public function checkScopes(array $app_scopes): int|array
{
if (count($this->_scopes) === 0) {
return -1; // _scope is empty
@ -458,10 +450,8 @@ class phpnut
/**
* Internal function to handle all
* HTTP requests (POST,PUT,GET,DELETE)
*
* @param string|array $params
*/
protected function httpReq(string $act, string $req, $params = [], string $contentType='application/x-www-form-urlencoded')
protected function httpReq(string $act, string $req, string|array $params=[], string $contentType='application/x-www-form-urlencoded')
{
$ch = curl_init($req);
$headers = [];
@ -748,7 +738,7 @@ class phpnut
* Delete a Post. The current user must be the same user who created the Post.
* It returns the deleted Post on success.
* @param integer $post_id The ID of the post to delete
* @return array An associative array representing the post that was deleted
* @param array An associative array representing the post that was deleted
*/
public function deletePost(int $post_id)
{
@ -762,7 +752,7 @@ class phpnut
* 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 array $params An associative array of optional general parameters.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function getPostThread(int $post_id, array $params=[])
{
@ -777,7 +767,7 @@ class phpnut
* 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 array $params An associative array of optional general parameters.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function getPostRevisions(int $post_id, array $params=[])
{
@ -791,13 +781,13 @@ class phpnut
/**
* Get the most recent Posts created by a specific User in reverse
* chronological order (most recent first).
* @param string|int $user_id $user_id Either the ID of the user you wish to retrieve posts by,
* @param mixed $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
* as.
* @param array $params An associative array of optional general parameters.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function getUserPosts($user_id = 'me', array $params=[])
public function getUserPosts(string|int $user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -809,13 +799,13 @@ class phpnut
/**
* Get the most recent Posts mentioning by a specific User in reverse
* chronological order (newest first).
* @param string|int $user_id Either the ID of the user who is being mentioned, or
* @param mixed $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
* as.
* @param array $params An associative array of optional general parameters.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function getUserMentions($user_id='me', array $params=[])
public function getUserMentions(string|int $user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -827,7 +817,7 @@ class phpnut
/**
* Get the currently authenticated user's recent messages
* @param array $params An associative array of optional general parameters.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function getUserMessages(array $params=[])
{
@ -842,7 +832,7 @@ class phpnut
* Return the 20 most recent posts from the current User and
* the Users they follow.
* @param array $params An associative array of optional general parameters.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function getUserStream(array $params=[])
{
@ -857,7 +847,7 @@ class phpnut
* Retrieve a list of all public Posts on pnut.io, often referred to as the
* global stream.
* @param array $params An associative array of optional general parameters.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function getPublicPosts(array $params=[])
{
@ -870,7 +860,7 @@ class phpnut
/**
* Retrieve a list of "explore" streams
* @return array An array of associative arrays, each representing a single explore stream.
* @return An array of associative arrays, each representing a single explore stream.
*/
public function getPostExploreStreams()
{
@ -884,7 +874,7 @@ class phpnut
* Retrieve a list of posts from an "explore" stream on pnut.io.
* @param string $slug [<description>]
* @param array $params An associative array of optional general parameters.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function getPostExploreStream(string $slug, array $params=[])
{
@ -926,11 +916,10 @@ class phpnut
* are: count, before_id, since_id, include_muted, include_deleted,
* and include_post_raw.
* 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
* user who has bookmarked a post
*/
public function getBookmarked($user_id='me', array $params=[])
public function getBookmarked(string|int $user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -978,7 +967,7 @@ class phpnut
/**
* Repost an existing Post object.
* @param integer $post_id The id of the post
* @return mixed the reposted post
* @return the reposted post
*/
public function repost(int $post_id)
{
@ -991,7 +980,7 @@ class phpnut
/**
* Delete a post that the user has reposted.
* @param integer $post_id The id of the post
* @return mixed the un-reposted post
* @return the un-reposted post
*/
public function deleteRepost(int $post_id)
{
@ -1008,7 +997,7 @@ class phpnut
* This will likely change as the API evolves, as of this writing allowed keys
* are: count, before_id, since_id, include_muted, include_deleted,
* include_directed_posts, and include_raw.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function searchHashtags(string $hashtag, array $params=[])
{
@ -1055,7 +1044,7 @@ class phpnut
* This will likely change as the API evolves, as of this writing allowed keys
* are: count, before_id, since_id, include_muted, include_deleted,
* and include_post_raw.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function getUserPersonalStream(array $params=[])
{
@ -1082,7 +1071,7 @@ class phpnut
* This will likely change as the API evolves, as of this writing allowed keys
* are: count, before_id, since_id, include_muted, include_deleted,
* include_directed_posts, and include_raw.
* @return array An array of associative arrays, each representing a single post.
* @return An array of associative arrays, each representing a single post.
*/
public function getUserUnifiedStream(array $params=[])
{
@ -1107,14 +1096,14 @@ class phpnut
/**
* Returns a specific user object.
* @param string|int $user_id The ID of the user you want to retrieve, or the string "@-username", or the string
* @param mixed $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.
* @param array $params An associative array of optional general parameters.
* This will likely change as the API evolves, as of this writing allowed keys
* are: include_raw|include_user_raw.
* @return array An associative array representing the user data.
*/
public function getUser($user_id='me', array $params=[])
public function getUser(string|int $user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -1142,10 +1131,10 @@ class phpnut
/**
* Add the specified user ID to the list of users followed.
* Returns the User object of the user being followed.
* @param string|int $user_id The user ID of the user to follow.
* @param integer $user_id The user ID of the user to follow.
* @return array An associative array representing the user you just followed.
*/
public function followUser($user_id)
public function followUser(string|int $user_id)
{
return $this->httpReq(
'put',
@ -1156,10 +1145,10 @@ class phpnut
/**
* Removes the specified user ID to the list of users followed.
* Returns the User object of the user being unfollowed.
* @param string|int $user_id The user ID of the user to unfollow.
* @param integer $user_id The user ID of the user to unfollow.
* @return array An associative array representing the user you just unfollowed.
*/
public function unfollowUser($user_id)
public function unfollowUser(string|int $user_id)
{
return $this->httpReq(
'delete',
@ -1169,13 +1158,13 @@ class phpnut
/**
* Returns an array of User objects the specified user is following.
* @param string|int $user_id Either the ID of the user being followed, or
* @param mixed $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array An array of associative arrays, each representing a single
* user following $user_id
*/
public function getFollowing($user_id='me', array $params=[])
public function getFollowing(string|int $user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -1186,12 +1175,12 @@ class phpnut
/**
* Returns an array of User ids the specified user is following.
* @param string|int $user_id Either the ID of the user being followed, or
* @param mixed $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array user ids the specified user is following.
*/
public function getFollowingIDs($user_id='me')
public function getFollowingIDs(string|int $user_id='me')
{
return $this->httpReq(
'get',
@ -1201,13 +1190,13 @@ class phpnut
/**
* Returns an array of User objects for users following the specified user.
* @param string|int $user_id Either the ID of the user being followed, or
* @param mixed $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array An array of associative arrays, each representing a single
* user following $user_id
*/
public function getFollowers($user_id='me', array $params=[])
public function getFollowers(string|int $user_id='me', array $params=[])
{
return $this->httpReq(
'get',
@ -1218,12 +1207,12 @@ class phpnut
/**
* Returns an array of User ids for users following the specified user.
* @param string|int $user_id Either the ID of the user being followed, or
* @param mixed $user_id Either the ID of the user being followed, or
* the string "me", which will retrieve posts for the user you're authenticated
* as.
* @return array user ids for users following the specified user
*/
public function getFollowersIDs($user_id='me')
public function getFollowersIDs(string|int $user_id='me')
{
return $this->httpReq(
'get',
@ -1247,9 +1236,9 @@ class phpnut
/**
* Mute a user
* @param string|int $user_id The user ID to mute
* @param integer $user_id The user ID to mute
*/
public function muteUser($user_id)
public function muteUser(string|int $user_id)
{
return $this->httpReq(
'put',
@ -1259,9 +1248,9 @@ class phpnut
/**
* Unmute a user
* @param string|int $user_id The user ID to unmute
* @param integer $user_id The user ID to unmute
*/
public function unmuteUser($user_id)
public function unmuteUser(string|int $user_id)
{
return $this->httpReq(
'delete',
@ -1296,10 +1285,10 @@ class phpnut
/**
* List the users who match a specific search term
* @param string $query The search query. Supports @username or #tag searches as
* @param string $search The search query. Supports @username or #tag searches as
* well as normal search terms. Searches username, display name, bio information.
* Does not search posts.
* @return array|false An array of associative arrays, each representing one user.
* @return array An array of associative arrays, each representing one user.
*/
public function searchUsers(array $params=[], string $query='')
{
@ -1339,14 +1328,12 @@ class phpnut
*/
protected function updateUserImage(string $image, string $which='avatar')
{
$mimeType = '';
$test = @getimagesize($image);
if ($test && array_key_exists('mime', $test)) {
$mimeType = $test['mime'];
}
$data = [
$which => new CURLFile($image, $mimeType)
$which => new CurlFile($image, $mimeType)
];
return $this->httpReq(
'post-raw',
@ -1458,10 +1445,10 @@ class phpnut
/**
* get an existing private message channel between multiple users
* @param string|array $users Can be a comma- or space-separated string, or an array.
* @param mixed $users Can be a comma- or space-separated string, or an array.
* Usernames with @-symbol, or user ids.
*/
public function getExistingPM($users, array $params=[])
public function getExistingPM(string|array $users, array $params=[])
{
if (is_string($users)) {
$users = explode(',', str_replace(' ', ',', $users));
@ -1574,7 +1561,7 @@ class phpnut
/**
* Retrieve a list of "explore" streams
* @return array An array of associative arrays, each representing a single explore stream.
* @return An array of associative arrays, each representing a single explore stream.
*/
public function getChannelExploreStreams()
{
@ -1588,7 +1575,7 @@ class phpnut
* Retrieve a list of channels from an "explore" stream on pnut.io.
* @param string $slug [<description>]
* @param array $params An associative array of optional general parameters.
* @return array An array of associative arrays, each representing a single channel.
* @return An array of associative arrays, each representing a single channel.
*/
public function getChannelExploreStream(string $slug, array $params=[])
{
@ -1698,11 +1685,11 @@ class phpnut
/**
* create message
* @param string|int $channelid numeric or "pm" for auto-channel (type=io.pnut.core.pm)
* @param $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 $params query parameters
*/
public function createMessage($channelid, array $data, array $params=[])
public function createMessage(string|int $channelid, array $data, array $params=[])
{
if (isset($data['destinations'])) {
if (is_string($data['destinations'])) {
@ -1815,16 +1802,16 @@ class phpnut
public function createFile($file, array $data, array $params=[])
{
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)) {
throw new phpnutException('File path specified does not exist');
throw new PhpnutException('File path specified does not exist');
}
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']) {
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)) {
$data['name'] = basename($file);
@ -1836,7 +1823,7 @@ class phpnut
$mimeType = null;
}
if (!array_key_exists('kind', $data)) {
$test = @getimagesize($file);
$test = @getimagesize($path);
if ($test && array_key_exists('mime', $test)) {
$data['kind'] = 'image';
if (!$mimeType) {
@ -1853,7 +1840,7 @@ class phpnut
finfo_close($finfo);
}
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);
return $this->httpReq(
@ -2023,7 +2010,7 @@ class phpnut
/**
* Responds to a poll.
* @param integer $poll_id The ID of the poll to respond to
* @param array $positions list of positions for the poll response
* @param array list of positions for the poll response
* @param array $params An associative array of optional general parameters.
*/
public function respondToPoll(int $poll_id, array $positions, array $params=[])
@ -2098,6 +2085,8 @@ class phpnut
* List the polls that match a specific search term
* @param array $params a list of filter, search query, and general Poll parameters
* 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.
* or false on error
*/
@ -2177,12 +2166,14 @@ class phpnut
);
}
/**
* 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
* will receive a single parameter, which is the object wrapper containing
* the meta and data.
* @param mixed $function A PHP callback (either a string containing the function name,
* @param mixed A PHP callback (either a string containing the function name,
* or an array where the first element is the class/object and the second
* is the method).
*/
@ -2243,6 +2234,7 @@ class phpnut
/**
* Close the currently open stream.
* @return true;
*/
public function closeStream(): void
{
@ -2455,7 +2447,7 @@ class phpnut
* 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
* consume the stream without other actions, you can call processForever() instead.
* @param null|float $microseconds The number of microseconds to process for before
* @param float @microseconds The number of microseconds to process for before
* returning. There are 1,000,000 microseconds in a second.
*
* @return void

View file

@ -14,6 +14,7 @@ use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Plaintext;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
@ -75,7 +76,7 @@ function pnut_connect()
try {
$token = $nut->getAccessToken($callback_url);
DI::logger()->debug('Got Token', [$token]);
Logger::debug('Got Token', [$token]);
$o = DI::l10n()->t('You are now authenticated with pnut.io.');
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pnut', 'access_token', $token);
} catch (phpnutException $e) {
@ -89,7 +90,7 @@ function pnut_connect()
function pnut_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('pnut'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('pnut'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function pnut_addon_admin(string &$o)
@ -265,8 +266,8 @@ function pnut_post_hook(array &$b)
return;
}
DI::logger()->notice('PNUT post invoked', ['id' => $b['id'], 'guid' => $b['guid'], 'plink' => $b['plink']]);
DI::logger()->debug('PNUT array', $b);
Logger::notice('PNUT post invoked', ['id' => $b['id'], 'guid' => $b['guid'], 'plink' => $b['plink']]);
Logger::debug('PNUT array', $b);
$token = DI::pConfig()->get($b['uid'], 'pnut', 'access_token');
$nut = new phpnut\phpnut($token);
@ -275,7 +276,7 @@ function pnut_post_hook(array &$b)
$text = $msgarr['text'];
$raw = [];
DI::logger()->debug('PNUT msgarr', $msgarr);
Logger::debug('PNUT msgarr', $msgarr);
if (count($msgarr['parts']) > 1) {
$tstamp = time();
@ -291,23 +292,23 @@ function pnut_post_hook(array &$b)
if ($msgarr['type'] == 'photo') {
$fileraw = ['type' => 'dev.mcmillian.friendica.image', 'kind' => 'image', 'is_public' => true];
foreach ($msgarr['images'] as $image) {
DI::logger()->debug('PNUT image', $image);
Logger::debug('PNUT image', $image);
if (!empty($image['id'])) {
$photo = Photo::selectFirst([], ['id' => $image['id']]);
DI::logger()->debug('PNUT selectFirst');
Logger::debug('PNUT selectFirst');
} else {
$photo = Photo::createPhotoForExternalResource($image['url']);
DI::logger()->debug('PNUT createPhotoForExternalResource');
Logger::debug('PNUT createPhotoForExternalResource');
}
$picturedata = Photo::getImageForPhoto($photo);
DI::logger()->debug('PNUT photo', $photo);
Logger::debug('PNUT photo', $photo);
$picurefile = tempnam(System::getTempPath(), 'pnut');
file_put_contents($picurefile, $picturedata);
DI::logger()->debug('PNUT got file?', ['filename' => $picurefile]);
Logger::debug('PNUT got file?', ['filename' => $picurefile]);
$imagefile = $nut->createFile($picurefile, $fileraw);
DI::logger()->debug('PNUT file', ['pnutimagefile' => $imagefile]);
Logger::debug('PNUT file', ['pnutimagefile' => $imagefile]);
unlink($picurefile);
$raw['io.pnut.core.oembed'][] = ['+io.pnut.core.file' => ['file_id' => $imagefile['id'], 'file_token' => $imagefile['file_token'], 'format' => 'oembed']];
@ -317,5 +318,5 @@ function pnut_post_hook(array &$b)
$raw['io.pnut.core.crosspost'][] = ['canonical_url' => $b['plink']];
$nut->createPost($text, ['raw' => $raw]);
DI::logger()->debug('PNUT post complete', ['id' => $b['id'], 'text' => $text, 'raw' => $raw]);
Logger::debug('PNUT post complete', ['id' => $b['id'], 'text' => $text, 'raw' => $raw]);
}

View file

@ -6,8 +6,10 @@
* Author: Keith Fernie <http://friendika.me4.it/profile/keith>
*/
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -27,7 +29,7 @@ function public_server_install()
function public_server_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('public_server'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('public_server'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function public_server_register_account($b)
@ -46,7 +48,7 @@ function public_server_register_account($b)
function public_server_cron($b)
{
DI::logger()->notice("public_server: cron start");
Logger::notice("public_server: cron start");
$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]);
@ -95,7 +97,7 @@ function public_server_cron($b)
}
}
DI::logger()->notice("public_server: cron end");
Logger::notice("public_server: cron end");
}
function public_server_enotify(array &$b)

View file

@ -109,11 +109,9 @@ class http_class
var $connected_port = -1;
var $connected_ssl = 0;
private $content_length_set;
/* Private methods - DO NOT CALL */
private function Tokenize($string,$separator="")
Function Tokenize($string,$separator="")
{
if(!strcmp($separator,""))
{
@ -137,18 +135,18 @@ class http_class
}
}
private function CookieEncode($value, $name)
Function CookieEncode($value, $name)
{
return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value));
}
private function SetError($error, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
Function SetError($error, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
{
$this->error_code = $error_code;
return($this->error=$error);
}
private function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
Function SetPHPError($error, &$php_error_message, $error_code = HTTP_CLIENT_ERROR_UNSPECIFIED_ERROR)
{
if(IsSet($php_error_message)
&& strlen($php_error_message))
@ -156,7 +154,7 @@ class http_class
return($this->SetError($error, $error_code));
}
private function SetDataAccessError($error,$check_connection=0)
Function SetDataAccessError($error,$check_connection=0)
{
$this->error=$error;
$this->error_code = HTTP_CLIENT_ERROR_COMMUNICATION_FAILURE;
@ -176,7 +174,7 @@ class http_class
}
}
private function OutputDebug($message)
Function OutputDebug($message)
{
if($this->log_debug)
error_log($message);
@ -190,7 +188,7 @@ class http_class
}
}
private function GetLine()
Function GetLine()
{
for($line="";;)
{
@ -229,7 +227,7 @@ class http_class
}
}
private function PutLine($line)
Function PutLine($line)
{
if($this->debug)
$this->OutputDebug("C $line");
@ -241,7 +239,7 @@ class http_class
return(1);
}
private function PutData($data)
Function PutData($data)
{
if(strlen($data))
{
@ -256,7 +254,7 @@ class http_class
return(1);
}
private function FlushData()
Function FlushData()
{
if(!fflush($this->connection))
{
@ -266,7 +264,7 @@ class http_class
return(1);
}
private function ReadChunkSize()
Function ReadChunkSize()
{
if($this->remaining_chunk==0)
{
@ -291,7 +289,7 @@ class http_class
return("");
}
private function ReadBytes($length)
Function ReadBytes($length)
{
if($this->use_curl)
{
@ -358,7 +356,7 @@ class http_class
return($bytes);
}
private function EndOfInput()
Function EndOfInput()
{
if($this->use_curl)
return($this->read_response>=strlen($this->response));
@ -369,7 +367,7 @@ class http_class
return(feof($this->connection));
}
private function Resolve($domain, &$ip, $server_type)
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))
$ip=$domain;
@ -387,7 +385,7 @@ class http_class
return('');
}
private function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP')
Function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP')
{
$domain=$host_name;
$port = $host_port;
@ -554,7 +552,7 @@ class http_class
}
}
private function Disconnect()
Function Disconnect()
{
if($this->debug)
$this->OutputDebug("Disconnected from ".$this->connected_host);
@ -571,7 +569,7 @@ class http_class
/* Public methods */
public function GetRequestArguments($url, &$arguments)
Function GetRequestArguments($url, &$arguments)
{
$this->error = '';
$this->error_code = HTTP_CLIENT_ERROR_NO_ERROR;
@ -623,7 +621,7 @@ class http_class
return("");
}
public function Open($arguments)
Function Open($arguments)
{
if(strlen($this->error))
return($this->error);
@ -752,7 +750,7 @@ class http_class
return("");
}
public function Close($force = 0)
Function Close($force = 0)
{
if($this->state=="Disconnected")
return("1 already disconnected");
@ -769,7 +767,7 @@ class http_class
return($this->Disconnect());
}
private function PickCookies(&$cookies,$secure)
Function PickCookies(&$cookies,$secure)
{
if(IsSet($this->cookies[$secure]))
{
@ -805,7 +803,7 @@ class http_class
}
}
private function GetFileDefinition($file, &$definition)
Function GetFileDefinition($file, &$definition)
{
$name="";
if(IsSet($file["FileName"]))
@ -992,6 +990,9 @@ class http_class
if(GetType($length=@filesize($file["FileName"]))!="integer")
{
$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"]))
$error="it was not possible to access the file ".$file["FileName"];
return($error);
@ -1006,7 +1007,7 @@ class http_class
return("");
}
private function ConnectFromProxy($arguments, &$headers)
Function ConnectFromProxy($arguments, &$headers)
{
if(!$this->PutLine('CONNECT '.$this->host_name.':'.($this->host_port ? $this->host_port : 443).' HTTP/1.0')
|| (strlen($this->user_agent)
@ -1051,7 +1052,7 @@ class http_class
return("");
}
public function SendRequest($arguments)
Function SendRequest($arguments)
{
if(strlen($this->error))
return($this->error);
@ -1439,7 +1440,7 @@ class http_class
return("");
}
private function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0)
Function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0)
{
if(strlen($this->error))
return($this->error);
@ -1471,7 +1472,7 @@ class http_class
return("");
}
private function SendRequestBody($data, $end_of_data)
Function SendRequestBody($data, $end_of_data)
{
if(strlen($this->error))
return($this->error);
@ -1507,7 +1508,7 @@ class http_class
return("");
}
private function ReadReplyHeadersResponse(&$headers)
Function ReadReplyHeadersResponse(&$headers)
{
$headers=array();
if(strlen($this->error))
@ -1634,7 +1635,7 @@ class http_class
return("");
}
private function Redirect(&$headers)
Function Redirect(&$headers)
{
if($this->follow_redirect)
{
@ -1677,7 +1678,7 @@ class http_class
return("");
}
private function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation)
Function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation)
{
if($proxy)
{
@ -1696,10 +1697,9 @@ class http_class
if(IsSet($headers[$authenticate_header])
&& $this->sasl_authenticate)
{
if(!class_exists('sasl_client_class'))
{
if(function_exists("class_exists")
&& !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));
}
if(GetType($headers[$authenticate_header])=="array")
$authenticate=$headers[$authenticate_header];
else
@ -1719,7 +1719,7 @@ class http_class
else
$mechanisms[]=$mechanism;
}
$sasl=new \sasl_client_class();
$sasl=new sasl_client_class;
if(IsSet($user))
$sasl->SetCredential("user",$user);
if(IsSet($password))
@ -1731,8 +1731,6 @@ class http_class
$sasl->SetCredential("uri",$this->request_uri);
$sasl->SetCredential("method",$this->request_method);
$sasl->SetCredential("session",$this->session);
$message = '';
$interactions = [];
do
{
$status=$sasl->Start($mechanisms,$message,$interactions);
@ -1909,7 +1907,7 @@ class http_class
return("");
}
public function ReadReplyHeaders(&$headers)
Function ReadReplyHeaders(&$headers)
{
if(strlen($error=$this->ReadReplyHeadersResponse($headers)))
return($error);
@ -1940,7 +1938,7 @@ class http_class
return("");
}
private function ReadReplyBody(&$body,$length)
Function ReadReplyBody(&$body,$length)
{
$body="";
if(strlen($this->error))
@ -1982,7 +1980,7 @@ class http_class
return("");
}
public function ReadWholeReplyBody(&$body)
Function ReadWholeReplyBody(&$body)
{
$body = '';
for(;;)
@ -1995,7 +1993,7 @@ class http_class
}
}
private function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0)
Function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0)
{
$now=gmdate("Y-m-d H-i-s");
$cookies=array();
@ -2036,17 +2034,17 @@ class http_class
}
}
private function SavePersistentCookies(&$cookies, $domain='', $secure_only=0)
Function SavePersistentCookies(&$cookies, $domain='', $secure_only=0)
{
$this->SaveCookies($cookies, $domain, $secure_only, 1);
}
private function GetPersistentCookies(&$cookies, $domain='', $secure_only=0)
Function GetPersistentCookies(&$cookies, $domain='', $secure_only=0)
{
$this->SavePersistentCookies($cookies, $domain, $secure_only);
}
private function RestoreCookies($cookies, $clear=1)
Function RestoreCookies($cookies, $clear=1)
{
$new_cookies=($clear ? array() : $this->cookies);
for($secure_cookies=0, Reset($cookies); $secure_cookies<count($cookies); Next($cookies), $secure_cookies++)

View file

@ -6,10 +6,12 @@
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
*/
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Addon;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Worker;
@ -106,7 +108,7 @@ function pumpio_registerclient($host)
$params['logo_url'] = DI::baseUrl() . '/images/friendica-256.png';
$params['redirect_uris'] = DI::baseUrl() . '/pumpio/connect';
DI::logger()->info('pumpio_registerclient: ' . $url . ' parameters', $params);
Logger::info('pumpio_registerclient: ' . $url . ' parameters', $params);
// @TODO Rewrite this to our own HTTP client
$ch = curl_init($url);
@ -121,10 +123,10 @@ function pumpio_registerclient($host)
if ($curl_info['http_code'] == '200') {
$values = json_decode($s);
DI::logger()->info('pumpio_registerclient: success ', (array)$values);
Logger::info('pumpio_registerclient: success ', (array)$values);
return $values;
}
DI::logger()->info('pumpio_registerclient: failed: ', $curl_info);
Logger::info('pumpio_registerclient: failed: ', $curl_info);
return false;
}
@ -137,7 +139,7 @@ function pumpio_connect()
$hostname = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'host');
if ((($consumer_key == '') || ($consumer_secret == '')) && ($hostname != '')) {
DI::logger()->notice('pumpio_connect: register client');
Logger::notice('pumpio_connect: register client');
$clientdata = pumpio_registerclient($hostname);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key', $clientdata->client_id);
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret', $clientdata->client_secret);
@ -145,11 +147,11 @@ function pumpio_connect()
$consumer_key = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_key');
$consumer_secret = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'pumpio', 'consumer_secret');
DI::logger()->info('pumpio_connect: ckey: ' . $consumer_key . ' csecrect: ' . $consumer_secret);
Logger::info('pumpio_connect: ckey: ' . $consumer_key . ' csecrect: ' . $consumer_secret);
}
if (($consumer_key == '') || ($consumer_secret == '')) {
DI::logger()->notice('pumpio_connect: '.sprintf('Unable to register the client at the pump.io server "%s".', $hostname));
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);
}
@ -178,7 +180,7 @@ function pumpio_connect()
if (($success = $client->Initialize())) {
if (($success = $client->Process())) {
if (strlen($client->access_token)) {
DI::logger()->info('pumpio_connect: otoken: ' . $client->access_token . ', osecrect: ' . $client->access_token_secret);
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_secret', $client->access_token_secret);
}
@ -190,11 +192,11 @@ function pumpio_connect()
}
if ($success) {
DI::logger()->notice('pumpio_connect: authenticated');
Logger::notice('pumpio_connect: authenticated');
$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>';
} else {
DI::logger()->notice('pumpio_connect: could not connect');
Logger::notice('pumpio_connect: could not connect');
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
}
@ -318,7 +320,7 @@ function pumpio_settings_post(array &$b)
function pumpio_load_config(ConfigFileManager $loader)
{
DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('pumpio'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
DI::app()->getConfigCache()->load($loader->loadAddonConfig('pumpio'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC);
}
function pumpio_hook_fork(array &$b)
@ -344,7 +346,7 @@ function pumpio_hook_fork(array &$b)
if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) {
// 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])) {
DI::logger()->notice('No pump.io parent found for item ' . $post['id']);
Logger::notice('No pump.io parent found for item ' . $post['id']);
$b['execute'] = false;
return;
}
@ -388,7 +390,7 @@ function pumpio_send(array &$b)
return;
}
DI::logger()->debug('pumpio_send: parameter ', $b);
Logger::debug('pumpio_send: parameter ', $b);
$b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b));
@ -398,7 +400,7 @@ function pumpio_send(array &$b)
$orig_post = Post::selectFirst([], $condition);
if (!DBA::isResult($orig_post)) {
DI::logger()->notice('pumpio_send: no pumpio post ' . $b['parent']);
Logger::notice('pumpio_send: no pumpio post ' . $b['parent']);
return;
} else {
$iscomment = true;
@ -408,7 +410,7 @@ function pumpio_send(array &$b)
$receiver = pumpio_getreceiver($b);
DI::logger()->notice('pumpio_send: receiver ', $receiver);
Logger::notice('pumpio_send: receiver ', $receiver);
if (!count($receiver) && ($b['private'] == Item::PRIVATE) || !strstr($b['postopts'], 'pumpio')) {
return;
@ -542,13 +544,13 @@ function pumpio_send(array &$b)
}
$post_id = $user->object->id;
DI::logger()->notice('pumpio_send ' . $username . ': success ' . $post_id);
Logger::notice('pumpio_send ' . $username . ': success ' . $post_id);
if ($post_id && $iscomment) {
DI::logger()->notice('pumpio_send ' . $username . ': Update extid ' . $post_id . ' for post id ' . $b['id']);
Logger::notice('pumpio_send ' . $username . ': Update extid ' . $post_id . ' for post id ' . $b['id']);
Item::update(['extid' => $post_id], ['id' => $b['id']]);
}
} else {
DI::logger()->notice('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
Logger::notice('pumpio_send '.$username.': '.$url.' general error: ' . print_r($user, true));
Worker::defer();
}
}
@ -580,8 +582,6 @@ function pumpio_action(int $uid, string $uri, string $action, string $content =
$uri = $orig_post['uri'];
}
$objectType = '';
if (($orig_post['object-type'] != '') && (strstr($orig_post['object-type'], ActivityNamespace::ACTIVITY_SCHEMA))) {
$objectType = str_replace(ActivityNamespace::ACTIVITY_SCHEMA, '', $orig_post['object-type']);
} elseif (strstr($uri, '/api/comment/')) {
@ -618,9 +618,9 @@ function pumpio_action(int $uid, string $uri, string $action, string $content =
}
if ($success) {
DI::logger()->notice('pumpio_action '.$username.' '.$action.': success '.$uri);
Logger::notice('pumpio_action '.$username.' '.$action.': success '.$uri);
} else {
DI::logger()->notice('pumpio_action '.$username.' '.$action.': general error: '.$uri);
Logger::notice('pumpio_action '.$username.' '.$action.': general error: '.$uri);
Worker::defer();
}
}
@ -638,15 +638,15 @@ function pumpio_sync()
if ($last) {
$next = $last + ($poll_interval * 60);
if ($next > time()) {
DI::logger()->notice('pumpio: poll intervall not reached');
Logger::notice('pumpio: poll intervall not reached');
return;
}
}
DI::logger()->notice('pumpio: cron_start');
Logger::notice('pumpio: cron_start');
$pconfigs = DBA::selectToArray('pconfig', ['uid'], ['cat' => 'pumpio', 'k' => 'mirror', 'v' => '1']);
foreach ($pconfigs as $rr) {
DI::logger()->notice('pumpio: mirroring user '.$rr['uid']);
Logger::notice('pumpio: mirroring user '.$rr['uid']);
pumpio_fetchtimeline($rr['uid']);
}
@ -661,12 +661,12 @@ function pumpio_sync()
foreach ($pconfigs as $rr) {
if ($abandon_days != 0) {
if (DBA::exists('user', ["uid = ? AND `login_date` >= ?", $rr['uid'], $abandon_limit])) {
DI::logger()->notice('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
Logger::notice('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
continue;
}
}
DI::logger()->notice('pumpio: importing timeline from user '.$rr['uid']);
Logger::notice('pumpio: importing timeline from user '.$rr['uid']);
pumpio_fetchinbox($rr['uid']);
// check for new contacts once a day
@ -683,7 +683,7 @@ function pumpio_sync()
}
}
DI::logger()->notice('pumpio: cron_end');
Logger::notice('pumpio: cron_end');
DI::keyValue()->set('pumpio_last_poll', time());
}
@ -728,7 +728,7 @@ function pumpio_fetchtimeline(int $uid)
$url = 'https://'.$hostname.'/api/user/'.$username.'/feed/major';
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);
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;
@ -740,7 +740,7 @@ function pumpio_fetchtimeline(int $uid)
}
if (!$success) {
DI::logger()->notice('pumpio: error fetching posts for user ' . $uid . ' ' . $useraddr . ' ', $user);
Logger::notice('pumpio: error fetching posts for user ' . $uid . ' ' . $useraddr . ' ', $user);
return;
}
@ -800,11 +800,11 @@ function pumpio_fetchtimeline(int $uid)
}
}
DI::logger()->notice('pumpio: posting for user ' . $uid);
Logger::notice('pumpio: posting for user ' . $uid);
Item::insert($postarray, true);
DI::logger()->notice('pumpio: posting done - user ' . $uid);
Logger::notice('pumpio: posting done - user ' . $uid);
}
}
}
@ -827,7 +827,6 @@ function pumpio_dounlike(int $uid, array $self, $post, string $own_id)
}
$contactid = 0;
$contact = [];
if (Strings::compareLink($post->actor->url, $own_id)) {
$contactid = $self['id'];
@ -845,16 +844,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']]);
if (DBA::isResult($contact)) {
DI::logger()->notice('pumpio_dounlike: unliked existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
Logger::notice('pumpio_dounlike: unliked existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
} else {
DI::logger()->notice('pumpio_dounlike: not found. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' Url ' . $orig_post['uri']);
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)
{
if (empty($post->object->id)) {
DI::logger()->info('Got empty like: '.print_r($post, true));
Logger::info('Got empty like: '.print_r($post, true));
return;
}
@ -899,7 +898,7 @@ function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcomp
];
if (Post::exists($condition)) {
DI::logger()->notice('pumpio_dolike: found existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
Logger::notice('pumpio_dolike: found existing like. User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
return;
}
@ -933,7 +932,7 @@ function pumpio_dolike(int $uid, array $self, $post, string $own_id, $threadcomp
$ret = Item::insert($likedata);
DI::logger()->notice('pumpio_dolike: ' . $ret . ' User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
Logger::notice('pumpio_dolike: ' . $ret . ' User ' . $own_id . ' ' . $uid . ' Contact: ' . $contactid . ' URI ' . $orig_post['uri']);
}
function pumpio_get_contact($uid, $contact, $no_insert = false)
@ -1404,7 +1403,7 @@ function pumpio_fetchallcomments($uid, $id)
$hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
$username = DI::pConfig()->get($uid, 'pumpio', 'user');
DI::logger()->notice('pumpio_fetchallcomments: completing comment for user ' . $uid . ' post id ' . $id);
Logger::notice('pumpio_fetchallcomments: completing comment for user ' . $uid . ' post id ' . $id);
$own_id = 'https://' . $hostname . '/' . $username;
@ -1429,9 +1428,7 @@ function pumpio_fetchallcomments($uid, $id)
$client->access_token = $otoken;
$client->access_token_secret = $osecret;
DI::logger()->notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url);
$item = new \stdClass();
Logger::notice('pumpio_fetchallcomments: fetching comment for user ' . $uid . ', URL ' . $url);
if (pumpio_reachable($url)) {
$success = $client->CallAPI($url, 'GET', [], ['FailOnAccessError' => true], $item);
@ -1494,7 +1491,7 @@ function pumpio_fetchallcomments($uid, $id)
$post->object = $item;
DI::logger()->notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', json_decode(json_encode($post), true));
Logger::notice('pumpio_fetchallcomments: posting comment ' . $post->object->id . ' ', json_decode(json_encode($post), true));
pumpio_dopost($client, $uid, $self, $post, $own_id, false);
}
}

View file

@ -1,5 +1,5 @@
<?php
use Friendica\Core\Logger;
use Friendica\DI;
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')) {
$load = sys_getloadavg();
if (intval($load[0]) > DI::config()->get('system', 'maxloadavg', 50)) {
DI::logger()->notice('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.');
Logger::notice('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.');
return;
}
}

View file

@ -18,6 +18,7 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;

View file

@ -19,7 +19,9 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\DI;
@ -39,7 +41,7 @@ function randplace_install()
Hook::register('addon_settings', 'addon/randplace/randplace.php', 'randplace_settings');
Hook::register('addon_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
DI::logger()->notice("installed randplace");
Logger::notice("installed randplace");
}
function randplace_uninstall()
@ -49,7 +51,7 @@ function randplace_uninstall()
*
* Except hooks, they are all unregistered automatically and don't need to be unregistered manually.
*/
DI::logger()->notice("removed randplace");
Logger::notice("removed randplace");
}
function randplace_post_hook(&$item)
@ -60,7 +62,7 @@ function randplace_post_hook(&$item)
* - A status post by a profile owner
* - The profile owner must have allowed our addon
*/
DI::logger()->notice('randplace invoked');
Logger::notice('randplace invoked');
if (!DI::userSession()->getLocalUserId()) {
/* non-zero if this is a logged in user of this system */

View file

@ -3,13 +3,12 @@
namespace Friendica\Addon\ratioed;
use Friendica\Content\Pager;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Model\Verb;
use Friendica\Module\Moderation\Users\Active;
use Friendica\Protocol\Activity;
/**
* This class implements the "Behaviour" panel in Moderation/Users
@ -25,17 +24,38 @@ class RatioedPanel extends Active
return Renderer::replaceMacros($template, array('$config' => DI::baseUrl() . '/settings/addon'));
}
$action = $this->parameters['action'] ?? '';
$uid = $this->parameters['uid'] ?? 0;
$user = [];
if ($uid) {
$user = User::getById($uid, ['username', 'blocked']);
if (!$user) {
$this->systemMessages->addNotice($this->t('User not found'));
$this->baseUrl->redirect('ratioed');
$this->baseUrl->redirect('moderation/users');
}
}
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);
$valid_orders = [
@ -48,9 +68,9 @@ class RatioedPanel extends Active
];
$order = 'last-item';
$order_direction = '+';
if (!empty($_REQUEST['o'])) {
$new_order = $_REQUEST['o'];
$order_direction = '-';
if (!empty($request['o'])) {
$new_order = $request['o'];
if ($new_order[0] === '-') {
$order_direction = '-';
$new_order = substr($new_order, 1);
@ -76,11 +96,6 @@ class RatioedPanel extends Active
$this->t('Comments last 24h'),
$this->t('Reactions 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 = [
'name',
@ -93,11 +108,6 @@ class RatioedPanel extends Active
'comments',
'reactions',
'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);
@ -136,130 +146,9 @@ 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
{
DI::logger()->debug("ratioed: setupUserCallback");
Logger::debug("ratioed: setupUserCallback");
$parentCallback = parent::setupUserCallback();
return function ($user) use ($parentCallback) {
$blocked_count = DBA::count('user-contact', ['uid' => $user['uid'], 'is-blocked' => 1]);
@ -269,8 +158,9 @@ FROM (
if (DBA::isResult($self_contact_result)) {
$self_contact_result_row = DBA::fetch($self_contact_result);
$user['user_contact_uid'] = $self_contact_result_row['user_contact_uid'];
} else {
$user['user_contact_uid'] = null;
}
else {
$user['user_contact_uid'] = NULL;
}
if ($user['user_contact_uid']) {
@ -282,34 +172,34 @@ FROM (
if ($user['reactions'] > 0) {
$user['ratio'] = number_format($user['comments'] / $user['reactions'], 1, '.', '');
$user['ratioed'] = (float)($user['ratio']) >= 2.0;
} else {
$user['reactions'] = 0;
}
else {
if ($user['comments'] == 0) {
$user['comments'] = 0;
$user['ratio'] = 0;
$user['ratio'] = '0';
$user['ratioed'] = false;
} else {
}
else {
$user['ratio'] = '∞';
$user['ratioed'] = false;
}
}
} else {
}
else {
$user['comments'] = 'error';
$user['reactions'] = 'error';
$user['ratio'] = 'error';
$user['ratioed'] = false;
}
} else {
}
else {
$user['comments'] = 'error';
$user['reactions'] = 'error';
$user['ratio'] = 'error';
$user['ratioed'] = false;
}
$this->fillReplyGuyData($user);
$user = $parentCallback($user);
DI::logger()->debug("ratioed: setupUserCallback", [
Logger::debug("ratioed: setupUserCallback", [
'uid' => $user['uid'],
'blocked_by' => $user['blocked_by'],
'comments' => $user['comments'],

View file

@ -2,12 +2,13 @@
/**
* Name: Ratioed
* Description: Additional moderation user table with statistics about user behaviour
* Version: 0.3
* Version: 0.1
* Author: Matthew Exon <http://mat.exon.name>
*/
use Friendica\Addon\ratioed\RatioedPanel;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
/**
@ -17,7 +18,7 @@ function ratioed_install()
{
Hook::register('moderation_users_tabs', 'addon/ratioed/ratioed.php', 'ratioed_users_tabs');
DI::logger()->info("ratioed: installed");
Logger::info("ratioed: installed");
}
/**
@ -33,7 +34,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
*/
function ratioed_users_tabs(array &$arr) {
DI::logger()->debug("ratioed: users tabs");
Logger::debug("ratioed: users tabs");
array_push($arr['tabs'], [
'label' => DI::l10n()->t('Behaviour'),
@ -49,7 +50,7 @@ function ratioed_users_tabs(array &$arr) {
* @brief Displays the ratioed tab in the moderation panel
*/
function ratioed_content() {
DI::logger()->debug("ratioed: content");
Logger::debug("ratioed: content");
$ratioed = DI::getDice()->create(RatioedPanel::class, [$_SERVER]);
$httpException = DI::getDice()->create(Friendica\Module\Special\HTTPException::class);

View file

@ -2,7 +2,7 @@
<div class="panel-body">
<h2>Ratioed Plugin Help</h2>
<p>
This plugin provides moderators with additional statistics about
This plugin provides administrators with additional statistics about
the behaviour of users. These may be useful as early warning signs
that warrant more carefully watching the behaviour of a user. They
are <em>not</em> suitable as a trigger for instantly blocking,
@ -28,7 +28,7 @@
<p>
This plugin allows viewing of an actual ratio, calculated over the
last 24 hours. This is a useful timeframe for sudden dogpiling
events that moderators might not otherwise notice. The plugin
events that administrators might not otherwise notice. The plugin
also calculates other statistics.
</p>
<h3>Explanation of Statistics</h3>
@ -68,63 +68,10 @@
24h". It is intended to approximate the traditional ratio as
understood on Twitter.
</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>
<p>
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.
</p>
<h3>Extending</h3>

View file

@ -2,21 +2,26 @@
<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">
<h1>
{{$title}} - {{$page}} ({{$count}})
<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>
</h1>
<h1>{{$title}} - {{$page}} ({{$count}})</h1>
<p>
<a href="{{$base_url}}/moderation/users/create" class="btn btn-primary"><i class="fa fa-user-plus"></i> {{$h_newuser}}</a>
</p>
<form action="{{$baseurl}}/{{$query_string}}" method="post">
<input type="hidden" name="form_security_token" value="{{$form_security_token}}">
<table id="users" class="table table-hover">
<thead>
<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>
{{foreach $th_users as $k=>$th}}
{{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])) }}
{{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])) }}
<th class="th-{{$k}}">
<a href="{{$baseurl}}/ratioed?o={{if $order_direction_users == "+"}}-{{/if}}{{$th.1}}" class="table-order">
<a href="{{$baseurl}}/moderation/users/active?o={{if $order_direction_users == "+"}}-{{/if}}{{$th.1}}" class="table-order">
{{if $order_users == $th.1}}
{{if $order_direction_users == "+"}}
&#8595;
@ -36,8 +41,17 @@
</thead>
<tbody>
{{foreach $users as $u}}
<tr id="user-{{$u.uid}}" class="{{if $u.ratioed || $u.reply_guy}}blocked{{/if}}">
<td></td>
<tr id="user-{{$u.uid}}" class="{{if $u.ratioed}}blocked{{/if}}">
<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}}
&nbsp;
{{/if}}
</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>{{$u.email}}</td>
@ -49,7 +63,11 @@
<td>{{$u.login_date}}</td>
{{/if}}
{{if $order_users == $th_users.5.1}}
{{if $order_users == $th_users.4.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>
<i class="fa
{{if $u.page_flags_raw==0}}fa-user{{/if}} {{* PAGE_NORMAL *}}
@ -73,10 +91,6 @@
</td>
{{/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">
<button type="button" class="btn-link admin-settings-action-link" onclick="return details({{$u.uid}})"><span class="caret"></span></button>
</td>
@ -121,11 +135,30 @@
{{/foreach}}
</td>
<td class="text-right"></td>
<td class="text-right">
{{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}}
&nbsp;
{{/if}}
</td>
</tr>
{{/foreach}}
</tbody>
</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}}
</form>
</div>

View file

@ -7,6 +7,7 @@
*
*/
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;

View file

@ -8,6 +8,7 @@
use Friendica\Addon\s3_storage\src\S3Client;
use Friendica\Addon\s3_storage\src\S3Config;
use Friendica\App;
use Friendica\Core\Hook;
use Friendica\DI;

View file

@ -4,10 +4,10 @@ namespace Friendica\Addon\s3_storage\src;
defined('AKEEBAENGINE') or define('AKEEBAENGINE', 1);
use Akeeba\S3\Configuration;
use Akeeba\S3\Connector;
use Akeeba\S3\Exception\CannotDeleteFile;
use Akeeba\S3\Input;
use Akeeba\Engine\Postproc\Connector\S3v4\Configuration;
use Akeeba\Engine\Postproc\Connector\S3v4\Connector;
use Akeeba\Engine\Postproc\Connector\S3v4\Exception\CannotDeleteFile;
use Akeeba\Engine\Postproc\Connector\S3v4\Input;
use Friendica\Core\Storage\Capability\ICanWriteToStorage;
use Friendica\Core\Storage\Exception\StorageException;
use Friendica\Util\Strings;

View file

@ -4,8 +4,8 @@ namespace Friendica\Addon\s3_storage\src;
defined('AKEEBAENGINE') or define('AKEEBAENGINE', 1);
use Akeeba\S3\Configuration;
use Akeeba\S3\Connector;
use Akeeba\Engine\Postproc\Connector\S3v4\Configuration;
use Akeeba\Engine\Postproc\Connector\S3v4\Connector;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Storage\Capability\ICanConfigureStorage;

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-17 03:23+0100\n"
"POT-Creation-Date: 2021-05-18 07:23+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,82 +17,82 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: saml.php:81
msgid "managed via SAML authentication"
msgstr ""
#: saml.php:246
#: saml.php:231
msgid "Settings statement"
msgstr ""
#: saml.php:247
msgid "A statement on the settings page explaining where the user should go to change their e-mail and password. BBCode allowed."
#: 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:252
#: saml.php:237
msgid "IdP ID"
msgstr ""
#: saml.php:253
msgid "Identity provider (IdP) entity URI (e.g., https://example.com/auth/realms/user)."
#: saml.php:238
msgid ""
"Identity provider (IdP) entity URI (e.g., https://example.com/auth/realms/"
"user)."
msgstr ""
#: saml.php:257
#: saml.php:242
msgid "Client ID"
msgstr ""
#: saml.php:258
#: saml.php:243
msgid "Identifier assigned to client by the identity provider (IdP)."
msgstr ""
#: saml.php:262
#: saml.php:247
msgid "IdP SSO URL"
msgstr ""
#: saml.php:263
#: saml.php:248
msgid "The URL for your identity provider's SSO endpoint."
msgstr ""
#: saml.php:267
#: saml.php:252
msgid "IdP SLO request URL"
msgstr ""
#: saml.php:268
#: saml.php:253
msgid "The URL for your identity provider's SLO request endpoint."
msgstr ""
#: saml.php:272
#: saml.php:257
msgid "IdP SLO response URL"
msgstr ""
#: saml.php:273
#: saml.php:258
msgid "The URL for your identity provider's SLO response endpoint."
msgstr ""
#: saml.php:277
#: saml.php:262
msgid "SP private key"
msgstr ""
#: saml.php:278
#: saml.php:263
msgid "The private key the addon should use to authenticate."
msgstr ""
#: saml.php:282
#: saml.php:267
msgid "SP certificate"
msgstr ""
#: saml.php:283
#: saml.php:268
msgid "The certficate for the addon's private key."
msgstr ""
#: saml.php:287
#: saml.php:272
msgid "IdP certificate"
msgstr ""
#: saml.php:288
#: saml.php:273
msgid "The x509 certficate for your identity provider."
msgstr ""
#: saml.php:291
#: saml.php:276
msgid "Save Settings"
msgstr ""

1
saml/saml.css Normal file
View file

@ -0,0 +1 @@
#settings-form > div:first-of-type, #settings-form > h2:first-of-type, #wrapper_mpassword, #wrapper_email { display: none !important; }

View file

@ -8,6 +8,7 @@
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
@ -62,7 +63,7 @@ function saml_metadata()
);
}
} catch (Exception $e) {
DI::logger()->error($e->getMessage());
Logger::error($e->getMessage());
}
}
@ -74,38 +75,18 @@ function saml_install()
Hook::register('footer', __FILE__, 'saml_footer');
}
function saml_head(string &$body)
{
DI::page()->registerStylesheet(__DIR__ . '/saml.css');
}
function saml_footer(string &$body)
{
$fragment = addslashes(BBCode::convertForUriId(User::getSystemUriId(), DI::config()->get('saml', 'settings_statement')));
$samlhint = DI::l10n()->t('managed via SAML authentication');
$body .= <<<EOL
<script>
var target=$("#settings-nickname-desc");
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>
EOL;
}
@ -126,7 +107,7 @@ function saml_is_configured()
function saml_sso_initiate(string &$body)
{
if (!saml_is_configured()) {
DI::logger()->warning('SAML SSO tried to trigger, but the SAML addon is not configured yet!');
Logger::warning('SAML SSO tried to trigger, but the SAML addon is not configured yet!');
return;
}
@ -155,7 +136,7 @@ function saml_sso_reply()
if (!empty($errors)) {
echo 'Errors encountered.';
DI::logger()->error(implode(', ', $errors));
Logger::error(implode(', ', $errors));
exit();
}
@ -180,7 +161,7 @@ function saml_sso_reply()
}
if (!empty($user['uid'])) {
DI::auth()->setForUser($user);
DI::auth()->setForUser(DI::app(), $user);
}
if (isset($_POST['RelayState']) && Utils::getSelfURL() != $_POST['RelayState']) {
@ -191,7 +172,7 @@ function saml_sso_reply()
function saml_slo_initiate()
{
if (!saml_is_configured()) {
DI::logger()->warning('SAML SLO tried to trigger, but the SAML addon is not configured yet!');
Logger::warning('SAML SLO tried to trigger, but the SAML addon is not configured yet!');
return;
}
@ -222,7 +203,7 @@ function saml_slo_reply()
if (empty($errors)) {
$auth->redirectTo(DI::baseUrl());
} else {
DI::logger()->error(implode(', ', $errors));
Logger::error(implode(', ', $errors));
}
}
@ -315,7 +296,7 @@ function saml_addon_admin_post()
function saml_create_user($username, $email, $name)
{
if (!strlen($email) || !strlen($name)) {
DI::logger()->error('Could not create user: no email or username given.');
Logger::error('Could not create user: no email or username given.');
return false;
}
@ -337,7 +318,7 @@ function saml_create_user($username, $email, $name)
return $user;
} catch (Exception $e) {
DI::logger()->error(
Logger::error(
'Exception while creating user',
[
'username' => $username,

View file

@ -21,6 +21,7 @@
namespace Friendica\Addon\securemail;
use Friendica\App;
use Friendica\App\BaseURL;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;

Some files were not shown because too many files have changed in this diff Show more