diff --git a/.woodpecker/.code_standards_check.yml b/.woodpecker/.code_standards_check.yml index 60a1bd2a..50872d4c 100644 --- a/.woodpecker/.code_standards_check.yml +++ b/.woodpecker/.code_standards_check.yml @@ -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: diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index aeeff77c..418b253e 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -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() ]); diff --git a/advancedcontentfilter/src/middlewares.php b/advancedcontentfilter/src/middlewares.php new file mode 100644 index 00000000..2b831473 --- /dev/null +++ b/advancedcontentfilter/src/middlewares.php @@ -0,0 +1,32 @@ +. + * + */ + +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()); diff --git a/advancedcontentfilter/src/routes.php b/advancedcontentfilter/src/routes.php new file mode 100644 index 00000000..a46f1b4b --- /dev/null +++ b/advancedcontentfilter/src/routes.php @@ -0,0 +1,36 @@ +. + * + */ + +/* @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'); + }); +}); diff --git a/birdavatar/birdavatar.php b/birdavatar/birdavatar.php index cd49b183..4841ba52 100644 --- a/birdavatar/birdavatar.php +++ b/birdavatar/birdavatar.php @@ -6,7 +6,9 @@ * Author: Fabio */ +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'); } /** diff --git a/blackout/blackout.php b/blackout/blackout.php index ac1ee3e6..55fb8d32 100644 --- a/blackout/blackout.php +++ b/blackout/blackout.php @@ -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); } } diff --git a/blockbot/blockbot.php b/blockbot/blockbot.php index 71e35c93..022f188d 100644 --- a/blockbot/blockbot.php +++ b/blockbot/blockbot.php @@ -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(); } } @@ -442,7 +443,7 @@ function blockbot_is_monitor(array $parts): bool } /** - * Services in the centralized and decentralized social media environment + * Services in the centralized and decentralized social media environment * * @param array $parts * @return boolean diff --git a/bluesky/bluesky.php b/bluesky/bluesky.php index 7f6bb9e7..1355f000 100644 --- a/bluesky/bluesky.php +++ b/bluesky/bluesky.php @@ -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) @@ -105,16 +106,16 @@ function bluesky_item_by_link(array &$hookData) if (empty($did)) { 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 { $uri = $hookData['uri']; } $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); diff --git a/bluesky/bluesky_feed.php b/bluesky/bluesky_feed.php index e4aa3fdc..a20ef1b9 100644 --- a/bluesky/bluesky_feed.php +++ b/bluesky/bluesky_feed.php @@ -1,6 +1,6 @@ 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]]); } diff --git a/bluesky/bluesky_notifications.php b/bluesky/bluesky_notifications.php index e1bf2047..1fbc8f67 100644 --- a/bluesky/bluesky_notifications.php +++ b/bluesky/bluesky_notifications.php @@ -1,6 +1,6 @@ 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]]); } diff --git a/bluesky/bluesky_timeline.php b/bluesky/bluesky_timeline.php index 37b22d99..fda846ba 100644 --- a/bluesky/bluesky_timeline.php +++ b/bluesky/bluesky_timeline.php @@ -1,6 +1,6 @@ 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]]); } diff --git a/buglink/buglink.php b/buglink/buglink.php index b7dd6504..78fb8bef 100644 --- a/buglink/buglink.php +++ b/buglink/buglink.php @@ -6,6 +6,7 @@ * Author: Mike Macgirvin */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; diff --git a/calc/calc.php b/calc/calc.php index 76d1805c..a8a340c4 100644 --- a/calc/calc.php +++ b/calc/calc.php @@ -6,6 +6,7 @@ * Author: Mike Macgirvin */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; @@ -15,7 +16,7 @@ function calc_install() { function calc_app_menu(array &$b) { - $b['app_menu'][] = ''; + $b['app_menu'][] = ''; } /** @@ -295,7 +296,7 @@ $o .= <<< EOT

Calculator



-
+
@@ -322,7 +323,7 @@ $o .= <<< EOT - + @@ -344,13 +345,13 @@ $o .= <<< EOT - +
diff --git a/catavatar/catavatar.php b/catavatar/catavatar.php index 7b5f05c0..2116ac44 100644 --- a/catavatar/catavatar.php +++ b/catavatar/catavatar.php @@ -6,8 +6,11 @@ * Author: Fabio */ +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'); } /** diff --git a/cld/cld.php b/cld/cld.php index d4fef6c5..5ca4c932 100644 --- a/cld/cld.php +++ b/cld/cld.php @@ -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']); diff --git a/convert/UnitConvertor.php b/convert/UnitConvertor.php index a3650e9b..d7933a8f 100644 --- a/convert/UnitConvertor.php +++ b/convert/UnitConvertor.php @@ -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) @@ -279,4 +280,4 @@ class UnitConvertor } // end func getConvSpecs } // end class UnitConvertor -?> +?> \ No newline at end of file diff --git a/convert/convert.php b/convert/convert.php index 2545974c..57ce6ea8 100644 --- a/convert/convert.php +++ b/convert/convert.php @@ -6,6 +6,7 @@ * Author: Mike Macgirvin */ +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 = '

Unit Conversions

'; + $o .= '

Unit Conversions

'; if (isset($_POST['from_unit']) && isset($_POST['value'])) { $o .= ($conv->getTable(intval($_POST['value']), $_POST['from_unit'], $_POST['to_unit'], 5)) . '

'; @@ -199,9 +202,10 @@ function convert_content() { $o .= ''; $o .= ' - + {{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])) }} {{foreach $users as $u}} - - + + @@ -49,7 +63,11 @@ {{/if}} - {{if $order_users == $th_users.5.1}} + {{if $order_users == $th_users.4.1}} + + {{/if}} + + {{if !in_array($order_users,[$th_users.2.1, $th_users.3.1, $th_users.4.1]) }} @@ -121,11 +135,30 @@ {{/foreach}} - + {{/foreach}}
+
+ + +
+
- + {{if $order_users == $th.1}} {{if $order_direction_users == "+"}} ↓ @@ -36,8 +41,17 @@
+ {{if $u.is_deletable}} +
+ + +
+ {{else}} +   + {{/if}} +
{{$u.name}} {{$u.email}}{{$u.login_date}}{{$u.lastitem_date}} + {{if $u.is_deletable}} + + + + + + + {{else}} +   + {{/if}} +
+ {{$pager nofilter}} diff --git a/rendertime/rendertime.php b/rendertime/rendertime.php index 1cce5b1b..731cf003 100644 --- a/rendertime/rendertime.php +++ b/rendertime/rendertime.php @@ -7,6 +7,7 @@ * */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\DI; diff --git a/s3_storage/s3_storage.php b/s3_storage/s3_storage.php index c08c3172..361577be 100644 --- a/s3_storage/s3_storage.php +++ b/s3_storage/s3_storage.php @@ -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; diff --git a/s3_storage/src/S3Client.php b/s3_storage/src/S3Client.php index 613eda97..643df2b0 100644 --- a/s3_storage/src/S3Client.php +++ b/s3_storage/src/S3Client.php @@ -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; diff --git a/s3_storage/src/S3Config.php b/s3_storage/src/S3Config.php index 1831c666..809cdd28 100644 --- a/s3_storage/src/S3Config.php +++ b/s3_storage/src/S3Config.php @@ -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; diff --git a/saml/lang/C/messages.po b/saml/lang/C/messages.po index b4a4c8ce..05579568 100644 --- a/saml/lang/C/messages.po +++ b/saml/lang/C/messages.po @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/saml/saml.css b/saml/saml.css new file mode 100644 index 00000000..087633cd --- /dev/null +++ b/saml/saml.css @@ -0,0 +1 @@ +#settings-form > div:first-of-type, #settings-form > h2:first-of-type, #wrapper_mpassword, #wrapper_email { display: none !important; } diff --git a/saml/saml.php b/saml/saml.php index 83e4d3fd..56dd0f5d 100755 --- a/saml/saml.php +++ b/saml/saml.php @@ -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 .= << var target=$("#settings-nickname-desc"); if (target.length) { target.append("

$fragment

"); } -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)); -} 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, diff --git a/securemail/SecureTestEmail.php b/securemail/SecureTestEmail.php index 32510091..c614104f 100644 --- a/securemail/SecureTestEmail.php +++ b/securemail/SecureTestEmail.php @@ -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; diff --git a/securemail/securemail.php b/securemail/securemail.php index 7b412395..5390ebd1 100644 --- a/securemail/securemail.php +++ b/securemail/securemail.php @@ -7,7 +7,9 @@ */ use Friendica\Addon\securemail\SecureTestEmail; +use Friendica\App; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Object\EMail\IEmail; @@ -21,7 +23,7 @@ function securemail_install() Hook::register('emailer_send_prepare', 'addon/securemail/securemail.php', 'securemail_emailer_send_prepare', 10); - DI::logger()->notice('installed securemail'); + Logger::notice('installed securemail'); } /** @@ -30,6 +32,8 @@ function securemail_install() * @link https://github.com/friendica/friendica/blob/develop/doc/Addons.md#addon_settings 'addon_settings' hook * * @param array $data + * + * @see App */ function securemail_settings(array &$data) { @@ -63,6 +67,8 @@ function securemail_settings(array &$data) * @link https://github.com/friendica/friendica/blob/develop/doc/Addons.md#addon_settings_post 'addon_settings_post' hook * * @param array $b hook data + * + * @see App */ function securemail_settings_post(array &$b) { @@ -76,7 +82,7 @@ function securemail_settings_post(array &$b) DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'securemail', 'enable', $enable); if (!empty($_POST['securemail-test'])) { - $res = DI::emailer()->send(new SecureTestEmail(DI::config(), DI::pConfig(), DI::baseUrl())); + $res = DI::emailer()->send(new SecureTestEmail(DI::app(), DI::config(), DI::pConfig(), DI::baseUrl())); // revert to saved value DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'securemail', 'enable', $enable); @@ -96,6 +102,8 @@ function securemail_settings_post(array &$b) * @link https://github.com/friendica/friendica/blob/develop/doc/Addons.md#emailer_send_prepare 'emailer_send_prepare' hook * * @param IEmail $email Email + * + * @see App */ function securemail_emailer_send_prepare(IEmail &$email) { diff --git a/showmore/showmore.php b/showmore/showmore.php index e326aa98..8e85925a 100644 --- a/showmore/showmore.php +++ b/showmore/showmore.php @@ -8,6 +8,7 @@ * */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\DI; @@ -78,7 +79,6 @@ function get_body_length($body) * Checking any possible syntax of the style attribute with xpath is impossible * So we just get any element with a style attribute, and check them with a regexp */ - /** @var DOMNodeList $xr */ $xr = $xpath->query('//*[@style]'); foreach ($xr as $node) { if (preg_match('/.*display: *none *;.*/',$node->getAttribute('style'))) { diff --git a/showmore_dyn/showmore_dyn.php b/showmore_dyn/showmore_dyn.php index 4c2e62f5..7cb64bcc 100644 --- a/showmore_dyn/showmore_dyn.php +++ b/showmore_dyn/showmore_dyn.php @@ -7,8 +7,12 @@ * */ +use Friendica\App; use Friendica\Core\Hook; +use Friendica\Core\L10n; +use Friendica\Core\Logger; use Friendica\Core\Renderer; +use Friendica\Database\DBA; use Friendica\DI; function showmore_dyn_install() diff --git a/smiley_pack/lang/smiley_pack_es/smiley_pack_es.php b/smiley_pack/lang/smiley_pack_es/smiley_pack_es.php index 0f41101d..38b208da 100644 --- a/smiley_pack/lang/smiley_pack_es/smiley_pack_es.php +++ b/smiley_pack/lang/smiley_pack_es/smiley_pack_es.php @@ -3,10 +3,11 @@ * Name: Smiley Pack (Español) * Description: Pack of smileys that make master too AOLish. * Version: 1.02 - * Author: Thomas Willingham (based on Mike Macgirvin's Adult Smile template) + * Author: Thomas Willingham (based on Mike Macgirvin's Adult Smile template) * All smileys from sites offering them as Public Domain */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; @@ -18,7 +19,7 @@ function smiley_pack_smilies_es(array &$b) { #Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever. -#Be careful with invocation strings. If you have a smiley called foo, and another called foobar, typing :foobar will call foo. Avoid this with clever naming, using ~ instead of : +#Be careful with invocation strings. If you have a smiley called foo, and another called foobar, typing :foobar will call foo. Avoid this with clever naming, using ~ instead of : #when all else fails. @@ -48,7 +49,7 @@ function smiley_pack_smilies_es(array &$b) { $b['texts'][] = ':vaca'; $b['icons'][] = '' . ':vaca' . ''; - + $b['texts'][] = ':cangrejo'; $b['icons'][] = '' . ':cangrejo' . ''; @@ -69,7 +70,7 @@ function smiley_pack_smilies_es(array &$b) { $b['texts'][] = ':caballo'; $b['icons'][] = '' . ':caballo' . ''; - + $b['texts'][] = ':loro'; $b['icons'][] = '' . ':loro' . ''; @@ -106,7 +107,7 @@ function smiley_pack_smilies_es(array &$b) { $b['texts'][] = ':cuna'; $b['icons'][] = '' . ':cuna' . ''; - + $b['texts'][] = ':embarazada'; $b['icons'][] = '' . ':embarazada' . ''; @@ -115,10 +116,10 @@ function smiley_pack_smilies_es(array &$b) { $b['icons'][] = '' . ':cigüeña' . ''; -#Confused Smileys +#Confused Smileys $b['texts'][] = ':confundido'; $b['icons'][] = '' . ':confundido' . ''; - + $b['texts'][] = ':encogehombros'; $b['icons'][] = '' . ':encogehombros' . ''; @@ -153,13 +154,13 @@ function smiley_pack_smilies_es(array &$b) { $b['texts'][] = ':diabólico'; $b['icons'][] = '' . ':diabólico' . ''; - + $b['texts'][] = ':adbalancín'; $b['icons'][] = '' . ':adbalancín' . ''; $b['texts'][] = ':vuelvedemonio'; $b['icons'][] = '' . ':vuelvedemonio' . ''; - + $b['texts'][] = ':santo'; $b['icons'][] = '' . ':santo' . ''; @@ -241,7 +242,7 @@ function smiley_pack_smilies_es(array &$b) { $b['texts'][] = ':billar'; $b['icons'][] = '' . ':billar' . ''; - + $b['texts'][] = ':tenis'; $b['icons'][] = '' . ':tenis' . ''; diff --git a/smiley_pack/lang/smiley_pack_fr/smiley_pack_fr.php b/smiley_pack/lang/smiley_pack_fr/smiley_pack_fr.php index c5474e3c..63cf613e 100644 --- a/smiley_pack/lang/smiley_pack_fr/smiley_pack_fr.php +++ b/smiley_pack/lang/smiley_pack_fr/smiley_pack_fr.php @@ -9,6 +9,7 @@ * */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; @@ -22,7 +23,7 @@ function smiley_pack_fr_smilies(array &$b) #Smileys are split into various directories by the intended range of emotions. This is in case we get too big and need to modularise things. We can then cut and paste the right lines, move the right directory, and just change the name of the addon to happy_smilies or whatever. -#Be careful with invocation strings. If you have a smiley called foo, and another called foobar, typing :foobar will call foo. Avoid this with clever naming, using ~ instead of : +#Be careful with invocation strings. If you have a smiley called foo, and another called foobar, typing :foobar will call foo. Avoid this with clever naming, using ~ instead of : #when all else fails. @@ -55,7 +56,7 @@ function smiley_pack_fr_smilies(array &$b) $b['texts'][] = ':vache'; $b['icons'][] = '' . ':vache' . ''; - + $b['texts'][] = ':crabe'; $b['icons'][] = '' . ':crabe' . ''; @@ -73,7 +74,7 @@ function smiley_pack_fr_smilies(array &$b) $b['texts'][] = ':cheval'; $b['icons'][] = '' . ':cheval' . ''; - + $b['texts'][] = ':perroquet'; $b['icons'][] = '' . ':perroquet' . ''; @@ -107,7 +108,7 @@ function smiley_pack_fr_smilies(array &$b) $b['texts'][] = ':litbébé'; $b['icons'][] = '' . ':litbébé' . ''; - + $b['texts'][] = ':enceinte'; $b['icons'][] = '' . ':enceinte' . ''; @@ -116,10 +117,10 @@ function smiley_pack_fr_smilies(array &$b) $b['icons'][] = '' . ':cigogne' . ''; -#Confused Smileys +#Confused Smileys $b['texts'][] = ':paumé'; $b['icons'][] = '' . ':paumé' . ''; - + $b['texts'][] = ':hausseépaules'; $b['icons'][] = '' . ':hausseépaules' . ''; @@ -151,13 +152,13 @@ function smiley_pack_fr_smilies(array &$b) $b['texts'][] = ':démoniaque'; $b['icons'][] = '' . ':démoniaque' . ''; - + $b['texts'][] = ':bascule'; $b['icons'][] = '' . ':bascule' . ''; $b['texts'][] = ':possédé'; $b['icons'][] = '' . ':possédé' . ''; - + $b['texts'][] = ':tombe'; $b['icons'][] = '' . ':tombe' . ''; @@ -224,7 +225,7 @@ function smiley_pack_fr_smilies(array &$b) $b['texts'][] = ':billard'; $b['icons'][] = '' . ':billard' . ''; - + $b['texts'][] = ':équitation'; $b['icons'][] = '' . ':équitation' . ''; diff --git a/smileybutton/smileybutton.php b/smileybutton/smileybutton.php index 4d0a8d42..1df717b7 100644 --- a/smileybutton/smileybutton.php +++ b/smileybutton/smileybutton.php @@ -7,6 +7,7 @@ * Maintainer: Hypolite Petovan */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; @@ -19,7 +20,7 @@ function smileybutton_install() function smileybutton_jot_tool(string &$body) { // Disable if theme is quattro - if (DI::appHelper()->getCurrentTheme() == 'quattro') { + if (DI::app()->getCurrentTheme() == 'quattro') { return; } @@ -96,7 +97,7 @@ function smileybutton_jot_tool(string &$body) $s .= '
'; //Add css to header - $css_file = __DIR__ . '/view/' . DI::appHelper()->getCurrentTheme() . '.css'; + $css_file = __DIR__ . '/view/' . DI::app()->getCurrentTheme() . '.css'; if (!file_exists($css_file)) { $css_file = __DIR__ . '/view/default.css'; } @@ -104,7 +105,7 @@ function smileybutton_jot_tool(string &$body) DI::page()->registerStylesheet($css_file); //Get the correct image for the theme - $image = 'addon/smileybutton/view/' . DI::appHelper()->getCurrentTheme() . '.png'; + $image = 'addon/smileybutton/view/' . DI::app()->getCurrentTheme() . '.png'; if (!file_exists($image)) { $image = 'addon/smileybutton/view/default.png'; } diff --git a/smilies_adult/smilies_adult.php b/smilies_adult/smilies_adult.php index 4a80168d..e8af21e1 100644 --- a/smilies_adult/smilies_adult.php +++ b/smilies_adult/smilies_adult.php @@ -4,11 +4,12 @@ * Description: Smily icons that could or should not be included in core * Version: 1.0 * Author: Mike Macgirvin - * + * * This is a template for how to extend the "smily" code. - * + * */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; diff --git a/startpage/startpage.php b/startpage/startpage.php index 558af473..e4d80c0c 100644 --- a/startpage/startpage.php +++ b/startpage/startpage.php @@ -7,6 +7,7 @@ * */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\DI; diff --git a/statusnet/library/codebirdsn.php b/statusnet/library/codebirdsn.php index 9807d97f..020c69c4 100644 --- a/statusnet/library/codebirdsn.php +++ b/statusnet/library/codebirdsn.php @@ -31,10 +31,11 @@ use Friendica\Core\System; /** * Define constants */ -defined('CODEBIRD_RETURNFORMAT_ARRAY') or define('CODEBIRD_RETURNFORMAT_ARRAY', 0); -defined('CODEBIRD_RETURNFORMAT_JSON') or define('CODEBIRD_RETURNFORMAT_JSON', 1); -defined('CODEBIRD_RETURNFORMAT_OBJECT') or define('CODEBIRD_RETURNFORMAT_OBJECT', 2); - +$constants = explode(' ', 'OBJECT ARRAY JSON'); +foreach ($constants as $i => $id) { + $id = 'CODEBIRD_RETURNFORMAT_' . $id; + defined($id) or define($id, $i); +} $constants = array( 'CURLE_SSL_CERTPROBLEM' => 58, 'CURLE_SSL_CACERT' => 60, @@ -54,8 +55,6 @@ unset($id); * * @package codebird * @subpackage codebird-php - * - * @method object statuses_update(array $postdata) */ class CodebirdSN { @@ -118,7 +117,7 @@ class CodebirdSN * Returns singleton class instance * Always use this method unless you're working with multiple authenticated users at once * - * @return CodebirdSN The instance + * @return Codebird The instance */ public static function getInstance() { @@ -422,7 +421,6 @@ class CodebirdSN } break; case CODEBIRD_RETURNFORMAT_OBJECT: - /** @var object $reply */ $reply->httpstatus = $httpstatus; if ($httpstatus == 200) { self::setBearerToken($reply->access_token); @@ -493,7 +491,7 @@ class CodebirdSN /** * Generates a (hopefully) unique random string * - * @param int $length The optional length of the string to generate + * @param int optional $length The length of the string to generate * * @return string The random string */ @@ -508,9 +506,9 @@ class CodebirdSN /** * Generates an OAuth signature * - * @param string $httpmethod Usually either 'GET' or 'POST' or 'DELETE' - * @param string $method The API method to call - * @param array $params optional The API call parameters, associative + * @param string $httpmethod Usually either 'GET' or 'POST' or 'DELETE' + * @param string $method The API method to call + * @param array optional $params The API call parameters, associative * * @return string Authorization HTTP header */ @@ -764,13 +762,13 @@ class CodebirdSN * @param string $method The API method to call * @param array $params The parameters to send along * - * @return string + * @return void */ protected function _buildMultipart($method, $params) { // well, files will only work in multipart methods if (! $this->_detectMultipart($method)) { - return ''; + return; } // only check specific parameters @@ -785,19 +783,18 @@ class CodebirdSN ); // method might have files? if (! in_array($method, array_keys($possible_files))) { - return ''; + return; } $possible_files = explode(' ', $possible_files[$method]); - $data = ''; - $multipart_border = '--------------------' . $this->_nonce(); $multipart_request = ''; foreach ($params as $key => $value) { // is it an array? if (is_array($value)) { throw new \Exception('Using URL-encoded parameters is not supported for uploading media.'); + continue; } // check for filenames @@ -874,12 +871,12 @@ class CodebirdSN /** * Calls the API using cURL * - * @param string $httpmethod The HTTP method to use for making the request - * @param string $method The API method to call - * @param string $method_template The templated API method to call - * @param array $params optional The parameters to send along - * @param bool $multipart optional Whether to use multipart/form-data - * @param bool $app_only_auth optional Whether to use app-only bearer authentication + * @param string $httpmethod The HTTP method to use for making the request + * @param string $method The API method to call + * @param string $method_template The templated API method to call + * @param array optional $params The parameters to send along + * @param bool optional $multipart Whether to use multipart/form-data + * @param bool optional $app_only_auth Whether to use app-only bearer authentication * * @return mixed The API reply, encoded in the set return_format */ @@ -921,7 +918,7 @@ class CodebirdSN $authorization = 'Authorization: Bearer ' . self::$_oauth_bearer_token; } $request_headers = array(); - if ($authorization !== '') { + if (isset($authorization)) { $request_headers[] = $authorization; $request_headers[] = 'Expect:'; } @@ -962,7 +959,6 @@ class CodebirdSN $httpstatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); $reply = $this->_parseApiReply($method_template, $reply); if ($this->_return_format == CODEBIRD_RETURNFORMAT_OBJECT) { - /** @var object $reply */ $reply->httpstatus = $httpstatus; } elseif ($this->_return_format == CODEBIRD_RETURNFORMAT_ARRAY) { $reply['httpstatus'] = $httpstatus; diff --git a/statusnet/library/statusnetoauth.php b/statusnet/library/statusnetoauth.php index c32b2b4f..c9bb0163 100644 --- a/statusnet/library/statusnetoauth.php +++ b/statusnet/library/statusnetoauth.php @@ -52,6 +52,11 @@ class StatusNetOAuth extends TwitterOAuth * * Copied here from the TwitterOAuth library and complemented by applying the proxy settings of Friendica * + * @param string $method + * @param string $host + * @param string $path + * @param array $parameters + * * @return array|object API results */ function http($url, $method, $postfields = NULL) diff --git a/statusnet/library/twitteroauth.php b/statusnet/library/twitteroauth.php index bf413d23..b33b5f9d 100644 --- a/statusnet/library/twitteroauth.php +++ b/statusnet/library/twitteroauth.php @@ -93,7 +93,7 @@ class TwitterOAuth /** * Get a request_token * - * @param callable $oauth_callback + * @param callback $oauth_callback * @return array */ function getRequestToken($oauth_callback = null) @@ -112,6 +112,8 @@ class TwitterOAuth /** * Get the authorize URL * + * @param array $token + * @param bool $sign_in_with_tumblr * @return string */ function getAuthorizeURL($token, $sign_in_with_twitter = TRUE) diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 8663aaea..4bc32050 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -38,8 +38,10 @@ define('STATUSNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes require_once __DIR__ . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'statusnetoauth.php'; use CodebirdSN\CodebirdSN; +use Friendica\App; use Friendica\Content\Text\Plaintext; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\System; use Friendica\Database\DBA; @@ -57,7 +59,7 @@ function statusnet_install() Hook::register('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork'); Hook::register('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local'); Hook::register('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets'); - DI::logger()->notice('installed GNU Social'); + Logger::notice('installed GNU Social'); } function statusnet_jot_nets(array &$jotnets_fields) @@ -354,7 +356,7 @@ function statusnet_post_hook(array &$b) return; } - DI::logger()->notice('GNU Socialpost invoked'); + Logger::notice('GNU Socialpost invoked'); DI::pConfig()->load($b['uid'], 'statusnet'); @@ -364,8 +366,6 @@ function statusnet_post_hook(array &$b) $otoken = DI::pConfig()->get($b['uid'], 'statusnet', 'oauthtoken'); $osecret = DI::pConfig()->get($b['uid'], 'statusnet', 'oauthsecret'); - $iscomment = null; - if ($ckey && $csecret && $otoken && $osecret) { $dent = new StatusNetOAuth($api, $ckey, $csecret, $otoken, $osecret); $max_char = $dent->get_maxlength(); // max. length for a dent @@ -406,7 +406,7 @@ function statusnet_post_hook(array &$b) $cb->setToken($otoken, $osecret); $result = $cb->statuses_update($postdata); //$result = $dent->post('statuses/update', $postdata); - DI::logger()->info('statusnet_post send, result: ' . print_r($result, true) . + Logger::info('statusnet_post send, result: ' . print_r($result, true) . "\nmessage: " . $msg . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true)); if (!empty($result->source)) { @@ -414,9 +414,9 @@ function statusnet_post_hook(array &$b) } if (!empty($result->error)) { - DI::logger()->notice('Send to GNU Social failed: "' . $result->error . '"'); + Logger::notice('Send to GNU Social failed: "' . $result->error . '"'); } elseif ($iscomment) { - DI::logger()->notice('statusnet_post: Update extid ' . $result->id . ' for post id ' . $b['id']); + Logger::notice('statusnet_post: Update extid ' . $result->id . ' for post id ' . $b['id']); Item::update(['extid' => $hostname . '::' . $result->id, 'body' => $result->text], ['id' => $b['id']]); } } diff --git a/tesseract/tesseract.php b/tesseract/tesseract.php index a07c690c..b3e1feb6 100644 --- a/tesseract/tesseract.php +++ b/tesseract/tesseract.php @@ -7,8 +7,8 @@ */ use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\System; -use Friendica\DI; use thiagoalessio\TesseractOCR\TesseractOCR; require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; @@ -17,7 +17,7 @@ function tesseract_install() { Hook::register('ocr-detection', __FILE__, 'tesseract_ocr_detection'); - DI::logger()->notice('installed tesseract'); + Logger::notice('installed tesseract'); } function tesseract_ocr_detection(&$media) @@ -26,13 +26,12 @@ function tesseract_ocr_detection(&$media) try { $languages = $ocr->availableLanguages(); if ($languages) { - /** @phpstan-ignore-next-line ignore call of \thiagoalessio\TesseractOCR\Option::lang() */ $ocr->lang(implode('+', $languages)); } $ocr->tempDir(System::getTempPath()); $ocr->imageData($media['img_str'], strlen($media['img_str'])); $media['description'] = $ocr->run(); } catch (\Throwable $th) { - DI::logger()->info('Error calling TesseractOCR', ['message' => $th->getMessage()]); - } + Logger::info('Error calling TesseractOCR', ['message' => $th->getMessage()]); + } } diff --git a/testdrive/testdrive.php b/testdrive/testdrive.php index 90fb5918..55645284 100644 --- a/testdrive/testdrive.php +++ b/testdrive/testdrive.php @@ -6,6 +6,7 @@ * Author: Mike Macgirvin */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Search; use Friendica\Database\DBA; @@ -26,7 +27,7 @@ function testdrive_install() function testdrive_load_config(ConfigFileManager $loader) { - DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('testdrive'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); + DI::app()->getConfigCache()->load($loader->loadAddonConfig('testdrive'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); } function testdrive_globaldir_update(array &$b) diff --git a/tictac/tictac.php b/tictac/tictac.php index 082b58c1..0f9f4fb6 100644 --- a/tictac/tictac.php +++ b/tictac/tictac.php @@ -7,6 +7,7 @@ * Status: unsupported */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; @@ -29,12 +30,7 @@ function tictac_module() {} function tictac_content() { - $o = ''; - $dimen = 3; - $handicap = 0; - $mefirst = 0; - $yours = ''; - $mine = ''; + $o = ''; if($_POST['move']) { $handicap = DI::args()->get(1); @@ -49,6 +45,9 @@ function tictac_content() { $handicap = DI::args()->get(1); $dimen = 3; } + else { + $dimen = 3; + } $o .= '

' . DI::l10n()->t('3D Tic-Tac-Toe') . '


'; @@ -71,7 +70,6 @@ class tictac { private $dimen; private $first_move = true; private $handicap = 0; - private $mefirst; private $yours; private $mine; private $winning_play; @@ -163,10 +161,10 @@ class tictac { ]; - function __construct($dimen, $handicap, $mefirst, $yours, $mine) { - $this->dimen = $dimen; - $this->handicap = $handicap ? 1 : 0; - $this->mefirst = $mefirst ? 1 : 0; + function __construct($dimen,$handicap,$mefirst,$yours,$mine) { + $this->dimen = 3; + $this->handicap = (($handicap) ? 1 : 0); + $this->mefirst = (($mefirst) ? 1 : 0); $this->yours = str_replace('XXX','',$yours); $this->mine = $mine; $this->you = $this->parse_moves('you'); @@ -177,7 +175,6 @@ class tictac { } function play() { - $o = ''; if($this->first_move) { if(rand(0,1) == 1) { @@ -229,8 +226,6 @@ class tictac { } function parse_moves($player) { - $str = ''; - if($player == 'me') $str = $this->mine; if($player == 'you') @@ -634,7 +629,7 @@ function winning_move() { function draw_board() { if(! strlen($this->yours)) $this->yours = 'XXX'; - $o = "
handicap}/{$this->mefirst}/{$this->dimen}/{$this->yours}/{$this->mine}\" method=\"post\" />"; + $o .= "handicap}/{$this->mefirst}/{$this->dimen}/{$this->yours}/{$this->mine}\" method=\"post\" />"; for($x = 0; $x < $this->dimen; $x ++) { $o .= ''; for($y = 0; $y < $this->dimen; $y ++) { diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 819c0ca5..ecd6f862 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -14,6 +14,7 @@ use Friendica\Content\Text\NPF; 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\System; @@ -59,12 +60,12 @@ function tumblr_install() Hook::register('check_item_notification', __FILE__, 'tumblr_check_item_notification'); Hook::register('probe_detect', __FILE__, 'tumblr_probe_detect'); Hook::register('item_by_link', __FILE__, 'tumblr_item_by_link'); - DI::logger()->info('installed tumblr'); + Logger::info('installed tumblr'); } function tumblr_load_config(ConfigFileManager $loader) { - DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('tumblr'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); + DI::app()->getConfigCache()->load($loader->loadAddonConfig('tumblr'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); } function tumblr_check_item_notification(array &$notification_data) @@ -120,16 +121,16 @@ function tumblr_item_by_link(array &$hookData) return; } - DI::logger()->debug('Found tumblr post', ['url' => $hookData['uri'], 'blog' => $matches[1], 'id' => $matches[2]]); + Logger::debug('Found tumblr post', ['url' => $hookData['uri'], 'blog' => $matches[1], 'id' => $matches[2]]); $parameters = ['id' => $matches[2], 'reblog_info' => false, 'notes_info' => false, 'npf' => false]; $result = tumblr_get($hookData['uid'], 'blog/' . $matches[1] . '/posts', $parameters); if ($result->meta->status > 399) { - DI::logger()->notice('Error fetching status', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'blog' => $matches[1], 'id' => $matches[2]]); + Logger::notice('Error fetching status', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'blog' => $matches[1], 'id' => $matches[2]]); return []; } - DI::logger()->debug('Got post', ['blog' => $matches[1], 'id' => $matches[2], 'result' => $result->response->posts]); + Logger::debug('Got post', ['blog' => $matches[1], 'id' => $matches[2], 'result' => $result->response->posts]); if (!empty($result->response->posts)) { $hookData['item_id'] = tumblr_process_post($result->response->posts[0], $hookData['uid'], Item::PR_FETCHED); Item::incrementInbound(Protocol::TUMBLR); @@ -158,20 +159,20 @@ function tumblr_follow(array &$hook_data) return; } - DI::logger()->debug('Check if contact is Tumblr', ['url' => $hook_data['url']]); + Logger::debug('Check if contact is Tumblr', ['url' => $hook_data['url']]); $fields = tumblr_get_contact_by_url($hook_data['url'], $uid); if (empty($fields)) { - DI::logger()->debug('Contact is not a Tumblr contact', ['url' => $hook_data['url']]); + Logger::debug('Contact is not a Tumblr contact', ['url' => $hook_data['url']]); return; } $result = tumblr_post($uid, 'user/follow', ['url' => $fields['url']]); if ($result->meta->status <= 399) { $hook_data['contact'] = $fields; - DI::logger()->debug('Successfully start following', ['url' => $fields['url']]); + Logger::debug('Successfully start following', ['url' => $fields['url']]); } else { - DI::logger()->notice('Following failed', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'url' => $fields['url']]); + Logger::notice('Following failed', ['meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'url' => $fields['url']]); } } @@ -414,11 +415,11 @@ function tumblr_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) { @@ -431,30 +432,30 @@ function tumblr_cron() foreach ($pconfigs as $pconfig) { 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; } } - DI::logger()->notice('importing timeline - start', ['user' => $pconfig['uid']]); + Logger::notice('importing timeline - start', ['user' => $pconfig['uid']]); tumblr_fetch_dashboard($pconfig['uid'], $last); tumblr_fetch_tags($pconfig['uid'], $last); - DI::logger()->notice('importing timeline - done', ['user' => $pconfig['uid']]); + Logger::notice('importing timeline - done', ['user' => $pconfig['uid']]); } $last_clean = DI::keyValue()->get('tumblr_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::TUMBLR, 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('tumblr_last_clean', time()); - DI::logger()->notice('Contact cleanup done'); + Logger::notice('Contact cleanup done'); } - DI::logger()->notice('cron_end'); + Logger::notice('cron_end'); DI::keyValue()->set('tumblr_last_poll', time()); } @@ -477,7 +478,7 @@ function tumblr_hook_fork(array &$b) if (DI::pConfig()->get($post['uid'], 'tumblr', 'import')) { // Don't post if it isn't a reply to a tumblr post if (($post['gravity'] != Item::GRAVITY_PARENT) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::TUMBLR])) { - DI::logger()->notice('No tumblr parent found', ['item' => $post['id']]); + Logger::notice('No tumblr parent found', ['item' => $post['id']]); $b['execute'] = false; return; } @@ -524,20 +525,20 @@ function tumblr_send(array &$b) } if ($b['gravity'] != Item::GRAVITY_PARENT) { - DI::logger()->debug('Got comment', ['item' => $b]); + Logger::debug('Got comment', ['item' => $b]); $parent = tumblr_get_post_from_uri($b['thr-parent']); if (empty($parent)) { - DI::logger()->notice('No tumblr post', ['thr-parent' => $b['thr-parent']]); + Logger::notice('No tumblr post', ['thr-parent' => $b['thr-parent']]); return; } - DI::logger()->debug('Parent found', ['parent' => $parent]); + Logger::debug('Parent found', ['parent' => $parent]); $page = tumblr_get_page($b['uid']); if ($b['gravity'] == Item::GRAVITY_COMMENT) { - DI::logger()->notice('Commenting is not supported (yet)'); + Logger::notice('Commenting is not supported (yet)'); } else { if (($b['verb'] == Activity::LIKE) && !$b['deleted']) { $params = ['id' => $parent['id'], 'reblog_key' => $parent['reblog_key']]; @@ -561,12 +562,12 @@ function tumblr_send(array &$b) } if ($result->meta->status < 400) { - DI::logger()->info('Successfully performed activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response]); + Logger::info('Successfully performed activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response]); if (!$b['deleted'] && !empty($result->response->id_string)) { Item::update(['extid' => 'tumblr::' . $result->response->id_string], ['guid' => $b['guid']]); } } else { - DI::logger()->notice('Error while performing activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); + Logger::notice('Error while performing activity', ['verb' => $b['verb'], 'deleted' => $b['deleted'], 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); } } return; @@ -664,9 +665,9 @@ function tumblr_send_legacy(array $b) $result = tumblr_post($b['uid'], 'blog/' . $page . '/post', $params); if ($result->meta->status < 400) { - DI::logger()->info('Success (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); + Logger::info('Success (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); } else { - DI::logger()->notice('Error posting blog (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); + Logger::notice('Error posting blog (legacy)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); } } @@ -675,7 +676,7 @@ function tumblr_send_npf(array $post): bool $page = tumblr_get_page($post['uid']); if (empty($page)) { - DI::logger()->notice('Missing page, post will not be send to Tumblr.', ['uid' => $post['uid'], 'page' => $page, 'id' => $post['id']]); + Logger::notice('Missing page, post will not be send to Tumblr.', ['uid' => $post['uid'], 'page' => $page, 'id' => $post['id']]); // "true" is returned, since the legacy function will fail as well. return true; } @@ -706,10 +707,10 @@ function tumblr_send_npf(array $post): bool $result = tumblr_post($post['uid'], 'blog/' . $page . '/posts', $params); if ($result->meta->status < 400) { - DI::logger()->info('Success (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); + Logger::info('Success (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response]); return true; } else { - DI::logger()->notice('Error posting blog (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); + Logger::notice('Error posting blog (NPF)', ['blog' => $page, 'meta' => $result->meta, 'response' => $result->response, 'errors' => $result->errors, 'params' => $params]); return false; } } @@ -746,10 +747,10 @@ function tumblr_fetch_tags(int $uid, int $last_poll) foreach (array_reverse($data->response) as $post) { $id = tumblr_process_post($post, $uid, Item::PR_TAG, $last_poll); if (!empty($id)) { - DI::logger()->debug('Tag post imported', ['tag' => $tag, 'id' => $id]); + Logger::debug('Tag post imported', ['tag' => $tag, 'id' => $id]); $post = Post::selectFirst(['uri-id'], ['id' => $id]); $stored = Post\Category::storeFileByURIId($post['uri-id'], $uid, Post\Category::SUBCRIPTION, $tag); - DI::logger()->debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'tag' => $tag, 'stored' => $stored]); + Logger::debug('Stored tag subscription for user', ['uri-id' => $post['uri-id'], 'uid' => $uid, 'tag' => $tag, 'stored' => $stored]); Item::incrementInbound(Protocol::TUMBLR); } } @@ -774,7 +775,7 @@ function tumblr_fetch_dashboard(int $uid, int $last_poll) $dashboard = tumblr_get($uid, 'user/dashboard', $parameters); if ($dashboard->meta->status > 399) { - DI::logger()->notice('Error fetching dashboard', ['meta' => $dashboard->meta, 'response' => $dashboard->response, 'errors' => $dashboard->errors]); + Logger::notice('Error fetching dashboard', ['meta' => $dashboard->meta, 'response' => $dashboard->response, 'errors' => $dashboard->errors]); return []; } @@ -787,7 +788,7 @@ function tumblr_fetch_dashboard(int $uid, int $last_poll) $last = $post->id; } - DI::logger()->debug('Importing post', ['uid' => $uid, 'created' => date(DateTimeFormat::MYSQL, $post->timestamp), 'id' => $post->id_string]); + Logger::debug('Importing post', ['uid' => $uid, 'created' => date(DateTimeFormat::MYSQL, $post->timestamp), 'id' => $post->id_string]); tumblr_process_post($post, $uid, Item::PR_NONE, $last_poll); Item::incrementInbound(Protocol::TUMBLR); @@ -1062,7 +1063,7 @@ function tumblr_get_type_replacement(array $data, string $plink): string } default: - DI::logger()->notice('Unknown type', ['type' => $data['type'], 'data' => $data, 'plink' => $plink]); + Logger::notice('Unknown type', ['type' => $data['type'], 'data' => $data, 'plink' => $plink]); $body = ''; } @@ -1117,9 +1118,9 @@ function tumblr_get_contact(stdClass $blog, int $uid): array $cid = $contact['id']; Contact::update($fields, ['id' => $cid], true); } - DI::logger()->debug('Get user contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); + Logger::debug('Get user contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); } else { - DI::logger()->debug('Get public contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); + Logger::debug('Get public contact', ['id' => $cid, 'uid' => $uid, 'update' => $update]); } if (!empty($avatar)) { @@ -1155,13 +1156,13 @@ function tumblr_get_contact_fields(stdClass $blog, int $uid, bool $update): arra ]; if (!$update) { - DI::logger()->debug('Got contact fields', ['uid' => $uid, 'url' => $fields['url']]); + Logger::debug('Got contact fields', ['uid' => $uid, 'url' => $fields['url']]); return $fields; } $info = tumblr_get($uid, 'blog/' . $blog->uuid . '/info'); if ($info->meta->status > 399) { - DI::logger()->notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors]); + Logger::notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors]); return $fields; } Item::incrementInbound(Protocol::TUMBLR); @@ -1183,7 +1184,7 @@ function tumblr_get_contact_fields(stdClass $blog, int $uid, bool $update): arra $fields['header'] = $info->response->blog->theme->header_image_focused; - DI::logger()->debug('Got updated contact fields', ['uid' => $uid, 'url' => $fields['url']]); + Logger::debug('Got updated contact fields', ['uid' => $uid, 'url' => $fields['url']]); return $fields; } @@ -1225,7 +1226,7 @@ function tumblr_get_blogs(int $uid): array { $userinfo = tumblr_get($uid, 'user/info'); if ($userinfo->meta->status > 399) { - DI::logger()->notice('Error fetching blogs', ['meta' => $userinfo->meta, 'response' => $userinfo->response, 'errors' => $userinfo->errors]); + Logger::notice('Error fetching blogs', ['meta' => $userinfo->meta, 'response' => $userinfo->response, 'errors' => $userinfo->errors]); return []; } @@ -1281,15 +1282,15 @@ function tumblr_get_contact_by_url(string $url, int $uid): ?array return null; } - DI::logger()->debug('Update Tumblr blog data', ['url' => $url, 'blog' => $blog, 'uid' => $uid]); + Logger::debug('Update Tumblr blog data', ['url' => $url, 'blog' => $blog, 'uid' => $uid]); $info = tumblr_get($uid, 'blog/' . $blog . '/info'); if ($info->meta->status > 399) { - DI::logger()->notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors, 'blog' => $blog, 'uid' => $uid]); + Logger::notice('Error fetching blog info', ['meta' => $info->meta, 'response' => $info->response, 'errors' => $info->errors, 'blog' => $blog, 'uid' => $uid]); return null; } - DI::logger()->debug('Got data', ['blog' => $blog, 'meta' => $info->meta]); + Logger::debug('Got data', ['blog' => $blog, 'meta' => $info->meta]); Item::incrementInbound(Protocol::TUMBLR); $baseurl = 'https://tumblr.com'; @@ -1418,7 +1419,7 @@ function tumblr_get_token(int $uid, string $code = ''): string $refresh_token = DI::pConfig()->get($uid, 'tumblr', 'refresh_token'); if (empty($code) && !empty($access_token) && ($expires_at > (time()))) { - DI::logger()->debug('Got token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); + Logger::debug('Got token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); return $access_token; } @@ -1430,11 +1431,11 @@ function tumblr_get_token(int $uid, string $code = ''): string if (empty($refresh_token) && empty($code)) { $result = tumblr_exchange_token($uid); if (empty($result->refresh_token)) { - DI::logger()->info('Invalid result while exchanging token', ['uid' => $uid]); + Logger::info('Invalid result while exchanging token', ['uid' => $uid]); return ''; } $expires_at = time() + $result->expires_in; - DI::logger()->debug('Updated token from OAuth1 to OAuth2', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); + Logger::debug('Updated token from OAuth1 to OAuth2', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); } else { if (!empty($code)) { $parameters['code'] = $code; @@ -1446,18 +1447,18 @@ function tumblr_get_token(int $uid, string $code = ''): string $curlResult = DI::httpClient()->post('https://api.tumblr.com/v2/oauth2/token', $parameters); if (!$curlResult->isSuccess()) { - DI::logger()->info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBodyString(), 'parameters' => $parameters]); + Logger::info('Error fetching token', ['uid' => $uid, 'code' => $code, 'result' => $curlResult->getBodyString(), 'parameters' => $parameters]); return ''; } $result = json_decode($curlResult->getBodyString()); if (empty($result)) { - DI::logger()->info('Invalid result when updating token', ['uid' => $uid]); + Logger::info('Invalid result when updating token', ['uid' => $uid]); return ''; } $expires_at = time() + $result->expires_in; - DI::logger()->debug('Renewed token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); + Logger::debug('Renewed token', ['uid' => $uid, 'expires_at' => date('c', $expires_at)]); } DI::pConfig()->set($uid, 'tumblr', 'access_token', $result->access_token); @@ -1501,7 +1502,7 @@ function tumblr_exchange_token(int $uid): stdClass $response = $client->post('oauth2/exchange', ['auth' => 'oauth']); return json_decode($response->getBody()->getContents()); } catch (RequestException $exception) { - DI::logger()->notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]); + Logger::notice('Exchange failed', ['code' => $exception->getCode(), 'message' => $exception->getMessage()]); return new stdClass; } } diff --git a/twitter/twitter.php b/twitter/twitter.php index a9654405..10f8a2fb 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -38,6 +38,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\Plaintext; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Core\Worker; use Friendica\DI; @@ -66,7 +67,7 @@ function twitter_install() function twitter_load_config(ConfigFileManager $loader) { - DI::appHelper()->getConfigCache()->load($loader->loadAddonConfig('twitter'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); + DI::app()->getConfigCache()->load($loader->loadAddonConfig('twitter'), \Friendica\Core\Config\ValueObject\Cache::SOURCE_STATIC); } function twitter_jot_nets(array &$jotnets_fields) @@ -216,7 +217,7 @@ function twitter_post_hook(array &$b) $b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], DI::contentItem()->addSharedPost($b)); - DI::logger()->notice('twitter post invoked', ['id' => $b['id'], 'guid' => $b['guid']]); + Logger::notice('twitter post invoked', ['id' => $b['id'], 'guid' => $b['guid']]); DI::pConfig()->load($b['uid'], 'twitter'); @@ -226,17 +227,17 @@ function twitter_post_hook(array &$b) $access_secret = DI::pConfig()->get($b['uid'], 'twitter', 'access_secret'); if (empty($api_key) || empty($api_secret) || empty($access_token) || empty($access_secret)) { - DI::logger()->info('Missing keys, secrets or tokens.'); + Logger::info('Missing keys, secrets or tokens.'); return; } $msgarr = Plaintext::getPost($b, 280, true, BBCode::TWITTER); - DI::logger()->debug('Got plaintext', ['id' => $b['id'], 'message' => $msgarr]); + Logger::debug('Got plaintext', ['id' => $b['id'], 'message' => $msgarr]); $media_ids = []; if (!empty($msgarr['images']) || !empty($msgarr['remote_images'])) { - DI::logger()->info('Got images', ['id' => $b['id'], 'images' => $msgarr['images'] ?? []]); + Logger::info('Got images', ['id' => $b['id'], 'images' => $msgarr['images'] ?? []]); $retrial = Worker::getRetrial(); if ($retrial > 4) { @@ -249,7 +250,7 @@ function twitter_post_hook(array &$b) try { $media_ids[] = twitter_upload_image($b['uid'], $image, $retrial); } catch (RequestException $exception) { - DI::logger()->warning('Error while uploading image', ['image' => $image, 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); + Logger::warning('Error while uploading image', ['image' => $image, 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); Worker::defer(); return; } @@ -258,13 +259,13 @@ function twitter_post_hook(array &$b) $in_reply_to_tweet_id = 0; - DI::logger()->debug('Post message', ['id' => $b['id'], 'parts' => count($msgarr['parts'])]); + Logger::debug('Post message', ['id' => $b['id'], 'parts' => count($msgarr['parts'])]); foreach ($msgarr['parts'] as $key => $part) { try { $id = twitter_post_status($b['uid'], $part, $media_ids, $in_reply_to_tweet_id); - DI::logger()->info('twitter_post send', ['part' => $key, 'id' => $b['id'], 'result' => $id]); + Logger::info('twitter_post send', ['part' => $key, 'id' => $b['id'], 'result' => $id]); } catch (RequestException $exception) { - DI::logger()->warning('Error while posting message', ['part' => $key, 'id' => $b['id'], 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); + Logger::warning('Error while posting message', ['part' => $key, 'id' => $b['id'], 'code' => $exception->getCode(), 'message' => $exception->getMessage()]); $status = [ 'code' => $exception->getCode(), 'reason' => $exception->getResponse()->getReasonPhrase(), @@ -318,9 +319,9 @@ function twitter_upload_image(int $uid, array $image, int $retrial) $picturedata = $picture->asString(); $new_size = strlen($picturedata); - 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, 'image' => $image]); + 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, 'image' => $image]); $media = twitter_post($uid, 'https://upload.twitter.com/1.1/media/upload.json', 'form_params', ['media' => base64_encode($picturedata)]); - DI::logger()->info('Uploading done', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size, 'image' => $image]); + Logger::info('Uploading done', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size, 'image' => $image]); if (isset($media->media_id_string)) { $media_id = $media->media_id_string; @@ -333,10 +334,10 @@ function twitter_upload_image(int $uid, array $image, int $retrial) ] ]; $ret = twitter_post($uid, 'https://upload.twitter.com/1.1/media/metadata/create.json', 'json', $data); - DI::logger()->info('Metadata create', ['uid' => $uid, 'data' => $data, 'return' => $ret]); + Logger::info('Metadata create', ['uid' => $uid, 'data' => $data, 'return' => $ret]); } } else { - DI::logger()->error('Failed upload', ['uid' => $uid, 'size' => strlen($picturedata), 'image' => $image['url'], 'return' => $media]); + Logger::error('Failed upload', ['uid' => $uid, 'size' => strlen($picturedata), 'image' => $image['url'], 'return' => $media]); throw new Exception('Failed upload of ' . $image['url']); } @@ -372,7 +373,7 @@ function twitter_post(int $uid, string $url, string $type, array $data): stdClas DI::pConfig()->set($uid, 'twitter', 'last_status', $status); $content = json_decode($body) ?? new stdClass; - DI::logger()->debug('Success', ['content' => $content]); + Logger::debug('Success', ['content' => $content]); return $content; } @@ -401,7 +402,7 @@ function twitter_test_connection(int $uid) 'content' => $response->getBody()->getContents() ]; DI::pConfig()->set(1, 'twitter', 'last_status', $status); - DI::logger()->info('Test successful', ['uid' => $uid]); + Logger::info('Test successful', ['uid' => $uid]); } catch (RequestException $exception) { $status = [ 'code' => $exception->getCode(), @@ -409,6 +410,6 @@ function twitter_test_connection(int $uid) 'content' => $exception->getMessage() ]; DI::pConfig()->set(1, 'twitter', 'last_status', $status); - DI::logger()->info('Test failed', ['uid' => $uid]); + Logger::info('Test failed', ['uid' => $uid]); } } diff --git a/unicode_smilies/unicode_smilies.php b/unicode_smilies/unicode_smilies.php index 8ec47175..8d55c4be 100644 --- a/unicode_smilies/unicode_smilies.php +++ b/unicode_smilies/unicode_smilies.php @@ -7,6 +7,7 @@ * Author: Matthias Ebers */ +use Friendica\App; use Friendica\Content\Smilies; use Friendica\Core\Hook; diff --git a/viewsrc/viewsrc.php b/viewsrc/viewsrc.php index bd07b541..c4d21ccb 100644 --- a/viewsrc/viewsrc.php +++ b/viewsrc/viewsrc.php @@ -7,6 +7,7 @@ * */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; diff --git a/webdav_storage/webdav_storage.php b/webdav_storage/webdav_storage.php index fd2eb0d9..adcbea29 100644 --- a/webdav_storage/webdav_storage.php +++ b/webdav_storage/webdav_storage.php @@ -8,10 +8,11 @@ use Friendica\Addon\webdav_storage\src\WebDav; use Friendica\Addon\webdav_storage\src\WebDavConfig; +use Friendica\App; use Friendica\Core\Hook; use Friendica\DI; -function webdav_storage_install() +function webdav_storage_install($a) { Hook::register('storage_instance' , __FILE__, 'webdav_storage_instance'); Hook::register('storage_config' , __FILE__, 'webdav_storage_config'); diff --git a/webrtc/webrtc.php b/webrtc/webrtc.php index e5d4ce6e..e142b374 100644 --- a/webrtc/webrtc.php +++ b/webrtc/webrtc.php @@ -7,6 +7,7 @@ * Author: Tobias Diekershoff */ +use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; use Friendica\DI; diff --git a/wppost/wppost.php b/wppost/wppost.php index de216806..dba738de 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -9,6 +9,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Hook; +use Friendica\Core\Logger; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; @@ -256,13 +257,11 @@ function wppost_send(array &$b) EOT; - DI::logger()->debug('wppost: data: ' . $xml); - - $x = ''; + Logger::debug('wppost: data: ' . $xml); if ($wp_blog !== 'test') { $x = DI::httpClient()->post($wp_blog, $xml)->getBodyString(); } - DI::logger()->info('posted to wordpress: ' . $x); + Logger::info('posted to wordpress: ' . (($x) ? $x : '')); } }